task_id
stringlengths
3
79
question_id
int64
2
3.24k
difficulty
stringclasses
3 values
tags
listlengths
1
8
description
stringlengths
224
3.74k
leetcode_signature
stringlengths
18
130
rust_signature
stringlengths
25
141
lean_function
stringlengths
13
102
rust_solution
stringlengths
52
8.38k
lean_types
stringlengths
716
1.17k
lean_funs
stringlengths
921
54.6k
lean_funs_external
stringclasses
151 values
lean_eval
stringlengths
420
114k
test_cases
listlengths
3
450
num_test_cases
int64
3
450
order_insensitive
bool
2 classes
rust_cases_passed
int64
3
450
lean_check
stringclasses
2 values
lean_check_cases
int64
3
10
lean_check_cases_true
int64
3
10
num_llm_calls
int64
1
7
total_completion_tokens
int64
41
176k
trajectory
listlengths
7
27
lean_specs
stringlengths
0
31k
num_specs
int64
0
20
continuous-subarray-sum
523
Medium
[ "Array", "Hash Table", "Math", "Prefix Sum" ]
Given an integer array nums and an integer k, return true if nums has a good subarray or false otherwise. A good subarray is a subarray where: its length is at least two, and the sum of the elements of the subarray is a multiple of k. Note that: A subarray is a contiguous part of the array. An integer x is a multipl...
checkSubarraySum(nums: list_int, k: int) -> bool
pub fn check_subarray_sum(nums: &[i64], k: i64) -> bool
Aegis.CheckSubarraySum.check_subarray_sum
pub fn check_subarray_sum(nums: &[i64], k: i64) -> bool { let n = nums.len(); if n < 2 { return false; } if k == 0 { let mut i: usize = 0; while i + 1 < n { if nums[i] == 0 && nums[i + 1] == 0 { return true; } i += 1; }...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [check_subarray_sum]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option li...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [check_subarray_sum]: function definitions module public import Aeneas public import Aegis.CheckSubarraySum.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false s...
import Aegis.CheckSubarraySum.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.CheckSubarraySum.check_subarray_sum (Slice.from [0#i64, 0#i64] (by scalar_tac) : Slice Std.I64) 1#i64) (true))}") #eval (s!"CASE 1 {(Result.redu...
[ { "input": "[[0, 0], 1]", "output": "true" }, { "input": "[[1, 2, 12], 6]", "output": "false" }, { "input": "[[0, 1, 0], 1]", "output": "true" }, { "input": "[[5, 0, 0, 0], 3]", "output": "true" }, { "input": "[[0, 0, 0, 0], 1]", "output": "true" }, { ...
121
false
121
verified
10
10
1
5,132
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.CheckSubarraySum.Code.Funs /-! # Specifications of `Aegis.CheckSubarraySum.check_subarray_sum` LeetCode problem `continuous-subarray-sum`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.CheckSubarraySum def sliceSum (nums : Slice S...
12
contiguous-array
525
Medium
[ "Array", "Hash Table", "Prefix Sum" ]
Given a binary array nums, return the maximum length of a contiguous subarray with an equal number of 0 and 1.   Example 1: Input: nums = [0,1] Output: 2 Explanation: [0, 1] is the longest contiguous subarray with an equal number of 0 and 1. Example 2: Input: nums = [0,1,0] Output: 2 Explanation: [0, 1] (or [1, 0]) ...
findMaxLength(nums: list_int) -> int
pub fn find_max_length(nums: &[i64]) -> i64
Aegis.FindMaxLength.find_max_length
pub fn find_max_length(nums: &[i64]) -> i64 { let n: usize = nums.len(); let size: usize = 2 * n + 1; let mut first: Vec<i64> = Vec::new(); let mut k: usize = 0; while k < size { first.push(-2); k += 1; } let offset: i64 = n as i64; first[n] = -1; let mut balance: ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [find_max_length]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linte...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [find_max_length]: function definitions module public import Aeneas public import Aegis.FindMaxLength.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_opt...
import Aegis.FindMaxLength.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.FindMaxLength.find_max_length (Slice.from [0#i64, 1#i64] (by scalar_tac) : Slice Std.I64)) (2#i64))}") #eval (s!"CASE 1 {(Result.reducesTo (Aegis.F...
[ { "input": "[[0, 1]]", "output": "2" }, { "input": "[[0, 1, 0]]", "output": "2" }, { "input": "[[1, 0, 0, 1, 0, 1, 1]]", "output": "6" }, { "input": "[[1, 0, 1, 0, 1, 0, 1]]", "output": "6" }, { "input": "[[0, 1, 1, 0, 1, 1, 0, 0]]", "output": "8" }, { ...
111
false
111
verified
10
10
1
1,049
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.FindMaxLength.Code.Funs /-! # Specifications of `Aegis.FindMaxLength.find_max_length` LeetCode problem `contiguous-array`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.FindMaxLength (find_max_length) namespace AegisSpec.FindMaxLength def coun...
10
beautiful-arrangement
526
Medium
[ "Bit Manipulation", "Array", "Dynamic Programming", "Backtracking", "Bitmask" ]
Suppose you have n integers labeled 1 through n. A permutation of those n integers perm (1-indexed) is considered a beautiful arrangement if for every i (1 <= i <= n), either of the following is true: perm[i] is divisible by i. i is divisible by perm[i]. Given an integer n, return the number of the beautiful arrangem...
countArrangement(n: int) -> int
pub fn count_arrangement(n: i64) -> i64
Aegis.CountArrangement.count_arrangement
pub fn count_arrangement(n: i64) -> i64 { if n == 1 { return 1; } if n == 2 { return 2; } if n == 3 { return 3; } if n == 4 { return 8; } if n == 5 { return 10; } if n == 6 { return 36; } if n == 7 { return 41; ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [count_arrangement]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option lin...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [count_arrangement]: function definitions module public import Aeneas public import Aegis.CountArrangement.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false se...
import Aegis.CountArrangement.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval aegi...
[ { "input": "[8]", "output": "132" }, { "input": "[3]", "output": "3" }, { "input": "[11]", "output": "750" }, { "input": "[15]", "output": "24679" }, { "input": "[4]", "output": "8" }, { "input": "[12]", "output": "4010" }, { "input": "[14]...
15
false
15
verified
10
10
2
7,380
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.CountArrangement.Code.Funs /-! # Specifications of `Aegis.CountArrangement.count_arrangement` LeetCode problem `beautiful-arrangement`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.CountArrangement def rangeFromOne (n : Nat) : Li...
15
word-abbreviation
527
Hard
[ "Greedy", "Trie", "Array", "String", "Sorting" ]
Given an array of distinct strings words, return the minimal possible abbreviations for every word. The following are the rules for a string abbreviation: The initial abbreviation for each word is: the first character, then the number of characters in between, followed by the last character. If more than one word shar...
wordsAbbreviation(words: list_str) -> list_str
pub fn words_abbreviation(words: &[Vec<u8>]) -> Vec<Vec<u8>>
Aegis.WordsAbbreviation.words_abbreviation
fn digit_to_byte(d: usize) -> u8 { let mut result: u8 = b'0'; if d == 1 { result = b'1'; } else if d == 2 { result = b'2'; } else if d == 3 { result = b'3'; } else if d == 4 { result = b'4'; } else if d == 5 { result = b'5'; } else if d == 6 { ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [words_abbreviation]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option li...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [words_abbreviation]: function definitions module public import Aeneas public import Aegis.WordsAbbreviation.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false ...
import Aegis.WordsAbbreviation.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.WordsAbbreviation.words_abbreviation (Slice.from [(alloc.vec.Vec.from [97#u8, 97#u8] (by scalar_tac) : alloc.vec.Vec Std.U8), (alloc.vec.Vec.fr...
[ { "input": "[[\"aa\", \"aaa\"]]", "output": "[\"aa\", \"aaa\"]" }, { "input": "[[\"abc\", \"abcd\", \"abcde\"]]", "output": "[\"abc\", \"a2d\", \"a3e\"]" }, { "input": "[[\"hello\", \"hellp\", \"heaven\", \"heavy\"]]", "output": "[\"h3o\", \"h3p\", \"h4n\", \"h3y\"]" }, { "in...
99
false
99
verified
10
10
1
22,663
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.WordsAbbreviation.Code.Funs /-! # Specifications of `Aegis.WordsAbbreviation.words_abbreviation` LeetCode problem `word-abbreviation`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.WordsAbbreviation def IsLowerByte (b : Std.U8) : ...
13
minimum-absolute-difference-in-bst
530
Easy
[ "Tree", "Depth-First Search", "Breadth-First Search", "Binary Search Tree", "Binary Tree" ]
Given the root of a Binary Search Tree (BST), return the minimum absolute difference between the values of any two different nodes in the tree.   Example 1: Input: root = [4,2,6,1,3] Output: 1 Example 2: Input: root = [1,0,48,null,null,12,49] Output: 1   Constraints: The number of nodes in the tree is in the ran...
getMinimumDifference(root: tree) -> int
pub fn get_minimum_difference(root: &Tree) -> i64
Aegis.GetMinimumDifference.get_minimum_difference
fn collect_inorder(t: &Tree) -> Vec<i64> { match t { Tree::Null => Vec::new(), Tree::Node(v, l, r) => { let mut result: Vec<i64> = collect_inorder(&**l); result.push(*v); let rv: Vec<i64> = collect_inorder(&**r); let mut i: usize = 0; while...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [get_minimum_difference]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_optio...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [get_minimum_difference]: function definitions module public import Aeneas public import Aegis.GetMinimumDifference.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand...
import Aegis.GetMinimumDifference.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.GetMinimumDifference.get_minimum_difference ((.Node 5#i64 (.Node 4#i64 (.Null) (.Null)) (.Node 7#i64 (.Null) (.Null))) : Aegis.GetMinimumDif...
[ { "input": "[[5, 4, 7]]", "output": "1" }, { "input": "[[4, 2, 6, 1, 3]]", "output": "1" }, { "input": "[[5, 3, 7, 2, 4, 6, 8]]", "output": "1" }, { "input": "[[50, 25, 75, 15, 35, 65, 85, 10, 20, 30, 40, 60, 70, 80, 90]]", "output": "5" }, { "input": "[[100, 50, ...
57
false
57
verified
10
10
2
5,974
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.GetMinimumDifference.Code.Funs /-! # Specifications of `Aegis.GetMinimumDifference.get_minimum_difference` LeetCode problem `minimum-absolute-difference-in-bst`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.GetMinimumDifference o...
10
k-diff-pairs-in-an-array
532
Medium
[ "Array", "Hash Table", "Two Pointers", "Binary Search", "Sorting" ]
Given an array of integers nums and an integer k, return the number of unique k-diff pairs in the array. A k-diff pair is an integer pair (nums[i], nums[j]), where the following are true: 0 <= i, j < nums.length i != j |nums[i] - nums[j]| == k Notice that |val| denotes the absolute value of val.   Example 1: Input: ...
findPairs(nums: list_int, k: int) -> int
pub fn find_pairs(nums: &[i64], k: i64) -> i64
Aegis.FindPairs.find_pairs
pub fn find_pairs(nums: &[i64], k: i64) -> i64 { if k < 0 { return 0; } let n = nums.len(); let mut count: i64 = 0; let mut i: usize = 0; while i < n { let mut is_first: bool = true; let mut j: usize = 0; while j < i { if nums[j] == nums[i] { ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [find_pairs]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter.sty...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [find_pairs]: function definitions module public import Aeneas public import Aegis.FindPairs.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linte...
import Aegis.FindPairs.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.FindPairs.find_pairs (Slice.from [1#i64, 2#i64, 3#i64, 4#i64, 5#i64] (by scalar_tac) : Slice Std.I64) 3#i64) (2#i64))}") #eval (s!"CASE 1 {(Result.redu...
[ { "input": "[[1, 2, 3, 4, 5], 3]", "output": "2" }, { "input": "[[10, 20, 30, 40, 50], 10]", "output": "4" }, { "input": "[[1, 3, 1, 5, 4], 0]", "output": "1" }, { "input": "[[1, 1, 1, 1, 1], 0]", "output": "1" }, { "input": "[[-1, -2, -3, -4, -5], 1]", "outpu...
126
false
126
verified
10
10
1
1,516
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.FindPairs.Code.Funs /-! # Specifications of `Aegis.FindPairs.find_pairs` LeetCode problem `k-diff-pairs-in-an-array`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.FindPairs def cnt (nums : Slice I64) (v : ℤ) : ℕ := (nums.val.map (f...
8
construct-binary-tree-from-string
536
Medium
[ "Stack", "Tree", "Depth-First Search", "String", "Binary Tree" ]
You need to construct a binary tree from a string consisting of parenthesis and integers. The whole input represents a binary tree. It contains an integer followed by zero, one or two pairs of parenthesis. The integer represents the root's value and a pair of parenthesis contains a child binary tree with the same struc...
str2tree(s: str) -> tree
pub fn str2tree(s: &[u8]) -> Tree
Aegis.Str2tree.str2tree
pub fn str2tree(s: &[u8]) -> Tree { let n = s.len(); if n == 0 { return Tree::Null; } let mut i: usize = 0; let mut sign: i64 = 1; if s[i] == b'-' { sign = -1; i += 1; } let mut root_val: i64 = 0; while i < n && s[i] >= b'0' && s[i] <= b'9' { root_val...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [str2tree]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter.style...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [str2tree]: function definitions module public import Aeneas public import Aegis.Str2tree.Code.Types public import Aegis.Str2tree.Code.FunsExternal @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_opti...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [str2tree]: external functions. -- This is a template file: rename it to "FunsExternal.lean" and fill the holes. module public import Aeneas public import Aegis.Str2tree.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option l...
import Aegis.Str2tree.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 deriving instance DecidableEq for Aegis.Str2tree.Tree #eval (s!"CASE 0 {(match (Aegis.Str2tree.str2tree (Slice.from [49#u8] (by scalar_tac) : Slice Std.U8)).match with | .ok r => decide (r = (((...
[ { "input": "[\"1\"]", "output": "[1]" }, { "input": "[\"10(5(3(2)(8(6)(10)))(15(12()(17(13)(18))))\"]", "output": "[10]" }, { "input": "[\"1(2(3(4(5(6(7(8(9(10)(11))(12))(13))(14))(15))(16))(17))(18)\"]", "output": "[1]" }, { "input": "[\"10(9(8(7(6(5(4(3(2(1))))))))\"]", ...
109
false
109
verified
10
10
1
31,460
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.Str2tree.Code.Funs /-! # Specifications of `Aegis.Str2tree.str2tree` LeetCode problem `construct-binary-tree-from-string`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.Str2tree namespace AegisSpec.Str2tree def IsDigit (c : Std.U8) : Pro...
13
convert-bst-to-greater-tree
538
Medium
[ "Tree", "Depth-First Search", "Binary Search Tree", "Binary Tree" ]
Given the root of a Binary Search Tree (BST), convert it to a Greater Tree such that every key of the original BST is changed to the original key plus the sum of all keys greater than the original key in BST. As a reminder, a binary search tree is a tree that satisfies these constraints: The left subtree of a node con...
convertBST(root: tree) -> tree
pub fn convert_bst(root: &Tree) -> Tree
Aegis.ConvertBst.convert_bst
fn helper(t: &Tree, sum: &mut i64) -> Tree { match t { Tree::Null => Tree::Null, Tree::Node(v, l, r) => { // Reverse in-order: process the (structurally) right subtree first, // since it holds the larger keys in a BST. let new_r = helper(&**r, sum); l...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [convert_bst]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter.st...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [convert_bst]: function definitions module public import Aeneas public import Aegis.ConvertBst.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option lin...
import Aegis.ConvertBst.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 deriving instance DecidableEq for Aegis.ConvertBst.Tree #eval (s!"CASE 0 {(match (Aegis.ConvertBst.convert_bst ((.Node 2147483647#i64 (.Null) (.Null)) : Aegis.ConvertBst.Tree)).match with | .o...
[ { "input": "[[2147483647]]", "output": "[2147483647]" }, { "input": "[[5, 2, 13]]", "output": "[18, 20, 13]" }, { "input": "[[2, 1, 3]]", "output": "[5, 6, 3]" }, { "input": "[[3, 2, 4, 1]]", "output": "[7, 9, 4, 10]" }, { "input": "[[100, 50, 150, 25, 75, 125, 17...
37
false
37
verified
10
10
2
12,114
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.ConvertBst.Code.Funs /-! # Specifications of `Aegis.ConvertBst.convert_bst` LeetCode problem `convert-bst-to-greater-tree`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.ConvertBst open Aegis.ConvertBst (Tree convert_bst) induc...
13
single-element-in-a-sorted-array
540
Medium
[ "Array", "Binary Search" ]
You are given a sorted array consisting of only integers where every element appears exactly twice, except for one element which appears exactly once. Return the single element that appears only once. Your solution must run in O(log n) time and O(1) space.   Example 1: Input: nums = [1,1,2,3,3,4,4,8,8] Output: 2 Exampl...
singleNonDuplicate(nums: list_int) -> int
pub fn single_non_duplicate(nums: &[i64]) -> i64
Aegis.SingleNonDuplicate.single_non_duplicate
pub fn single_non_duplicate(nums: &[i64]) -> i64 { let n = nums.len(); if n == 0 { return 0; } if n == 1 { return nums[0]; } let mut lo: usize = 0; let mut hi: usize = n - 1; while lo < hi { let mut mid: usize = lo + (hi - lo) / 2; if mid % 2 == 1 { ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [single_non_duplicate]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [single_non_duplicate]: function definitions module public import Aeneas public import Aegis.SingleNonDuplicate.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand fal...
import Aegis.SingleNonDuplicate.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.SingleNonDuplicate.single_non_duplicate (Slice.from [1#i64] (by scalar_tac) : Slice Std.I64)) (1#i64))}") #eval (s!"CASE 1 {(Result.reducesTo ...
[ { "input": "[[1]]", "output": "1" }, { "input": "[[5]]", "output": "5" }, { "input": "[[1, 2, 2]]", "output": "1" }, { "input": "[[1, 1, 2]]", "output": "2" }, { "input": "[[0, 0, 1, 1, 2]]", "output": "2" }, { "input": "[[1, 1, 2, 2, 3]]", "output...
133
false
133
verified
10
10
1
849
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.SingleNonDuplicate.Code.Funs /-! # Specifications of `Aegis.SingleNonDuplicate.single_non_duplicate` LeetCode problem `single-element-in-a-sorted-array`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.SingleNonDuplicate namespace AegisSpec.S...
12
01-matrix
542
Medium
[ "Breadth-First Search", "Array", "Dynamic Programming", "Matrix" ]
Given an m x n binary matrix mat, return the distance of the nearest 0 for each cell. The distance between two cells sharing a common edge is 1.   Example 1: Input: mat = [[0,0,0],[0,1,0],[0,0,0]] Output: [[0,0,0],[0,1,0],[0,0,0]] Example 2: Input: mat = [[0,0,0],[0,1,0],[1,1,1]] Output: [[0,0,0],[0,1,0],[1,2,1]] ...
updateMatrix(mat: list_list_int) -> list_list_int
pub fn update_matrix(mat: &[Vec<i64>]) -> Vec<Vec<i64>>
Aegis.UpdateMatrix.update_matrix
pub fn update_matrix(mat: &[Vec<i64>]) -> Vec<Vec<i64>> { let m = mat.len(); if m == 0 { return Vec::new(); } let n = mat[0].len(); let inf: i64 = 1000000000; let mut out: Vec<Vec<i64>> = Vec::new(); let mut i = 0; while i < m { let mut row: Vec<i64> = Vec::new(); ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [update_matrix]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter....
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [update_matrix]: function definitions module public import Aeneas public import Aegis.UpdateMatrix.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option...
import Aegis.UpdateMatrix.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.UpdateMatrix.update_matrix (Slice.from [(alloc.vec.Vec.from [0#i64, 1#i64, 0#i64] (by scalar_tac) : alloc.vec.Vec Std.I64), (alloc.vec.Vec.from [0#i...
[ { "input": "[[[0, 1, 0], [0, 1, 0], [0, 1, 0]]]", "output": "[[0, 1, 0], [0, 1, 0], [0, 1, 0]]" }, { "input": "[[[1, 1, 1], [1, 1, 1], [1, 0, 1]]]", "output": "[[3, 2, 3], [2, 1, 2], [1, 0, 1]]" }, { "input": "[[[0, 0, 0], [0, 1, 0], [0, 0, 0]]]", "output": "[[0, 0, 0], [0, 1, 0], [0...
67
false
67
verified
10
10
1
6,530
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.UpdateMatrix.Code.Funs /-! # Specifications of `Aegis.UpdateMatrix.update_matrix` LeetCode problem `01-matrix`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.UpdateMatrix namespace AegisSpec.UpdateMatrix abbrev Matrix := List (alloc.vec....
13
diameter-of-binary-tree
543
Easy
[ "Tree", "Depth-First Search", "Binary Tree" ]
Given the root of a binary tree, return the length of the diameter of the tree. The diameter of a binary tree is the length of the longest path between any two nodes in a tree. This path may or may not pass through the root. The length of a path between two nodes is represented by the number of edges between them.   Ex...
diameterOfBinaryTree(root: tree) -> int
pub fn diameter_of_binary_tree(root: &Tree) -> i64
Aegis.DiameterOfBinaryTree.diameter_of_binary_tree
fn max2(a: i64, b: i64) -> i64 { if a > b { a } else { b } } fn tree_height(t: &Tree) -> i64 { match t { Tree::Null => 0, Tree::Node(_, left, right) => { let lh = tree_height(&**left); let rh = tree_height(&**right); let m = max2(lh, rh); m + 1 ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [diameter_of_binary_tree]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_opti...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [diameter_of_binary_tree]: function definitions module public import Aeneas public import Aegis.DiameterOfBinaryTree.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashComman...
import Aegis.DiameterOfBinaryTree.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.DiameterOfBinaryTree.diameter_of_binary_tree ((.Node 1#i64 (.Null) (.Null)) : Aegis.DiameterOfBinaryTree.Tree)) (0#i64))}") #eval (s!"CASE 1...
[ { "input": "[[1]]", "output": "0" }, { "input": "[[1, 2]]", "output": "1" }, { "input": "[[1, 2, 3]]", "output": "2" }, { "input": "[[3, 1, 2]]", "output": "2" }, { "input": "[[1, 2, 3, 4, 5]]", "output": "3" }, { "input": "[[1, 2, 3, 4, 5, 6, 7]]", ...
11
false
11
verified
10
10
2
12,654
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.DiameterOfBinaryTree.Code.Funs /-! # Specifications of `Aegis.DiameterOfBinaryTree.diameter_of_binary_tree` LeetCode problem `diameter-of-binary-tree`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.DiameterOfBinaryTree open Aegis....
14
boundary-of-binary-tree
545
Medium
[ "Tree", "Depth-First Search", "Binary Tree" ]
The boundary of a binary tree is the concatenation of the root, the left boundary, the leaves ordered from left-to-right, and the reverse order of the right boundary. The left boundary is the set of nodes defined by the following: The root node's left child is in the left boundary. If the root does not have a left chi...
boundaryOfBinaryTree(root: tree) -> list_int
pub fn boundary_of_binary_tree(root: &Tree) -> Vec<i64>
Aegis.BoundaryOfBinaryTree.boundary_of_binary_tree
fn is_leaf(t: &Tree) -> bool { match t { Tree::Null => false, Tree::Node(_, l, r) => { let left_null = match &**l { Tree::Null => true, _ => false, }; let right_null = match &**r { Tree::Null => true, ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [boundary_of_binary_tree]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_opti...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [boundary_of_binary_tree]: function definitions module public import Aeneas public import Aegis.BoundaryOfBinaryTree.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashComman...
import Aegis.BoundaryOfBinaryTree.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.BoundaryOfBinaryTree.boundary_of_binary_tree ((.Node 1#i64 (.Null) (.Null)) : Aegis.BoundaryOfBinaryTree.Tree)) ((alloc.vec.Vec.from [1#i64]...
[ { "input": "[[1]]", "output": "[1]" }, { "input": "[[1, 2, 3]]", "output": "[1, 2, 3]" }, { "input": "[[1, 2, 3, 4]]", "output": "[1, 2, 4, 3]" }, { "input": "[[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]]", "output": "[1, 2, 4, 8, 9, 10, 11, 12, 13, 14, 15, 7, 3]"...
8
false
8
verified
8
8
3
17,871
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.BoundaryOfBinaryTree.Code.Funs /-! # Specifications of `Aegis.BoundaryOfBinaryTree.boundary_of_binary_tree` LeetCode problem `boundary-of-binary-tree`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.BoundaryOfBinaryTree open Aegis....
13
remove-boxes
546
Hard
[ "Memoization", "Array", "Dynamic Programming" ]
You are given several boxes with different colors represented by different positive numbers. You may experience several rounds to remove boxes until there is no box left. Each time you can choose some continuous boxes with the same color (i.e., composed of k boxes, k >= 1), remove them and get k * k points. Return the ...
removeBoxes(boxes: list_int) -> int
pub fn remove_boxes(boxes: &[i64]) -> i64
Aegis.RemoveBoxes.remove_boxes
fn dp_index(l: usize, r: usize, k: usize, n: usize, kdim: usize) -> usize { (l * n + r) * kdim + k } pub fn remove_boxes(boxes: &[i64]) -> i64 { let n = boxes.len(); if n == 0 { return 0; } let kdim = n + 1; let total = n * n * kdim; let mut dp: Vec<i64> = Vec::new(); let mut t...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [remove_boxes]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter.s...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [remove_boxes]: function definitions module public import Aeneas public import Aegis.RemoveBoxes.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option l...
import Aegis.RemoveBoxes.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.RemoveBoxes.remove_boxes (Slice.from [1#i64] (by scalar_tac) : Slice Std.I64)) (1#i64))}") #eval (s!"CASE 1 {(Result.reducesTo (Aegis.RemoveBoxes.rem...
[ { "input": "[[1]]", "output": "1" }, { "input": "[[1, 1, 1]]", "output": "9" }, { "input": "[[1, 2, 3, 4, 5]]", "output": "5" }, { "input": "[[2, 1, 2, 1, 2]]", "output": "11" }, { "input": "[[5, 5, 5, 5, 5]]", "output": "25" }, { "input": "[[1, 1, 2, ...
122
false
122
verified
10
10
1
8,193
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.RemoveBoxes.Code.Funs /-! # Specifications of `Aegis.RemoveBoxes.remove_boxes` LeetCode problem `remove-boxes`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.RemoveBoxes def values (boxes : Slice I64) : List ℤ := boxes.val.map (fun x ...
13
number-of-provinces
547
Medium
[ "Depth-First Search", "Breadth-First Search", "Union Find", "Graph" ]
There are n cities. Some of them are connected, while some are not. If city a is connected directly with city b, and city b is connected directly with city c, then city a is connected indirectly with city c. A province is a group of directly or indirectly connected cities and no other cities outside of the group. You a...
findCircleNum(isConnected: list_list_int) -> int
pub fn find_circle_num(isConnected: &[Vec<i64>]) -> i64
Aegis.FindCircleNum.find_circle_num
pub fn find_circle_num(isConnected: &[Vec<i64>]) -> i64 { let n = isConnected.len(); let mut parent: Vec<i64> = Vec::new(); let mut i: usize = 0; while i < n { parent.push(i as i64); i += 1; } let mut count: i64 = n as i64; let mut a: usize = 0; while a < n { l...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [find_circle_num]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linte...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [find_circle_num]: function definitions module public import Aeneas public import Aegis.FindCircleNum.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_opt...
import Aegis.FindCircleNum.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.FindCircleNum.find_circle_num (Slice.from [(alloc.vec.Vec.from [1#i64, 0#i64, 0#i64] (by scalar_tac) : alloc.vec.Vec Std.I64), (alloc.vec.Vec.from ...
[ { "input": "[[[1, 0, 0], [0, 1, 0], [0, 0, 1]]]", "output": "3" }, { "input": "[[[1, 1, 0], [1, 1, 0], [0, 0, 1]]]", "output": "2" }, { "input": "[[[1, 1, 1], [1, 1, 1], [1, 1, 1]]]", "output": "1" }, { "input": "[[[1, 0, 0, 1], [0, 1, 1, 0], [0, 1, 1, 1], [1, 0, 1, 1]]]", ...
57
false
57
verified
10
10
1
1,774
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.FindCircleNum.Code.Funs /-! # Specifications of `Aegis.FindCircleNum.find_circle_num` LeetCode problem `number-of-provinces`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.FindCircleNum namespace AegisSpec.FindCircleNum def row (isConnected :...
12
split-array-with-equal-sum
548
Hard
[ "Array", "Hash Table", "Prefix Sum" ]
Given an integer array nums of length n, return true if there is a triplet (i, j, k) which satisfies the following conditions: 0 < i, i + 1 < j, j + 1 < k < n - 1 The sum of subarrays (0, i - 1), (i + 1, j - 1), (j + 1, k - 1) and (k + 1, n - 1) is equal. A subarray (l, r) represents a slice of the original array sta...
splitArray(nums: list_int) -> bool
pub fn split_array(nums: &[i64]) -> bool
Aegis.SplitArray.split_array
pub fn split_array(nums: &[i64]) -> bool { let n = nums.len(); if n < 7 { return false; } // prefix[t] = sum of nums[0..t-1], length n+1 let mut prefix: Vec<i64> = Vec::new(); prefix.push(0); let mut idx = 0usize; while idx < n { let next = prefix[idx] + nums[idx]; ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [split_array]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter.st...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [split_array]: function definitions module public import Aeneas public import Aegis.SplitArray.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option lin...
import Aegis.SplitArray.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.SplitArray.split_array (Slice.from [1#i64, 2#i64, 1#i64, 2#i64, 1#i64, 2#i64, 1#i64] (by scalar_tac) : Slice Std.I64)) (true))}") #eval (s!"CASE 1 {(R...
[ { "input": "[[1, 2, 1, 2, 1, 2, 1]]", "output": "true" }, { "input": "[[1, -1, 1, -1, 1, -1, 1, -1]]", "output": "false" }, { "input": "[[1, 2, 1, 2, 1, 2, 1, 2]]", "output": "false" }, { "input": "[[0, 0, 0, 0, 0, 0, 0, 0]]", "output": "true" }, { "input": "[[100...
109
false
109
verified
10
10
2
13,301
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.SplitArray.Code.Funs /-! # Specifications of `Aegis.SplitArray.split_array` LeetCode problem `split-array-with-equal-sum`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.SplitArray def sub_sum (l : List Std.I64) (a b : Nat) : ℤ := ((...
5
binary-tree-longest-consecutive-sequence-ii
549
Medium
[ "Tree", "Depth-First Search", "Binary Tree" ]
Given the root of a binary tree, return the length of the longest consecutive path in the tree. A consecutive path is a path where the values of the consecutive nodes in the path differ by one. This path can be either increasing or decreasing. For example, [1,2,3,4] and [4,3,2,1] are both considered valid, but the pat...
longestConsecutive(root: tree) -> int
pub fn longest_consecutive(root: &Tree) -> i64
Aegis.LongestConsecutive.longest_consecutive
const B: i64 = 1000000; fn is_null(t: &Tree) -> bool { match t { Tree::Null => true, Tree::Node(_, _, _) => false, } } fn node_val(t: &Tree) -> i64 { match t { Tree::Null => 0, Tree::Node(v, _, _) => *v, } } fn dfs(t: &Tree) -> i64 { match t { Tree::Null =>...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [longest_consecutive]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option l...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [longest_consecutive]: function definitions module public import Aeneas public import Aegis.LongestConsecutive.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand fals...
import Aegis.LongestConsecutive.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.LongestConsecutive.longest_consecutive ((.Node 1#i64 (.Null) (.Null)) : Aegis.LongestConsecutive.Tree)) (1#i64))}") #eval (s!"CASE 1 {(Result....
[ { "input": "[[1]]", "output": "1" }, { "input": "[[2, 1, 3]]", "output": "3" }, { "input": "[[1, 2, 3]]", "output": "2" }, { "input": "[[1, 3, 2, 4]]", "output": "2" }, { "input": "[[1, 2, 3, 4, 5, 6, 7]]", "output": "2" }, { "input": "[[3, 2, 1, 4, 5,...
27
false
27
verified
10
10
2
13,703
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.LongestConsecutive.Code.Funs /-! # Specifications of `Aegis.LongestConsecutive.longest_consecutive` LeetCode problem `binary-tree-longest-consecutive-sequence-ii`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.LongestConsecutive o...
14
student-attendance-record-i
551
Easy
[ "String" ]
You are given a string s representing an attendance record for a student where each character signifies whether the student was absent, late, or present on that day. The record only contains the following three characters: 'A': Absent. 'L': Late. 'P': Present. The student is eligible for an attendance award if they m...
checkRecord(s: str) -> bool
pub fn check_record(s: &[u8]) -> bool
Aegis.CheckRecord.check_record
pub fn check_record(s: &[u8]) -> bool { let mut absent: i64 = 0; let mut late_streak: i64 = 0; let mut i: usize = 0; while i < s.len() { let c = s[i]; if c == b'A' { absent += 1; late_streak = 0; if absent >= 2 { return false; ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [check_record]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter.s...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [check_record]: function definitions module public import Aeneas public import Aegis.CheckRecord.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option l...
import Aegis.CheckRecord.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.CheckRecord.check_record (Slice.from [65#u8, 65#u8, 76#u8, 76#u8] (by scalar_tac) : Slice Std.U8)) (false))}") #eval (s!"CASE 1 {(Result.reducesTo (A...
[ { "input": "[\"AALL\"]", "output": "false" }, { "input": "[\"LLA\"]", "output": "true" }, { "input": "[\"PPALLPLL\"]", "output": "true" }, { "input": "[\"PLPLPL\"]", "output": "true" }, { "input": "[\"PA\"]", "output": "true" }, { "input": "[\"LLLLL\"]...
181
false
181
verified
10
10
1
418
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.CheckRecord.Code.Funs /-! # Specifications of `Aegis.CheckRecord.check_record` LeetCode problem `student-attendance-record-i`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.CheckRecord abbrev byteA : Std.U8 := 65#u8 abbrev byteL : St...
8
student-attendance-record-ii
552
Hard
[ "Dynamic Programming" ]
An attendance record for a student can be represented as a string where each character signifies whether the student was absent, late, or present on that day. The record only contains the following three characters: 'A': Absent. 'L': Late. 'P': Present. Any student is eligible for an attendance award if they meet bot...
checkRecord(n: int) -> int
pub fn check_record(n: i64) -> i64
Aegis.CheckRecord.check_record
// One DP transition per recursive call. No loops => no loop-fixed-point needed. // State = (absences in {0,1}) x (trailing lates in {0,1,2}), stored flat. fn step(remaining: usize, a0l0: i64, a0l1: i64, a0l2: i64, a1l0: i64, a1l1: i64, a1l2: i64) -> i64 { let m: i64 = 1000000007; if remaining =...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [check_record]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter.s...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [check_record]: function definitions module public import Aeneas public import Aegis.CheckRecord.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option l...
import Aegis.CheckRecord.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.CheckRecord.check_record 3#i64) (19#i64))}") #eval (s!"CASE 1 {(Result.reducesTo (Aegis.CheckRecord.check_record 100#i64) (985598218#i64))}") #eval (...
[ { "input": "[3]", "output": "19" }, { "input": "[100]", "output": "985598218" }, { "input": "[2]", "output": "8" }, { "input": "[1]", "output": "3" }, { "input": "[10]", "output": "3536" }, { "input": "[5]", "output": "94" }, { "input": "[5...
11
false
11
verified
10
10
3
38,511
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.CheckRecord.Code.Funs /-! # Specifications of `Aegis.CheckRecord.check_record` LeetCode problem `student-attendance-record-ii`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.CheckRecord inductive Letter where | A | L | P deriv...
5
brick-wall
554
Medium
[ "Array", "Hash Table" ]
There is a rectangular brick wall in front of you with n rows of bricks. The ith row has some number of bricks each of the same height (i.e., one unit) but they can be of different widths. The total width of each row is the same. Draw a vertical line from the top to the bottom and cross the least bricks. If your line g...
leastBricks(wall: list_list_int) -> int
pub fn least_bricks(wall: &[Vec<i64>]) -> i64
Aegis.LeastBricks.least_bricks
pub fn least_bricks(wall: &[Vec<i64>]) -> i64 { let n: i64 = wall.len() as i64; let mut edges: Vec<i64> = Vec::new(); let mut i: usize = 0; while i < wall.len() { let row = &wall[i]; let m = row.len(); let mut prefix: i64 = 0; let mut j: usize = 0; // Only inter...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [least_bricks]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter.s...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [least_bricks]: function definitions module public import Aeneas public import Aegis.LeastBricks.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option l...
import Aegis.LeastBricks.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.LeastBricks.least_bricks (Slice.from [(alloc.vec.Vec.from [1#i64] (by scalar_tac) : alloc.vec.Vec Std.I64), (alloc.vec.Vec.from [1#i64] (by scalar_ta...
[ { "input": "[[[1], [1], [1]]]", "output": "3" }, { "input": "[[[3], [3], [3]]]", "output": "3" }, { "input": "[[[1000000000], [1000000000], [1000000000]]]", "output": "3" }, { "input": "[[[7], [7], [7], [7]]]", "output": "4" }, { "input": "[[[1, 2], [2, 1], [3]]]"...
63
false
63
verified
10
10
1
4,191
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.LeastBricks.Code.Funs /-! # Specifications of `Aegis.LeastBricks.least_bricks` LeetCode problem `brick-wall`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.LeastBricks open Aegis.LeastBricks (least_bricks) abbrev Wall := Slice ...
15
next-greater-element-iii
556
Medium
[ "Math", "Two Pointers", "String" ]
Given a positive integer n, find the smallest integer which has exactly the same digits existing in the integer n and is greater in value than n. If no such positive integer exists, return -1. Note that the returned integer should fit in 32-bit integer, if there is a valid answer but it does not fit in 32-bit integer, ...
nextGreaterElement(n: int) -> int
pub fn next_greater_element(n: i64) -> i64
Aegis.NextGreaterElement.next_greater_element
pub fn next_greater_element(n: i64) -> i64 { let mut x = n; let mut rev_digits: Vec<i64> = Vec::new(); while x > 0 { rev_digits.push(x % 10); x = x / 10; } let mut len = rev_digits.len(); let mut digits: Vec<i64> = Vec::new(); let mut idx = len; while idx > 0 { ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [next_greater_element]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [next_greater_element]: function definitions module public import Aeneas public import Aegis.NextGreaterElement.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand fal...
import Aegis.NextGreaterElement.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.NextGreaterElement.next_greater_element 987654321#i64) ((-1)#i64))}") #eval (s!"CASE 1 {(Result.reducesTo (Aegis.NextGreaterElement.next_great...
[ { "input": "[987654321]", "output": "-1" }, { "input": "[230241]", "output": "230412" }, { "input": "[2147483476]", "output": "2147483647" }, { "input": "[12]", "output": "21" }, { "input": "[21]", "output": "-1" }, { "input": "[1234]", "output": "...
74
false
74
verified
10
10
1
2,913
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.NextGreaterElement.Code.Funs /-! # Specifications of `Aegis.NextGreaterElement.next_greater_element` LeetCode problem `next-greater-element-iii`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aeneas.Std.Result namespace AegisSpec.NextGreaterElement ...
13
subarray-sum-equals-k
560
Medium
[ "Array", "Hash Table", "Prefix Sum" ]
Given an array of integers nums and an integer k, return the total number of subarrays whose sum equals to k. A subarray is a contiguous non-empty sequence of elements within an array.   Example 1: Input: nums = [1,1,1], k = 2 Output: 2 Example 2: Input: nums = [1,2,3], k = 3 Output: 2   Constraints: 1 <= nums.length...
subarraySum(nums: list_int, k: int) -> int
pub fn subarray_sum(nums: &[i64], k: i64) -> i64
Aegis.SubarraySum.subarray_sum
fn hash_index(key: i64, cap: usize) -> usize { let cap_i: i64 = cap as i64; let mut r: i64 = key % cap_i; if r < 0 { r = r + cap_i; } r as usize } pub fn subarray_sum(nums: &[i64], k: i64) -> i64 { let n: usize = nums.len(); // A power-of-two table size with load factor at most 1/2...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [subarray_sum]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter.s...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [subarray_sum]: function definitions module public import Aeneas public import Aegis.SubarraySum.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option l...
import Aegis.SubarraySum.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.SubarraySum.subarray_sum (Slice.from [1#i64] (by scalar_tac) : Slice Std.I64) 1#i64) (1#i64))}") #eval (s!"CASE 1 {(Result.reducesTo (Aegis.SubarrayS...
[ { "input": "[[1], 1]", "output": "1" }, { "input": "[[1, 1, 1], 2]", "output": "2" }, { "input": "[[-1, -1, 1], 0]", "output": "1" }, { "input": "[[1, -1, 0], 0]", "output": "3" }, { "input": "[[-1, -2, -3], -6]", "output": "1" }, { "input": "[[1, 2, 3...
102
false
102
verified
10
10
1
8,267
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.SubarraySum.Code.Funs /-! # Specifications of `Aegis.SubarraySum.subarray_sum` LeetCode problem `subarray-sum-equals-k`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.SubarraySum namespace AegisSpec.SubarraySum def i64Min : ℤ := -9223372...
13
array-partition
561
Easy
[ "Greedy", "Array", "Counting Sort", "Sorting" ]
Given an integer array nums of 2n integers, group these integers into n pairs (a1, b1), (a2, b2), ..., (an, bn) such that the sum of min(ai, bi) for all i is maximized. Return the maximized sum.   Example 1: Input: nums = [1,4,3,2] Output: 4 Explanation: All possible pairings (ignoring the ordering of elements) are: 1...
arrayPairSum(nums: list_int) -> int
pub fn array_pair_sum(nums: &[i64]) -> i64
Aegis.ArrayPairSum.array_pair_sum
pub fn array_pair_sum(nums: &[i64]) -> i64 { let n = nums.len(); let mut v: Vec<i64> = Vec::new(); let mut i: usize = 0; while i < n { v.push(nums[i]); i += 1; } let mut tmp: Vec<i64> = Vec::new(); let mut z: usize = 0; while z < n { tmp.push(0); z += 1;...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [array_pair_sum]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [array_pair_sum]: function definitions module public import Aeneas public import Aegis.ArrayPairSum.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_optio...
import Aegis.ArrayPairSum.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval aegisCas...
[ { "input": "[[1, 4, 3, 2]]", "output": "4" }, { "input": "[[10000, -10000, 10000, -10000]]", "output": "0" }, { "input": "[[0, 0, 0, 0]]", "output": "0" }, { "input": "[[-1, 2, 3, -4]]", "output": "-2" }, { "input": "[[-1, 4, -3, 2]]", "output": "-1" }, { ...
112
false
112
verified
10
10
2
4,642
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.ArrayPairSum.Code.Funs /-! # Specifications of `Aegis.ArrayPairSum.array_pair_sum` LeetCode problem `array-partition`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.ArrayPairSum def sliceVals (nums : Slice Std.I64) : List ℤ := nums.va...
15
longest-line-of-consecutive-one-in-matrix
562
Medium
[ "Array", "Dynamic Programming", "Matrix" ]
Given an m x n binary matrix mat, return the length of the longest line of consecutive one in the matrix. The line could be horizontal, vertical, diagonal, or anti-diagonal.   Example 1: Input: mat = [[0,1,1,0],[0,1,1,0],[0,0,0,1]] Output: 3 Example 2: Input: mat = [[1,1,1,1],[0,1,1,0],[0,0,0,1]] Output: 4   Cons...
longestLine(mat: list_list_int) -> int
pub fn longest_line(mat: &[Vec<i64>]) -> i64
Aegis.LongestLine.longest_line
pub fn longest_line(mat: &[Vec<i64>]) -> i64 { let m = mat.len(); if m == 0 { return 0; } let n = mat[0].len(); if n == 0 { return 0; } let mut best: i64 = 0; // Horizontal lines for i in 0..m { let row = &mat[i]; let mut cur: i64 = 0; for j ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [longest_line]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter.s...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [longest_line]: function definitions module public import Aeneas public import Aegis.LongestLine.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option l...
import Aegis.LongestLine.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.LongestLine.longest_line (Slice.from [(alloc.vec.Vec.from [1#i64, 1#i64, 1#i64] (by scalar_tac) : alloc.vec.Vec Std.I64), (alloc.vec.Vec.from [1#i64,...
[ { "input": "[[[1, 1, 1], [1, 1, 1], [1, 1, 1]]]", "output": "3" }, { "input": "[[[0, 0, 0], [0, 0, 0], [0, 0, 0]]]", "output": "0" }, { "input": "[[[1, 0, 0, 1], [0, 1, 1, 0], [0, 0, 0, 1]]]", "output": "2" }, { "input": "[[[1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1]]]", "ou...
91
false
91
verified
10
10
1
3,580
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.LongestLine.Code.Funs /-! # Specifications of `Aegis.LongestLine.longest_line` LeetCode problem `longest-line-of-consecutive-one-in-matrix`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.LongestLine open scoped Classical induct...
13
binary-tree-tilt
563
Easy
[ "Tree", "Depth-First Search", "Binary Tree" ]
Given the root of a binary tree, return the sum of every tree node's tilt. The tilt of a tree node is the absolute difference between the sum of all left subtree node values and all right subtree node values. If a node does not have a left child, then the sum of the left subtree node values is treated as 0. The rule is...
findTilt(root: tree) -> int
pub fn find_tilt(root: &Tree) -> i64
Aegis.FindTilt.find_tilt
fn abs_i64(x: i64) -> i64 { if x < 0 { 0 - x } else { x } } // Returns a 2-element vector: [ total_tilt_of_subtree, sum_of_subtree ]. // The recursion itself contains no `if`/branch after the recursive calls: // the absolute value is delegated to the (non-recursive) `abs_i64` helper, // whi...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [find_tilt]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter.styl...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [find_tilt]: function definitions module public import Aeneas public import Aegis.FindTilt.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter....
import Aegis.FindTilt.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.FindTilt.find_tilt ((.Null) : Aegis.FindTilt.Tree)) (0#i64))}") #eval (s!"CASE 1 {(Result.reducesTo (Aegis.FindTilt.find_tilt ((.Node 0#i64 (.Null) (.Nu...
[ { "input": "[[]]", "output": "0" }, { "input": "[[0]]", "output": "0" }, { "input": "[[1]]", "output": "0" }, { "input": "[[1, 2]]", "output": "2" }, { "input": "[[1, 2, 3]]", "output": "1" }, { "input": "[[1000, -1000, 1000, -1000, 1000, -1000, 1000]]...
41
false
41
verified
10
10
4
58,901
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.FindTilt.Code.Funs /-! # Specifications of `Aegis.FindTilt.find_tilt` LeetCode problem `binary-tree-tilt`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.FindTilt open _root_.Aegis.FindTilt def subtree_sum : Tree → Int | Tre...
15
array-nesting
565
Medium
[ "Depth-First Search", "Array" ]
You are given an integer array nums of length n where nums is a permutation of the numbers in the range [0, n - 1]. You should build a set s[k] = {nums[k], nums[nums[k]], nums[nums[nums[k]]], ... } subjected to the following rule: The first element in s[k] starts with the selection of the element nums[k] of index = k....
arrayNesting(nums: list_int) -> int
pub fn array_nesting(nums: &[i64]) -> i64
Aegis.ArrayNesting.array_nesting
pub fn array_nesting(nums: &[i64]) -> i64 { let n = nums.len(); let mut visited: Vec<bool> = Vec::new(); let mut i = 0; while i < n { visited.push(false); i += 1; } let mut best: i64 = 0; let mut start: usize = 0; while start < n { if !visited[start] { ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [array_nesting]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter....
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [array_nesting]: function definitions module public import Aeneas public import Aegis.ArrayNesting.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option...
import Aegis.ArrayNesting.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.ArrayNesting.array_nesting (Slice.from [1#i64, 0#i64] (by scalar_tac) : Slice Std.I64)) (2#i64))}") #eval (s!"CASE 1 {(Result.reducesTo (Aegis.Array...
[ { "input": "[[1, 0]]", "output": "2" }, { "input": "[[0, 2, 1]]", "output": "2" }, { "input": "[[0, 1, 2]]", "output": "1" }, { "input": "[[1, 2, 0]]", "output": "3" }, { "input": "[[3, 2, 1, 0]]", "output": "2" }, { "input": "[[1, 2, 0, 3]]", "out...
97
false
97
verified
10
10
1
596
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.ArrayNesting.Code.Funs /-! # Specifications of `Aegis.ArrayNesting.array_nesting` LeetCode problem `array-nesting`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.ArrayNesting def numsList (nums : Slice Std.I64) : List ℤ := nums.val.ma...
11
reshape-the-matrix
566
Easy
[ "Array", "Matrix", "Simulation" ]
In MATLAB, there is a handy function called reshape which can reshape an m x n matrix into a new one with a different size r x c keeping its original data. You are given an m x n matrix mat and two integers r and c representing the number of rows and the number of columns of the wanted reshaped matrix. The reshaped mat...
matrixReshape(mat: list_list_int, r: int, c: int) -> list_list_int
pub fn matrix_reshape(mat: &[Vec<i64>], r: i64, c: i64) -> Vec<Vec<i64>>
Aegis.MatrixReshape.matrix_reshape
pub fn matrix_reshape(mat: &[Vec<i64>], r: i64, c: i64) -> Vec<Vec<i64>> { let m = mat.len(); let n = mat[0].len(); let total: i64 = (m as i64) * (n as i64); let target: i64 = r * c; if total != target { let mut out: Vec<Vec<i64>> = Vec::new(); let mut i = 0; while i < m { ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [matrix_reshape]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [matrix_reshape]: function definitions module public import Aeneas public import Aegis.MatrixReshape.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_opti...
import Aegis.MatrixReshape.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.MatrixReshape.matrix_reshape (Slice.from [(alloc.vec.Vec.from [1#i64, 2#i64] (by scalar_tac) : alloc.vec.Vec Std.I64), (alloc.vec.Vec.from [3#i64, ...
[ { "input": "[[[1, 2], [3, 4]], 1, 4]", "output": "[[1, 2, 3, 4]]" }, { "input": "[[[1, 2], [3, 4]], 2, 2]", "output": "[[1, 2], [3, 4]]" }, { "input": "[[[1, 2], [3, 4]], 2, 4]", "output": "[[1, 2], [3, 4]]" }, { "input": "[[[1, 2], [3, 4]], 4, 1]", "output": "[[1], [2], ...
97
false
97
verified
10
10
1
1,169
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MatrixReshape.Code.Funs /-! # Specifications of `Aegis.MatrixReshape.matrix_reshape` LeetCode problem `reshape-the-matrix`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.MatrixReshape def rowMajor (rows : List (alloc.vec.Vec Std.I64))...
7
permutation-in-string
567
Medium
[ "Hash Table", "Two Pointers", "String", "Sliding Window" ]
Given two strings s1 and s2, return true if s2 contains a permutation of s1, or false otherwise. In other words, return true if one of s1's permutations is the substring of s2.   Example 1: Input: s1 = "ab", s2 = "eidbaooo" Output: true Explanation: s2 contains one permutation of s1 ("ba"). Example 2: Input: s1 = "a...
checkInclusion(s1: str, s2: str) -> bool
pub fn check_inclusion(s1: &[u8], s2: &[u8]) -> bool
Aegis.CheckInclusion.check_inclusion
pub fn check_inclusion(s1: &[u8], s2: &[u8]) -> bool { let n1 = s1.len(); let n2 = s2.len(); if n1 > n2 { return false; } let mut need: Vec<i64> = Vec::new(); let mut window: Vec<i64> = Vec::new(); let mut i: usize = 0; while i < 26 { need.push(0); window.push(...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [check_inclusion]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linte...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [check_inclusion]: function definitions module public import Aeneas public import Aegis.CheckInclusion.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_op...
import Aegis.CheckInclusion.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.CheckInclusion.check_inclusion (Slice.from [97#u8, 98#u8, 99#u8] (by scalar_tac) : Slice Std.U8) (Slice.from [98#u8, 98#u8, 98#u8, 99#u8, 99#u8, 9...
[ { "input": "[\"abc\", \"bbbccca\"]", "output": "false" }, { "input": "[\"adc\", \"dcda\"]", "output": "true" }, { "input": "[\"abc\", \"bbbccba\"]", "output": "true" }, { "input": "[\"abcde\", \"adecb\"]", "output": "true" }, { "input": "[\"test\", \"ttewest\"]", ...
95
false
95
verified
10
10
1
1,791
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.CheckInclusion.Code.Funs /-! # Specifications of `Aegis.CheckInclusion.check_inclusion` LeetCode problem `permutation-in-string`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.CheckInclusion def countByte (bs : List Std.U8) (c : S...
15
maximum-vacation-days
568
Hard
[ "Array", "Dynamic Programming", "Matrix" ]
LeetCode wants to give one of its best employees the option to travel among n cities to collect algorithm problems. But all work and no play makes Jack a dull boy, you could take vacations in some particular cities and weeks. Your job is to schedule the traveling to maximize the number of vacation days you could take, ...
maxVacationDays(flights: list_list_int, days: list_list_int) -> int
pub fn max_vacation_days(flights: &[Vec<i64>], days: &[Vec<i64>]) -> i64
Aegis.MaxVacationDays.max_vacation_days
pub fn max_vacation_days(flights: &[Vec<i64>], days: &[Vec<i64>]) -> i64 { let n = days.len(); if n == 0 { return 0; } let k = days[0].len(); if k == 0 { return 0; } let neg: i64 = -1_000_000_000; let mut dp: Vec<i64> = Vec::new(); let mut i = 0; while i < n { ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [max_vacation_days]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option lin...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [max_vacation_days]: function definitions module public import Aeneas public import Aegis.MaxVacationDays.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set...
import Aegis.MaxVacationDays.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.MaxVacationDays.max_vacation_days (Slice.from [(alloc.vec.Vec.from [0#i64, 1#i64] (by scalar_tac) : alloc.vec.Vec Std.I64), (alloc.vec.Vec.from [...
[ { "input": "[[[0, 1], [1, 0]], [[3, 3, 3], [1, 1, 1]]]", "output": "9" }, { "input": "[[[0, 1, 1], [1, 0, 1], [1, 1, 0]], [[1, 3, 1], [6, 0, 3], [3, 3, 3]]]", "output": "12" }, { "input": "[[[0, 0, 0], [0, 0, 0], [0, 0, 0]], [[1, 1, 1], [7, 7, 7], [7, 7, 7]]]", "output": "3" }, {...
70
false
70
verified
10
10
1
1,622
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MaxVacationDays.Code.Funs /-! # Specifications of `Aegis.MaxVacationDays.max_vacation_days` LeetCode problem `maximum-vacation-days`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.MaxVacationDays (max_vacation_days) namespace AegisSpec.MaxVacat...
8
subtree-of-another-tree
572
Easy
[ "Tree", "Depth-First Search", "Binary Tree", "String Matching", "Hash Function" ]
Given the roots of two binary trees root and subRoot, return true if there is a subtree of root with the same structure and node values of subRoot and false otherwise. A subtree of a binary tree tree is a tree that consists of a node in tree and all of this node's descendants. The tree tree could also be considered as ...
isSubtree(root: tree, subRoot: tree) -> bool
pub fn is_subtree(root: &Tree, subRoot: &Tree) -> bool
Aegis.IsSubtree.is_subtree
fn same_tree(a: &Tree, b: &Tree) -> bool { match a { Tree::Null => match b { Tree::Null => true, Tree::Node(_, _, _) => false, }, Tree::Node(av, al, ar) => match b { Tree::Null => false, Tree::Node(bv, bl, br) => { if *av != *bv...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [is_subtree]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter.sty...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [is_subtree]: function definitions module public import Aeneas public import Aegis.IsSubtree.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linte...
import Aegis.IsSubtree.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.IsSubtree.is_subtree ((.Node 1#i64 (.Null) (.Null)) : Aegis.IsSubtree.Tree) ((.Node 1#i64 (.Null) (.Null)) : Aegis.IsSubtree.Tree)) (true))}") #eval (s...
[ { "input": "[[1], [1]]", "output": "true" }, { "input": "[[1], [2]]", "output": "false" }, { "input": "[[1, 2, 1], [2]]", "output": "true" }, { "input": "[[1, 2, 3], [2]]", "output": "true" }, { "input": "[[1, 2, 3], [1, 2]]", "output": "false" }, { "i...
72
false
72
verified
10
10
1
1,476
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.IsSubtree.Code.Funs /-! # Specifications of `Aegis.IsSubtree.is_subtree` LeetCode problem `subtree-of-another-tree`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.IsSubtree (Tree same_tree is_subtree) namespace AegisSpec.IsSubtree def si...
12
squirrel-simulation
573
Medium
[ "Array", "Math" ]
You are given two integers height and width representing a garden of size height x width. You are also given: an array tree where tree = [treer, treec] is the position of the tree in the garden, an array squirrel where squirrel = [squirrelr, squirrelc] is the position of the squirrel in the garden, and an array nuts w...
minDistance(height: int, width: int, tree: list_int, squirrel: list_int, nuts: list_list_int) -> int
pub fn min_distance(height: i64, width: i64, tree: &[i64], squirrel: &[i64], nuts: &[Vec<i64>]) -> i64
Aegis.MinDistance.min_distance
fn abs_diff(a: i64, b: i64) -> i64 { let d = a - b; if d < 0 { -d } else { d } } pub fn min_distance( height: i64, width: i64, tree: &[i64], squirrel: &[i64], nuts: &[Vec<i64>], ) -> i64 { let _ = height; let _ = width; let tr = tree[0]; let tc = tre...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [min_distance]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter.s...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [min_distance]: function definitions module public import Aeneas public import Aegis.MinDistance.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option l...
import Aegis.MinDistance.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.MinDistance.min_distance 1#i64 3#i64 (Slice.from [0#i64, 1#i64] (by scalar_tac) : Slice Std.I64) (Slice.from [0#i64, 0#i64] (by scalar_tac) : Slice S...
[ { "input": "[1, 3, [0, 1], [0, 0], [[0, 2]]]", "output": "3" }, { "input": "[100, 100, [50, 50], [99, 99], [[49, 49], [51, 51]]]", "output": "102" }, { "input": "[3, 3, [1, 1], [2, 2], [[0, 0], [2, 2]]]", "output": "6" }, { "input": "[5, 7, [2, 2], [4, 4], [[3, 0], [2, 5]]]",...
78
false
78
verified
10
10
1
1,612
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MinDistance.Code.Funs /-! # Specifications of `Aegis.MinDistance.min_distance` LeetCode problem `squirrel-simulation`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open scoped BigOperators namespace AegisSpec.MinDistance def coords (s : Slice I64) : Lis...
12
distribute-candies
575
Easy
[ "Array", "Hash Table" ]
Alice has n candies, where the ith candy is of type candyType[i]. Alice noticed that she started to gain weight, so she visited a doctor. The doctor advised Alice to only eat n / 2 of the candies she has (n is always even). Alice likes her candies very much, and she wants to eat the maximum number of different types of...
distributeCandies(candyType: list_int) -> int
pub fn distribute_candies(candyType: &[i64]) -> i64
Aegis.DistributeCandies.distribute_candies
pub fn distribute_candies(candyType: &[i64]) -> i64 { let n = candyType.len(); let mut distinct: i64 = 0; let mut i: usize = 0; while i < n { let mut seen: bool = false; let mut j: usize = 0; while j < i { if candyType[j] == candyType[i] { seen = tru...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [distribute_candies]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option li...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [distribute_candies]: function definitions module public import Aeneas public import Aegis.DistributeCandies.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false ...
import Aegis.DistributeCandies.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.DistributeCandies.distribute_candies (Slice.from [1#i64, 1#i64, 2#i64, 3#i64] (by scalar_tac) : Slice Std.I64)) (2#i64))}") #eval (s!"CASE 1 {(...
[ { "input": "[[1, 1, 2, 3]]", "output": "2" }, { "input": "[[1, 2, 3, 4]]", "output": "2" }, { "input": "[[6, 6, 6, 6]]", "output": "1" }, { "input": "[[1, 1, 1, 2, 2, 2]]", "output": "2" }, { "input": "[[0, 0, 0, 0, 0, 0]]", "output": "1" }, { "input":...
106
false
106
verified
10
10
1
1,255
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.DistributeCandies.Code.Funs /-! # Specifications of `Aegis.DistributeCandies.distribute_candies` LeetCode problem `distribute-candies`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.DistributeCandies def numDistinct (s : Slice Std.I64...
11
out-of-boundary-paths
576
Medium
[ "Dynamic Programming" ]
There is an m x n grid with a ball. The ball is initially at the position [startRow, startColumn]. You are allowed to move the ball to one of the four adjacent cells in the grid (possibly out of the grid crossing the grid boundary). You can apply at most maxMove moves to the ball. Given the five integers m, n, maxMove,...
findPaths(m: int, n: int, maxMove: int, startRow: int, startColumn: int) -> int
pub fn find_paths(m: i64, n: i64, maxMove: i64, startRow: i64, startColumn: i64) -> i64
Aegis.FindPaths.find_paths
pub fn find_paths(m: i64, n: i64, maxMove: i64, startRow: i64, startColumn: i64) -> i64 { let md: i64 = 1000000007; let rows = m as usize; let cols = n as usize; let mut dp: Vec<Vec<i64>> = Vec::new(); let mut r = 0; while r < rows { let mut row: Vec<i64> = Vec::new(); let mut c...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [find_paths]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter.sty...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [find_paths]: function definitions module public import Aeneas public import Aegis.FindPaths.Code.Types public import Aegis.FindPaths.Code.FunsExternal @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [find_paths]: external functions. -- This is a template file: rename it to "FunsExternal.lean" and fill the holes. module public import Aeneas public import Aegis.FindPaths.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_optio...
import Aegis.FindPaths.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.FindPaths.find_paths 3#i64 3#i64 1#i64 1#i64 1#i64) (0#i64))}") #eval (s!"CASE 1 {(Result.reducesTo (Aegis.FindPaths.find_paths 5#i64 5#i64 50#i64 0#i6...
[ { "input": "[3, 3, 1, 1, 1]", "output": "0" }, { "input": "[5, 5, 50, 0, 0]", "output": "101070018" }, { "input": "[2, 2, 2, 0, 0]", "output": "6" }, { "input": "[3, 3, 0, 1, 1]", "output": "0" }, { "input": "[4, 4, 0, 2, 2]", "output": "0" }, { "input...
117
false
117
verified
10
10
1
3,137
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.FindPaths.Code.Funs /-! # Specifications of `Aegis.FindPaths.find_paths` LeetCode problem `out-of-boundary-paths`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aeneas.Std.Result namespace AegisSpec.FindPaths def isMove (d : Int × Int) : Prop := d...
11
shortest-unsorted-continuous-subarray
581
Medium
[ "Stack", "Greedy", "Array", "Two Pointers", "Sorting", "Monotonic Stack" ]
Given an integer array nums, you need to find one continuous subarray such that if you only sort this subarray in non-decreasing order, then the whole array will be sorted in non-decreasing order. Return the shortest such subarray and output its length.   Example 1: Input: nums = [2,6,4,8,10,9,15] Output: 5 Explanatio...
findUnsortedSubarray(nums: list_int) -> int
pub fn find_unsorted_subarray(nums: &[i64]) -> i64
Aegis.FindUnsortedSubarray.find_unsorted_subarray
pub fn find_unsorted_subarray(nums: &[i64]) -> i64 { let n = nums.len(); if n <= 1 { return 0; } let mut left: usize = 0; while left + 1 < n && nums[left] <= nums[left + 1] { left += 1; } if left + 1 == n { return 0; } let mut right: usize = n - 1; whi...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [find_unsorted_subarray]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_optio...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [find_unsorted_subarray]: function definitions module public import Aeneas public import Aegis.FindUnsortedSubarray.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand...
import Aegis.FindUnsortedSubarray.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.FindUnsortedSubarray.find_unsorted_subarray (Slice.from [1#i64] (by scalar_tac) : Slice Std.I64)) (0#i64))}") #eval (s!"CASE 1 {(Result.redu...
[ { "input": "[[1]]", "output": "0" }, { "input": "[[3, 2, 1]]", "output": "3" }, { "input": "[[1, 2, 3, 4]]", "output": "0" }, { "input": "[[1, 3, 2, 4, 5]]", "output": "2" }, { "input": "[[1, 2, 3, 5, 4]]", "output": "2" }, { "input": "[[1, 2, 5, 4, 3]...
158
false
158
verified
10
10
1
4,677
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.FindUnsortedSubarray.Code.Funs /-! # Specifications of `Aegis.FindUnsortedSubarray.find_unsorted_subarray` LeetCode problem `shortest-unsorted-continuous-subarray`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.FindUnsortedSubarray de...
11
delete-operation-for-two-strings
583
Medium
[ "String", "Dynamic Programming" ]
Given two strings word1 and word2, return the minimum number of steps required to make word1 and word2 the same. In one step, you can delete exactly one character in either string.   Example 1: Input: word1 = "sea", word2 = "eat" Output: 2 Explanation: You need one step to make "sea" to "ea" and another step to make "...
minDistance(word1: str, word2: str) -> int
pub fn min_distance(word1: &[u8], word2: &[u8]) -> i64
Aegis.MinDistance.min_distance
pub fn min_distance(word1: &[u8], word2: &[u8]) -> i64 { let n = word1.len(); let m = word2.len(); let mut dp: Vec<i64> = Vec::new(); let mut j = 0; while j <= m { dp.push(0); j += 1; } let mut i = 0; while i < n { let mut diag: i64 = 0; let mut j = 1; ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [min_distance]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter.s...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [min_distance]: function definitions module public import Aeneas public import Aegis.MinDistance.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option l...
import Aegis.MinDistance.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.MinDistance.min_distance (Slice.from [97#u8, 98#u8, 99#u8] (by scalar_tac) : Slice Std.U8) (Slice.from [100#u8, 101#u8, 102#u8] (by scalar_tac) : Sli...
[ { "input": "[\"abc\", \"def\"]", "output": "6" }, { "input": "[\"abcde\", \"fghij\"]", "output": "10" }, { "input": "[\"abcdefghijklmnopqrstuvwxyz\", \"zyxwvutsrqponmlkjihgfedcba\"]", "output": "50" }, { "input": "[\"sea\", \"eat\"]", "output": "2" }, { "input": "...
104
false
104
verified
10
10
1
1,360
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MinDistance.Code.Funs /-! # Specifications of `Aegis.MinDistance.min_distance` LeetCode problem `delete-operation-for-two-strings`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.MinDistance namespace AegisSpec.MinDistance def CommonSubse...
16
tag-validator
591
Hard
[ "Stack", "String" ]
Given a string representing a code snippet, implement a tag validator to parse the code and return whether it is valid. A code snippet is valid if all the following rules hold: The code must be wrapped in a valid closed tag. Otherwise, the code is invalid. A closed tag (not necessarily valid) has exactly the following...
isValid(code: str) -> bool
pub fn is_valid(code: &[u8]) -> bool
Aegis.IsValid.is_valid
fn name_key(code: &[u8], start: usize, end: usize) -> i64 { let len = end - start; let mut result: i64 = -1; if len >= 1 && len <= 9 { let mut val: i64 = 0; let mut ok: bool = true; let mut k = start; while k < end { let b = code[k]; if b < b'A' || b >...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [is_valid]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter.style...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [is_valid]: function definitions module public import Aeneas public import Aegis.IsValid.Code.Types public import Aegis.IsValid.Code.FunsExternal @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [is_valid]: external functions. -- This is a template file: rename it to "FunsExternal.lean" and fill the holes. module public import Aeneas public import Aegis.IsValid.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option li...
import Aegis.IsValid.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.IsValid.is_valid (Slice.from [60#u8, 65#u8, 62#u8, 97#u8, 98#u8, 99#u8, 60#u8, 47#u8, 65#u8, 62#u8] (by scalar_tac) : Slice Std.U8)) (true))}") #eval (s!...
[ { "input": "[\"<A>abc</A>\"]", "output": "true" }, { "input": "[\"<A><![CDATA[wahaha]]]></A>\"]", "output": "true" }, { "input": "[\"<A><B><![CDATA[CDATA]]></B></A>\"]", "output": "true" }, { "input": "[\"<A><B></C></B></A>\"]", "output": "false" }, { "input": "[\...
231
false
231
verified
10
10
2
17,916
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.IsValid.Code.Funs /-! # Specifications of `Aegis.IsValid.is_valid` LeetCode problem `tag-validator`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.IsValid def isUpper (b : Aeneas.Std.U8) : Prop := 65 ≤ b.val ∧ b.val ≤ 90 def inAlphab...
13
valid-square
593
Medium
[ "Geometry", "Math" ]
Given the coordinates of four points in 2D space p1, p2, p3 and p4, return true if the four points construct a square. The coordinate of a point pi is represented as [xi, yi]. The input is not given in any order. A valid square has four equal sides with positive length and four equal angles (90-degree angles).   Exampl...
validSquare(p1: list_int, p2: list_int, p3: list_int, p4: list_int) -> bool
pub fn valid_square(p1: &[i64], p2: &[i64], p3: &[i64], p4: &[i64]) -> bool
Aegis.ValidSquare.valid_square
fn sq_dist(a: &[i64], b: &[i64]) -> i64 { let dx = a[0] - b[0]; let dy = a[1] - b[1]; dx * dx + dy * dy } pub fn valid_square(p1: &[i64], p2: &[i64], p3: &[i64], p4: &[i64]) -> bool { let mut ds: Vec<i64> = Vec::new(); ds.push(sq_dist(p1, p2)); ds.push(sq_dist(p1, p3)); ds.push(sq_dist(p1, ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [valid_square]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter.s...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [valid_square]: function definitions module public import Aeneas public import Aegis.ValidSquare.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option l...
import Aegis.ValidSquare.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.ValidSquare.valid_square (Slice.from [(-1)#i64, (-1)#i64] (by scalar_tac) : Slice Std.I64) (Slice.from [(-1)#i64, 1#i64] (by scalar_tac) : Slice Std....
[ { "input": "[[-1, -1], [-1, 1], [1, 1], [1, -1]]", "output": "true" }, { "input": "[[1, 2], [3, 4], [5, 6], [7, 8]]", "output": "false" }, { "input": "[[2, 2], [3, 3], [4, 4], [5, 5]]", "output": "false" }, { "input": "[[0, 0], [0, 0], [0, 0], [0, 0]]", "output": "false" ...
89
false
89
verified
10
10
1
2,107
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.ValidSquare.Code.Funs /-! # Specifications of `Aegis.ValidSquare.valid_square` LeetCode problem `valid-square`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.ValidSquare open Aegis.ValidSquare def coord (p : Slice Std.I64) (k :...
15
longest-harmonious-subsequence
594
Easy
[ "Array", "Hash Table", "Counting", "Sorting", "Sliding Window" ]
We define a harmonious array as an array where the difference between its maximum value and its minimum value is exactly 1. Given an integer array nums, return the length of its longest harmonious subsequence among all its possible subsequences.   Example 1: Input: nums = [1,3,2,2,5,2,3,7] Output: 5 Explanation: The l...
findLHS(nums: list_int) -> int
pub fn find_lhs(nums: &[i64]) -> i64
Aegis.FindLhs.find_lhs
pub fn find_lhs(nums: &[i64]) -> i64 { let n: usize = nums.len(); let mut v: Vec<i64> = Vec::new(); let mut idx: usize = 0; while idx < n { v.push(nums[idx]); idx += 1; } if n == 0 { return 0; } // Bottom-up merge sort to keep the implementation inside the safe...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [find_lhs]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter.style...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [find_lhs]: function definitions module public import Aeneas public import Aegis.FindLhs.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.un...
import Aegis.FindLhs.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.FindLhs.find_lhs (Slice.from [1#i64] (by scalar_tac) : Slice Std.I64)) (0#i64))}") #eval (s!"CASE 1 {(Result.reducesTo (Aegis.FindLhs.find_lhs (Slice.fro...
[ { "input": "[[1]]", "output": "0" }, { "input": "[[2, 1]]", "output": "2" }, { "input": "[[1000000000, -1000000000]]", "output": "0" }, { "input": "[[1, 2]]", "output": "2" }, { "input": "[[5, 5, 5, 6]]", "output": "4" }, { "input": "[[1, 1, 1, 1]]", ...
116
false
116
verified
10
10
1
4,014
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.FindLhs.Code.Funs /-! # Specifications of `Aegis.FindLhs.find_lhs` LeetCode problem `longest-harmonious-subsequence`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.FindLhs def atIdx (l : List Std.I64) (i : ℕ) (h : i < l.length) : ℤ :=...
12
range-addition-ii
598
Easy
[ "Array", "Math" ]
You are given an m x n matrix M initialized with all 0's and an array of operations ops, where ops[i] = [ai, bi] means M[x][y] should be incremented by one for all 0 <= x < ai and 0 <= y < bi. Count and return the number of maximum integers in the matrix after performing all the operations.   Example 1: Input: m = 3,...
maxCount(m: int, n: int, ops: list_list_int) -> int
pub fn max_count(m: i64, n: i64, ops: &[Vec<i64>]) -> i64
Aegis.MaxCount.max_count
pub fn max_count(m: i64, n: i64, ops: &[Vec<i64>]) -> i64 { if ops.len() == 0 { return m * n; } let mut min_a: i64 = m; let mut min_b: i64 = n; let mut i: usize = 0; while i < ops.len() { let a: i64 = ops[i][0]; let b: i64 = ops[i][1]; if a < min_a { ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [max_count]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter.styl...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [max_count]: function definitions module public import Aeneas public import Aegis.MaxCount.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter....
import Aegis.MaxCount.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.MaxCount.max_count 1#i64 1#i64 (Slice.from [] (by scalar_tac) : Slice (alloc.vec.Vec Std.I64))) (1#i64))}") #eval (s!"CASE 1 {(Result.reducesTo (Aegis.M...
[ { "input": "[1, 1, []]", "output": "1" }, { "input": "[3, 3, []]", "output": "9" }, { "input": "[5, 4, [[2, 2]]]", "output": "4" }, { "input": "[1, 1, [[1, 1]]]", "output": "1" }, { "input": "[4, 5, [[2, 3], [3, 4]]]", "output": "6" }, { "input": "[3, ...
112
false
112
verified
10
10
1
544
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MaxCount.Code.Funs /-! # Specifications of `Aegis.MaxCount.max_count` LeetCode problem `range-addition-ii`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.MaxCount (max_count) namespace AegisSpec.MaxCount def opsList (ops : Slice (alloc.v...
13
minimum-index-sum-of-two-lists
599
Easy
[ "Array", "Hash Table", "String" ]
Given two arrays of strings list1 and list2, find the common strings with the least index sum. A common string is a string that appeared in both list1 and list2. A common string with the least index sum is a common string such that if it appeared at list1[i] and list2[j] then i + j should be the minimum value among all...
findRestaurant(list1: list_str, list2: list_str) -> list_str
pub fn find_restaurant(list1: &[Vec<u8>], list2: &[Vec<u8>]) -> Vec<Vec<u8>>
Aegis.FindRestaurant.find_restaurant
fn strings_equal(a: &[Vec<u8>], i: usize, b: &[Vec<u8>], j: usize) -> bool { if a[i].len() != b[j].len() { return false; } let mut k: usize = 0; while k < a[i].len() { if a[i][k] != b[j][k] { return false; } k += 1; } true } pub fn find_restaurant(l...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [find_restaurant]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linte...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [find_restaurant]: function definitions module public import Aeneas public import Aegis.FindRestaurant.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_op...
import Aegis.FindRestaurant.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(match (Aegis.FindRestaurant.find_restaurant (Slice.from [(alloc.vec.Vec.from [97#u8, 112#u8, 112#u8, 108#u8, 101#u8] (by scalar_tac) : alloc.vec.Vec Std.U8), (alloc.vec.V...
[ { "input": "[[\"apple\", \"banana\"], [\"banana\", \"apple\"]]", "output": "[\"apple\", \"banana\"]" }, { "input": "[[\"Poke Bar\", \"Sushi Spot\", \"Tataki House\"], [\"Tataki House\", \"Poke Bar\", \"Sushi Spot\"]]", "output": "[\"Poke Bar\"]" }, { "input": "[[\"Pizza Palace\", \"Pasta...
93
true
93
verified
10
10
1
2,685
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.FindRestaurant.Code.Funs /-! # Specifications of `Aegis.FindRestaurant.find_restaurant` LeetCode problem `minimum-index-sum-of-two-lists`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open scoped Classical open Aegis.FindRestaurant namespace AegisSpec.Fi...
11
non-negative-integers-without-consecutive-ones
600
Hard
[ "Dynamic Programming" ]
Given a positive integer n, return the number of the integers in the range [0, n] whose binary representations do not contain consecutive ones.   Example 1: Input: n = 5 Output: 5 Explanation: Here are the non-negative integers <= 5 with their corresponding binary representations: 0 : 0 1 : 1 2 : 10 3 : 11 4 : 100 5 :...
findIntegers(n: int) -> int
pub fn find_integers(n: i64) -> i64
Aegis.FindIntegers.find_integers
pub fn find_integers(n: i64) -> i64 { // g[k] = number of length-k binary strings with no two consecutive 1s. // g[0]=1, g[1]=2, g[k]=g[k-1]+g[k-2]. Precomputed up to k=30. let mut g: Vec<i64> = Vec::new(); g.push(1); g.push(2); g.push(3); g.push(5); g.push(8); g.push(13); g.pus...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [find_integers]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter....
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [find_integers]: function definitions module public import Aeneas public import Aegis.FindIntegers.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option...
import Aegis.FindIntegers.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.FindIntegers.find_integers 100#i64) (34#i64))}") #eval (s!"CASE 1 {(Result.reducesTo (Aegis.FindIntegers.find_integers 15#i64) (8#i64))}") #eval (s!...
[ { "input": "[100]", "output": "34" }, { "input": "[15]", "output": "8" }, { "input": "[1000000]", "output": "17711" }, { "input": "[32]", "output": "14" }, { "input": "[2]", "output": "3" }, { "input": "[1]", "output": "2" }, { "input": "[1...
26
false
26
verified
10
10
2
33,171
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.FindIntegers.Code.Funs /-! # Specifications of `Aegis.FindIntegers.find_integers` LeetCode problem `non-negative-integers-without-consecutive-ones`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.FindIntegers def hasTwoAdjacentOnes...
9
can-place-flowers
605
Easy
[ "Greedy", "Array" ]
You have a long flowerbed in which some of the plots are planted, and some are not. However, flowers cannot be planted in adjacent plots. Given an integer array flowerbed containing 0's and 1's, where 0 means empty and 1 means not empty, and an integer n, return true if n new flowers can be planted in the flowerbed wit...
canPlaceFlowers(flowerbed: list_int, n: int) -> bool
pub fn can_place_flowers(flowerbed: &[i64], n: i64) -> bool
Aegis.CanPlaceFlowers.can_place_flowers
pub fn can_place_flowers(flowerbed: &[i64], n: i64) -> bool { let len = flowerbed.len(); let mut planted: i64 = 0; let mut i: usize = 0; let mut prev: i64 = 0; // an empty plot just before the left edge while i < len { let cur: i64 = flowerbed[i]; let mut next: i64 = 0; // an empty...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [can_place_flowers]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option lin...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [can_place_flowers]: function definitions module public import Aeneas public import Aegis.CanPlaceFlowers.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set...
import Aegis.CanPlaceFlowers.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.CanPlaceFlowers.can_place_flowers (Slice.from [0#i64] (by scalar_tac) : Slice Std.I64) 1#i64) (true))}") #eval (s!"CASE 1 {(Result.reducesTo (Aeg...
[ { "input": "[[0], 1]", "output": "true" }, { "input": "[[1], 0]", "output": "true" }, { "input": "[[0, 0], 1]", "output": "true" }, { "input": "[[1, 1], 0]", "output": "true" }, { "input": "[[1, 0, 1, 0, 1], 0]", "output": "true" }, { "input": "[[1, 0,...
107
false
107
verified
10
10
2
6,380
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.CanPlaceFlowers.Code.Funs /-! # Specifications of `Aegis.CanPlaceFlowers.can_place_flowers` LeetCode problem `can-place-flowers`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.CanPlaceFlowers set_option autoImplicit false namespace Aegis...
14
valid-triangle-number
611
Medium
[ "Greedy", "Array", "Two Pointers", "Binary Search", "Sorting" ]
Given an integer array nums, return the number of triplets chosen from the array that can make triangles if we take them as side lengths of a triangle.   Example 1: Input: nums = [2,2,3,4] Output: 3 Explanation: Valid combinations are: 2,3,4 (using the first 2) 2,3,4 (using the second 2) 2,2,3 Example 2: Input: num...
triangleNumber(nums: list_int) -> int
pub fn triangle_number(nums: &[i64]) -> i64
Aegis.TriangleNumber.triangle_number
pub fn triangle_number(nums: &[i64]) -> i64 { let n = nums.len(); if n < 3 { return 0; } let mut arr: Vec<i64> = Vec::new(); let mut i: usize = 0; while i < n { arr.push(nums[i]); i += 1; } let mut i: usize = 1; while i < n { let key: i64 = arr[i]; ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [triangle_number]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linte...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [triangle_number]: function definitions module public import Aeneas public import Aegis.TriangleNumber.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_op...
import Aegis.TriangleNumber.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.TriangleNumber.triangle_number (Slice.from [0#i64, 0#i64, 0#i64] (by scalar_tac) : Slice Std.I64)) (0#i64))}") #eval (s!"CASE 1 {(Result.reducesTo...
[ { "input": "[[0, 0, 0]]", "output": "0" }, { "input": "[[1, 2, 3]]", "output": "0" }, { "input": "[[1, 1, 1, 1]]", "output": "4" }, { "input": "[[4, 2, 3, 4]]", "output": "4" }, { "input": "[[0, 1, 0, 1]]", "output": "0" }, { "input": "[[5, 5, 5, 5]]",...
115
false
115
verified
10
10
1
2,285
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.TriangleNumber.Code.Funs /-! # Specifications of `Aegis.TriangleNumber.triangle_number` LeetCode problem `valid-triangle-number`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.TriangleNumber namespace AegisSpec.TriangleNumber def elems (nums...
11
merge-two-binary-trees
617
Easy
[ "Tree", "Depth-First Search", "Breadth-First Search", "Binary Tree" ]
You are given two binary trees root1 and root2. Imagine that when you put one of them to cover the other, some nodes of the two trees are overlapped while the others are not. You need to merge the two trees into a new binary tree. The merge rule is that if two nodes overlap, then sum node values up as the new value of ...
mergeTrees(root1: tree, root2: tree) -> tree
pub fn merge_trees(root1: &Tree, root2: &Tree) -> Tree
Aegis.MergeTrees.merge_trees
pub fn merge_trees(root1: &Tree, root2: &Tree) -> Tree { match root1 { Tree::Null => clone_tree(root2), Tree::Node(v1, l1, r1) => match root2 { Tree::Null => clone_tree(root1), Tree::Node(v2, l2, r2) => Tree::Node( *v1 + *v2, Box::new(merge_tre...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [merge_trees]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter.st...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [merge_trees]: function definitions module public import Aeneas public import Aegis.MergeTrees.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option lin...
import Aegis.MergeTrees.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 deriving instance DecidableEq for Aegis.MergeTrees.Tree #eval (s!"CASE 0 {(match (Aegis.MergeTrees.merge_trees ((.Null) : Aegis.MergeTrees.Tree) ((.Node 1#i64 (.Null) (.Null)) : Aegis.MergeTre...
[ { "input": "[[], [1]]", "output": "[1]" }, { "input": "[[1], []]", "output": "[1]" }, { "input": "[[1, 2], []]", "output": "[1, 2]" }, { "input": "[[1], [1, 2]]", "output": "[2, 2]" }, { "input": "[[1, 2], [3]]", "output": "[4, 2]" }, { "input": "[[1, ...
34
false
34
verified
10
10
1
3,365
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MergeTrees.Code.Funs /-! # Specifications of `Aegis.MergeTrees.merge_trees` LeetCode problem `merge-two-binary-trees`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.MergeTrees open Aegis.MergeTrees (Tree merge_trees) inductive Step w...
13
task-scheduler
621
Medium
[ "Greedy", "Array", "Hash Table", "Counting", "Sorting", "Heap (Priority Queue)" ]
You are given an array of CPU tasks, each labeled with a letter from A to Z, and a number n. Each CPU interval can be idle or allow the completion of one task. Tasks can be completed in any order, but there's a constraint: there has to be a gap of at least n intervals between two tasks with the same label. Return the m...
leastInterval(tasks: list_str, n: int) -> int
pub fn least_interval(tasks: &[Vec<u8>], n: i64) -> i64
Aegis.LeastInterval.least_interval
pub fn least_interval(tasks: &[Vec<u8>], n: i64) -> i64 { let mut counts: Vec<i64> = Vec::new(); let mut i: usize = 0; while i < 26 { counts.push(0); i = i + 1; } let mut total: i64 = 0; let mut t: usize = 0; while t < tasks.len() { let label = tasks[t][0]; l...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [least_interval]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [least_interval]: function definitions module public import Aeneas public import Aegis.LeastInterval.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_opti...
import Aegis.LeastInterval.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.LeastInterval.least_interval (Slice.from [(alloc.vec.Vec.from [65#u8] (by scalar_tac) : alloc.vec.Vec Std.U8)] (by scalar_tac) : Slice (alloc.vec.V...
[ { "input": "[[\"A\"], 5]", "output": "1" }, { "input": "[[\"A\"], 0]", "output": "1" }, { "input": "[[\"A\", \"B\", \"C\", \"D\"], 0]", "output": "4" }, { "input": "[[\"A\", \"A\", \"B\", \"B\"], 0]", "output": "4" }, { "input": "[[\"A\", \"A\", \"A\", \"B\", \"B\...
86
false
86
verified
10
10
1
1,765
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.LeastInterval.Code.Funs /-! # Specifications of `Aegis.LeastInterval.least_interval` LeetCode problem `task-scheduler`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.LeastInterval namespace AegisSpec.LeastInterval def SizePre (tasks : Sl...
9
add-one-row-to-tree
623
Medium
[ "Tree", "Depth-First Search", "Breadth-First Search", "Binary Tree" ]
Given the root of a binary tree and two integers val and depth, add a row of nodes with value val at the given depth depth. Note that the root node is at depth 1. The adding rule is: Given the integer depth, for each not null tree node cur at the depth depth - 1, create two tree nodes with value val as cur's left subt...
addOneRow(root: tree, val: int, depth: int) -> tree
pub fn add_one_row(root: &Tree, val: i64, depth: i64) -> Tree
Aegis.AddOneRow.add_one_row
fn clone_tree(t: &Tree) -> Tree { match t { Tree::Null => Tree::Null, Tree::Node(v, l, r) => Tree::Node( *v, Box::new(clone_tree(&**l)), Box::new(clone_tree(&**r)), ), } } fn add_helper(t: &Tree, val: i64, depth: i64, cur_depth: i64) -> Tree { mat...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [add_one_row]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter.st...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [add_one_row]: function definitions module public import Aeneas public import Aegis.AddOneRow.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option lint...
import Aegis.AddOneRow.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 deriving instance DecidableEq for Aegis.AddOneRow.Tree #eval (s!"CASE 0 {(match (Aegis.AddOneRow.add_one_row ((.Node 1#i64 (.Null) (.Null)) : Aegis.AddOneRow.Tree) 2#i64 1#i64).match with | .ok...
[ { "input": "[[1], 2, 1]", "output": "[2, 1]" }, { "input": "[[1, 2, 3], 4, 4]", "output": "[1, 2, 3]" }, { "input": "[[1, 2, 3], 5, 4]", "output": "[1, 2, 3]" }, { "input": "[[1, 2, 3], 4, 5]", "output": "[1, 2, 3]" }, { "input": "[[1, 2, 3, 4], 5, 5]", "outpu...
23
false
23
verified
10
10
1
3,188
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.AddOneRow.Code.Funs /-! # Specifications of `Aegis.AddOneRow.add_one_row` LeetCode problem `add-one-row-to-tree`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.AddOneRow namespace AegisSpec.AddOneRow inductive Dir where | left : Dir ...
12
minimum-factorization
625
Medium
[ "Greedy", "Math" ]
Given a positive integer num, return the smallest positive integer x whose multiplication of each digit equals num. If there is no answer or the answer is not fit in 32-bit signed integer, return 0.   Example 1: Input: num = 48 Output: 68 Example 2: Input: num = 15 Output: 35   Constraints: 1 <= num <= 231 - 1
smallestFactorization(num: int) -> int
pub fn smallest_factorization(num: i64) -> i64
Aegis.SmallestFactorization.smallest_factorization
pub fn smallest_factorization(num: i64) -> i64 { if num < 10 { return num; } let mut n = num; let mut res: i64 = 0; let mut mult: i64 = 1; let mut d: i64 = 9; let mut overflow = false; while d >= 2 { let mut continuing = true; while continuing { if n...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [smallest_factorization]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_optio...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [smallest_factorization]: function definitions module public import Aeneas public import Aegis.SmallestFactorization.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashComman...
import Aegis.SmallestFactorization.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.SmallestFactorization.smallest_factorization 3249#i64) (0#i64))}") #eval (s!"CASE 1 {(Result.reducesTo (Aegis.SmallestFactorization.smalles...
[ { "input": "[3249]", "output": "0" }, { "input": "[10]", "output": "25" }, { "input": "[48]", "output": "68" }, { "input": "[210]", "output": "567" }, { "input": "[1000000000]", "output": "0" }, { "input": "[360]", "output": "589" }, { "inp...
52
false
52
verified
10
10
2
2,203
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.SmallestFactorization.Code.Funs /-! # Specifications of `Aegis.SmallestFactorization.smallest_factorization` LeetCode problem `minimum-factorization`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.SmallestFactorization open Aegis....
16
maximum-product-of-three-numbers
628
Easy
[ "Array", "Math", "Sorting" ]
Given an integer array nums, find three numbers whose product is maximum and return the maximum product.   Example 1: Input: nums = [1,2,3] Output: 6 Example 2: Input: nums = [1,2,3,4] Output: 24 Example 3: Input: nums = [-1,-2,-3] Output: -6   Constraints: 3 <= nums.length <= 104 -1000 <= nums[i] <= 1000
maximumProduct(nums: list_int) -> int
pub fn maximum_product(nums: &[i64]) -> i64
Aegis.MaximumProduct.maximum_product
pub fn maximum_product(nums: &[i64]) -> i64 { let mut max1: i64 = -1000000; let mut max2: i64 = -1000000; let mut max3: i64 = -1000000; let mut min1: i64 = 1000000; let mut min2: i64 = 1000000; let n: usize = nums.len(); let mut i: usize = 0; while i < n { let x: i64 = nums[i]...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [maximum_product]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linte...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [maximum_product]: function definitions module public import Aeneas public import Aegis.MaximumProduct.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_op...
import Aegis.MaximumProduct.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.MaximumProduct.maximum_product (Slice.from [1#i64, 2#i64, 3#i64] (by scalar_tac) : Slice Std.I64)) (6#i64))}") #eval (s!"CASE 1 {(Result.reducesTo...
[ { "input": "[[1, 2, 3]]", "output": "6" }, { "input": "[[-1, -2, -3]]", "output": "-6" }, { "input": "[[-1, 0, 1]]", "output": "0" }, { "input": "[[-100, 0, 100]]", "output": "0" }, { "input": "[[-10, -10, 5, 2]]", "output": "500" }, { "input": "[[1, 2...
111
false
111
verified
10
10
1
3,380
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MaximumProduct.Code.Funs /-! # Specifications of `Aegis.MaximumProduct.maximum_product` LeetCode problem `maximum-product-of-three-numbers`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.MaximumProduct namespace AegisSpec.MaximumProduct def en...
10
k-inverse-pairs-array
629
Hard
[ "Dynamic Programming" ]
For an integer array nums, an inverse pair is a pair of integers [i, j] where 0 <= i < j < nums.length and nums[i] > nums[j]. Given two integers n and k, return the number of different arrays consisting of numbers from 1 to n such that there are exactly k inverse pairs. Since the answer can be huge, return it modulo 10...
kInversePairs(n: int, k: int) -> int
pub fn k_inverse_pairs(n: i64, k: i64) -> i64
Aegis.KInversePairs.k_inverse_pairs
pub fn k_inverse_pairs(n: i64, k: i64) -> i64 { const MOD: i64 = 1000000007; if k < 0 { return 0; } if n <= 0 { if k == 0 { return 1; } else { return 0; } } if k > n * (n - 1) / 2 { return 0; } let n_us = n as usize; l...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [k_inverse_pairs]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linte...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [k_inverse_pairs]: function definitions module public import Aeneas public import Aegis.KInversePairs.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_opt...
import Aegis.KInversePairs.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.KInversePairs.k_inverse_pairs 1000#i64 500#i64) (955735232#i64))}") #eval (s!"CASE 1 {(Result.reducesTo (Aegis.KInversePairs.k_inverse_pairs 100#i6...
[ { "input": "[1000, 500]", "output": "955735232" }, { "input": "[100, 0]", "output": "1" }, { "input": "[20, 50]", "output": "788876615" }, { "input": "[1000, 0]", "output": "1" }, { "input": "[10, 10]", "output": "21670" }, { "input": "[3, 0]", "ou...
80
false
80
verified
10
10
1
4,981
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.KInversePairs.Code.Funs /-! # Specifications of `Aegis.KInversePairs.k_inverse_pairs` LeetCode problem `k-inverse-pairs-array`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.KInversePairs open Aegis.KInversePairs (k_inverse_pairs)...
11
course-schedule-iii
630
Hard
[ "Greedy", "Array", "Sorting", "Heap (Priority Queue)" ]
There are n different online courses numbered from 1 to n. You are given an array courses where courses[i] = [durationi, lastDayi] indicate that the ith course should be taken continuously for durationi days and must be finished before or on lastDayi. You will start on the 1st day and you cannot take two or more course...
scheduleCourse(courses: list_list_int) -> int
pub fn schedule_course(courses: &[Vec<i64>]) -> i64
Aegis.ScheduleCourse.schedule_course
pub fn schedule_course(courses: &[Vec<i64>]) -> i64 { let n: usize = courses.len(); if n == 0 { return 0; } let mut max_duration: i64 = 0; let mut i: usize = 0; while i < n { let d: i64 = courses[i][0]; if d > max_duration { max_duration = d; } ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [schedule_course]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linte...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [schedule_course]: function definitions module public import Aeneas public import Aegis.ScheduleCourse.Code.Types public import Aegis.ScheduleCourse.Code.FunsExternal @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNames...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [schedule_course]: external functions. -- This is a template file: rename it to "FunsExternal.lean" and fill the holes. module public import Aeneas public import Aegis.ScheduleCourse.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error...
import Aegis.ScheduleCourse.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.ScheduleCourse.schedule_course (Slice.from [(alloc.vec.Vec.from [1#i64, 2#i64] (by scalar_tac) : alloc.vec.Vec Std.I64)] (by scalar_tac) : Slice (...
[ { "input": "[[[1, 2]]]", "output": "1" }, { "input": "[[[3, 2], [4, 3]]]", "output": "0" }, { "input": "[[[5, 5], [2, 5], [4, 6]]]", "output": "2" }, { "input": "[[[10, 15], [20, 30], [10, 25]]]", "output": "2" }, { "input": "[[[100, 100], [200, 200], [300, 300]]]...
130
false
130
verified
10
10
1
11,796
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.ScheduleCourse.Code.Funs /-! # Specifications of `Aegis.ScheduleCourse.schedule_course` LeetCode problem `course-schedule-iii`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.ScheduleCourse abbrev CourseSlice := Slice (alloc.vec.Vec St...
12
sum-of-square-numbers
633
Medium
[ "Math", "Two Pointers", "Binary Search" ]
Given a non-negative integer c, decide whether there're two integers a and b such that a2 + b2 = c.   Example 1: Input: c = 5 Output: true Explanation: 1 * 1 + 2 * 2 = 5 Example 2: Input: c = 3 Output: false   Constraints: 0 <= c <= 231 - 1
judgeSquareSum(c: int) -> bool
pub fn judge_square_sum(c: i64) -> bool
Aegis.JudgeSquareSum.judge_square_sum
pub fn judge_square_sum(c: i64) -> bool { let mut b: i64 = 0; while (b + 1) * (b + 1) <= c { b += 1; } let mut a: i64 = 0; while a <= b { let sum = a * a + b * b; if sum == c { return true; } if sum < c { a += 1; } else { ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [judge_square_sum]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option lint...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [judge_square_sum]: function definitions module public import Aeneas public import Aegis.JudgeSquareSum.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_o...
import Aegis.JudgeSquareSum.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.JudgeSquareSum.judge_square_sum 0#i64) (true))}") #eval (s!"CASE 1 {(Result.reducesTo (Aegis.JudgeSquareSum.judge_square_sum 1000000001#i64) (fals...
[ { "input": "[0]", "output": "true" }, { "input": "[1000000001]", "output": "false" }, { "input": "[25]", "output": "true" }, { "input": "[2]", "output": "true" }, { "input": "[3]", "output": "false" }, { "input": "[5]", "output": "true" }, { ...
52
false
52
verified
10
10
1
949
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.JudgeSquareSum.Code.Funs /-! # Specifications of `Aegis.JudgeSquareSum.judge_square_sum` LeetCode problem `sum-of-square-numbers`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result ControlFlow Error open Aegis.JudgeSquareSum namespace AegisSpec.JudgeSquareSum...
8
find-the-derangement-of-an-array
634
Medium
[ "Math", "Dynamic Programming", "Combinatorics" ]
In combinatorial mathematics, a derangement is a permutation of the elements of a set, such that no element appears in its original position. You are given an integer n. There is originally an array consisting of n integers from 1 to n in ascending order, return the number of derangements it can generate. Since the ans...
findDerangement(n: int) -> int
pub fn find_derangement(n: i64) -> i64
Aegis.FindDerangement.find_derangement
pub fn find_derangement(n: i64) -> i64 { let modv: i64 = 1000000007; if n <= 0 { return 1; } if n == 1 { return 0; } if n == 2 { return 1; } let mut prev2: i64 = 0; // D(1) let mut prev1: i64 = 1; // D(2) let mut i: i64 = 3; while i <= n { l...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [find_derangement]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option lint...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [find_derangement]: function definitions module public import Aeneas public import Aegis.FindDerangement.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_...
import Aegis.FindDerangement.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.FindDerangement.find_derangement 3#i64) (2#i64))}") #eval (s!"CASE 1 {(Result.reducesTo (Aegis.FindDerangement.find_derangement 100000#i64) (1833...
[ { "input": "[3]", "output": "2" }, { "input": "[100000]", "output": "183389504" }, { "input": "[100]", "output": "944828409" }, { "input": "[4]", "output": "9" }, { "input": "[10000]", "output": "381587473" }, { "input": "[1000000]", "output": "102...
24
false
24
verified
10
10
1
893
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.FindDerangement.Code.Funs /-! # Specifications of `Aegis.FindDerangement.find_derangement` LeetCode problem `find-the-derangement-of-an-array`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.FindDerangement noncomputable def numDer...
6
exclusive-time-of-functions
636
Medium
[ "Stack", "Array" ]
On a single-threaded CPU, we execute a program containing n functions. Each function has a unique ID between 0 and n-1. Function calls are stored in a call stack: when a function call starts, its ID is pushed onto the stack, and when a function call ends, its ID is popped off the stack. The function whose ID is at the ...
exclusiveTime(n: int, logs: list_str) -> list_int
pub fn exclusive_time(n: i64, logs: &[Vec<u8>]) -> Vec<i64>
Aegis.ExclusiveTime.exclusive_time
pub fn exclusive_time(n: i64, logs: &[Vec<u8>]) -> Vec<i64> { let mut ans: Vec<i64> = Vec::new(); let mut i: i64 = 0; while i < n { ans.push(0); i += 1; } let mut stack: Vec<usize> = Vec::new(); let mut prev: i64 = 0; let mut k: usize = 0; while k < logs.len() { ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [exclusive_time]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [exclusive_time]: function definitions module public import Aeneas public import Aegis.ExclusiveTime.Code.Types public import Aegis.ExclusiveTime.Code.FunsExternal @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespac...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [exclusive_time]: external functions. -- This is a template file: rename it to "FunsExternal.lean" and fill the holes. module public import Aeneas public import Aegis.ExclusiveTime.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error s...
import Aegis.ExclusiveTime.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.ExclusiveTime.exclusive_time 1#i64 (Slice.from [(alloc.vec.Vec.from [48#u8, 58#u8, 115#u8, 116#u8, 97#u8, 114#u8, 116#u8, 58#u8, 48#u8] (by scalar_...
[ { "input": "[1, [\"0:start:0\", \"0:end:1\"]]", "output": "[2]" }, { "input": "[2, [\"0:start:0\", \"1:start:1\", \"1:end:2\", \"0:end:3\"]]", "output": "[2, 2]" }, { "input": "[2, [\"0:start:0\", \"1:start:2\", \"1:end:5\", \"0:end:6\"]]", "output": "[3, 4]" }, { "input": "[...
69
false
69
verified
10
10
1
4,061
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.ExclusiveTime.Code.Funs /-! # Specifications of `Aegis.ExclusiveTime.exclusive_time` LeetCode problem `exclusive-time-of-functions`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.ExclusiveTime namespace AegisSpec.ExclusiveTime abbrev LogEntry ...
14
decode-ways-ii
639
Hard
[ "String", "Dynamic Programming" ]
A message containing letters from A-Z can be encoded into numbers using the following mapping: 'A' -> "1" 'B' -> "2" ... 'Z' -> "26" To decode an encoded message, all the digits must be grouped then mapped back into letters using the reverse of the mapping above (there may be multiple ways). For example, "11106" can ...
numDecodings(s: str) -> int
pub fn num_decodings(s: &[u8]) -> i64
Aegis.NumDecodings.num_decodings
pub fn num_decodings(s: &[u8]) -> i64 { let n = s.len(); if n == 0 { return 0; } let md: i64 = 1000000007; let first = s[0]; let mut prev2: i64 = 1; let mut prev1: i64 = 0; if first == b'*' { prev1 = 9; } else if first == b'0' { prev1 = 0; } else { ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [num_decodings]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter....
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [num_decodings]: function definitions module public import Aeneas public import Aegis.NumDecodings.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option...
import Aegis.NumDecodings.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.NumDecodings.num_decodings (Slice.from [42#u8, 49#u8, 42#u8, 50#u8, 42#u8, 51#u8, 42#u8, 52#u8, 42#u8, 53#u8, 42#u8, 54#u8, 42#u8, 55#u8, 42#u8, 56#...
[ { "input": "[\"*1*2*3*4*5*6*7*8*9*\"]", "output": "554657727" }, { "input": "[\"26\"]", "output": "2" }, { "input": "[\"2*\"]", "output": "15" }, { "input": "[\"11106\"]", "output": "2" }, { "input": "[\"210\"]", "output": "1" }, { "input": "[\"*******...
157
false
157
verified
10
10
1
5,673
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.NumDecodings.Code.Funs /-! # Specifications of `Aegis.NumDecodings.num_decodings` LeetCode problem `decode-ways-ii`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.NumDecodings def M : ℕ := 1000000007 def residue (a : ℕ) : ℤ := ((a % ...
11
maximum-length-of-pair-chain
646
Medium
[ "Greedy", "Array", "Dynamic Programming", "Sorting" ]
You are given an array of n pairs pairs where pairs[i] = [lefti, righti] and lefti < righti. A pair p2 = [c, d] follows a pair p1 = [a, b] if b < c. A chain of pairs can be formed in this fashion. Return the length longest chain which can be formed. You do not need to use up all the given intervals. You can select pair...
findLongestChain(pairs: list_list_int) -> int
pub fn find_longest_chain(pairs: &[Vec<i64>]) -> i64
Aegis.FindLongestChain.find_longest_chain
pub fn find_longest_chain(pairs: &[Vec<i64>]) -> i64 { let n = pairs.len(); if n == 0 { return 0; } let mut starts: Vec<i64> = Vec::new(); let mut ends: Vec<i64> = Vec::new(); let mut i = 0; while i < n { starts.push(pairs[i][0]); ends.push(pairs[i][1]); i +...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [find_longest_chain]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option li...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [find_longest_chain]: function definitions module public import Aeneas public import Aegis.FindLongestChain.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false s...
import Aegis.FindLongestChain.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.FindLongestChain.find_longest_chain (Slice.from [(alloc.vec.Vec.from [(-1)#i64, (-2)#i64] (by scalar_tac) : alloc.vec.Vec Std.I64), (alloc.vec.V...
[ { "input": "[[[-1, -2], [-3, -4], [-5, -6]]]", "output": "3" }, { "input": "[[[7, 9], [4, 5], [2, 3]]]", "output": "3" }, { "input": "[[[1, 2], [7, 8], [4, 5]]]", "output": "3" }, { "input": "[[[-10, 10], [-20, -10], [0, 5]]]", "output": "2" }, { "input": "[[[1, 2...
106
false
106
verified
10
10
1
25,289
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.FindLongestChain.Code.Funs /-! # Specifications of `Aegis.FindLongestChain.find_longest_chain` LeetCode problem `maximum-length-of-pair-chain`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.FindLongestChain abbrev PairVec : Type := Ae...
11
palindromic-substrings
647
Medium
[ "Two Pointers", "String", "Dynamic Programming" ]
Given a string s, return the number of palindromic substrings in it. A string is a palindrome when it reads the same backward as forward. A substring is a contiguous sequence of characters within the string.   Example 1: Input: s = "abc" Output: 3 Explanation: Three palindromic strings: "a", "b", "c". Example 2: Inp...
countSubstrings(s: str) -> int
pub fn count_substrings(s: &[u8]) -> i64
Aegis.CountSubstrings.count_substrings
pub fn count_substrings(s: &[u8]) -> i64 { let n = s.len(); let mut count: i64 = 0; let mut center: usize = 0; while center < n { // Odd-length palindromes centered at center. let mut l = center; let mut r = center; while r < n && s[l] == s[r] { count += 1; ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [count_substrings]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option lint...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [count_substrings]: function definitions module public import Aeneas public import Aegis.CountSubstrings.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_...
import Aegis.CountSubstrings.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.CountSubstrings.count_substrings (Slice.from [97#u8, 98#u8, 98#u8, 97#u8] (by scalar_tac) : Slice Std.U8)) (6#i64))}") #eval (s!"CASE 1 {(Result....
[ { "input": "[\"abba\"]", "output": "6" }, { "input": "[\"aaaaa\"]", "output": "15" }, { "input": "[\"babad\"]", "output": "7" }, { "input": "[\"noon\"]", "output": "6" }, { "input": "[\"banana\"]", "output": "10" }, { "input": "[\"aabbbaa\"]", "out...
140
false
140
verified
10
10
1
1,550
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.CountSubstrings.Code.Funs /-! # Specifications of `Aegis.CountSubstrings.count_substrings` LeetCode problem `palindromic-substrings`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.CountSubstrings def bytes (s : Slice U8) : List ℕ := s...
12
2-keys-keyboard
650
Medium
[ "Math", "Dynamic Programming" ]
There is only one character 'A' on the screen of a notepad. You can perform one of two operations on this notepad for each step: Copy All: You can copy all the characters present on the screen (a partial copy is not allowed). Paste: You can paste the characters which are copied last time. Given an integer n, return t...
minSteps(n: int) -> int
pub fn min_steps(n: i64) -> i64
Aegis.MinSteps.min_steps
pub fn min_steps(n: i64) -> i64 { let mut m = n; let mut ans = 0; let mut d = 2; while d * d <= m { while m % d == 0 { ans += d; m /= d; } d += 1; } if m > 1 { ans += m; } ans }
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [min_steps]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter.styl...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [min_steps]: function definitions module public import Aeneas public import Aegis.MinSteps.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter....
import Aegis.MinSteps.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.MinSteps.min_steps 3#i64) (3#i64))}") #eval (s!"CASE 1 {(Result.reducesTo (Aegis.MinSteps.min_steps 12#i64) (7#i64))}") #eval (s!"CASE 2 {(Result.reduce...
[ { "input": "[3]", "output": "3" }, { "input": "[12]", "output": "7" }, { "input": "[100]", "output": "14" }, { "input": "[10]", "output": "7" }, { "input": "[1000]", "output": "21" }, { "input": "[5]", "output": "5" }, { "input": "[4]", ...
65
false
65
verified
10
10
1
485
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MinSteps.Code.Funs /-! # Specifications of `Aegis.MinSteps.min_steps` LeetCode problem `2-keys-keyboard`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.MinSteps inductive Op where | copyAll | paste deriving DecidableEq, Repr de...
16
4-keys-keyboard
651
Medium
[ "Math", "Dynamic Programming" ]
Imagine you have a special keyboard with the following keys: A: Print one 'A' on the screen. Ctrl-A: Select the whole screen. Ctrl-C: Copy selection to buffer. Ctrl-V: Print buffer on screen appending it after what has already been printed. Given an integer n, return the maximum number of 'A' you can print on the scr...
maxA(n: int) -> int
pub fn max_a(n: i64) -> i64
Aegis.MaxA.max_a
pub fn max_a(n: i64) -> i64 { if n <= 0 { return 0; } let m = n as usize; let mut dp: Vec<i64> = Vec::new(); let mut k: usize = 0; while k <= m { dp.push(0); k += 1; } let mut i: usize = 1; while i <= m { // Option 1: press 'A' once. let mut...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [max_a]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter.style.wh...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [max_a]: function definitions module public import Aeneas public import Aegis.MaxA.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVa...
import Aegis.MaxA.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.MaxA.max_a 3#i64) (3#i64))}") #eval (s!"CASE 1 {(Result.reducesTo (Aegis.MaxA.max_a 15#i64) (81#i64))}") #eval (s!"CASE 2 {(Result.reducesTo (Aegis.MaxA.max...
[ { "input": "[3]", "output": "3" }, { "input": "[15]", "output": "81" }, { "input": "[20]", "output": "324" }, { "input": "[2]", "output": "2" }, { "input": "[1]", "output": "1" }, { "input": "[50]", "output": "1327104" }, { "input": "[7]", ...
49
false
49
verified
10
10
1
1,459
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MaxA.Code.Funs /-! # Specifications of `Aegis.MaxA.max_a` LeetCode problem `4-keys-keyboard`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.MaxA def copyBest (m : Nat) (prev : List Nat) : Nat := (List.range (m - 2)).foldr (fun k acc...
13
two-sum-iv-input-is-a-bst
653
Easy
[ "Tree", "Depth-First Search", "Breadth-First Search", "Binary Search Tree", "Hash Table", "Two Pointers", "Binary Tree" ]
Given the root of a binary search tree and an integer k, return true if there exist two elements in the BST such that their sum is equal to k, or false otherwise.   Example 1: Input: root = [5,3,6,2,4,null,7], k = 9 Output: true Example 2: Input: root = [5,3,6,2,4,null,7], k = 28 Output: false   Constraints: The...
findTarget(root: tree, k: int) -> bool
pub fn find_target(root: &Tree, k: i64) -> bool
Aegis.FindTarget.find_target
fn collect(t: &Tree, out: &mut Vec<i64>) { match t { Tree::Null => {} Tree::Node(v, l, r) => { out.push(*v); collect(l, out); collect(r, out); } } } pub fn find_target(root: &Tree, k: i64) -> bool { let mut vals: Vec<i64> = Vec::new(); collect...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [find_target]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter.st...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [find_target]: function definitions module public import Aeneas public import Aegis.FindTarget.Code.Types public import Aegis.FindTarget.Code.FunsExternal @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false s...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [find_target]: external functions. -- This is a template file: rename it to "FunsExternal.lean" and fill the holes. module public import Aeneas public import Aegis.FindTarget.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_opt...
import Aegis.FindTarget.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.FindTarget.find_target ((.Node 1#i64 (.Null) (.Null)) : Aegis.FindTarget.Tree) 2#i64) (false))}") #eval (s!"CASE 1 {(Result.reducesTo (Aegis.FindTarge...
[ { "input": "[[1], 2]", "output": "false" }, { "input": "[[2, 1, 3], 4]", "output": "true" }, { "input": "[[1, 0, 2], 3]", "output": "true" }, { "input": "[[1, 0, 2], 1]", "output": "true" }, { "input": "[[2, 1, 3], 5]", "output": "true" }, { "input": "...
45
false
45
verified
10
10
2
13,860
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.FindTarget.Code.Funs /-! # Specifications of `Aegis.FindTarget.find_target` LeetCode problem `two-sum-iv-input-is-a-bst`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.FindTarget open Aegis.FindTarget def mkI64 (n : ℤ) : Std.I64 := ⟨...
8
maximum-binary-tree
654
Medium
[ "Stack", "Tree", "Array", "Divide and Conquer", "Binary Tree", "Monotonic Stack" ]
You are given an integer array nums with no duplicates. A maximum binary tree can be built recursively from nums using the following algorithm: Create a root node whose value is the maximum value in nums. Recursively build the left subtree on the subarray prefix to the left of the maximum value. Recursively build the ...
constructMaximumBinaryTree(nums: list_int) -> tree
pub fn construct_maximum_binary_tree(nums: &[i64]) -> Tree
Aegis.ConstructMaximumBinaryTree.construct_maximum_binary_tree
fn find_max_index(nums: &[i64], lo: usize, hi: usize) -> usize { let mut best = lo; let mut i = lo + 1; while i < hi { if nums[i] > nums[best] { best = i; } i += 1; } best } fn build(nums: &[i64], lo: usize, hi: usize) -> Tree { if lo >= hi { return T...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [construct_maximum_binary_tree]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false se...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [construct_maximum_binary_tree]: function definitions module public import Aeneas public import Aegis.ConstructMaximumBinaryTree.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linte...
import Aegis.ConstructMaximumBinaryTree.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 deriving instance DecidableEq for Aegis.ConstructMaximumBinaryTree.Tree #eval (s!"CASE 0 {(match (Aegis.ConstructMaximumBinaryTree.construct_maximum_binary_tree (Slice.from [1#...
[ { "input": "[[1]]", "output": "[1]" }, { "input": "[[1, 3, 2]]", "output": "[3, 1, 2]" }, { "input": "[[1, 2, 3]]", "output": "[3, 2, null, 1]" }, { "input": "[[3, 1, 2]]", "output": "[3, null, 2, 1]" }, { "input": "[[2, 1, 3]]", "output": "[3, 2, null, null, ...
118
false
118
verified
10
10
1
2,613
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.ConstructMaximumBinaryTree.Code.Funs /-! # Specifications of `Aegis.ConstructMaximumBinaryTree.construct_maximum_binary_tree` LeetCode problem `maximum-binary-tree`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result set_option autoImplicit false namespac...
20
coin-path
656
Hard
[ "Array", "Dynamic Programming" ]
You are given an integer array coins (1-indexed) of length n and an integer maxJump. You can jump to any index i of the array coins if coins[i] != -1 and you have to pay coins[i] when you visit index i. In addition to that, if you are currently at index i, you can only jump to any index i + k where i + k <= n and k is ...
cheapestJump(coins: list_int, maxJump: int) -> list_int
pub fn cheapest_jump(coins: &[i64], maxJump: i64) -> Vec<i64>
Aegis.CheapestJump.cheapest_jump
pub fn cheapest_jump(coins: &[i64], maxJump: i64) -> Vec<i64> { let n = coins.len(); if n == 0 { return Vec::new(); } let inf: i64 = 1000000000000000000; let mut dp: Vec<i64> = Vec::new(); let mut i: usize = 0; while i < n { dp.push(inf); i += 1; } if coins...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [cheapest_jump]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter....
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [cheapest_jump]: function definitions module public import Aeneas public import Aegis.CheapestJump.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option...
import Aegis.CheapestJump.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.CheapestJump.cheapest_jump (Slice.from [1#i64, (-1)#i64, (-1)#i64, (-1)#i64, 5#i64] (by scalar_tac) : Slice Std.I64) 2#i64) ((alloc.vec.Vec.from [] ...
[ { "input": "[[1, -1, -1, -1, 5], 2]", "output": "[]" }, { "input": "[[1, -1, -1, -1, -1], 1]", "output": "[]" }, { "input": "[[1, 2, 4, -1, 2], 1]", "output": "[]" }, { "input": "[[1, -1, 1, -1, 1], 1]", "output": "[]" }, { "input": "[[1, -1, -1, -1, 1], 4]", ...
110
false
110
verified
10
10
1
7,096
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.CheapestJump.Code.Funs /-! # Specifications of `Aegis.CheapestJump.cheapest_jump` LeetCode problem `coin-path`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.CheapestJump def vecInts (v : alloc.vec.Vec Aeneas.Std.I64) : List Int :...
15
robot-return-to-origin
657
Easy
[ "String", "Simulation" ]
There is a robot starting at the position (0, 0), the origin, on a 2D plane. Given a sequence of its moves, judge if this robot ends up at (0, 0) after it completes its moves. You are given a string moves that represents the move sequence of the robot where moves[i] represents its ith move. Valid moves are 'R' (right),...
judgeCircle(moves: str) -> bool
pub fn judge_circle(moves: &[u8]) -> bool
Aegis.JudgeCircle.judge_circle
pub fn judge_circle(moves: &[u8]) -> bool { let mut x: i64 = 0; let mut y: i64 = 0; let n = moves.len(); let mut i: usize = 0; while i < n { let c = moves[i]; if c == b'R' { x = x + 1; } else if c == b'L' { x = x - 1; } else if c == b'U' { ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [judge_circle]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter.s...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [judge_circle]: function definitions module public import Aeneas public import Aegis.JudgeCircle.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option l...
import Aegis.JudgeCircle.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.JudgeCircle.judge_circle (Slice.from [76#u8, 85#u8, 76#u8, 76#u8, 68#u8, 68#u8, 82#u8, 82#u8, 85#u8, 85#u8, 82#u8, 82#u8, 68#u8, 68#u8, 76#u8, 76#u8]...
[ { "input": "[\"LULLDDRRUURRDDLL\"]", "output": "false" }, { "input": "[\"UUUUUUUUUUDDDDDDDDDDLLLLRRRR\"]", "output": "true" }, { "input": "[\"UDLR\"]", "output": "true" }, { "input": "[\"UUDDRRLL\"]", "output": "true" }, { "input": "[\"LUDD\"]", "output": "fal...
112
false
112
verified
10
10
1
179
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.JudgeCircle.Code.Funs /-! # Specifications of `Aegis.JudgeCircle.judge_circle` LeetCode problem `robot-return-to-origin`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.JudgeCircle abbrev codeU : Nat := 85 abbrev codeD : Nat := 68 ab...
7
find-k-closest-elements
658
Medium
[ "Array", "Two Pointers", "Binary Search", "Sorting", "Sliding Window", "Heap (Priority Queue)" ]
Given a sorted integer array arr, two integers k and x, return the k closest integers to x in the array. The result should also be sorted in ascending order. An integer a is closer to x than an integer b if: |a - x| < |b - x|, or |a - x| == |b - x| and a < b   Example 1: Input: arr = [1,2,3,4,5], k = 4, x = 3 Output...
findClosestElements(arr: list_int, k: int, x: int) -> list_int
pub fn find_closest_elements(arr: &[i64], k: i64, x: i64) -> Vec<i64>
Aegis.FindClosestElements.find_closest_elements
pub fn find_closest_elements(arr: &[i64], k: i64, x: i64) -> Vec<i64> { let n = arr.len(); let kk = k as usize; let mut lo: usize = 0; let mut hi: usize = n - 1; while hi - lo + 1 > kk { let left_dist: i64 = if x >= arr[lo] { x - arr[lo] } else { arr[lo] - x...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [find_closest_elements]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [find_closest_elements]: function definitions module public import Aeneas public import Aegis.FindClosestElements.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand f...
import Aegis.FindClosestElements.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.FindClosestElements.find_closest_elements (Slice.from [1#i64, 3#i64, 5#i64, 7#i64, 9#i64] (by scalar_tac) : Slice Std.I64) 1#i64 6#i64) ((all...
[ { "input": "[[1, 3, 5, 7, 9], 1, 6]", "output": "[5]" }, { "input": "[[1, 2, 3, 4, 5], 1, 2]", "output": "[2]" }, { "input": "[[1, 3, 5, 7, 9], 2, 6]", "output": "[5, 7]" }, { "input": "[[1, 2, 3, 4, 5], 2, 3]", "output": "[2, 3]" }, { "input": "[[1, 1, 1, 1, 1], ...
128
false
128
verified
10
10
1
2,504
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.FindClosestElements.Code.Funs /-! # Specifications of `Aegis.FindClosestElements.find_closest_elements` LeetCode problem `find-k-closest-elements`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aeneas.Std.Result namespace AegisSpec.FindClosestElement...
14
split-array-into-consecutive-subsequences
659
Medium
[ "Greedy", "Array", "Hash Table", "Heap (Priority Queue)" ]
You are given an integer array nums that is sorted in non-decreasing order. Determine if it is possible to split nums into one or more subsequences such that both of the following conditions are true: Each subsequence is a consecutive increasing sequence (i.e. each integer is exactly one more than the previous integer...
isPossible(nums: list_int) -> bool
pub fn is_possible(nums: &[i64]) -> bool
Aegis.IsPossible.is_possible
pub fn is_possible(nums: &[i64]) -> bool { let n: usize = nums.len(); if n < 3 { return false; } let size: usize = 2005; let mut freq: Vec<i64> = Vec::new(); let mut need: Vec<i64> = Vec::new(); let mut i: usize = 0; while i < size { freq.push(0); need.push(0);...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [is_possible]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter.st...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [is_possible]: function definitions module public import Aeneas public import Aegis.IsPossible.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option lin...
import Aegis.IsPossible.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.IsPossible.is_possible (Slice.from [1#i64, 2#i64, 3#i64, 4#i64, 4#i64, 5#i64] (by scalar_tac) : Slice Std.I64)) (false))}") #eval (s!"CASE 1 {(Result....
[ { "input": "[[1, 2, 3, 4, 4, 5]]", "output": "false" }, { "input": "[[1, 2, 3, 3, 4, 5]]", "output": "true" }, { "input": "[[1, 2, 3, 3, 4, 4, 5, 5]]", "output": "true" }, { "input": "[[1, 2, 2, 3, 3, 4, 4, 5, 5]]", "output": "true" }, { "input": "[[1, 2, 3, 3, 3,...
123
false
123
verified
10
10
3
9,707
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.IsPossible.Code.Funs /-! # Specifications of `Aegis.IsPossible.is_possible` LeetCode problem `split-array-into-consecutive-subsequences`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.IsPossible (is_possible) namespace AegisSpec.IsPossible ...
12
remove-9
660
Hard
[ "Math" ]
Start from integer 1, remove any integer that contains 9 such as 9, 19, 29... Now, you will have a new integer sequence [1, 2, 3, 4, 5, 6, 7, 8, 10, 11, ...]. Given an integer n, return the nth (1-indexed) integer in the new sequence.   Example 1: Input: n = 9 Output: 10 Example 2: Input: n = 10 Output: 11   Constr...
newInteger(n: int) -> int
pub fn new_integer(n: i64) -> i64
Aegis.NewInteger.new_integer
pub fn new_integer(n: i64) -> i64 { let mut x: i64 = n; let mut place: i64 = 1; let mut ans: i64 = 0; while x > 0 { let digit: i64 = x % 9; ans = ans + digit * place; x = x / 9; place = place * 10; } ans }
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [new_integer]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter.st...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [new_integer]: function definitions module public import Aeneas public import Aegis.NewInteger.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option lin...
import Aegis.NewInteger.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.NewInteger.new_integer 80000000#i64) (176472328#i64))}") #eval (s!"CASE 1 {(Result.reducesTo (Aegis.NewInteger.new_integer 15#i64) (16#i64))}") #eval ...
[ { "input": "[80000000]", "output": "176472328" }, { "input": "[15]", "output": "16" }, { "input": "[81]", "output": "100" }, { "input": "[9]", "output": "10" }, { "input": "[88888888]", "output": "205230561" }, { "input": "[123456789]", "output": "...
58
false
58
verified
10
10
1
1,647
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.NewInteger.Code.Funs import Mathlib.Data.Nat.Digits.Lemmas /-! # Specifications of `Aegis.NewInteger.new_integer` LeetCode problem `remove-9`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.NewInteger def DecimalNoNine (m : ℕ) : Pr...
9
image-smoother
661
Easy
[ "Array", "Matrix" ]
An image smoother is a filter of the size 3 x 3 that can be applied to each cell of an image by rounding down the average of the cell and the eight surrounding cells (i.e., the average of the nine cells in the blue smoother). If one or more of the surrounding cells of a cell is not present, we do not consider it in the...
imageSmoother(img: list_list_int) -> list_list_int
pub fn image_smoother(img: &[Vec<i64>]) -> Vec<Vec<i64>>
Aegis.ImageSmoother.image_smoother
pub fn image_smoother(img: &[Vec<i64>]) -> Vec<Vec<i64>> { let m = img.len(); if m == 0 { return Vec::new(); } let n = img[0].len(); if n == 0 { return Vec::new(); } let mut out: Vec<Vec<i64>> = Vec::new(); let mut i: usize = 0; while i < m { let mut row: Ve...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [image_smoother]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [image_smoother]: function definitions module public import Aeneas public import Aegis.ImageSmoother.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_opti...
import Aegis.ImageSmoother.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.ImageSmoother.image_smoother (Slice.from [(alloc.vec.Vec.from [1#i64] (by scalar_tac) : alloc.vec.Vec Std.I64)] (by scalar_tac) : Slice (alloc.vec....
[ { "input": "[[[1]]]", "output": "[[1]]" }, { "input": "[[[255]]]", "output": "[[255]]" }, { "input": "[[[1, 2], [3, 4]]]", "output": "[[2, 2], [2, 2]]" }, { "input": "[[[1, 1], [1, 1]]]", "output": "[[1, 1], [1, 1]]" }, { "input": "[[[10, 20], [30, 40]]]", "ou...
81
false
81
verified
10
10
1
647
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.ImageSmoother.Code.Funs /-! # Specifications of `Aegis.ImageSmoother.image_smoother` LeetCode problem `image-smoother`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.ImageSmoother namespace AegisSpec.ImageSmoother def nrows (img : Slice ...
10
maximum-width-of-binary-tree
662
Medium
[ "Tree", "Depth-First Search", "Breadth-First Search", "Binary Tree" ]
Given the root of a binary tree, return the maximum width of the given tree. The maximum width of a tree is the maximum width among all levels. The width of one level is defined as the length between the end-nodes (the leftmost and rightmost non-null nodes), where the null nodes between the end-nodes that would be pres...
widthOfBinaryTree(root: tree) -> int
pub fn width_of_binary_tree(root: &Tree) -> i64
Aegis.WidthOfBinaryTree.width_of_binary_tree
fn flatten_tree(t: &Tree, left: &mut Vec<i64>, right: &mut Vec<i64>) -> i64 { match t { Tree::Null => -1, Tree::Node(_value, l, r) => { let left_idx: i64 = flatten_tree(&**l, left, right); let right_idx: i64 = flatten_tree(&**r, left, right); let idx: i64 = left....
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [width_of_binary_tree]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [width_of_binary_tree]: function definitions module public import Aeneas public import Aegis.WidthOfBinaryTree.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand fals...
import Aegis.WidthOfBinaryTree.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.WidthOfBinaryTree.width_of_binary_tree ((.Node 1#i64 (.Null) (.Null)) : Aegis.WidthOfBinaryTree.Tree)) (1#i64))}") #eval (s!"CASE 1 {(Result.re...
[ { "input": "[[1]]", "output": "1" }, { "input": "[[1, 3, 2, 5]]", "output": "2" }, { "input": "[[1, 2, 3, 4, 5, 6, 7]]", "output": "4" }, { "input": "[[1, 3, 2, 5, 3, 9, 6, 7, 8, 10, 11, 12, 13, 14, 15]]", "output": "8" }, { "input": "[[1, 2, 3, 4, 5, 6, 7, 8, 9, ...
7
false
7
verified
7
7
1
10,896
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.WidthOfBinaryTree.Code.Funs /-! # Specifications of `Aegis.WidthOfBinaryTree.width_of_binary_tree` LeetCode problem `maximum-width-of-binary-tree`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.WidthOfBinaryTree open Aegis.WidthOf...
14
equal-tree-partition
663
Medium
[ "Tree", "Depth-First Search", "Binary Tree" ]
Given the root of a binary tree, return true if you can partition the tree into two trees with equal sums of values after removing exactly one edge on the original tree.   Example 1: Input: root = [5,10,10,null,null,2,3] Output: true Example 2: Input: root = [1,2,10,null,null,2,20] Output: false Explanation: You c...
checkEqualTree(root: tree) -> bool
pub fn check_equal_tree(root: &Tree) -> bool
Aegis.CheckEqualTree.check_equal_tree
pub fn check_equal_tree(root: &Tree) -> bool { let total = tree_sum(root); if total % 2 != 0 { return false; } let target = total / 2; check_subtree(root, target) } fn tree_sum(t: &Tree) -> i64 { match t { Tree::Null => 0, Tree::Node(v, left, right) => { *v...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [check_equal_tree]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option lint...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [check_equal_tree]: function definitions module public import Aeneas public import Aegis.CheckEqualTree.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_o...
import Aegis.CheckEqualTree.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.CheckEqualTree.check_equal_tree ((.Node 1#i64 (.Null) (.Null)) : Aegis.CheckEqualTree.Tree)) (false))}") #eval (s!"CASE 1 {(Result.reducesTo (Aegi...
[ { "input": "[[1]]", "output": "false" }, { "input": "[[0]]", "output": "false" }, { "input": "[[0, 1, -1]]", "output": "false" }, { "input": "[[1, -1, 0]]", "output": "true" }, { "input": "[[0, 1, 1]]", "output": "true" }, { "input": "[[1, 2, 3, 4, 5, ...
60
false
60
verified
10
10
1
5,899
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.CheckEqualTree.Code.Funs /-! # Specifications of `Aegis.CheckEqualTree.check_equal_tree` LeetCode problem `equal-tree-partition`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.CheckEqualTree open Aegis.CheckEqualTree def size :...
11
strange-printer
664
Hard
[ "String", "Dynamic Programming" ]
There is a strange printer with the following two special properties: The printer can only print a sequence of the same character each time. At each turn, the printer can print new characters starting from and ending at any place and will cover the original existing characters. Given a string s, return the minimum nu...
strangePrinter(s: str) -> int
pub fn strange_printer(s: &[u8]) -> i64
Aegis.StrangePrinter.strange_printer
pub fn strange_printer(s: &[u8]) -> i64 { let n = s.len(); if n == 0 { return 0; } let total = n * n; let mut dp: Vec<i64> = Vec::new(); let mut t: usize = 0; while t < total { dp.push(0); t += 1; } let mut i: usize = 0; while i < n { dp[i * n + ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [strange_printer]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linte...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [strange_printer]: function definitions module public import Aeneas public import Aegis.StrangePrinter.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_op...
import Aegis.StrangePrinter.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.StrangePrinter.strange_printer (Slice.from [112#u8, 112#u8, 112#u8, 112#u8, 112#u8, 112#u8, 112#u8, 112#u8] (by scalar_tac) : Slice Std.U8)) (1#i6...
[ { "input": "[\"pppppppp\"]", "output": "1" }, { "input": "[\"abcba\"]", "output": "3" }, { "input": "[\"aabbaa\"]", "output": "2" }, { "input": "[\"zzzzy\"]", "output": "2" }, { "input": "[\"abababab\"]", "output": "5" }, { "input": "[\"ppqpqr\"]", ...
102
false
102
verified
10
10
1
6,016
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.StrangePrinter.Code.Funs /-! # Specifications of `Aegis.StrangePrinter.strange_printer` LeetCode problem `strange-printer`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.StrangePrinter open Aegis.StrangePrinter structure Turn w...
13
non-decreasing-array
665
Medium
[ "Array" ]
Given an array nums with n integers, your task is to check if it could become non-decreasing by modifying at most one element. We define an array is non-decreasing if nums[i] <= nums[i + 1] holds for every i (0-based) such that (0 <= i <= n - 2).   Example 1: Input: nums = [4,2,3] Output: true Explanation: You could m...
checkPossibility(nums: list_int) -> bool
pub fn check_possibility(nums: &[i64]) -> bool
Aegis.CheckPossibility.check_possibility
pub fn check_possibility(nums: &[i64]) -> bool { let n = nums.len(); let mut count: i64 = 0; let mut bad: usize = 0; let mut prev: i64 = 0; if n > 0 { prev = nums[0]; } for i in 0..n { let cur: i64 = nums[i]; if i > 0 { if prev > cur { co...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [check_possibility]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option lin...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [check_possibility]: function definitions module public import Aeneas public import Aegis.CheckPossibility.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false se...
import Aegis.CheckPossibility.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.CheckPossibility.check_possibility (Slice.from [1#i64] (by scalar_tac) : Slice Std.I64)) (true))}") #eval (s!"CASE 1 {(Result.reducesTo (Aegis.C...
[ { "input": "[[1]]", "output": "true" }, { "input": "[[1, 2]]", "output": "true" }, { "input": "[[10, 5, 7]]", "output": "true" }, { "input": "[[1, 1, 1]]", "output": "true" }, { "input": "[[1, 2, 4]]", "output": "true" }, { "input": "[[2, 2, 2]]", ...
165
false
165
verified
10
10
4
35,778
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.CheckPossibility.Code.Funs /-! # Specifications of `Aegis.CheckPossibility.check_possibility` LeetCode problem `non-decreasing-array`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.CheckPossibility def NonDecreasing (l : List Std....
7
beautiful-arrangement-ii
667
Medium
[ "Array", "Math" ]
Given two integers n and k, construct a list answer that contains n different positive integers ranging from 1 to n and obeys the following requirement: Suppose this list is answer = [a1, a2, a3, ... , an], then the list [|a1 - a2|, |a2 - a3|, |a3 - a4|, ... , |an-1 - an|] has exactly k distinct integers. Return the ...
constructArray(n: int, k: int) -> list_int
pub fn construct_array(n: i64, k: i64) -> Vec<i64>
Aegis.ConstructArray.construct_array
pub fn construct_array(n: i64, k: i64) -> Vec<i64> { let mut ans: Vec<i64> = Vec::new(); let mut low: i64 = 1; let mut high: i64 = n; let mut i: i64 = 0; while i < k { if i % 2 == 0 { ans.push(low); low += 1; } else { ans.push(high); h...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [construct_array]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linte...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [construct_array]: function definitions module public import Aeneas public import Aegis.ConstructArray.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_op...
import Aegis.ConstructArray.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.ConstructArray.construct_array 3#i64 1#i64) ((alloc.vec.Vec.from [1#i64, 2#i64, 3#i64] (by scalar_tac) : alloc.vec.Vec Std.I64)))}") #eval (s!"CAS...
[ { "input": "[3, 1]", "output": "[1, 2, 3]" }, { "input": "[3, 2]", "output": "[1, 3, 2]" }, { "input": "[5, 2]", "output": "[1, 5, 4, 3, 2]" }, { "input": "[5, 3]", "output": "[1, 5, 2, 3, 4]" }, { "input": "[5, 4]", "output": "[1, 5, 2, 4, 3]" }, { "i...
57
false
57
verified
10
10
1
2,531
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.ConstructArray.Code.Funs /-! # Specifications of `Aegis.ConstructArray.construct_array` LeetCode problem `beautiful-arrangement-ii`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.ConstructArray def entries (r : alloc.vec.Vec Std.I...
12
kth-smallest-number-in-multiplication-table
668
Hard
[ "Math", "Binary Search" ]
Nearly everyone has used the Multiplication Table. The multiplication table of size m x n is an integer matrix mat where mat[i][j] == i * j (1-indexed). Given three integers m, n, and k, return the kth smallest element in the m x n multiplication table.   Example 1: Input: m = 3, n = 3, k = 5 Output: 3 Explanation: T...
findKthNumber(m: int, n: int, k: int) -> int
pub fn find_kth_number(m: i64, n: i64, k: i64) -> i64
Aegis.FindKthNumber.find_kth_number
pub fn find_kth_number(m: i64, n: i64, k: i64) -> i64 { let total: i64 = m * n; let mut lo: i64 = 1; let mut hi: i64 = total; while lo < hi { let mid: i64 = lo + (hi - lo) / 2; let count: i64 = count_leq(m, n, mid); if count >= k { hi = mid; } else { ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [find_kth_number]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linte...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [find_kth_number]: function definitions module public import Aeneas public import Aegis.FindKthNumber.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_opt...
import Aegis.FindKthNumber.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.FindKthNumber.find_kth_number 3#i64 3#i64 5#i64) (3#i64))}") #eval (s!"CASE 1 {(Result.reducesTo (Aegis.FindKthNumber.find_kth_number 10#i64 10#i64...
[ { "input": "[3, 3, 5]", "output": "3" }, { "input": "[10, 10, 25]", "output": "10" }, { "input": "[5, 5, 1]", "output": "1" }, { "input": "[4, 4, 10]", "output": "6" }, { "input": "[4, 4, 8]", "output": "4" }, { "input": "[30000, 30000, 10000]", "o...
95
false
95
verified
10
10
1
1,732
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.FindKthNumber.Code.Funs /-! # Specifications of `Aegis.FindKthNumber.find_kth_number` LeetCode problem `kth-smallest-number-in-multiplication-table`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.FindKthNumber namespace AegisSpec.FindKthNumber ...
9
trim-a-binary-search-tree
669
Medium
[ "Tree", "Depth-First Search", "Binary Search Tree", "Binary Tree" ]
Given the root of a binary search tree and the lowest and highest boundaries as low and high, trim the tree so that all its elements lies in [low, high]. Trimming the tree should not change the relative structure of the elements that will remain in the tree (i.e., any node's descendant should remain a descendant). It c...
trimBST(root: tree, low: int, high: int) -> tree
pub fn trim_bst(root: &Tree, low: i64, high: i64) -> Tree
Aegis.TrimBst.trim_bst
pub fn trim_bst(root: &Tree, low: i64, high: i64) -> Tree { match root { Tree::Null => Tree::Null, Tree::Node(v, left, right) => { let val = *v; if val < low { trim_bst(&**right, low, high) } else if val > high { trim_bst(&**left, ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [trim_bst]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter.style...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [trim_bst]: function definitions module public import Aeneas public import Aegis.TrimBst.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.un...
import Aegis.TrimBst.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 deriving instance DecidableEq for Aegis.TrimBst.Tree #eval (s!"CASE 0 {(match (Aegis.TrimBst.trim_bst ((.Node 1#i64 (.Null) (.Null)) : Aegis.TrimBst.Tree) 1#i64 2#i64).match with | .ok r => decid...
[ { "input": "[[1], 1, 2]", "output": "[1]" }, { "input": "[[2, 1, 3], 1, 2]", "output": "[2, 1]" }, { "input": "[[1, 0, 2], 1, 2]", "output": "[1, null, 2]" } ]
3
false
3
verified
3
3
1
1,212
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.TrimBst.Code.Funs /-! # Specifications of `Aegis.TrimBst.trim_bst` LeetCode problem `trim-a-binary-search-tree`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result set_option autoImplicit false namespace AegisSpec.TrimBst open Aegis.TrimBst def nodeCount : ...
15
maximum-swap
670
Medium
[ "Greedy", "Math" ]
You are given an integer num. You can swap two digits at most once to get the maximum valued number. Return the maximum valued number you can get.   Example 1: Input: num = 2736 Output: 7236 Explanation: Swap the number 2 and the number 7. Example 2: Input: num = 9973 Output: 9973 Explanation: No swap.   Constraint...
maximumSwap(num: int) -> int
pub fn maximum_swap(num: i64) -> i64
Aegis.MaximumSwap.maximum_swap
pub fn maximum_swap(num: i64) -> i64 { if num < 10 { return num; } let mut digits: Vec<i64> = Vec::new(); let mut x: i64 = num; while x > 0 { digits.push(x % 10); x = x / 10; } let n: usize = digits.len(); let mut i: usize = 0; while i < n / 2 { le...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [maximum_swap]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter.s...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [maximum_swap]: function definitions module public import Aeneas public import Aegis.MaximumSwap.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option l...
import Aegis.MaximumSwap.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.MaximumSwap.maximum_swap 9#i64) (9#i64))}") #eval (s!"CASE 1 {(Result.reducesTo (Aegis.MaximumSwap.maximum_swap 987654321#i64) (987654321#i64))}") #e...
[ { "input": "[9]", "output": "9" }, { "input": "[987654321]", "output": "987654321" }, { "input": "[123456789]", "output": "923456781" }, { "input": "[12]", "output": "21" }, { "input": "[21]", "output": "21" }, { "input": "[0]", "output": "0" }, ...
119
false
119
verified
10
10
1
4,089
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MaximumSwap.Code.Funs /-! # Specifications of `Aegis.MaximumSwap.maximum_swap` LeetCode problem `maximum-swap`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.MaximumSwap def digitsNat (n : ℕ) : List ℕ := (List.range (Nat.log 1...
15
second-minimum-node-in-a-binary-tree
671
Easy
[ "Tree", "Depth-First Search", "Binary Tree" ]
Given a non-empty special binary tree consisting of nodes with the non-negative value, where each node in this tree has exactly two or zero sub-node. If the node has two sub-nodes, then this node's value is the smaller value among its two sub-nodes. More formally, the property root.val = min(root.left.val, root.right.v...
findSecondMinimumValue(root: tree) -> int
pub fn find_second_minimum_value(root: &Tree) -> i64
Aegis.FindSecondMinimumValue.find_second_minimum_value
pub fn find_second_minimum_value(root: &Tree) -> i64 { match root { Tree::Null => -1, Tree::Node(v, _, _) => { let minv = *v; dfs(root, minv, -1) } } } fn dfs(t: &Tree, minv: i64, mut best: i64) -> i64 { match t { Tree::Null => best, Tree::Nod...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [find_second_minimum_value]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_op...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [find_second_minimum_value]: function definitions module public import Aeneas public import Aegis.FindSecondMinimumValue.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCo...
import Aegis.FindSecondMinimumValue.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.FindSecondMinimumValue.find_second_minimum_value ((.Node 2#i64 (.Node 2#i64 (.Null) (.Null)) (.Node 2#i64 (.Null) (.Null))) : Aegis.FindSe...
[ { "input": "[[2, 2, 2]]", "output": "-1" }, { "input": "[[5, 5, 6, 5, 6]]", "output": "6" }, { "input": "[[5, 5, 5, 5, 5]]", "output": "-1" }, { "input": "[[3, 3, 3, 3, 3, 3, 3]]", "output": "-1" }, { "input": "[[5, 5, 5, 5, 5, 5, 5]]", "output": "-1" }, {...
70
false
70
verified
10
10
1
1,722
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.FindSecondMinimumValue.Code.Funs /-! # Specifications of `Aegis.FindSecondMinimumValue.find_second_minimum_value` LeetCode problem `second-minimum-node-in-a-binary-tree`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.FindSecondMinimu...
9
bulb-switcher-ii
672
Medium
[ "Bit Manipulation", "Depth-First Search", "Breadth-First Search", "Math" ]
There is a room with n bulbs labeled from 1 to n that all are turned on initially, and four buttons on the wall. Each of the four buttons has a different functionality where: Button 1: Flips the status of all the bulbs. Button 2: Flips the status of all the bulbs with even labels (i.e., 2, 4, ...). Button 3: Flips the...
flipLights(n: int, presses: int) -> int
pub fn flip_lights(n: i64, presses: i64) -> i64
Aegis.FlipLights.flip_lights
pub fn flip_lights(n: i64, presses: i64) -> i64 { let k: i64 = if n < 6 { n } else { 6 }; let mut seen: Vec<i64> = Vec::new(); let mut unique_count: i64 = 0; let mut code: i64 = 0; while code < 16 { let mut bits: i64 = 0; let mut temp: i64 = code; while temp > 0 { ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [flip_lights]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter.st...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [flip_lights]: function definitions module public import Aeneas public import Aegis.FlipLights.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option lin...
import Aegis.FlipLights.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.FlipLights.flip_lights 1#i64 1#i64) (2#i64))}") #eval (s!"CASE 1 {(Result.reducesTo (Aegis.FlipLights.flip_lights 5#i64 3#i64) (8#i64))}") #eval (s!"C...
[ { "input": "[1, 1]", "output": "2" }, { "input": "[5, 3]", "output": "8" }, { "input": "[1000, 1000]", "output": "8" }, { "input": "[4, 2]", "output": "7" }, { "input": "[2, 1]", "output": "3" }, { "input": "[10, 4]", "output": "8" }, { "in...
90
false
90
verified
10
10
1
5,104
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.FlipLights.Code.Funs /-! # Specifications of `Aegis.FlipLights.flip_lights` LeetCode problem `bulb-switcher-ii`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.FlipLights namespace AegisSpec.FlipLights abbrev Status (n : Nat) : Type := Fi...
11
number-of-longest-increasing-subsequence
673
Medium
[ "Binary Indexed Tree", "Segment Tree", "Array", "Dynamic Programming" ]
Given an integer array nums, return the number of longest increasing subsequences. Notice that the sequence has to be strictly increasing.   Example 1: Input: nums = [1,3,5,4,7] Output: 2 Explanation: The two longest increasing subsequences are [1, 3, 4, 7] and [1, 3, 5, 7]. Example 2: Input: nums = [2,2,2,2,2] Outp...
findNumberOfLIS(nums: list_int) -> int
pub fn find_number_of_lis(nums: &[i64]) -> i64
Aegis.FindNumberOfLis.find_number_of_lis
pub fn find_number_of_lis(nums: &[i64]) -> i64 { let n = nums.len(); if n == 0 { return 0; } let mut lengths: Vec<i64> = Vec::new(); let mut counts: Vec<i64> = Vec::new(); let mut i: usize = 0; while i < n { lengths.push(1); counts.push(1); let mut j: usize...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [find_number_of_lis]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option li...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [find_number_of_lis]: function definitions module public import Aeneas public import Aegis.FindNumberOfLis.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false se...
import Aegis.FindNumberOfLis.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.FindNumberOfLis.find_number_of_lis (Slice.from [1#i64] (by scalar_tac) : Slice Std.I64)) (1#i64))}") #eval (s!"CASE 1 {(Result.reducesTo (Aegis.F...
[ { "input": "[[1]]", "output": "1" }, { "input": "[[1, 2]]", "output": "1" }, { "input": "[[2, 1]]", "output": "2" }, { "input": "[[5, 4, 3, 2, 1]]", "output": "5" }, { "input": "[[1, 3, 5, 4, 7]]", "output": "2" }, { "input": "[[2, 2, 2, 2, 2]]", "...
109
false
109
verified
10
10
1
1,101
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.FindNumberOfLis.Code.Funs /-! # Specifications of `Aegis.FindNumberOfLis.find_number_of_lis` LeetCode problem `number-of-longest-increasing-subsequence`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.FindNumberOfLis def vals (nums : S...
9
longest-continuous-increasing-subsequence
674
Easy
[ "Array" ]
Given an unsorted array of integers nums, return the length of the longest continuous increasing subsequence (i.e. subarray). The subsequence must be strictly increasing. A continuous increasing subsequence is defined by two indices l and r (l < r) such that it is [nums[l], nums[l + 1], ..., nums[r - 1], nums[r]] and f...
findLengthOfLCIS(nums: list_int) -> int
pub fn find_length_of_lcis(nums: &[i64]) -> i64
Aegis.FindLengthOfLcis.find_length_of_lcis
pub fn find_length_of_lcis(nums: &[i64]) -> i64 { let n = nums.len(); if n == 0 { return 1; } let mut best: i64 = 1; let mut current: i64 = 1; let mut i: usize = 1; while i < n { if nums[i] > nums[i - 1] { current += 1; } else { current = 1; ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [find_length_of_lcis]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option l...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [find_length_of_lcis]: function definitions module public import Aeneas public import Aegis.FindLengthOfLcis.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false ...
import Aegis.FindLengthOfLcis.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.FindLengthOfLcis.find_length_of_lcis (Slice.from [] (by scalar_tac) : Slice Std.I64)) (1#i64))}") #eval (s!"CASE 1 {(Result.reducesTo (Aegis.Fin...
[ { "input": "[[]]", "output": "1" }, { "input": "[[1]]", "output": "1" }, { "input": "[[1, 2]]", "output": "2" }, { "input": "[[2, 1]]", "output": "1" }, { "input": "[[1, 2]]", "output": "2" }, { "input": "[[1, 2, 2]]", "output": "2" }, { "i...
134
false
134
verified
10
10
1
412
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.FindLengthOfLcis.Code.Funs /-! # Specifications of `Aegis.FindLengthOfLcis.find_length_of_lcis` LeetCode problem `longest-continuous-increasing-subsequence`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.FindLengthOfLcis def conte...
9
cut-off-trees-for-golf-event
675
Hard
[ "Breadth-First Search", "Array", "Matrix", "Heap (Priority Queue)" ]
You are asked to cut off all the trees in a forest for a golf event. The forest is represented as an m x n matrix. In this matrix: 0 means the cell cannot be walked through. 1 represents an empty cell that can be walked through. A number greater than 1 represents a tree in a cell that can be walked through, and this n...
cutOffTree(forest: list_list_int) -> int
pub fn cut_off_tree(forest: &[Vec<i64>]) -> i64
Aegis.CutOffTree.cut_off_tree
pub fn cut_off_tree(forest: &[Vec<i64>]) -> i64 { let m = forest.len(); if m == 0 { return 0; } let n = forest[0].len(); if n == 0 { return 0; } let mut heights: Vec<i64> = Vec::new(); let mut rows: Vec<usize> = Vec::new(); let mut cols: Vec<usize> = Vec::new(); ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [cut_off_tree]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter.s...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [cut_off_tree]: function definitions module public import Aeneas public import Aegis.CutOffTree.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option li...
import Aegis.CutOffTree.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.CutOffTree.cut_off_tree (Slice.from [(alloc.vec.Vec.from [1#i64, 2#i64] (by scalar_tac) : alloc.vec.Vec Std.I64), (alloc.vec.Vec.from [3#i64, 4#i64] (...
[ { "input": "[[[1, 2], [3, 4]]]", "output": "4" }, { "input": "[[[1, 1], [2, 0]]]", "output": "1" }, { "input": "[[[1, 2, 3], [0, 0, 4], [7, 6, 5]]]", "output": "6" }, { "input": "[[[3, 0, 0], [1, 0, 0], [2, 0, 0]]]", "output": "4" }, { "input": "[[[1, 1, 0], [0, 0...
99
false
99
verified
10
10
1
5,306
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.CutOffTree.Code.Funs /-! # Specifications of `Aegis.CutOffTree.cut_off_tree` LeetCode problem `cut-off-trees-for-golf-event`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.CutOffTree open Classical Aegis.CutOffTree abbrev Cell := ℕ ×...
13
valid-parenthesis-string
678
Medium
[ "Stack", "Greedy", "String", "Dynamic Programming" ]
Given a string s containing only three types of characters: '(', ')' and '*', return true if s is valid. The following rules define a valid string: Any left parenthesis '(' must have a corresponding right parenthesis ')'. Any right parenthesis ')' must have a corresponding left parenthesis '('. Left parenthesis '(' mu...
checkValidString(s: str) -> bool
pub fn check_valid_string(s: &[u8]) -> bool
Aegis.CheckValidString.check_valid_string
pub fn check_valid_string(s: &[u8]) -> bool { let mut min_open: i64 = 0; let mut max_open: i64 = 0; let n = s.len(); for i in 0..n { let c = s[i]; if c == b'(' { min_open += 1; max_open += 1; } else if c == b')' { min_open -= 1; ma...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [check_valid_string]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option li...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [check_valid_string]: function definitions module public import Aeneas public import Aegis.CheckValidString.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false s...
import Aegis.CheckValidString.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.CheckValidString.check_valid_string (Slice.from [40#u8, 40#u8, 41#u8, 41#u8, 42#u8] (by scalar_tac) : Slice Std.U8)) (true))}") #eval (s!"CASE 1...
[ { "input": "[\"(())*\"]", "output": "true" }, { "input": "[\"((((((**))))))\"]", "output": "true" }, { "input": "[\"(()*\"]", "output": "true" }, { "input": "[\"****\"]", "output": "true" }, { "input": "[\"(()****)\"]", "output": "true" }, { "input": "...
181
false
181
verified
10
10
1
369
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.CheckValidString.Code.Funs /-! # Specifications of `Aegis.CheckValidString.check_valid_string` LeetCode problem `valid-parenthesis-string`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.CheckValidString open Aegis.CheckValidString de...
14
24-game
679
Hard
[ "Array", "Math", "Backtracking" ]
You are given an integer array cards of length 4. You have four cards, each containing a number in the range [1, 9]. You should arrange the numbers on these cards in a mathematical expression using the operators ['+', '-', '*', '/'] and the parentheses '(' and ')' to get the value 24. You are restricted with the follow...
judgePoint24(cards: list_int) -> bool
pub fn judge_point24(cards: &[i64]) -> bool
Aegis.JudgePoint24.judge_point24
fn apply(an: i64, ad: i64, bn: i64, bd: i64, op: i64) -> Vec<i64> { let mut res: Vec<i64> = Vec::new(); if op == 0 { res.push(an * bd + bn * ad); res.push(ad * bd); } else if op == 1 { res.push(an * bd - bn * ad); res.push(ad * bd); } else if op == 2 { res.push(an...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [judge_point24]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter....
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [judge_point24]: function definitions module public import Aeneas public import Aegis.JudgePoint24.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option...
import Aegis.JudgePoint24.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.JudgePoint24.judge_point24 (Slice.from [9#i64, 9#i64, 9#i64, 9#i64] (by scalar_tac) : Slice Std.I64)) (false))}") #eval (s!"CASE 1 {(Result.reducesT...
[ { "input": "[[9, 9, 9, 9]]", "output": "false" }, { "input": "[[2, 8, 1, 4]]", "output": "true" }, { "input": "[[4, 4, 7, 7]]", "output": "true" }, { "input": "[[1, 10, 1, 10]]", "output": "false" }, { "input": "[[1, 3, 4, 6]]", "output": "true" }, { "...
109
false
109
verified
10
10
2
28,295
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Mathlib.Data.Real.Basic import Aegis.JudgePoint24.Code.Funs /-! # Specifications of `Aegis.JudgePoint24.judge_point24` LeetCode problem `24-game`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result ControlFlow Error namespace AegisSpec.JudgePoint24 inductive Expr w...
4
valid-palindrome-ii
680
Easy
[ "Greedy", "Two Pointers", "String" ]
Given a string s, return true if the s can be palindrome after deleting at most one character from it.   Example 1: Input: s = "aba" Output: true Example 2: Input: s = "abca" Output: true Explanation: You could delete the character 'c'. Example 3: Input: s = "abc" Output: false   Constraints: 1 <= s.length <= 10...
validPalindrome(s: str) -> bool
pub fn valid_palindrome(s: &[u8]) -> bool
Aegis.ValidPalindrome.valid_palindrome
fn is_palindrome_range(s: &[u8], mut left: usize, mut right: usize) -> bool { while left < right { if s[left] != s[right] { return false; } left += 1; right -= 1; } true } pub fn valid_palindrome(s: &[u8]) -> bool { let n = s.len(); if n <= 2 { re...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [valid_palindrome]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option lint...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [valid_palindrome]: function definitions module public import Aeneas public import Aegis.ValidPalindrome.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_...
import Aegis.ValidPalindrome.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.ValidPalindrome.valid_palindrome (Slice.from [114#u8, 97#u8, 99#u8, 101#u8, 101#u8, 99#u8, 97#u8, 114#u8] (by scalar_tac) : Slice Std.U8)) (true)...
[ { "input": "[\"raceecar\"]", "output": "true" }, { "input": "[\"abcba\"]", "output": "true" }, { "input": "[\"deeee\"]", "output": "true" }, { "input": "[\"ab\"]", "output": "true" }, { "input": "[\"abc\"]", "output": "false" }, { "input": "[\"racecarx...
108
false
108
verified
10
10
1
950
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.ValidPalindrome.Code.Funs /-! # Specifications of `Aegis.ValidPalindrome.valid_palindrome` LeetCode problem `valid-palindrome-ii`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.ValidPalindrome def byteAt (l : List Std.U8) (i : Nat) : ...
10
baseball-game
682
Easy
[ "Stack", "Array", "Simulation" ]
You are keeping the scores for a baseball game with strange rules. At the beginning of the game, you start with an empty record. You are given a list of strings operations, where operations[i] is the ith operation you must apply to the record and is one of the following: An integer x. Record a new score of x. '+'...
calPoints(operations: list_str) -> int
pub fn cal_points(operations: &[Vec<u8>]) -> i64
Aegis.CalPoints.cal_points
pub fn cal_points(operations: &[Vec<u8>]) -> i64 { let mut scores: Vec<i64> = Vec::new(); let n_ops = operations.len(); let mut i: usize = 0; while i < n_ops { let op = &operations[i]; if op.len() == 1 && op[0] == b'C' { if scores.len() > 0 { scores.pop(); ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [cal_points]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter.sty...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [cal_points]: function definitions module public import Aeneas public import Aegis.CalPoints.Code.Types public import Aegis.CalPoints.Code.FunsExternal @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [cal_points]: external functions. -- This is a template file: rename it to "FunsExternal.lean" and fill the holes. module public import Aeneas public import Aegis.CalPoints.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_optio...
import Aegis.CalPoints.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.CalPoints.cal_points (Slice.from [(alloc.vec.Vec.from [49#u8] (by scalar_tac) : alloc.vec.Vec Std.U8), (alloc.vec.Vec.from [67#u8] (by scalar_tac) : al...
[ { "input": "[[\"1\", \"C\"]]", "output": "0" }, { "input": "[[\"10\", \"20\", \"30\", \"D\", \"+\"]]", "output": "210" }, { "input": "[[\"5\", \"2\", \"C\", \"D\", \"+\"]]", "output": "30" }, { "input": "[[\"100\", \"-50\", \"D\", \"C\", \"+\"]]", "output": "100" }, {...
75
false
75
verified
10
10
1
1,568
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.CalPoints.Code.Funs /-! # Specifications of `Aegis.CalPoints.cal_points` LeetCode problem `baseball-game`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result Aegis.CalPoints set_option autoImplicit false namespace AegisSpec.CalPoints inductive Op where | ...
12
k-empty-slots
683
Hard
[ "Binary Indexed Tree", "Segment Tree", "Queue", "Array", "Ordered Set", "Sliding Window", "Monotonic Queue", "Heap (Priority Queue)" ]
You have n bulbs in a row numbered from 1 to n. Initially, all the bulbs are turned off. We turn on exactly one bulb every day until all bulbs are on after n days. You are given an array bulbs of length n where bulbs[i] = x means that on the (i+1)th day, we will turn on the bulb at position x where i is 0-indexed and x...
kEmptySlots(bulbs: list_int, k: int) -> int
pub fn k_empty_slots(bulbs: &[i64], k: i64) -> i64
Aegis.KEmptySlots.k_empty_slots
pub fn k_empty_slots(bulbs: &[i64], k: i64) -> i64 { let n = bulbs.len(); if n == 0 { return -1; } if k < 0 { return -1; } let kk = k as usize; if kk + 2 > n { return -1; } let mut days: Vec<i64> = Vec::new(); let mut i: usize = 0; while i < n { ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [k_empty_slots]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter....
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [k_empty_slots]: function definitions module public import Aeneas public import Aegis.KEmptySlots.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option ...
import Aegis.KEmptySlots.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.KEmptySlots.k_empty_slots (Slice.from [2#i64, 1#i64, 3#i64] (by scalar_tac) : Slice Std.I64) 1#i64) ((-1)#i64))}") #eval (s!"CASE 1 {(Result.reducesT...
[ { "input": "[[2, 1, 3], 1]", "output": "-1" }, { "input": "[[1, 2, 3], 1]", "output": "-1" }, { "input": "[[1, 3, 2], 1]", "output": "2" }, { "input": "[[1, 4, 3, 2], 1]", "output": "3" }, { "input": "[[2, 1, 3, 5, 4], 1]", "output": "4" }, { "input": ...
115
false
115
verified
10
10
1
9,600
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.KEmptySlots.Code.Funs /-! # Specifications of `Aegis.KEmptySlots.k_empty_slots` LeetCode problem `k-empty-slots`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.KEmptySlots (k_empty_slots) namespace AegisSpec.KEmptySlots def nOf (bulbs : Slice ...
10
redundant-connection
684
Medium
[ "Depth-First Search", "Breadth-First Search", "Union Find", "Graph" ]
In this problem, a tree is an undirected graph that is connected and has no cycles. You are given a graph that started as a tree with n nodes labeled from 1 to n, with one additional edge added. The added edge has two different vertices chosen from 1 to n, and was not an edge that already existed. The graph is represen...
findRedundantConnection(edges: list_list_int) -> list_int
pub fn find_redundant_connection(edges: &[Vec<i64>]) -> Vec<i64>
Aegis.FindRedundantConnection.find_redundant_connection
pub fn find_redundant_connection(edges: &[Vec<i64>]) -> Vec<i64> { let n = edges.len(); let mut parent: Vec<i64> = Vec::new(); let mut size: Vec<i64> = Vec::new(); let mut i = 0usize; while i <= n { parent.push(i as i64); size.push(1); i += 1; } let mut idx = 0usiz...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [find_redundant_connection]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_op...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [find_redundant_connection]: function definitions module public import Aeneas public import Aegis.FindRedundantConnection.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashC...
import Aegis.FindRedundantConnection.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.FindRedundantConnection.find_redundant_connection (Slice.from [(alloc.vec.Vec.from [1#i64, 2#i64] (by scalar_tac) : alloc.vec.Vec Std.I64...
[ { "input": "[[[1, 2], [2, 3], [3, 1]]]", "output": "[3, 1]" }, { "input": "[[[1, 2], [2, 3], [1, 3]]]", "output": "[1, 3]" }, { "input": "[[[1, 2], [1, 3], [2, 3]]]", "output": "[2, 3]" }, { "input": "[[[3, 4], [1, 2], [2, 4], [3, 5], [2, 5]]]", "output": "[2, 5]" }, ...
76
false
76
verified
10
10
1
1,886
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.FindRedundantConnection.Code.Funs /-! # Specifications of `Aegis.FindRedundantConnection.find_redundant_connection` LeetCode problem `redundant-connection`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.FindRedundantConnection def...
14
repeated-string-match
686
Medium
[ "String", "String Matching" ]
Given two strings a and b, return the minimum number of times you should repeat string a so that string b is a substring of it. If it is impossible for b​​​​​​ to be a substring of a after repeating it, return -1. Notice: string "abc" repeated 0 times is "", repeated 1 time is "abc" and repeated 2 times is "abcabc".   ...
repeatedStringMatch(a: str, b: str) -> int
pub fn repeated_string_match(a: &[u8], b: &[u8]) -> i64
Aegis.RepeatedStringMatch.repeated_string_match
pub fn repeated_string_match(a: &[u8], b: &[u8]) -> i64 { let n = a.len(); let m = b.len(); if m == 0 { return 0; } if n == 0 { return -1; } let q = (m + n - 1) / n; let mut s: Vec<u8> = Vec::new(); let mut i = 0usize; while i < q { let mut j = 0usize; ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [repeated_string_match]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [repeated_string_match]: function definitions module public import Aeneas public import Aegis.RepeatedStringMatch.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand f...
import Aegis.RepeatedStringMatch.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.RepeatedStringMatch.repeated_string_match (Slice.from [97#u8, 98#u8, 97#u8, 98#u8] (by scalar_tac) : Slice Std.U8) (Slice.from [97#u8, 98#u8,...
[ { "input": "[\"abab\", \"abababab\"]", "output": "2" }, { "input": "[\"ab\", \"aba\"]", "output": "2" }, { "input": "[\"abc\", \"def\"]", "output": "-1" }, { "input": "[\"abc\", \"abcabc\"]", "output": "2" }, { "input": "[\"aaaaaaaaaaaaaaaaaaaaaab\", \"ba\"]", ...
144
false
144
verified
10
10
1
5,674
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.RepeatedStringMatch.Code.Funs /-! # Specifications of `Aegis.RepeatedStringMatch.repeated_string_match` LeetCode problem `repeated-string-match`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.RepeatedStringMatch namespace AegisSpec.Repeated...
14
longest-univalue-path
687
Medium
[ "Tree", "Depth-First Search", "Binary Tree" ]
Given the root of a binary tree, return the length of the longest path, where each node in the path has the same value. This path may or may not pass through the root. The length of the path between two nodes is represented by the number of edges between them.   Example 1: Input: root = [5,4,5,1,1,null,5] Output: 2 E...
longestUnivaluePath(root: tree) -> int
pub fn longest_univalue_path(root: &Tree) -> i64
Aegis.LongestUnivaluePath.longest_univalue_path
fn extend(t: &Tree, v: i64, down: i64) -> i64 { match t { Tree::Null => 0, Tree::Node(cv, _, _) => { if *cv == v { down + 1 } else { 0 } } } } fn max_i64(a: i64, b: i64) -> i64 { if a > b { a } else { ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [longest_univalue_path]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [longest_univalue_path]: function definitions module public import Aeneas public import Aegis.LongestUnivaluePath.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand f...
import Aegis.LongestUnivaluePath.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.LongestUnivaluePath.longest_univalue_path ((.Null) : Aegis.LongestUnivaluePath.Tree)) (0#i64))}") #eval (s!"CASE 1 {(Result.reducesTo (Aegis....
[ { "input": "[[]]", "output": "0" }, { "input": "[[1, 2]]", "output": "0" }, { "input": "[[1, 1, 1, 1]]", "output": "3" }, { "input": "[[1, 2, 3, 4, 5, 6, 7]]", "output": "0" }, { "input": "[[5, 5, 5, 5, 5, 5, 5]]", "output": "4" }, { "input": "[[5, 5, ...
41
false
41
verified
10
10
4
20,173
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.LongestUnivaluePath.Code.Funs /-! # Specifications of `Aegis.LongestUnivaluePath.longest_univalue_path` LeetCode problem `longest-univalue-path`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aeneas.Std.Result namespace AegisSpec.LongestUnivaluePath ...
12
maximum-sum-of-3-non-overlapping-subarrays
689
Hard
[ "Array", "Dynamic Programming" ]
Given an integer array nums and an integer k, find three non-overlapping subarrays of length k with maximum sum and return them. Return the result as a list of indices representing the starting position of each interval (0-indexed). If there are multiple answers, return the lexicographically smallest one.   Example 1: ...
maxSumOfThreeSubarrays(nums: list_int, k: int) -> list_int
pub fn max_sum_of_three_subarrays(nums: &[i64], k: i64) -> Vec<i64>
Aegis.MaxSumOfThreeSubarrays.max_sum_of_three_subarrays
pub fn max_sum_of_three_subarrays(nums: &[i64], k: i64) -> Vec<i64> { let mut res: Vec<i64> = Vec::new(); if k <= 0 { return res; } let n = nums.len(); let kk = k as usize; if 3 * kk > n { return res; } let m = n - kk + 1; // sums[i] = sum of nums[i .. i + kk] l...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [max_sum_of_three_subarrays]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_o...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [max_sum_of_three_subarrays]: function definitions module public import Aeneas public import Aegis.MaxSumOfThreeSubarrays.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashC...
import Aegis.MaxSumOfThreeSubarrays.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.MaxSumOfThreeSubarrays.max_sum_of_three_subarrays (Slice.from [3#i64, 5#i64, 10#i64, 7#i64, 6#i64, 2#i64] (by scalar_tac) : Slice Std.I64)...
[ { "input": "[[3, 5, 10, 7, 6, 2], 1]", "output": "[2, 3, 4]" }, { "input": "[[10, 20, 30, 40, 50, 60, 70, 80, 90, 100], 4]", "output": "[]" }, { "input": "[[1, 2, 1, 2, 6, 7, 5, 1], 2]", "output": "[0, 3, 5]" }, { "input": "[[1, 2, 1, 2, 1, 2, 1, 2, 1], 2]", "output": "[0...
80
false
80
verified
10
10
1
14,020
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MaxSumOfThreeSubarrays.Code.Funs /-! # Specifications of `Aegis.MaxSumOfThreeSubarrays.max_sum_of_three_subarrays` LeetCode problem `maximum-sum-of-3-non-overlapping-subarrays`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.MaxSumOfThreeSubarr...
11
stickers-to-spell-word
691
Hard
[ "Bit Manipulation", "Memoization", "Array", "Hash Table", "String", "Dynamic Programming", "Backtracking", "Bitmask" ]
We are given n different types of stickers. Each sticker has a lowercase English word on it. You would like to spell out the given string target by cutting individual letters from your collection of stickers and rearranging them. You can use each sticker more than once if you want, and you have infinite quantities of e...
minStickers(stickers: list_str, target: str) -> int
pub fn min_stickers(stickers: &[Vec<u8>], target: &[u8]) -> i64
Aegis.MinStickers.min_stickers
pub fn min_stickers(stickers: &[Vec<u8>], target: &[u8]) -> i64 { let n = target.len(); if n == 0 { return 0; } let size: usize = 1usize << n; let inf: i64 = 1000000000; let mut dp: Vec<i64> = Vec::new(); let mut i: usize = 0; while i < size { dp.push(inf); i +=...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [min_stickers]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter.s...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [min_stickers]: function definitions module public import Aeneas public import Aegis.MinStickers.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option l...
import Aegis.MinStickers.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.MinStickers.min_stickers (Slice.from [(alloc.vec.Vec.from [97#u8, 98#u8, 99#u8, 100#u8] (by scalar_tac) : alloc.vec.Vec Std.U8)] (by scalar_tac) : Sl...
[ { "input": "[[\"abcd\"], \"abcdabcd\"]", "output": "2" }, { "input": "[[\"abc\"], \"d\"]", "output": "-1" }, { "input": "[[\"abc\"], \"abcd\"]", "output": "-1" }, { "input": "[[\"a\"], \"a\"]", "output": "1" }, { "input": "[[\"aaa\", \"bbb\"], \"aabbbccc\"]", ...
146
false
146
verified
10
10
1
9,995
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MinStickers.Code.Funs /-! # Specifications of `Aegis.MinStickers.min_stickers` LeetCode problem `stickers-to-spell-word`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result ControlFlow Error namespace AegisSpec.MinStickers def isLowerByte (b : Std.U8) : P...
14
top-k-frequent-words
692
Medium
[ "Trie", "Array", "Hash Table", "String", "Bucket Sort", "Counting", "Sorting", "Heap (Priority Queue)" ]
Given an array of strings words and an integer k, return the k most frequent strings. Return the answer sorted by the frequency from highest to lowest. Sort the words with the same frequency by their lexicographical order.   Example 1: Input: words = ["i","love","leetcode","i","love","coding"], k = 2 Output: ["i","lov...
topKFrequent(words: list_str, k: int) -> list_str
pub fn top_k_frequent(words: &[Vec<u8>], k: i64) -> Vec<Vec<u8>>
Aegis.TopKFrequent.top_k_frequent
pub fn top_k_frequent(words: &[Vec<u8>], k: i64) -> Vec<Vec<u8>> { let n = words.len(); let mut unique: Vec<Vec<u8>> = Vec::new(); let mut counts: Vec<i64> = Vec::new(); let mut i: usize = 0; while i < n { let w = &words[i]; let un = unique.len(); let mut found: usize = un;...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [top_k_frequent]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [top_k_frequent]: function definitions module public import Aeneas public import Aegis.TopKFrequent.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_optio...
import Aegis.TopKFrequent.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.TopKFrequent.top_k_frequent (Slice.from [(alloc.vec.Vec.from [97#u8] (by scalar_tac) : alloc.vec.Vec Std.U8), (alloc.vec.Vec.from [97#u8, 97#u8] (by...
[ { "input": "[[\"a\", \"aa\", \"aaa\"], 1]", "output": "[\"a\"]" }, { "input": "[[\"a\", \"aa\", \"aaa\"], 2]", "output": "[\"a\", \"aa\"]" }, { "input": "[[\"zebra\", \"dog\", \"duck\", \"dog\", \"zebra\", \"zebra\"], 1]", "output": "[\"zebra\"]" }, { "input": "[[\"hello\", \...
92
false
92
verified
10
10
1
6,485
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.TopKFrequent.Code.Funs /-! # Specifications of `Aegis.TopKFrequent.top_k_frequent` LeetCode problem `top-k-frequent-words`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.TopKFrequent open Aegis.TopKFrequent (top_k_frequent) abb...
12
binary-number-with-alternating-bits
693
Easy
[ "Bit Manipulation" ]
Given a positive integer, check whether it has alternating bits: namely, if two adjacent bits will always have different values.   Example 1: Input: n = 5 Output: true Explanation: The binary representation of 5 is: 101 Example 2: Input: n = 7 Output: false Explanation: The binary representation of 7 is: 111. Exampl...
hasAlternatingBits(n: int) -> bool
pub fn has_alternating_bits(n: i64) -> bool
Aegis.HasAlternatingBits.has_alternating_bits
pub fn has_alternating_bits(n: i64) -> bool { let mut x: i64 = n; let mut prev: i64 = x % 2; x = x / 2; while x > 0 { let cur: i64 = x % 2; if cur == prev { return false; } prev = cur; x = x / 2; } true }
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [has_alternating_bits]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [has_alternating_bits]: function definitions module public import Aeneas public import Aegis.HasAlternatingBits.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand fal...
import Aegis.HasAlternatingBits.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.HasAlternatingBits.has_alternating_bits 3#i64) (false))}") #eval (s!"CASE 1 {(Result.reducesTo (Aegis.HasAlternatingBits.has_alternating_bits ...
[ { "input": "[3]", "output": "false" }, { "input": "[11]", "output": "false" }, { "input": "[15]", "output": "false" }, { "input": "[2]", "output": "true" }, { "input": "[1]", "output": "true" }, { "input": "[7]", "output": "false" }, { "inp...
71
false
71
verified
10
10
1
404
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.HasAlternatingBits.Code.Funs /-! # Specifications of `Aegis.HasAlternatingBits.has_alternating_bits` LeetCode problem `binary-number-with-alternating-bits`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.HasAlternatingBits def bitA...
9
number-of-distinct-islands
694
Medium
[ "Depth-First Search", "Breadth-First Search", "Union Find", "Hash Table", "Hash Function" ]
You are given an m x n binary matrix grid. An island is a group of 1's (representing land) connected 4-directionally (horizontal or vertical.) You may assume all four edges of the grid are surrounded by water. An island is considered to be the same as another if and only if one island can be translated (and not rotated...
numDistinctIslands(grid: list_list_int) -> int
pub fn num_distinct_islands(grid: &[Vec<i64>]) -> i64
Aegis.NumDistinctIslands.num_distinct_islands
pub fn num_distinct_islands(grid: &[Vec<i64>]) -> i64 { let m = grid.len(); if m == 0 { return 0; } let n = grid[0].len(); if n == 0 { return 0; } let mut visited: Vec<Vec<bool>> = Vec::new(); let mut i = 0; while i < m { let mut row: Vec<bool> = Vec::new(); ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [num_distinct_islands]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [num_distinct_islands]: function definitions module public import Aeneas public import Aegis.NumDistinctIslands.Code.Types public import Aegis.NumDistinctIslands.Code.FunsExternal @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option li...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [num_distinct_islands]: external functions. -- This is a template file: rename it to "FunsExternal.lean" and fill the holes. module public import Aeneas public import Aegis.NumDistinctIslands.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlF...
import Aegis.NumDistinctIslands.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.NumDistinctIslands.num_distinct_islands (Slice.from [(alloc.vec.Vec.from [1#i64, 1#i64, 0#i64, 0#i64, 1#i64] (by scalar_tac) : alloc.vec.Vec S...
[ { "input": "[[[1, 1, 0, 0, 1], [1, 0, 0, 0, 0], [0, 0, 1, 1, 0], [0, 0, 1, 0, 0]]]", "output": "2" }, { "input": "[[[1, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 1]]]", "output": "1" }, { "input": "[[[1, 1, 0, 1, 1], [1, 0, 0, 0, 0], [0, 0, 0, 0, 1], [1, 1, 0, 1, 1]]]",...
64
false
64
verified
10
10
1
10,302
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.NumDistinctIslands.Code.Funs /-! # Specifications of `Aegis.NumDistinctIslands.num_distinct_islands` LeetCode problem `number-of-distinct-islands`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.NumDistinctIslands abbrev Grid : Type :=...
12
max-area-of-island
695
Medium
[ "Depth-First Search", "Breadth-First Search", "Union Find", "Array", "Matrix" ]
You are given an m x n binary matrix grid. An island is a group of 1's (representing land) connected 4-directionally (horizontal or vertical.) You may assume all four edges of the grid are surrounded by water. The area of an island is the number of cells with a value 1 in the island. Return the maximum area of an islan...
maxAreaOfIsland(grid: list_list_int) -> int
pub fn max_area_of_island(grid: &[Vec<i64>]) -> i64
Aegis.MaxAreaOfIsland.max_area_of_island
pub fn max_area_of_island(grid: &[Vec<i64>]) -> i64 { let m: usize = grid.len(); if m == 0 { return 0; } let n: usize = grid[0].len(); if n == 0 { return 0; } let mut cells: Vec<i64> = Vec::new(); let mut i: usize = 0; while i < m { let mut j: usize = 0; ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [max_area_of_island]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option li...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [max_area_of_island]: function definitions module public import Aeneas public import Aegis.MaxAreaOfIsland.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false se...
import Aegis.MaxAreaOfIsland.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.MaxAreaOfIsland.max_area_of_island (Slice.from [(alloc.vec.Vec.from [1#i64] (by scalar_tac) : alloc.vec.Vec Std.I64)] (by scalar_tac) : Slice (al...
[ { "input": "[[[1]]]", "output": "1" }, { "input": "[[[0]]]", "output": "0" }, { "input": "[[[0, 0, 0, 0, 0, 0, 0, 0]]]", "output": "0" }, { "input": "[[[1, 0, 1, 1, 1], [1, 0, 1, 0, 1], [1, 0, 1, 1, 1], [1, 0, 0, 0, 0]]]", "output": "8" }, { "input": "[[[1, 1, 0, ...
59
false
59
verified
10
10
1
12,611
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MaxAreaOfIsland.Code.Funs /-! # Specifications of `Aegis.MaxAreaOfIsland.max_area_of_island` LeetCode problem `max-area-of-island`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aeneas.Std.alloc.vec open Aegis.MaxAreaOfIsland namespace AegisSpe...
15
count-binary-substrings
696
Easy
[ "Two Pointers", "String" ]
Given a binary string s, return the number of non-empty substrings that have the same number of 0's and 1's, and all the 0's and all the 1's in these substrings are grouped consecutively. Substrings that occur multiple times are counted the number of times they occur.   Example 1: Input: s = "00110011" Output: 6 Expla...
countBinarySubstrings(s: str) -> int
pub fn count_binary_substrings(s: &[u8]) -> i64
Aegis.CountBinarySubstrings.count_binary_substrings
pub fn count_binary_substrings(s: &[u8]) -> i64 { let n = s.len(); if n == 0 { return 0; } let mut ans: i64 = 0; let mut prev: i64 = 0; let mut cur: i64 = 1; let mut i: usize = 1; while i < n { if s[i] == s[i - 1] { cur += 1; } else { if ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [count_binary_substrings]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_opti...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [count_binary_substrings]: function definitions module public import Aeneas public import Aegis.CountBinarySubstrings.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashComma...
import Aegis.CountBinarySubstrings.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.CountBinarySubstrings.count_binary_substrings (Slice.from [48#u8, 48#u8, 48#u8, 49#u8, 49#u8, 49#u8, 48#u8, 48#u8, 48#u8, 49#u8, 49#u8, 49#...
[ { "input": "[\"000111000111\"]", "output": "9" }, { "input": "[\"01\"]", "output": "1" }, { "input": "[\"110011\"]", "output": "4" }, { "input": "[\"00110011\"]", "output": "6" }, { "input": "[\"11110000\"]", "output": "4" }, { "input": "[\"10101\"]", ...
158
false
158
verified
10
10
1
512
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.CountBinarySubstrings.Code.Funs /-! # Specifications of `Aegis.CountBinarySubstrings.count_binary_substrings` LeetCode problem `count-binary-substrings`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.CountBinarySubstrings open Aeg...
13
degree-of-an-array
697
Easy
[ "Array", "Hash Table" ]
Given a non-empty array of non-negative integers nums, the degree of this array is defined as the maximum frequency of any one of its elements. Your task is to find the smallest possible length of a (contiguous) subarray of nums, that has the same degree as nums.   Example 1: Input: nums = [1,2,2,3,1] Output: 2 Explan...
findShortestSubArray(nums: list_int) -> int
pub fn find_shortest_sub_array(nums: &[i64]) -> i64
Aegis.FindShortestSubArray.find_shortest_sub_array
pub fn find_shortest_sub_array(nums: &[i64]) -> i64 { let n: usize = nums.len(); if n == 0 { return 0; } if n == 1 { return 1; } let base: i64 = (n as i64) + 1; let mut a: Vec<i64> = Vec::new(); let mut max_key: i64 = 0; let mut i: usize = 0; while i < n { ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [find_shortest_sub_array]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_opti...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [find_shortest_sub_array]: function definitions module public import Aeneas public import Aegis.FindShortestSubArray.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashComman...
import Aegis.FindShortestSubArray.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval ...
[ { "input": "[[1]]", "output": "1" }, { "input": "[[1, 2, 2, 3, 1]]", "output": "2" }, { "input": "[[4, 4, 4, 4, 4]]", "output": "5" }, { "input": "[[5, 5, 5, 5, 5]]", "output": "5" }, { "input": "[[1, 2, 3, 4, 5]]", "output": "1" }, { "input": "[[1, 1,...
93
false
93
verified
10
10
2
16,809
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.FindShortestSubArray.Code.Funs /-! # Specifications of `Aegis.FindShortestSubArray.find_shortest_sub_array` LeetCode problem `degree-of-an-array`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.FindShortestSubArray def vals (nums : Sli...
17
falling-squares
699
Hard
[ "Segment Tree", "Array", "Ordered Set" ]
There are several squares being dropped onto the X-axis of a 2D plane. You are given a 2D integer array positions where positions[i] = [lefti, sideLengthi] represents the ith square with a side length of sideLengthi that is dropped with its left edge aligned with X-coordinate lefti. Each square is dropped one at a time...
fallingSquares(positions: list_list_int) -> list_int
pub fn falling_squares(positions: &[Vec<i64>]) -> Vec<i64>
Aegis.FallingSquares.falling_squares
pub fn falling_squares(positions: &[Vec<i64>]) -> Vec<i64> { let n = positions.len(); let mut ans: Vec<i64> = Vec::new(); let mut lefts: Vec<i64> = Vec::new(); let mut rights: Vec<i64> = Vec::new(); let mut tops: Vec<i64> = Vec::new(); let mut tallest: i64 = 0; let mut i: usize = 0; w...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [falling_squares]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linte...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [falling_squares]: function definitions module public import Aeneas public import Aegis.FallingSquares.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_op...
import Aegis.FallingSquares.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.FallingSquares.falling_squares (Slice.from [(alloc.vec.Vec.from [100#i64, 100#i64] (by scalar_tac) : alloc.vec.Vec Std.I64), (alloc.vec.Vec.from [...
[ { "input": "[[[100, 100], [200, 100]]]", "output": "[100, 100]" }, { "input": "[[[1, 1000000], [1000001, 1000000]]]", "output": "[1000000, 1000000]" }, { "input": "[[[1, 5], [2, 2], [7, 3]]]", "output": "[5, 7, 7]" }, { "input": "[[[1, 3], [3, 2], [5, 1]]]", "output": "[3...
105
false
105
verified
10
10
1
1,558
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.FallingSquares.Code.Funs /-! # Specifications of `Aegis.FallingSquares.falling_squares` LeetCode problem `falling-squares`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.FallingSquares namespace AegisSpec.FallingSquares def rowsOf (positions :...
10
search-in-a-binary-search-tree
700
Easy
[ "Tree", "Binary Search Tree", "Binary Tree" ]
You are given the root of a binary search tree (BST) and an integer val. Find the node in the BST that the node's value equals val and return the subtree rooted with that node. If such a node does not exist, return null.   Example 1: Input: root = [4,2,7,1,3], val = 2 Output: [2,1,3] Example 2: Input: root = [4,2,...
searchBST(root: tree, val: int) -> tree
pub fn search_bst(root: &Tree, val: i64) -> Tree
Aegis.SearchBst.search_bst
pub fn search_bst(root: &Tree, val: i64) -> Tree { match root { Tree::Null => Tree::Null, Tree::Node(v, left, right) => { if *v == val { clone_tree(root) } else if val < *v { search_bst(&**left, val) } else { search_...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [search_bst]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter.sty...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [search_bst]: function definitions module public import Aeneas public import Aegis.SearchBst.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linte...
import Aegis.SearchBst.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 deriving instance DecidableEq for Aegis.SearchBst.Tree #eval (s!"CASE 0 {(match (Aegis.SearchBst.search_bst ((.Node 1#i64 (.Null) (.Null)) : Aegis.SearchBst.Tree) 1#i64).match with | .ok r => d...
[ { "input": "[[1], 1]", "output": "[1]" }, { "input": "[[5], 5]", "output": "[5]" }, { "input": "[[2, 1, 3], 1]", "output": "[1]" }, { "input": "[[1, 0, 2], 1]", "output": "[1, 0, 2]" }, { "input": "[[2, 1, 3], 2]", "output": "[2, 1, 3]" }, { "input": "...
16
false
16
verified
10
10
1
1,108
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.SearchBst.Code.Funs /-! # Specifications of `Aegis.SearchBst.search_bst` LeetCode problem `search-in-a-binary-search-tree`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.SearchBst namespace AegisSpec.SearchBst inductive Subtree : Tree → ...
12
insert-into-a-binary-search-tree
701
Medium
[ "Tree", "Binary Search Tree", "Binary Tree" ]
You are given the root node of a binary search tree (BST) and a value to insert into the tree. Return the root node of the BST after the insertion. It is guaranteed that the new value does not exist in the original BST. Notice that there may exist multiple valid ways for the insertion, as long as the tree remains a BST...
insertIntoBST(root: tree, val: int) -> tree
pub fn insert_into_bst(root: &Tree, val: i64) -> Tree
Aegis.InsertIntoBst.insert_into_bst
fn clone_tree(t: &Tree) -> Tree { match t { Tree::Null => Tree::Null, Tree::Node(v, left, right) => Tree::Node( *v, Box::new(clone_tree(left)), Box::new(clone_tree(right)), ), } } fn insert(t: &Tree, val: i64) -> Tree { match t { Tree::Nul...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [insert_into_bst]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linte...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [insert_into_bst]: function definitions module public import Aeneas public import Aegis.InsertIntoBst.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_opt...
import Aegis.InsertIntoBst.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 deriving instance DecidableEq for Aegis.InsertIntoBst.Tree #eval (s!"CASE 0 {(match (Aegis.InsertIntoBst.insert_into_bst ((.Null) : Aegis.InsertIntoBst.Tree) 5#i64).match with | .ok r => de...
[ { "input": "[[], 5]", "output": "[5]" }, { "input": "[[], 1]", "output": "[1]" }, { "input": "[[1], 0]", "output": "[1, 0]" }, { "input": "[[2147483647], -2147483648]", "output": "[2147483647, -2147483648]" }, { "input": "[[1], 2]", "output": "[1, null, 2]" ...
34
false
34
verified
10
10
1
1,504
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.InsertIntoBst.Code.Funs /-! # Specifications of `Aegis.InsertIntoBst.insert_into_bst` LeetCode problem `insert-into-a-binary-search-tree`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.InsertIntoBst open Aegis.InsertIntoBst def...
11
binary-search
704
Easy
[ "Array", "Binary Search" ]
Given an array of integers nums which is sorted in ascending order, and an integer target, write a function to search target in nums. If target exists, then return its index. Otherwise, return -1. You must write an algorithm with O(log n) runtime complexity.   Example 1: Input: nums = [-1,0,3,5,9,12], target = 9 Outpu...
search(nums: list_int, target: int) -> int
pub fn search(nums: &[i64], target: i64) -> i64
Aegis.Search.search
pub fn search(nums: &[i64], target: i64) -> i64 { let n = nums.len(); let mut lo: usize = 0; let mut hi: usize = n; while lo < hi { let mid: usize = lo + (hi - lo) / 2; if nums[mid] == target { return mid as i64; } else if nums[mid] < target { lo = mid +...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [search]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter.style.w...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [search]: function definitions module public import Aeneas public import Aegis.Search.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unuse...
import Aegis.Search.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.Search.search (Slice.from [0#i64] (by scalar_tac) : Slice Std.I64) 0#i64) (0#i64))}") #eval (s!"CASE 1 {(Result.reducesTo (Aegis.Search.search (Slice.from...
[ { "input": "[[0], 0]", "output": "0" }, { "input": "[[5], 5]", "output": "0" }, { "input": "[[5], 4]", "output": "-1" }, { "input": "[[0], 1]", "output": "-1" }, { "input": "[[10000], 10000]", "output": "0" }, { "input": "[[1], 0]", "output": "-1" ...
115
false
115
verified
10
10
1
379
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.Search.Code.Funs /-! # Specifications of `Aegis.Search.search` LeetCode problem `binary-search`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.Search def entry (nums : Slice Std.I64) (i : ℕ) (h : i < nums.val.length) : ℤ := (nums.va...
9
to-lower-case
709
Easy
[ "String" ]
Given a string s, return the string after replacing every uppercase letter with the same lowercase letter.   Example 1: Input: s = "Hello" Output: "hello" Example 2: Input: s = "here" Output: "here" Example 3: Input: s = "LOVELY" Output: "lovely"   Constraints: 1 <= s.length <= 100 s consists of printable ASCII ...
toLowerCase(s: str) -> str
pub fn to_lower_case(s: &[u8]) -> Vec<u8>
Aegis.ToLowerCase.to_lower_case
pub fn to_lower_case(s: &[u8]) -> Vec<u8> { let mut out: Vec<u8> = Vec::new(); let n = s.len(); let mut i: usize = 0; while i < n { let b = s[i]; if b >= b'A' && b <= b'Z' { out.push(b + 32); } else { out.push(b); } i += 1; } out ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [to_lower_case]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter....
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [to_lower_case]: function definitions module public import Aeneas public import Aegis.ToLowerCase.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option ...
import Aegis.ToLowerCase.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.ToLowerCase.to_lower_case (Slice.from [72#u8, 101#u8, 108#u8, 108#u8, 111#u8] (by scalar_tac) : Slice Std.U8)) ((alloc.vec.Vec.from [104#u8, 101#u8, ...
[ { "input": "[\"Hello\"]", "output": "\"hello\"" }, { "input": "[\"here\"]", "output": "\"here\"" }, { "input": "[\"LOVELY\"]", "output": "\"lovely\"" } ]
3
false
3
verified
3
3
1
360
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.ToLowerCase.Code.Funs /-! # Specifications of `Aegis.ToLowerCase.to_lower_case` LeetCode problem `to-lower-case`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result Aegis.ToLowerCase namespace AegisSpec.ToLowerCase def code (b : U8) : Nat := b.val def isUppe...
10
number-of-distinct-islands-ii
711
Hard
[ "Depth-First Search", "Breadth-First Search", "Union Find", "Hash Table", "Hash Function" ]
You are given an m x n binary matrix grid. An island is a group of 1's (representing land) connected 4-directionally (horizontal or vertical.) You may assume all four edges of the grid are surrounded by water. An island is considered to be the same as another if they have the same shape, or have the same shape after ro...
numDistinctIslands2(grid: list_list_int) -> int
pub fn num_distinct_islands2(grid: &[Vec<i64>]) -> i64
Aegis.NumDistinctIslands2.num_distinct_islands2
fn copy_vec(v: &[i64]) -> Vec<i64> { let mut out: Vec<i64> = Vec::new(); let mut i = 0; while i < v.len() { out.push(v[i]); i += 1; } out } fn vec_eq(a: &[i64], b: &[i64]) -> bool { if a.len() != b.len() { return false; } let mut i = 0; while i < a.len() { ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [num_distinct_islands2]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [num_distinct_islands2]: function definitions module public import Aeneas public import Aegis.NumDistinctIslands2.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand f...
import Aegis.NumDistinctIslands2.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.NumDistinctIslands2.num_distinct_islands2 (Slice.from [(alloc.vec.Vec.from [1#i64] (by scalar_tac) : alloc.vec.Vec Std.I64)] (by scalar_tac) ...
[ { "input": "[[[1]]]", "output": "1" }, { "input": "[[[0]]]", "output": "0" }, { "input": "[[[1, 1, 0], [1, 0, 1], [0, 0, 1]]]", "output": "2" }, { "input": "[[[1, 1, 0], [0, 1, 1], [0, 0, 0], [1, 1, 1], [0, 1, 0]]]", "output": "2" }, { "input": "[[[1, 1, 0, 0], [1...
77
false
77
verified
10
10
1
11,213
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.NumDistinctIslands2.Code.Funs /-! # Specifications of `Aegis.NumDistinctIslands2.num_distinct_islands2` LeetCode problem `number-of-distinct-islands-ii`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.NumDistinctIslands2 def gridConten...
13