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
longest-substring-with-at-most-two-distinct-characters
159
Medium
[ "Hash Table", "String", "Sliding Window" ]
Given a string s, return the length of the longest substring that contains at most two distinct characters.   Example 1: Input: s = "eceba" Output: 3 Explanation: The substring is "ece" which its length is 3. Example 2: Input: s = "ccaabbb" Output: 5 Explanation: The substring is "aabbb" which its length is 5.   Co...
lengthOfLongestSubstringTwoDistinct(s: str) -> int
pub fn length_of_longest_substring_two_distinct(s: &[u8]) -> i64
Aegis.LengthOfLongestSubstringTwoDistinct.length_of_longest_substring_two_distinct
pub fn length_of_longest_substring_two_distinct(s: &[u8]) -> i64 { let n = s.len(); let mut left: usize = 0; let mut right: usize = 0; let mut char1: u8 = 0; let mut char2: u8 = 0; let mut count1: i64 = 0; let mut count2: i64 = 0; let mut distinct: i64 = 0; let mut best: i64 = 0; ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [length_of_longest_substring_two_distinct]: 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.unusedVariabl...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [length_of_longest_substring_two_distinct]: function definitions module public import Aeneas public import Aegis.LengthOfLongestSubstringTwoDistinct.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace fa...
import Aegis.LengthOfLongestSubstringTwoDistinct.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 {...
[ { "input": "[\"abcdefghijklmnopqrstuvwxyz\"]", "output": "2" }, { "input": "[\"ababccababcc\"]", "output": "4" }, { "input": "[\"aabacbebebe\"]", "output": "6" }, { "input": "[\"a\"]", "output": "1" }, { "input": "[\"abcabcabc\"]", "output": "2" }, { "...
80
false
80
verified
10
10
1
4,672
[ { "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.LengthOfLongestSubstringTwoDistinct.Code.Funs /-! # Specifications of `Aegis.LengthOfLongestSubstringTwoDistinct.length_of_longest_substring_two_distinct` LeetCode problem `longest-substring-with-at-most-two-distinct-characters`. Each `spec_<n>` theorem states one property of the function. -/ open Aenea...
14
one-edit-distance
161
Medium
[ "Two Pointers", "String" ]
Given two strings s and t, return true if they are both one edit distance apart, otherwise return false. A string s is said to be one distance apart from a string t if you can: Insert exactly one character into s to get t. Delete exactly one character from s to get t. Replace exactly one character of s with a differen...
isOneEditDistance(s: str, t: str) -> bool
pub fn is_one_edit_distance(s: &[u8], t: &[u8]) -> bool
Aegis.IsOneEditDistance.is_one_edit_distance
pub fn is_one_edit_distance(s: &[u8], t: &[u8]) -> bool { let n = s.len(); let m = t.len(); let mut diff: usize = 0; if n > m { diff = n - m; } else { diff = m - n; } if diff > 1 { return false; } let mut i: usize = 0; let mut j: usize = 0; let mut e...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [is_one_edit_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 ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [is_one_edit_distance]: function definitions module public import Aeneas public import Aegis.IsOneEditDistance.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand fals...
import Aegis.IsOneEditDistance.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 aeg...
[ { "input": "[\"123\", \"1234\"]", "output": "true" }, { "input": "[\"abc\", \"abcd\"]", "output": "true" }, { "input": "[\"ab\", \"acb\"]", "output": "true" }, { "input": "[\"abcd\", \"abde\"]", "output": "false" }, { "input": "[\"cat\", \"dog\"]", "output": "...
175
false
175
verified
10
10
2
5,616
[ { "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.IsOneEditDistance.Code.Funs /-! # Specifications of `Aegis.IsOneEditDistance.is_one_edit_distance` LeetCode problem `one-edit-distance`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.IsOneEditDistance def IsAlnumByte (b : Std.U8) ...
6
find-peak-element
162
Medium
[ "Array", "Binary Search" ]
A peak element is an element that is strictly greater than its neighbors. Given a 0-indexed integer array nums, find a peak element, and return its index. If the array contains multiple peaks, return the index to any of the peaks. You may imagine that nums[-1] = nums[n] = -∞. In other words, an element is always consid...
findPeakElement(nums: list_int) -> int
pub fn find_peak_element(nums: &[i64]) -> i64
Aegis.FindPeakElement.find_peak_element
pub fn find_peak_element(nums: &[i64]) -> i64 { let n = nums.len(); if n == 0 { return 0; } let mut lo: usize = 0; let mut hi: usize = n - 1; while lo < hi { let mid: usize = lo + (hi - lo) / 2; if nums[mid] < nums[mid + 1] { lo = mid + 1; } else { ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [find_peak_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 lin...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [find_peak_element]: function definitions module public import Aeneas public import Aegis.FindPeakElement.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.FindPeakElement.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 aegis...
[ { "input": "[[1]]", "output": "0" }, { "input": "[[2, 1]]", "output": "0" }, { "input": "[[1, 2]]", "output": "1" }, { "input": "[[1, 3, 2]]", "output": "1" }, { "input": "[[1, 2, 3, 1]]", "output": "2" }, { "input": "[[1, 3, 2, 1]]", "output": "1"...
92
false
92
verified
10
10
1
764
[ { "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.FindPeakElement.Code.Funs /-! # Specifications of `Aegis.FindPeakElement.find_peak_element` LeetCode problem `find-peak-element`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.FindPeakElement def vals (nums : Slice Std.I64) : List...
11
missing-ranges
163
Easy
[ "Array" ]
You are given an inclusive range [lower, upper] and a sorted unique integer array nums, where all elements are within the inclusive range. A number x is considered missing if x is in the range [lower, upper] and x is not in nums. Return the shortest sorted list of ranges that exactly covers all the missing numbers. Tha...
findMissingRanges(nums: list_int, lower: int, upper: int) -> list_list_int
pub fn find_missing_ranges(nums: &[i64], lower: i64, upper: i64) -> Vec<Vec<i64>>
Aegis.FindMissingRanges.find_missing_ranges
#[allow(unused_macros)] macro_rules! vec { () => { ::std::vec::Vec::<::std::vec::Vec<i64>>::new() }; ($($item:expr),+ $(,)?) => {{ let mut v = ::std::vec::Vec::new(); $( v.push($item); )+ v }}; } pub fn find_missing_ranges(nums: &[i64], lower: i64, up...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [find_missing_ranges]: 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_missing_ranges]: function definitions module public import Aeneas public import Aegis.FindMissingRanges.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false...
import Aegis.FindMissingRanges.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.FindMissingRanges.find_missing_ranges (Slice.from [(-1)#i64] (by scalar_tac) : Slice Std.I64) (-1)#i64 (-1)#i64) ((alloc.vec.Vec.from [] (by sc...
[ { "input": "[[-1], -1, -1]", "output": "[]" }, { "input": "[[10], 10, 10]", "output": "[]" }, { "input": "[[], 1, 1]", "output": "[[1, 1]]" }, { "input": "[[], -3, 3]", "output": "[[-3, 3]]" }, { "input": "[[], -1000, 1000]", "output": "[[-1000, 1000]]" }, ...
127
false
127
verified
10
10
4
70,750
[ { "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.FindMissingRanges.Code.Funs /-! # Specifications of `Aegis.FindMissingRanges.find_missing_ranges` LeetCode problem `missing-ranges`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.FindMissingRanges def sliceVals (nums : Slice Std.I64) ...
16
compare-version-numbers
165
Medium
[ "Two Pointers", "String" ]
Given two version strings, version1 and version2, compare them. A version string consists of revisions separated by dots '.'. The value of the revision is its integer conversion ignoring leading zeros. To compare version strings, compare their revision values in left-to-right order. If one of the version strings has fe...
compareVersion(version1: str, version2: str) -> int
pub fn compare_version(version1: &[u8], version2: &[u8]) -> i64
Aegis.CompareVersion.compare_version
pub fn compare_version(version1: &[u8], version2: &[u8]) -> i64 { let n1: usize = version1.len(); let n2: usize = version2.len(); let mut i: usize = 0; let mut j: usize = 0; while i < n1 || j < n2 { let mut v1: i64 = 0; while i < n1 && version1[i] != b'.' { let d1: i64 ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [compare_version]: 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 -- [compare_version]: function definitions module public import Aeneas public import Aegis.CompareVersion.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.CompareVersion.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 aegisC...
[ { "input": "[\"0\", \"0.0.0\"]", "output": "0" }, { "input": "[\"1.1.1.1\", \"1.1.1.1\"]", "output": "0" }, { "input": "[\"1.2.3.4\", \"1.2.3\"]", "output": "1" }, { "input": "[\"1.1.1.1\", \"1.1.1\"]", "output": "1" }, { "input": "[\"1.0.0\", \"1\"]", "output...
119
false
119
verified
10
10
1
1,652
[ { "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.CompareVersion.Code.Funs /-! # Specifications of `Aegis.CompareVersion.compare_version` LeetCode problem `compare-version-numbers`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.CompareVersion def bytes (s : Slice U8) : List Nat :...
5
majority-element
169
Easy
[ "Array", "Hash Table", "Divide and Conquer", "Counting", "Sorting" ]
Given an array nums of size n, return the majority element. The majority element is the element that appears more than ⌊n / 2⌋ times. You may assume that the majority element always exists in the array.   Example 1: Input: nums = [3,2,3] Output: 3 Example 2: Input: nums = [2,2,1,1,1,2,2] Output: 2   Constraints: n ==...
majorityElement(nums: list_int) -> int
pub fn majority_element(nums: &[i64]) -> i64
Aegis.MajorityElement.majority_element
pub fn majority_element(nums: &[i64]) -> i64 { let mut candidate: i64 = 0; let mut count: i64 = 0; let n = nums.len(); let mut i: usize = 0; while i < n { if count == 0 { candidate = nums[i]; count = 1; } else if nums[i] == candidate { count = cou...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [majority_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 lint...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [majority_element]: function definitions module public import Aeneas public import Aegis.MajorityElement.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.MajorityElement.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 aegis...
[ { "input": "[[3, 2, 3]]", "output": "3" }, { "input": "[[1000000000, -1000000000, 1000000000, 1000000000, 1000000000]]", "output": "1000000000" }, { "input": "[[1, 1, 2, 2, 2, 2, 2]]", "output": "2" }, { "input": "[[1, 1, 1, 1, 2, 2, 3]]", "output": "1" }, { "inpu...
45
false
45
verified
10
10
1
406
[ { "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.MajorityElement.Code.Funs /-! # Specifications of `Aegis.MajorityElement.majority_element` LeetCode problem `majority-element`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.MajorityElement def freq (l : List Std.I64) (v : Std.I64) : ...
2
excel-sheet-column-number
171
Easy
[ "Math", "String" ]
Given a string columnTitle that represents the column title as appears in an Excel sheet, return its corresponding column number. For example: A -> 1 B -> 2 C -> 3 ... Z -> 26 AA -> 27 AB -> 28 ...   Example 1: Input: columnTitle = "A" Output: 1 Example 2: Input: columnTitle = "AB" Output: 28 Example 3: Input: ...
titleToNumber(columnTitle: str) -> int
pub fn title_to_number(columnTitle: &[u8]) -> i64
Aegis.TitleToNumber.title_to_number
pub fn title_to_number(columnTitle: &[u8]) -> i64 { let mut result: i64 = 0; let mut i: usize = 0; while i < columnTitle.len() { let c: u8 = columnTitle[i]; let digit: i64 = (c as i64) - 64; // 'A' = 65, so 'A' -> 1 result = result * 26 + digit; i = i + 1; } result ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [title_to_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 -- [title_to_number]: function definitions module public import Aeneas public import Aegis.TitleToNumber.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.TitleToNumber.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 aegisCa...
[ { "input": "[\"MAD\"]", "output": "8818" }, { "input": "[\"AAA\"]", "output": "703" }, { "input": "[\"ZY\"]", "output": "701" }, { "input": "[\"AC\"]", "output": "29" }, { "input": "[\"Z\"]", "output": "26" }, { "input": "[\"ZYZ\"]", "output": "182...
200
false
200
verified
10
10
1
557
[ { "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.TitleToNumber.Code.Funs /-! # Specifications of `Aegis.TitleToNumber.title_to_number` LeetCode problem `excel-sheet-column-number`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.TitleToNumber def byteAt (s : Slice Std.U8) (i : Nat...
10
factorial-trailing-zeroes
172
Medium
[ "Math" ]
Given an integer n, return the number of trailing zeroes in n!. Note that n! = n * (n - 1) * (n - 2) * ... * 3 * 2 * 1.   Example 1: Input: n = 3 Output: 0 Explanation: 3! = 6, no trailing zero. Example 2: Input: n = 5 Output: 1 Explanation: 5! = 120, one trailing zero. Example 3: Input: n = 0 Output: 0   Constra...
trailingZeroes(n: int) -> int
pub fn trailing_zeroes(n: i64) -> i64
Aegis.TrailingZeroes.trailing_zeroes
pub fn trailing_zeroes(n: i64) -> i64 { let mut count: i64 = 0; let mut m: i64 = n; while m > 0 { m = m / 5; count = count + m; } count }
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [trailing_zeroes]: 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 -- [trailing_zeroes]: function definitions module public import Aeneas public import Aegis.TrailingZeroes.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.TrailingZeroes.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 aegisC...
[ { "input": "[0]", "output": "0" }, { "input": "[3]", "output": "0" }, { "input": "[10000]", "output": "2499" }, { "input": "[25]", "output": "6" }, { "input": "[100]", "output": "24" }, { "input": "[1000]", "output": "249" }, { "input": "[1...
71
false
71
verified
10
10
1
215
[ { "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.TrailingZeroes.Code.Funs /-! # Specifications of `Aegis.TrailingZeroes.trailing_zeroes` LeetCode problem `factorial-trailing-zeroes`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.TrailingZeroes def legendreSum5 (n : Nat) : Nat := (Fi...
12
dungeon-game
174
Hard
[ "Array", "Dynamic Programming", "Matrix" ]
The demons had captured the princess and imprisoned her in the bottom-right corner of a dungeon. The dungeon consists of m x n rooms laid out in a 2D grid. Our valiant knight was initially positioned in the top-left room and must fight his way through dungeon to rescue the princess. The knight has an initial health poi...
calculateMinimumHP(dungeon: list_list_int) -> int
pub fn calculate_minimum_hp(dungeon: &[Vec<i64>]) -> i64
Aegis.CalculateMinimumHp.calculate_minimum_hp
pub fn calculate_minimum_hp(dungeon: &[Vec<i64>]) -> i64 { let m = dungeon.len(); if m == 0 { return 1; } let n = dungeon[0].len(); if n == 0 { return 1; } let inf: i64 = 1000000000000; let mut dp: Vec<i64> = Vec::new(); let mut k: usize = 0; while k <= n { ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [calculate_minimum_hp]: 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 -- [calculate_minimum_hp]: function definitions module public import Aeneas public import Aegis.CalculateMinimumHp.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand fal...
import Aegis.CalculateMinimumHp.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 ae...
[ { "input": "[[[0]]]", "output": "1" }, { "input": "[[[-2, -1], [-1, 10]]]", "output": "4" }, { "input": "[[[1, -3, 3], [0, -2, 0], [-3, -3, -3]]]", "output": "3" }, { "input": "[[[-5, -4, -6], [-6, -5, -8], [3, 3, 1]]]", "output": "12" }, { "input": "[[[-2, -3, 3]...
98
false
98
verified
10
10
1
4,314
[ { "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.CalculateMinimumHp.Code.Funs /-! # Specifications of `Aegis.CalculateMinimumHp.calculate_minimum_hp` LeetCode problem `dungeon-game`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.CalculateMinimumHp (calculate_minimum_hp) namespace AegisSpec.Ca...
10
repeated-dna-sequences
187
Medium
[ "Bit Manipulation", "Hash Table", "String", "Sliding Window", "Hash Function", "Rolling Hash" ]
The DNA sequence is composed of a series of nucleotides abbreviated as 'A', 'C', 'G', and 'T'. For example, "ACGAATTCCG" is a DNA sequence. When studying DNA, it is useful to identify repeated sequences within the DNA. Given a string s that represents a DNA sequence, return all the 10-letter-long sequences (substring...
findRepeatedDnaSequences(s: str) -> list_str
pub fn find_repeated_dna_sequences(s: &[u8]) -> Vec<Vec<u8>>
Aegis.FindRepeatedDnaSequences.find_repeated_dna_sequences
fn dna_val(c: u8) -> i64 { if c == b'A' { 0 } else if c == b'C' { 1 } else if c == b'G' { 2 } else { 3 } } pub fn find_repeated_dna_sequences(s: &[u8]) -> Vec<Vec<u8>> { let mut out: Vec<Vec<u8>> = Vec::new(); let n: usize = s.len(); if n < 10 { r...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [find_repeated_dna_sequences]: 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_...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [find_repeated_dna_sequences]: function definitions module public import Aeneas public import Aegis.FindRepeatedDnaSequences.Code.Types public import Aegis.FindRepeatedDnaSequences.Code.FunsExternal @[expose] public section open Aeneas Aeneas.Std Result ControlFlow ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [find_repeated_dna_sequences]: external functions. -- This is a template file: rename it to "FunsExternal.lean" and fill the holes. module public import Aeneas public import Aegis.FindRepeatedDnaSequences.Code.Types @[expose] public section open Aeneas Aeneas.Std Re...
import Aegis.FindRepeatedDnaSequences.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}" #e...
[ { "input": "[\"TTTTTTTTTTAAAAAAAAAA\"]", "output": "[]" }, { "input": "[\"GAAAAAAAAATTTTTTTTTTAAAAAAAAAA\"]", "output": "[]" }, { "input": "[\"AAAAAAAAAAAAA\"]", "output": "[\"AAAAAAAAAA\"]" }, { "input": "[\"AAAAAAAAAATTTTTTTTTTAAAAAAAAAA\"]", "output": "[\"AAAAAAAAAA\"]...
137
true
137
verified
10
10
4
92,349
[ { "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.FindRepeatedDnaSequences.Code.Funs /-! # Specifications of `Aegis.FindRepeatedDnaSequences.find_repeated_dna_sequences` LeetCode problem `repeated-dna-sequences`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.FindRepeatedDnaSequences ...
2
best-time-to-buy-and-sell-stock-iv
188
Hard
[ "Array", "Dynamic Programming" ]
You are given an integer array prices where prices[i] is the price of a given stock on the ith day, and an integer k. Find the maximum profit you can achieve. You may complete at most k transactions: i.e. you may buy at most k times and sell at most k times. Note: You may not engage in multiple transactions simultaneou...
maxProfit(k: int, prices: list_int) -> int
pub fn max_profit(k: i64, prices: &[i64]) -> i64
Aegis.MaxProfit.max_profit
pub fn max_profit(k: i64, prices: &[i64]) -> i64 { if k <= 0 { return 0; } let n = prices.len(); if n < 2 { return 0; } let kk = k as usize; let mut buy: Vec<i64> = Vec::new(); let mut sell: Vec<i64> = Vec::new(); let mut i = 0usize; while i <= kk { buy...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [max_profit]: 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 -- [max_profit]: function definitions module public import Aeneas public import Aegis.MaxProfit.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.MaxProfit.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 aegisCase "...
[ { "input": "[1, [1]]", "output": "0" }, { "input": "[2, [2, 4, 1]]", "output": "2" }, { "input": "[5, [1, 2, 3, 4, 5]]", "output": "4" }, { "input": "[1, [3, 3, 3, 3, 3]]", "output": "0" }, { "input": "[1, [7, 6, 4, 3, 1]]", "output": "0" }, { "input":...
97
false
97
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.MaxProfit.Code.Funs /-! # Specifications of `Aegis.MaxProfit.max_profit` LeetCode problem `best-time-to-buy-and-sell-stock-iv`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.MaxProfit def pricesOf (prices : Slice Std.I64) : List I...
13
reverse-bits
190
Easy
[ "Bit Manipulation", "Divide and Conquer" ]
Reverse bits of a given 32 bits unsigned integer. Note: Note that in some languages, such as Java, there is no unsigned integer type. In this case, both input and output will be given as a signed integer type. They should not affect your implementation, as the integer's internal binary representation is the same, whet...
reverseBits(n: int) -> int
pub fn reverse_bits(n: i64) -> i64
Aegis.ReverseBits.reverse_bits
pub fn reverse_bits(n: i64) -> i64 { let mut x: i64 = n & 0xFFFFFFFF; let mut result: i64 = 0; let mut i: usize = 0; while i < 32 { result = (result << 1) | (x & 1); x = x >> 1; i += 1; } result }
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [reverse_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 linter.s...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [reverse_bits]: function definitions module public import Aeneas public import Aegis.ReverseBits.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.ReverseBits.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 aegisCase...
[ { "input": "[0]", "output": "0" }, { "input": "[0]", "output": "0" }, { "input": "[2147483648]", "output": "1" }, { "input": "[43261596]", "output": "964176192" }, { "input": "[4294967293]", "output": "3221225471" }, { "input": "[1]", "output": "21...
6
false
6
verified
6
6
1
603
[ { "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.ReverseBits.Code.Funs /-! # Specifications of `Aegis.ReverseBits.reverse_bits` LeetCode problem `reverse-bits`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.ReverseBits def bitAt (x : ℤ) (i : ℕ) : ℤ := (x / (2 : ℤ) ^ i) % 2 ...
8
number-of-1-bits
191
Easy
[ "Bit Manipulation", "Divide and Conquer" ]
Given a positive integer n, write a function that returns the number of set bits in its binary representation (also known as the Hamming weight).   Example 1: Input: n = 11 Output: 3 Explanation: The input binary string 1011 has a total of three set bits. Example 2: Input: n = 128 Output: 1 Explanation: The input bi...
hammingWeight(n: int) -> int
pub fn hamming_weight(n: i64) -> i64
Aegis.HammingWeight.hamming_weight
pub fn hamming_weight(n: i64) -> i64 { let mut x = n; let mut count = 0i64; while x > 0 { count += x % 2; x = x / 2; } count }
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [hamming_weight]: 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 -- [hamming_weight]: function definitions module public import Aeneas public import Aegis.HammingWeight.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.HammingWeight.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 aegisCa...
[ { "input": "[0]", "output": "0" }, { "input": "[4095]", "output": "12" }, { "input": "[11]", "output": "3" }, { "input": "[15]", "output": "4" }, { "input": "[2147483647]", "output": "31" }, { "input": "[32]", "output": "1" }, { "input": "[...
139
false
139
verified
10
10
1
524
[ { "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.HammingWeight.Code.Funs /-! # Specifications of `Aegis.HammingWeight.hamming_weight` LeetCode problem `number-of-1-bits`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.HammingWeight def setBits31 (N : Int) : Nat := ((Finset.ra...
13
house-robber
198
Medium
[ "Array", "Dynamic Programming" ]
You are a professional robber planning to rob houses along a street. Each house has a certain amount of money stashed, the only constraint stopping you from robbing each of them is that adjacent houses have security systems connected and it will automatically contact the police if two adjacent houses were broken into o...
rob(nums: list_int) -> int
pub fn rob(nums: &[i64]) -> i64
Aegis.Rob.rob
fn rob_helper(nums: &[i64], i: usize, prev2: i64, prev1: i64) -> i64 { if i >= nums.len() { return prev1; } let take: i64 = prev2 + nums[i]; let mut cur: i64 = prev1; if take > cur { cur = take; } rob_helper(nums, i + 1, prev1, cur) } pub fn rob(nums: &[i64]) -> i64 { ro...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [rob]: 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.whit...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [rob]: function definitions module public import Aeneas public import Aegis.Rob.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.unusedVaria...
import Aegis.Rob.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 aegisCase "eval/R...
[ { "input": "[[1]]", "output": "1" }, { "input": "[[0]]", "output": "0" }, { "input": "[[1, 2]]", "output": "2" }, { "input": "[[1, 2, 3, 1]]", "output": "4" }, { "input": "[[2, 1, 1, 2]]", "output": "4" }, { "input": "[[5, 10, 5, 10]]", "output": "...
117
false
117
verified
10
10
4
20,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.Rob.Code.Funs /-! # Specifications of `Aegis.Rob.rob` LeetCode problem `house-robber`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.Rob def vals (nums : Slice I64) : List ℤ := nums.val.map (fun x => x.val) def size (nums : Slice I64...
13
binary-tree-right-side-view
199
Medium
[ "Tree", "Depth-First Search", "Breadth-First Search", "Binary Tree" ]
Given the root of a binary tree, imagine yourself standing on the right side of it, return the values of the nodes you can see ordered from top to bottom.   Example 1: Input: root = [1,2,3,null,5,null,4] Output: [1,3,4] Explanation: Example 2: Input: root = [1,2,3,4,null,null,null,5] Output: [1,3,4,5] Explanation: ...
rightSideView(root: tree) -> list_int
pub fn right_side_view(root: &Tree) -> Vec<i64>
Aegis.RightSideView.right_side_view
fn collect_right(t: &Tree, depth: usize, out: &mut Vec<i64>) { match t { Tree::Null => {} Tree::Node(value, left, right) => { if depth == out.len() { out.push(*value); } collect_right(&**right, depth + 1, out); collect_right(&**left, de...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [right_side_view]: 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 -- [right_side_view]: function definitions module public import Aeneas public import Aegis.RightSideView.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.RightSideView.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 aegisCa...
[ { "input": "[[]]", "output": "[]" }, { "input": "[[1, 2, 3, 4, 5, 6, 7]]", "output": "[1, 3, 7]" }, { "input": "[[100, -50, 50, -75, -25, 25, 75, -100, 0, 0, 100]]", "output": "[100, 50, 75, 100]" }, { "input": "[[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]]", "out...
6
false
6
verified
6
6
1
2,013
[ { "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.RightSideView.Code.Funs /-! # Specifications of `Aegis.RightSideView.right_side_view` LeetCode problem `binary-tree-right-side-view`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.RightSideView open Aegis.RightSideView def valu...
12
bitwise-and-of-numbers-range
201
Medium
[ "Bit Manipulation" ]
Given two integers left and right that represent the range [left, right], return the bitwise AND of all numbers in this range, inclusive.   Example 1: Input: left = 5, right = 7 Output: 4 Example 2: Input: left = 0, right = 0 Output: 0 Example 3: Input: left = 1, right = 2147483647 Output: 0   Constraints: 0 <= ...
rangeBitwiseAnd(left: int, right: int) -> int
pub fn range_bitwise_and(left: i64, right: i64) -> i64
Aegis.RangeBitwiseAnd.range_bitwise_and
pub fn range_bitwise_and(left: i64, right: i64) -> i64 { let mut l = left; let mut r = right; let mut shift: i64 = 0; while l < r { l = l >> 1; r = r >> 1; shift = shift + 1; } l << shift }
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [range_bitwise_and]: 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 -- [range_bitwise_and]: function definitions module public import Aeneas public import Aegis.RangeBitwiseAnd.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.RangeBitwiseAnd.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 aegis...
[ { "input": "[5, 7]", "output": "4" }, { "input": "[100, 105]", "output": "96" }, { "input": "[16, 31]", "output": "16" }, { "input": "[123456, 654321]", "output": "0" }, { "input": "[8, 12]", "output": "8" }, { "input": "[0, 0]", "output": "0" },...
97
false
97
verified
10
10
1
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.RangeBitwiseAnd.Code.Funs import Mathlib.Data.Int.Bitwise /-! # Specifications of `Aegis.RangeBitwiseAnd.range_bitwise_and` LeetCode problem `bitwise-and-of-numbers-range`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.RangeBitwiseAnd ...
11
happy-number
202
Easy
[ "Hash Table", "Math", "Two Pointers" ]
Write an algorithm to determine if a number n is happy. A happy number is a number defined by the following process: Starting with any positive integer, replace the number by the sum of the squares of its digits. Repeat the process until the number equals 1 (where it will stay), or it loops endlessly in a cycle which ...
isHappy(n: int) -> bool
pub fn is_happy(n: i64) -> bool
Aegis.IsHappy.is_happy
pub fn is_happy(n: i64) -> bool { let mut slow = n; let mut fast = digit_square_sum(n); while fast != 1 && slow != fast { slow = digit_square_sum(slow); fast = digit_square_sum(digit_square_sum(fast)); } fast == 1 } fn digit_square_sum(mut x: i64) -> i64 { let mut sum: i64 = 0...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [is_happy]: 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_happy]: function definitions module public import Aeneas public import Aegis.IsHappy.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.IsHappy.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 aegisCase "ev...
[ { "input": "[100]", "output": "true" }, { "input": "[4]", "output": "false" }, { "input": "[20]", "output": "false" }, { "input": "[2]", "output": "false" }, { "input": "[1111111]", "output": "true" }, { "input": "[19]", "output": "true" }, { ...
55
false
55
verified
10
10
1
831
[ { "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.IsHappy.Code.Funs /-! # Specifications of `Aegis.IsHappy.is_happy` LeetCode problem `happy-number`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.IsHappy def decimalDigits (m : Nat) : List Nat := if h : m = 0 then [] else m % 10 :: ...
8
remove-linked-list-elements
203
Easy
[ "Recursion", "Linked List" ]
Given the head of a linked list and an integer val, remove all the nodes of the linked list that has Node.val == val, and return the new head.   Example 1: Input: head = [1,2,6,3,4,5,6], val = 6 Output: [1,2,3,4,5] Example 2: Input: head = [], val = 1 Output: [] Example 3: Input: head = [7,7,7,7], val = 7 Output:...
removeElements(head: linkedlist, val: int) -> linkedlist
pub fn remove_elements(head: &List, val: i64) -> List
Aegis.RemoveElements.remove_elements
pub fn remove_elements(head: &List, val: i64) -> List { match head { List::Nil => List::Nil, List::Cons(v, next) => { let rest = remove_elements(&**next, val); if *v == val { rest } else { List::Cons(*v, Box::new(rest)) ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [remove_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 linte...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [remove_elements]: function definitions module public import Aeneas public import Aegis.RemoveElements.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.RemoveElements.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}" deriving ins...
[ { "input": "[[1, 1, 1, 2, 3], 1]", "output": "[2, 3]" }, { "input": "[[50, 20, 30, 20, 10], 20]", "output": "[50, 30, 10]" }, { "input": "[[10, 20, 30, 40, 50], 10]", "output": "[20, 30, 40, 50]" }, { "input": "[[50, 40, 30, 20, 10], 50]", "output": "[40, 30, 20, 10]" }...
104
false
104
verified
10
10
1
5,818
[ { "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.RemoveElements.Code.Funs /-! # Specifications of `Aegis.RemoveElements.remove_elements` LeetCode problem `remove-linked-list-elements`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.RemoveElements open Aegis.RemoveElements def elems ...
11
reverse-linked-list
206
Easy
[ "Recursion", "Linked List" ]
Given the head of a singly linked list, reverse the list, and return the reversed list.   Example 1: Input: head = [1,2,3,4,5] Output: [5,4,3,2,1] Example 2: Input: head = [1,2] Output: [2,1] Example 3: Input: head = [] Output: []   Constraints: The number of nodes in the list is the range [0, 5000]. -5000 <= ...
reverseList(head: linkedlist) -> linkedlist
pub fn reverse_list(head: &List) -> List
Aegis.ReverseList.reverse_list
fn reverse_acc(l: &List, acc: List) -> List { match l { List::Nil => acc, List::Cons(v, next) => reverse_acc(&**next, List::Cons(*v, Box::new(acc))), } } pub fn reverse_list(head: &List) -> List { reverse_acc(head, List::Nil) }
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [reverse_list]: 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 -- [reverse_list]: function definitions module public import Aeneas public import Aegis.ReverseList.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.ReverseList.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}" deriving instan...
[ { "input": "[[1]]", "output": "[1]" }, { "input": "[[3]]", "output": "[3]" }, { "input": "[[-5000]]", "output": "[-5000]" }, { "input": "[[0]]", "output": "[0]" }, { "input": "[[5000]]", "output": "[5000]" }, { "input": "[[-1]]", "output": "[-1]" ...
98
false
98
verified
10
10
1
2,065
[ { "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.ReverseList.Code.Funs /-! # Specifications of `Aegis.ReverseList.reverse_list` LeetCode problem `reverse-linked-list`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.ReverseList abbrev RustList : Type := Aegis.ReverseList.List def nod...
2
course-schedule
207
Medium
[ "Depth-First Search", "Breadth-First Search", "Graph", "Topological Sort" ]
There are a total of numCourses courses you have to take, labeled from 0 to numCourses - 1. You are given an array prerequisites where prerequisites[i] = [ai, bi] indicates that you must take course bi first if you want to take course ai. For example, the pair [0, 1], indicates that to take course 0 you have to first ...
canFinish(numCourses: int, prerequisites: list_list_int) -> bool
pub fn can_finish(numCourses: i64, prerequisites: &[Vec<i64>]) -> bool
Aegis.CanFinish.can_finish
pub fn can_finish(numCourses: i64, prerequisites: &[Vec<i64>]) -> bool { let n: usize = numCourses as usize; let mut adj: Vec<Vec<i64>> = Vec::new(); let mut indegree: Vec<i64> = Vec::new(); let mut i: usize = 0; while i < n { let row: Vec<i64> = Vec::new(); adj.push(row); ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [can_finish]: 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 -- [can_finish]: function definitions module public import Aeneas public import Aegis.CanFinish.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.CanFinish.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 aegisCase "...
[ { "input": "[1, []]", "output": "true" }, { "input": "[2, [[1, 0]]]", "output": "true" }, { "input": "[2, [[1, 0], [0, 1]]]", "output": "false" }, { "input": "[3, [[1, 0], [2, 1]]]", "output": "true" }, { "input": "[5, [[1, 4], [2, 4], [3, 1], [3, 2]]]", "outp...
79
false
79
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.CanFinish.Code.Funs /-! # Specifications of `Aegis.CanFinish.can_finish` LeetCode problem `course-schedule`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.CanFinish namespace AegisSpec.CanFinish def pairsOf (prerequisites : Slice (alloc....
11
minimum-size-subarray-sum
209
Medium
[ "Array", "Binary Search", "Prefix Sum", "Sliding Window" ]
Given an array of positive integers nums and a positive integer target, return the minimal length of a subarray whose sum is greater than or equal to target. If there is no such subarray, return 0 instead.   Example 1: Input: target = 7, nums = [2,3,1,2,4,3] Output: 2 Explanation: The subarray [4,3] has the minimal le...
minSubArrayLen(target: int, nums: list_int) -> int
pub fn min_sub_array_len(target: i64, nums: &[i64]) -> i64
Aegis.MinSubArrayLen.min_sub_array_len
pub fn min_sub_array_len(target: i64, nums: &[i64]) -> i64 { let n = nums.len(); let mut left: usize = 0; let mut sum: i64 = 0; let mut best: i64 = 0; let mut cur_len: i64 = 0; for right in 0..n { sum += nums[right]; cur_len += 1; while sum >= target { if be...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [min_sub_array_len]: 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 -- [min_sub_array_len]: function definitions module public import Aeneas public import Aegis.MinSubArrayLen.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.MinSubArrayLen.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 aegisC...
[ { "input": "[4, [1, 4, 4]]", "output": "1" }, { "input": "[3, [1, 1, 1]]", "output": "3" }, { "input": "[1000, [250, 250, 250, 250]]", "output": "4" }, { "input": "[8, [1, 2, 3, 4, 5]]", "output": "2" }, { "input": "[9, [4, 3, 3, 2, 1]]", "output": "3" }, ...
73
false
73
verified
10
10
1
853
[ { "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.MinSubArrayLen.Code.Funs /-! # Specifications of `Aegis.MinSubArrayLen.min_sub_array_len` LeetCode problem `minimum-size-subarray-sum`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.MinSubArrayLen def contents (nums : Slice I64) : Lis...
10
course-schedule-ii
210
Medium
[ "Depth-First Search", "Breadth-First Search", "Graph", "Topological Sort" ]
There are a total of numCourses courses you have to take, labeled from 0 to numCourses - 1. You are given an array prerequisites where prerequisites[i] = [ai, bi] indicates that you must take course bi first if you want to take course ai. For example, the pair [0, 1], indicates that to take course 0 you have to first ...
findOrder(numCourses: int, prerequisites: list_list_int) -> list_int
pub fn find_order(numCourses: i64, prerequisites: &[Vec<i64>]) -> Vec<i64>
Aegis.FindOrder.find_order
pub fn find_order(numCourses: i64, prerequisites: &[Vec<i64>]) -> Vec<i64> { let n = numCourses as usize; let mut adj: Vec<Vec<i64>> = Vec::new(); let mut indeg: Vec<i64> = Vec::new(); let mut i: usize = 0; while i < n { adj.push(Vec::new()); indeg.push(0); i += 1; } ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [find_order]: 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_order]: function definitions module public import Aeneas public import Aegis.FindOrder.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.FindOrder.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 aegisCase "...
[ { "input": "[1, []]", "output": "[0]" }, { "input": "[3, [[1, 0], [0, 1]]]", "output": "[]" }, { "input": "[2, [[1, 0]]]", "output": "[0, 1]" }, { "input": "[3, [[0, 1], [1, 2], [2, 0]]]", "output": "[]" }, { "input": "[3, [[1, 0], [1, 2], [0, 1]]]", "output":...
91
false
91
verified
10
10
1
13,113
[ { "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.FindOrder.Code.Funs /-! # Specifications of `Aegis.FindOrder.find_order` LeetCode problem `course-schedule-ii`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.FindOrder def contents (v : alloc.vec.Vec Std.I64) : List Int := v.val.map (...
13
house-robber-ii
213
Medium
[ "Array", "Dynamic Programming" ]
You are a professional robber planning to rob houses along a street. Each house has a certain amount of money stashed. All houses at this place are arranged in a circle. That means the first house is the neighbor of the last one. Meanwhile, adjacent houses have a security system connected, and it will automatically con...
rob(nums: list_int) -> int
pub fn rob(nums: &[i64]) -> i64
Aegis.Rob.rob
pub fn rob(nums: &[i64]) -> i64 { let n: usize = nums.len(); if n == 0 { return 0; } if n == 1 { return nums[0]; } // We solve the linear "house robber" problem twice: // Case A: only houses with indices 0 .. n-2 are usable (last house excluded) // Case B: only hous...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [rob]: 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.whit...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [rob]: function definitions module public import Aeneas public import Aegis.Rob.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.unusedVaria...
import Aegis.Rob.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.Rob.rob (Slice.from [1000#i64] (by scalar_tac) : Slice Std.I64)) (1000#i64))}") #eval (s!"CASE 1 {(Result.reducesTo (Aegis.Rob.rob (Slice.from [0#i64] (by sc...
[ { "input": "[[1000]]", "output": "1000" }, { "input": "[[0]]", "output": "0" }, { "input": "[[1, 2]]", "output": "2" }, { "input": "[[2, 3, 2]]", "output": "3" }, { "input": "[[1, 2, 3]]", "output": "3" }, { "input": "[[1, 2, 3, 1]]", "output": "4"...
122
false
122
verified
10
10
4
68,211
[ { "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.Rob.Code.Funs /-! # Specifications of `Aegis.Rob.rob` LeetCode problem `house-robber-ii`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.Rob namespace AegisSpec.Rob def valAt (nums : Slice Std.I64) (i : Int) : Int := match nums.val[i.toNat]? ...
13
kth-largest-element-in-an-array
215
Medium
[ "Array", "Divide and Conquer", "Quickselect", "Sorting", "Heap (Priority Queue)" ]
Given an integer array nums and an integer k, return the kth largest element in the array. Note that it is the kth largest element in the sorted order, not the kth distinct element. Can you solve it without sorting?   Example 1: Input: nums = [3,2,1,5,6,4], k = 2 Output: 5 Example 2: Input: nums = [3,2,3,1,2,4,5,5,6], ...
findKthLargest(nums: list_int, k: int) -> int
pub fn find_kth_largest(nums: &[i64], k: i64) -> i64
Aegis.FindKthLargest.find_kth_largest
pub fn find_kth_largest(nums: &[i64], k: i64) -> i64 { let n: usize = nums.len(); if n == 0 { return 0; } let mut v: Vec<i64> = Vec::new(); let mut idx: usize = 0; while idx < n { v.push(nums[idx]); idx += 1; } let target: usize = n - (k as usize); let mut l...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [find_kth_largest]: 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_kth_largest]: function definitions module public import Aeneas public import Aegis.FindKthLargest.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.FindKthLargest.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 aegisC...
[ { "input": "[[1], 1]", "output": "1" }, { "input": "[[10000, -10000, 0], 2]", "output": "0" }, { "input": "[[-1, -2, -3, -4, -5], 2]", "output": "-2" }, { "input": "[[3, 2, 1, 5, 6, 4], 2]", "output": "5" }, { "input": "[[7, 6, 5, 4, 3, 2, 1], 5]", "output": "...
78
false
78
verified
10
10
2
11,248
[ { "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.FindKthLargest.Code.Funs /-! # Specifications of `Aegis.FindKthLargest.find_kth_largest` LeetCode problem `kth-largest-element-in-an-array`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.FindKthLargest namespace AegisSpec.FindKthLargest def co...
11
combination-sum-iii
216
Medium
[ "Array", "Backtracking" ]
Find all valid combinations of k numbers that sum up to n such that the following conditions are true: Only numbers 1 through 9 are used. Each number is used at most once. Return a list of all possible valid combinations. The list must not contain the same combination twice, and the combinations may be returned in an...
combinationSum3(k: int, n: int) -> list_list_int
pub fn combination_sum3(k: i64, n: i64) -> Vec<Vec<i64>>
Aegis.CombinationSum3.combination_sum3
// The harness-generated tests use the literal `vec![]` for the empty expected // result while comparing against `Vec<Vec<i64>>`. With nested vectors that // literal is otherwise ambiguous (`Vec<i64>: PartialEq<?E>` has several std // impls), producing `E0282: type annotations needed`. Providing a local // `vec!` mac...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [combination_sum3]: 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 -- [combination_sum3]: function definitions module public import Aeneas public import Aegis.CombinationSum3.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.CombinationSum3.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.CombinationSum3.combination_sum3 7#i64 56#i64) ((alloc.vec.Vec.from [] (by scalar_tac) : alloc.vec.Vec (alloc.vec.Vec Std.I64))))}") #eval (s!"CA...
[ { "input": "[7, 56]", "output": "[]" }, { "input": "[4, 1]", "output": "[]" }, { "input": "[8, 84]", "output": "[]" }, { "input": "[7, 63]", "output": "[]" }, { "input": "[6, 45]", "output": "[]" }, { "input": "[2, 18]", "output": "[]" }, { ...
62
true
62
verified
10
10
2
32,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.CombinationSum3.Code.Funs /-! # Specifications of `Aegis.CombinationSum3.combination_sum3` LeetCode problem `combination-sum-iii`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.CombinationSum3 open Aegis.CombinationSum3 def val...
14
contains-duplicate
217
Easy
[ "Array", "Hash Table", "Sorting" ]
Given an integer array nums, return true if any value appears at least twice in the array, and return false if every element is distinct.   Example 1: Input: nums = [1,2,3,1] Output: true Explanation: The element 1 occurs at the indices 0 and 3. Example 2: Input: nums = [1,2,3,4] Output: false Explanation: All eleme...
containsDuplicate(nums: list_int) -> bool
pub fn contains_duplicate(nums: &[i64]) -> bool
Aegis.ContainsDuplicate.contains_duplicate
pub fn contains_duplicate(nums: &[i64]) -> bool { let n = nums.len(); if n <= 1 { return false; } let mut v: Vec<i64> = Vec::new(); let mut i: usize = 0; while i < n { v.push(nums[i]); i += 1; } let mut width: usize = 1; while width < n { let mut nex...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [contains_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 li...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [contains_duplicate]: function definitions module public import Aeneas public import Aegis.ContainsDuplicate.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false ...
import Aegis.ContainsDuplicate.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 aeg...
[ { "input": "[[1]]", "output": "false" }, { "input": "[[0]]", "output": "false" }, { "input": "[[1, 2]]", "output": "false" }, { "input": "[[1000000000, -1000000000, 1000000000]]", "output": "true" }, { "input": "[[1, 2, 3, 1]]", "output": "true" }, { "...
94
false
94
verified
10
10
1
3,880
[ { "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.ContainsDuplicate.Code.Funs /-! # Specifications of `Aegis.ContainsDuplicate.contains_duplicate` LeetCode problem `contains-duplicate`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.ContainsDuplicate def elem (nums : Slice Std.I64) (t...
7
the-skyline-problem
218
Hard
[ "Binary Indexed Tree", "Segment Tree", "Array", "Divide and Conquer", "Ordered Set", "Line Sweep", "Heap (Priority Queue)" ]
A city's skyline is the outer contour of the silhouette formed by all the buildings in that city when viewed from a distance. Given the locations and heights of all the buildings, return the skyline formed by these buildings collectively. The geometric information of each building is given in the array buildings where ...
getSkyline(buildings: list_list_int) -> list_list_int
pub fn get_skyline(buildings: &[Vec<i64>]) -> Vec<Vec<i64>>
Aegis.GetSkyline.get_skyline
pub fn get_skyline(buildings: &[Vec<i64>]) -> Vec<Vec<i64>> { let n = buildings.len(); let base: i64 = 1048576; let half: i64 = 524288; let mut events: Vec<i64> = Vec::new(); let mut active: Vec<bool> = Vec::new(); let mut i: usize = 0; while i < n { let left = buildings[i][0]; ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [get_skyline]: 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 -- [get_skyline]: function definitions module public import Aeneas public import Aegis.GetSkyline.Code.Types public import Aegis.GetSkyline.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 -- [get_skyline]: external functions. -- This is a template file: rename it to "FunsExternal.lean" and fill the holes. module public import Aeneas public import Aegis.GetSkyline.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_opt...
import Aegis.GetSkyline.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.GetSkyline.get_skyline (Slice.from [(alloc.vec.Vec.from [1#i64, 1000000000#i64, 1#i64] (by scalar_tac) : alloc.vec.Vec Std.I64)] (by scalar_tac) : Sli...
[ { "input": "[[[1, 1000000000, 1]]]", "output": "[[1, 1], [1000000000, 0]]" }, { "input": "[[[0, 2, 3], [2, 5, 3]]]", "output": "[[0, 3], [5, 0]]" }, { "input": "[[[1, 2, 1], [1, 2, 2], [1, 2, 3]]]", "output": "[[1, 3], [2, 0]]" }, { "input": "[[[0, 3, 3], [1, 5, 3], [2, 4, 3]...
101
false
101
verified
10
10
1
17,318
[ { "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.GetSkyline.Code.Funs import Mathlib.Data.Real.Basic /-! # Specifications of `Aegis.GetSkyline.get_skyline` LeetCode problem `the-skyline-problem`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result ControlFlow Error namespace AegisSpec.GetSkyline def coor...
15
contains-duplicate-ii
219
Easy
[ "Array", "Hash Table", "Sliding Window" ]
Given an integer array nums and an integer k, return true if there are two distinct indices i and j in the array such that nums[i] == nums[j] and abs(i - j) <= k.   Example 1: Input: nums = [1,2,3,1], k = 3 Output: true Example 2: Input: nums = [1,0,1,1], k = 1 Output: true Example 3: Input: nums = [1,2,3,1,2,3], ...
containsNearbyDuplicate(nums: list_int, k: int) -> bool
pub fn contains_nearby_duplicate(nums: &[i64], k: i64) -> bool
Aegis.ContainsNearbyDuplicate.contains_nearby_duplicate
pub fn contains_nearby_duplicate(nums: &[i64], k: i64) -> bool { let n = nums.len(); // Open-addressing hash table with linear probing. // keys[h] = stored value, last[h] = most recent index of that value (-1 = empty). let mut cap: usize = 1; let target: usize = n * 2; while cap < target { ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [contains_nearby_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_op...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [contains_nearby_duplicate]: function definitions module public import Aeneas public import Aegis.ContainsNearbyDuplicate.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashC...
import Aegis.ContainsNearbyDuplicate.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.ContainsNearbyDuplicate.contains_nearby_duplicate (Slice.from [1#i64] (by scalar_tac) : Slice Std.I64) 0#i64) (false))}") #eval (s!"CASE ...
[ { "input": "[[1], 0]", "output": "false" }, { "input": "[[9, 9], 1]", "output": "true" }, { "input": "[[1, 1], 0]", "output": "false" }, { "input": "[[1000000000, 1000000000], 1]", "output": "true" }, { "input": "[[999999999, -999999999, 999999999], 2]", "outp...
106
false
106
verified
10
10
2
9,062
[ { "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.ContainsNearbyDuplicate.Code.Funs /-! # Specifications of `Aegis.ContainsNearbyDuplicate.contains_nearby_duplicate` LeetCode problem `contains-duplicate-ii`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.ContainsNearbyDuplicate open A...
12
contains-duplicate-iii
220
Hard
[ "Array", "Bucket Sort", "Ordered Set", "Sorting", "Sliding Window" ]
You are given an integer array nums and two integers indexDiff and valueDiff. Find a pair of indices (i, j) such that: i != j, abs(i - j) <= indexDiff. abs(nums[i] - nums[j]) <= valueDiff, and Return true if such pair exists or false otherwise.   Example 1: Input: nums = [1,2,3,1], indexDiff = 3, valueDiff = 0 Outpu...
containsNearbyAlmostDuplicate(nums: list_int, indexDiff: int, valueDiff: int) -> bool
pub fn contains_nearby_almost_duplicate(nums: &[i64], indexDiff: i64, valueDiff: i64) -> bool
Aegis.ContainsNearbyAlmostDuplicate.contains_nearby_almost_duplicate
fn lower_bound(v: &[i64], x: i64) -> usize { let mut lo: usize = 0; let mut hi: usize = v.len(); while lo < hi { let mid = lo + (hi - lo) / 2; if v[mid] < x { lo = mid + 1; } else { hi = mid; } } lo } fn upper_bound(v: &[i64], x: i64) -> usize...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [contains_nearby_almost_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...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [contains_nearby_almost_duplicate]: function definitions module public import Aeneas public import Aegis.ContainsNearbyAlmostDuplicate.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option...
import Aegis.ContainsNearbyAlmostDuplicate.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.ContainsNearbyAlmostDuplicate.contains_nearby_almost_duplicate (Slice.from [1#i64] (by scalar_tac) : Slice Std.I64) 1#i64 1#i64) (f...
[ { "input": "[[1], 1, 1]", "output": "false" }, { "input": "[[2147483647, -2147483647], 1, 2147483647]", "output": "false" }, { "input": "[[-1, 2147483647], 1, 2147483647]", "output": "false" }, { "input": "[[2147483647, -2147483647], 1, 4294967294]", "output": "true" },...
238
false
238
verified
10
10
1
15,208
[ { "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.ContainsNearbyAlmostDuplicate.Code.Funs /-! # Specifications of `Aegis.ContainsNearbyAlmostDuplicate.contains_nearby_almost_duplicate` LeetCode problem `contains-duplicate-iii`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.ContainsN...
11
count-complete-tree-nodes
222
Easy
[ "Bit Manipulation", "Tree", "Binary Search", "Binary Tree" ]
Given the root of a complete binary tree, return the number of the nodes in the tree. According to Wikipedia, every level, except possibly the last, is completely filled in a complete binary tree, and all nodes in the last level are as far left as possible. It can have between 1 and 2h nodes inclusive at the last level...
countNodes(root: tree) -> int
pub fn count_nodes(root: &Tree) -> i64
Aegis.CountNodes.count_nodes
fn left_height(t: &Tree) -> i64 { match t { Tree::Null => 0, Tree::Node(_, l, _) => 1 + left_height(l), } } fn right_height(t: &Tree) -> i64 { match t { Tree::Null => 0, Tree::Node(_, _, r) => 1 + right_height(r), } } fn perfect_nodes(h: i64) -> i64 { let mut res: i...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [count_nodes]: 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 -- [count_nodes]: function definitions module public import Aeneas public import Aegis.CountNodes.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.CountNodes.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.CountNodes.count_nodes ((.Null) : Aegis.CountNodes.Tree)) (0#i64))}") #eval (s!"CASE 1 {(Result.reducesTo (Aegis.CountNodes.count_nodes ((.Node 1#i64 ...
[ { "input": "[[]]", "output": "0" }, { "input": "[[1]]", "output": "1" }, { "input": "[[1, 2]]", "output": "2" }, { "input": "[[1, 2, 3]]", "output": "3" }, { "input": "[[1, 2, 3, 4]]", "output": "4" }, { "input": "[[1, 2, 3, 4, 5]]", "output": "5" ...
46
false
46
verified
10
10
1
4,508
[ { "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.CountNodes.Code.Funs /-! # Specifications of `Aegis.CountNodes.count_nodes` LeetCode problem `count-complete-tree-nodes`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.CountNodes open Aegis.CountNodes def nodeCount : Tree → Nat | T...
2
rectangle-area
223
Medium
[ "Geometry", "Math" ]
Given the coordinates of two rectilinear rectangles in a 2D plane, return the total area covered by the two rectangles. The first rectangle is defined by its bottom-left corner (ax1, ay1) and its top-right corner (ax2, ay2). The second rectangle is defined by its bottom-left corner (bx1, by1) and its top-right corner (...
computeArea(ax1: int, ay1: int, ax2: int, ay2: int, bx1: int, by1: int, bx2: int, by2: int) -> int
pub fn compute_area(ax1: i64, ay1: i64, ax2: i64, ay2: i64, bx1: i64, by1: i64, bx2: i64, by2: i64) -> i64
Aegis.ComputeArea.compute_area
pub fn compute_area( ax1: i64, ay1: i64, ax2: i64, ay2: i64, bx1: i64, by1: i64, bx2: i64, by2: i64, ) -> i64 { let area_a = (ax2 - ax1) * (ay2 - ay1); let area_b = (bx2 - bx1) * (by2 - by1); let left = if ax1 > bx1 { ax1 } else { bx1 }; let right = if ax2 < bx2 { ax2 } ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [compute_area]: 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 -- [compute_area]: function definitions module public import Aeneas public import Aegis.ComputeArea.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.ComputeArea.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.ComputeArea.compute_area (-2)#i64 (-2)#i64 2#i64 2#i64 (-2)#i64 (-2)#i64 2#i64 2#i64) (16#i64))}") #eval (s!"CASE 1 {(Result.reducesTo (Aegis.Compute...
[ { "input": "[-2, -2, 2, 2, -2, -2, 2, 2]", "output": "16" }, { "input": "[1, 1, 3, 3, 2, 2, 4, 4]", "output": "7" }, { "input": "[0, 0, 5, 5, 5, 5, 10, 10]", "output": "50" }, { "input": "[-3, 0, 3, 4, 0, -1, 9, 2]", "output": "45" }, { "input": "[-5, -5, 0, 0, -3...
76
false
76
verified
10
10
1
629
[ { "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.ComputeArea.Code.Funs /-! # Specifications of `Aegis.ComputeArea.compute_area` LeetCode problem `rectangle-area`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.ComputeArea def InI64 (x : ℤ) : Prop := Aeneas.Std.I64.min ≤ x ∧ x ≤ Aenea...
14
invert-binary-tree
226
Easy
[ "Tree", "Depth-First Search", "Breadth-First Search", "Binary Tree" ]
Given the root of a binary tree, invert the tree, and return its root.   Example 1: Input: root = [4,2,7,1,3,6,9] Output: [4,7,2,9,6,3,1] Example 2: Input: root = [2,1,3] Output: [2,3,1] Example 3: Input: root = [] Output: []   Constraints: The number of nodes in the tree is in the range [0, 100]. -100 <= Node...
invertTree(root: tree) -> tree
pub fn invert_tree(root: &Tree) -> Tree
Aegis.InvertTree.invert_tree
fn invert(t: &Tree) -> Tree { match t { Tree::Null => Tree::Null, Tree::Node(v, left, right) => { let inverted_left = invert(&**right); let inverted_right = invert(&**left); Tree::Node(*v, Box::new(inverted_left), Box::new(inverted_right)) } } } pub f...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [invert_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.st...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [invert_tree]: function definitions module public import Aeneas public import Aegis.InvertTree.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.InvertTree.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 deriving instance DecidableEq for Aegis.InvertTree.Tree #eval (s!"CASE 0 {(match (Aegis.InvertTree.invert_tree ((.Node 1#i64 (.Node 2#i64 (.Null) (.Null)) (.Null)) : Aegis.InvertTree.Tree)).ma...
[ { "input": "[[1, 2]]", "output": "[1, null, 2]" }, { "input": "[[2, 1, 3]]", "output": "[2, 3, 1]" }, { "input": "[[1, 3, 2, 5, 4]]", "output": "[1, 2, 3, null, null, 4, 5]" }, { "input": "[[8, 5, 1, 7, 10, 12]]", "output": "[8, 1, 5, null, 12, 10, 7]" }, { "input...
18
false
18
verified
10
10
1
790
[ { "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.InvertTree.Code.Funs /-! # Specifications of `Aegis.InvertTree.invert_tree` LeetCode problem `invert-binary-tree`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.InvertTree (Tree invert invert_tree) namespace AegisSpec.InvertTree def nodes : Tr...
10
basic-calculator-ii
227
Medium
[ "Stack", "Math", "String" ]
Given a string s which represents an expression, evaluate this expression and return its value.  The integer division should truncate toward zero. You may assume that the given expression is always valid. All intermediate results will be in the range of [-231, 231 - 1]. Note: You are not allowed to use any built-in fun...
calculate(s: str) -> int
pub fn calculate(s: &[u8]) -> i64
Aegis.Calculate.calculate
pub fn calculate(s: &[u8]) -> i64 { let mut stack: Vec<i64> = Vec::new(); let mut num: i64 = 0; let mut op: u8 = b'+'; let mut i: usize = 0; while i < s.len() { let c = s[i]; if c >= b'0' && c <= b'9' { num = num * 10 + ((c - b'0') as i64); } else if c == b' ' |...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [calculate]: 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 -- [calculate]: function definitions module public import Aeneas public import Aegis.Calculate.Code.Types public import Aegis.Calculate.Code.FunsExternal @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_o...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [calculate]: external functions. -- This is a template file: rename it to "FunsExternal.lean" and fill the holes. module public import Aeneas public import Aegis.Calculate.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option...
import Aegis.Calculate.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.Calculate.calculate (Slice.from [50#u8, 32#u8, 45#u8, 32#u8, 51#u8, 32#u8, 43#u8, 32#u8, 52#u8] (by scalar_tac) : Slice Std.U8)) (3#i64))}") #eval (s!"...
[ { "input": "[\"2 - 3 + 4\"]", "output": "3" }, { "input": "[\" 1000000000 - 500000000 + 250000000\"]", "output": "750000000" }, { "input": "[\"30 + 2 * 6 / (3 - 1)\"]", "output": "33" }, { "input": "[\"100 * ( 2 + 12 ) / 14\"]", "output": "200" }, { "input": "[\"1...
171
false
171
verified
10
10
1
5,607
[ { "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.Calculate.Code.Funs /-! # Specifications of `Aegis.Calculate.calculate` LeetCode problem `basic-calculator-ii`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result set_option autoImplicit false namespace AegisSpec.Calculate def IsDigit (c : U8) : Prop := 48 ≤...
5
summary-ranges
228
Easy
[ "Array" ]
You are given a sorted unique integer array nums. A range [a,b] is the set of all integers from a to b (inclusive). Return the smallest sorted list of ranges that cover all the numbers in the array exactly. That is, each element of nums is covered by exactly one of the ranges, and there is no integer x such that x is i...
summaryRanges(nums: list_int) -> list_str
pub fn summary_ranges(nums: &[i64]) -> Vec<Vec<u8>>
Aegis.SummaryRanges.summary_ranges
#![allow(unused_macros)] // The appended harness tests compare against empty expected lists with the bare // `vec![]`, whose element type is ambiguous when the other operand is // `Vec<Vec<u8>>` (several `PartialEq` impls match). This local macro fixes the // type for the empty case and keeps ordinary vector construct...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [summary_ranges]: 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 -- [summary_ranges]: function definitions module public import Aeneas public import Aegis.SummaryRanges.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.SummaryRanges.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.SummaryRanges.summary_ranges (Slice.from [] (by scalar_tac) : Slice Std.I64)) ((alloc.vec.Vec.from [] (by scalar_tac) : alloc.vec.Vec (alloc.vec.Ve...
[ { "input": "[[]]", "output": "[]" }, { "input": "[[1]]", "output": "[\"1\"]" }, { "input": "[[0]]", "output": "[\"0\"]" }, { "input": "[[5]]", "output": "[\"5\"]" }, { "input": "[[42]]", "output": "[\"42\"]" }, { "input": "[[2147483646, 2147483647]]", ...
120
false
120
verified
10
10
4
79,813
[ { "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.SummaryRanges.Code.Funs /-! # Specifications of `Aegis.SummaryRanges.summary_ranges` LeetCode problem `summary-ranges`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result ControlFlow Error namespace AegisSpec.SummaryRanges def intsOf (nums : Slice Std.I64) : ...
13
majority-element-ii
229
Medium
[ "Array", "Hash Table", "Counting", "Sorting" ]
Given an integer array of size n, find all elements that appear more than ⌊ n/3 ⌋ times.   Example 1: Input: nums = [3,2,3] Output: [3] Example 2: Input: nums = [1] Output: [1] Example 3: Input: nums = [1,2] Output: [1,2]   Constraints: 1 <= nums.length <= 5 * 104 -109 <= nums[i] <= 109   Follow up: Could you s...
majorityElement(nums: list_int) -> list_int
pub fn majority_element(nums: &[i64]) -> Vec<i64>
Aegis.MajorityElement.majority_element
pub fn majority_element(nums: &[i64]) -> Vec<i64> { let n = nums.len(); let mut candidate1: i64 = 0; let mut candidate2: i64 = 1; let mut count1: i64 = 0; let mut count2: i64 = 0; let mut i: usize = 0; while i < n { let num = nums[i]; if num == candidate1 { cou...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [majority_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 lint...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [majority_element]: function definitions module public import Aeneas public import Aegis.MajorityElement.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.MajorityElement.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.MajorityElement.majority_element (Slice.from [1#i64] (by scalar_tac) : Slice Std.I64)) ((alloc.vec.Vec.from [1#i64] (by scalar_tac) : alloc.vec.V...
[ { "input": "[[1]]", "output": "[1]" }, { "input": "[[3, 2, 3]]", "output": "[3]" }, { "input": "[[1, 2]]", "output": "[2, 1]" }, { "input": "[[2, 2, 1, 3]]", "output": "[2]" }, { "input": "[[-1, -2, -3, -1, -1, -1, 0]]", "output": "[-1]" }, { "input": ...
77
false
77
verified
10
10
1
8,154
[ { "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.MajorityElement.Code.Funs /-! # Specifications of `Aegis.MajorityElement.majority_element` LeetCode problem `majority-element-ii`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.MajorityElement def countOcc (l : List Std.I64) (x : Std....
9
kth-smallest-element-in-a-bst
230
Medium
[ "Tree", "Depth-First Search", "Binary Search Tree", "Binary Tree" ]
Given the root of a binary search tree, and an integer k, return the kth smallest value (1-indexed) of all the values of the nodes in the tree.   Example 1: Input: root = [3,1,4,null,2], k = 1 Output: 1 Example 2: Input: root = [5,3,6,2,4,null,null,1], k = 3 Output: 3   Constraints: The number of nodes in the tr...
kthSmallest(root: tree, k: int) -> int
pub fn kth_smallest(root: &Tree, k: i64) -> i64
Aegis.KthSmallest.kth_smallest
fn count_nodes(t: &Tree) -> i64 { match t { Tree::Null => 0, Tree::Node(_, l, r) => { let left_count = count_nodes(&**l); let right_count = count_nodes(&**r); 1 + left_count + right_count } } } fn kth_smallest_in(t: &Tree, k: i64) -> i64 { match t...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [kth_smallest]: 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 -- [kth_smallest]: function definitions module public import Aeneas public import Aegis.KthSmallest.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.KthSmallest.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.KthSmallest.kth_smallest ((.Node 1#i64 (.Null) (.Null)) : Aegis.KthSmallest.Tree) 1#i64) (1#i64))}") #eval (s!"CASE 1 {(Result.reducesTo (Aegis.KthSm...
[ { "input": "[[1], 1]", "output": "1" }, { "input": "[[3, 2, 4, 1], 2]", "output": "2" }, { "input": "[[4, 2, 5, 1, 3], 2]", "output": "2" }, { "input": "[[5, 3, 7, 2, 4, 6, 8, 1], 8]", "output": "8" }, { "input": "[[5, 3, 7, 2, 4, 6, 8, 1], 1]", "output": "1" ...
31
false
31
verified
10
10
1
5,833
[ { "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.KthSmallest.Code.Funs /-! # Specifications of `Aegis.KthSmallest.kth_smallest` LeetCode problem `kth-smallest-element-in-a-bst`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.KthSmallest open Aegis.KthSmallest def values : Tree → Lis...
10
power-of-two
231
Easy
[ "Bit Manipulation", "Recursion", "Math" ]
Given an integer n, return true if it is a power of two. Otherwise, return false. An integer n is a power of two, if there exists an integer x such that n == 2x.   Example 1: Input: n = 1 Output: true Explanation: 20 = 1 Example 2: Input: n = 16 Output: true Explanation: 24 = 16 Example 3: Input: n = 3 Output: fal...
isPowerOfTwo(n: int) -> bool
pub fn is_power_of_two(n: i64) -> bool
Aegis.IsPowerOfTwo.is_power_of_two
pub fn is_power_of_two(n: i64) -> bool { if n <= 0 { return false; } let mut m = n; while m % 2 == 0 { m = m / 2; } m == 1 }
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [is_power_of_two]: 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 -- [is_power_of_two]: function definitions module public import Aeneas public import Aegis.IsPowerOfTwo.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.IsPowerOfTwo.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.IsPowerOfTwo.is_power_of_two 3#i64) (false))}") #eval (s!"CASE 1 {(Result.reducesTo (Aegis.IsPowerOfTwo.is_power_of_two 2097152#i64) (true))}") #eva...
[ { "input": "[3]", "output": "false" }, { "input": "[2097152]", "output": "true" }, { "input": "[-16]", "output": "false" }, { "input": "[67108864]", "output": "true" }, { "input": "[4096]", "output": "true" }, { "input": "[2147483647]", "output": "...
101
false
101
verified
10
10
1
603
[ { "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.IsPowerOfTwo.Code.Funs /-! # Specifications of `Aegis.IsPowerOfTwo.is_power_of_two` LeetCode problem `power-of-two`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.IsPowerOfTwo def bitCount (x : ℕ) : ℕ := (Nat.bits x).count true ...
10
number-of-digit-one
233
Hard
[ "Recursion", "Math", "Dynamic Programming" ]
Given an integer n, count the total number of digit 1 appearing in all non-negative integers less than or equal to n.   Example 1: Input: n = 13 Output: 6 Example 2: Input: n = 0 Output: 0   Constraints: 0 <= n <= 109
countDigitOne(n: int) -> int
pub fn count_digit_one(n: i64) -> i64
Aegis.CountDigitOne.count_digit_one
pub fn count_digit_one(n: i64) -> i64 { let mut count: i64 = 0; let mut factor: i64 = 1; while factor <= n { let high: i64 = n / (factor * 10); let cur: i64 = (n / factor) % 10; let low: i64 = n % factor; if cur == 0 { count += high * factor; } else if c...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [count_digit_one]: 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 -- [count_digit_one]: function definitions module public import Aeneas public import Aegis.CountDigitOne.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.CountDigitOne.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.CountDigitOne.count_digit_one 0#i64) (0#i64))}") #eval (s!"CASE 1 {(Result.reducesTo (Aegis.CountDigitOne.count_digit_one 987654321#i64) (891632373...
[ { "input": "[0]", "output": "0" }, { "input": "[987654321]", "output": "891632373" }, { "input": "[100000]", "output": "50001" }, { "input": "[999999999]", "output": "900000000" }, { "input": "[999]", "output": "300" }, { "input": "[1000000]", "out...
76
false
76
verified
10
10
1
1,087
[ { "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.CountDigitOne.Code.Funs /-! # Specifications of `Aegis.CountDigitOne.count_digit_one` LeetCode problem `number-of-digit-one`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result Aegis.CountDigitOne namespace AegisSpec.CountDigitOne noncomputable def ones (y : ...
13
palindrome-linked-list
234
Easy
[ "Stack", "Recursion", "Linked List", "Two Pointers" ]
Given the head of a singly linked list, return true if it is a palindrome or false otherwise.   Example 1: Input: head = [1,2,2,1] Output: true Example 2: Input: head = [1,2] Output: false   Constraints: The number of nodes in the list is in the range [1, 105]. 0 <= Node.val <= 9   Follow up: Could you do it in...
isPalindrome(head: linkedlist) -> bool
pub fn is_palindrome(head: &List) -> bool
Aegis.IsPalindrome.is_palindrome
fn collect_rev(l: &List) -> Vec<i64> { match l { List::Nil => Vec::new(), List::Cons(x, next) => { let mut v: Vec<i64> = collect_rev(&**next); v.push(*x); v } } } pub fn is_palindrome(head: &List) -> bool { let vals: Vec<i64> = collect_rev(head); ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [is_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 linter....
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [is_palindrome]: function definitions module public import Aeneas public import Aegis.IsPalindrome.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.IsPalindrome.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.IsPalindrome.is_palindrome ((.Cons 1#i64 (.Nil)) : Aegis.IsPalindrome.List)) (true))}") #eval (s!"CASE 1 {(Result.reducesTo (Aegis.IsPalindrome.is_p...
[ { "input": "[[1]]", "output": "true" }, { "input": "[[1, 2]]", "output": "false" }, { "input": "[[1, 1]]", "output": "true" }, { "input": "[[1, 0, 1]]", "output": "true" }, { "input": "[[1, 0, 0, 1]]", "output": "true" }, { "input": "[[1, 2, 2, 1]]", ...
91
false
91
verified
10
10
2
9,324
[ { "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.IsPalindrome.Code.Funs /-! # Specifications of `Aegis.IsPalindrome.is_palindrome` LeetCode problem `palindrome-linked-list`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.IsPalindrome abbrev AList : Type := Aegis.IsPalindrome.List de...
7
product-of-array-except-self
238
Medium
[ "Array", "Prefix Sum" ]
Given an integer array nums, return an array answer such that answer[i] is equal to the product of all the elements of nums except nums[i]. The product of any prefix or suffix of nums is guaranteed to fit in a 32-bit integer. You must write an algorithm that runs in O(n) time and without using the division operation.  ...
productExceptSelf(nums: list_int) -> list_int
pub fn product_except_self(nums: &[i64]) -> Vec<i64>
Aegis.ProductExceptSelf.product_except_self
pub fn product_except_self(nums: &[i64]) -> Vec<i64> { let n = nums.len(); let mut ans: Vec<i64> = Vec::new(); let mut prefix: i64 = 1; let mut i: usize = 0; while i < n { ans.push(prefix); prefix = prefix * nums[i]; i = i + 1; } let mut suffix: i64 = 1; let mut...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [product_except_self]: 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 -- [product_except_self]: function definitions module public import Aeneas public import Aegis.ProductExceptSelf.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false...
import Aegis.ProductExceptSelf.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.ProductExceptSelf.product_except_self (Slice.from [1#i64, 2#i64, 3#i64, 4#i64] (by scalar_tac) : Slice Std.I64)) ((alloc.vec.Vec.from [24#i64, ...
[ { "input": "[[1, 2, 3, 4]]", "output": "[24, 12, 8, 6]" }, { "input": "[[2, -3, 4, -5]]", "output": "[60, -40, 30, -24]" }, { "input": "[[0, 0, 0, 0]]", "output": "[0, 0, 0, 0]" }, { "input": "[[5, 5, 5, 5]]", "output": "[125, 125, 125, 125]" }, { "input": "[[1, 0...
87
false
87
verified
10
10
1
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.ProductExceptSelf.Code.Funs /-! # Specifications of `Aegis.ProductExceptSelf.product_except_self` LeetCode problem `product-of-array-except-self`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.ProductExceptSelf def inI32 (x : ℤ) : Pro...
8
sliding-window-maximum
239
Hard
[ "Queue", "Array", "Sliding Window", "Monotonic Queue", "Heap (Priority Queue)" ]
You are given an array of integers nums, there is a sliding window of size k which is moving from the very left of the array to the very right. You can only see the k numbers in the window. Each time the sliding window moves right by one position. Return the max sliding window.   Example 1: Input: nums = [1,3,-1,-3,5,...
maxSlidingWindow(nums: list_int, k: int) -> list_int
pub fn max_sliding_window(nums: &[i64], k: i64) -> Vec<i64>
Aegis.MaxSlidingWindow.max_sliding_window
pub fn max_sliding_window(nums: &[i64], k: i64) -> Vec<i64> { let n = nums.len(); let mut out: Vec<i64> = Vec::new(); if n == 0 || k <= 0 { return out; } let k_usize = k as usize; if k_usize > n { return out; } let mut dq: Vec<i64> = Vec::new(); let mut head: usize...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [max_sliding_window]: 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_sliding_window]: function definitions module public import Aeneas public import Aegis.MaxSlidingWindow.Code.Types public import Aegis.MaxSlidingWindow.Code.FunsExternal @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.d...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [max_sliding_window]: external functions. -- This is a template file: rename it to "FunsExternal.lean" and fill the holes. module public import Aeneas public import Aegis.MaxSlidingWindow.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow ...
import Aegis.MaxSlidingWindow.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.MaxSlidingWindow.max_sliding_window (Slice.from [1#i64] (by scalar_tac) : Slice Std.I64) 1#i64) ((alloc.vec.Vec.from [1#i64] (by scalar_tac) : a...
[ { "input": "[[1], 1]", "output": "[1]" }, { "input": "[[4, -2], 2]", "output": "[4]" }, { "input": "[[9, 11], 2]", "output": "[11]" }, { "input": "[[7, 2, 4], 2]", "output": "[7, 4]" }, { "input": "[[1, 3, 1, 2, 0, 5], 3]", "output": "[3, 3, 2, 5]" }, { ...
104
false
104
verified
10
10
1
3,215
[ { "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.MaxSlidingWindow.Code.Funs /-! # Specifications of `Aegis.MaxSlidingWindow.max_sliding_window` LeetCode problem `sliding-window-maximum`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.MaxSlidingWindow namespace AegisSpec.MaxSlidingWindow ...
9
search-a-2d-matrix-ii
240
Medium
[ "Array", "Binary Search", "Divide and Conquer", "Matrix" ]
Write an efficient algorithm that searches for a value target in an m x n integer matrix matrix. This matrix has the following properties: Integers in each row are sorted in ascending from left to right. Integers in each column are sorted in ascending from top to bottom.   Example 1: Input: matrix = [[1,4,7,11,15],...
searchMatrix(matrix: list_list_int, target: int) -> bool
pub fn search_matrix(matrix: &[Vec<i64>], target: i64) -> bool
Aegis.SearchMatrix.search_matrix
pub fn search_matrix(matrix: &[Vec<i64>], target: i64) -> bool { let m = matrix.len(); let mut found = false; let mut valid = false; let mut n: usize = 0; if m > 0 { n = matrix[0].len(); if n > 0 { valid = true; } } if valid { let mut row: usize ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [search_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 -- [search_matrix]: function definitions module public import Aeneas public import Aegis.SearchMatrix.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.SearchMatrix.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.SearchMatrix.search_matrix (Slice.from [(alloc.vec.Vec.from [5#i64] (by scalar_tac) : alloc.vec.Vec Std.I64)] (by scalar_tac) : Slice (alloc.vec.Vec...
[ { "input": "[[[5]], 5]", "output": "true" }, { "input": "[[[1000000000]], 1000000000]", "output": "true" }, { "input": "[[[5]], 10]", "output": "false" }, { "input": "[[[1]], 1]", "output": "true" }, { "input": "[[[1]], 0]", "output": "false" }, { "inp...
95
false
95
verified
10
10
2
1,355
[ { "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.SearchMatrix.Code.Funs /-! # Specifications of `Aegis.SearchMatrix.search_matrix` LeetCode problem `search-a-2d-matrix-ii`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.SearchMatrix abbrev MatrixTy : Type := Slice (alloc.vec.Vec Std....
5
different-ways-to-add-parentheses
241
Medium
[ "Recursion", "Memoization", "Math", "String", "Dynamic Programming" ]
Given a string expression of numbers and operators, return all possible results from computing all the different possible ways to group numbers and operators. You may return the answer in any order. The test cases are generated such that the output values fit in a 32-bit integer and the number of different results does...
diffWaysToCompute(expression: str) -> list_int
pub fn diff_ways_to_compute(expression: &[u8]) -> Vec<i64>
Aegis.DiffWaysToCompute.diff_ways_to_compute
pub fn diff_ways_to_compute(expression: &[u8]) -> Vec<i64> { let n = expression.len(); let mut valid = true; if n == 0 { valid = false; } // Validate characters: only digits and '+', '-', '*'. let mut i = 0; while i < n { let c = expression[i]; if c < b'0' || c > b'...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [diff_ways_to_compute]: 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 -- [diff_ways_to_compute]: function definitions module public import Aeneas public import Aegis.DiffWaysToCompute.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand fals...
import Aegis.DiffWaysToCompute.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.DiffWaysToCompute.diff_ways_to_compute (Slice.from [51#u8, 43#u8, 53#u8, 47#u8, 50#u8, 42#u8, 51#u8] (by scalar_tac) : Slice Std.U8)) ((alloc.v...
[ { "input": "[\"3+5/2*3\"]", "output": "[]" }, { "input": "[\"9-3/3+2\"]", "output": "[]" }, { "input": "[\"1+2*3-4/2\"]", "output": "[]" }, { "input": "[\"6/2+3-1\"]", "output": "[]" }, { "input": "[\"11*11+22-33*4+55-66/2\"]", "output": "[]" }, { "inp...
154
true
154
verified
10
10
2
11,813
[ { "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.DiffWaysToCompute.Code.Funs /-! # Specifications of `Aegis.DiffWaysToCompute.diff_ways_to_compute` LeetCode problem `different-ways-to-add-parentheses`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.DiffWaysToCompute abbrev Byte := St...
16
shortest-word-distance
243
Easy
[ "Array", "String" ]
Given an array of strings wordsDict and two different strings that already exist in the array word1 and word2, return the shortest distance between these two words in the list.   Example 1: Input: wordsDict = ["practice", "makes", "perfect", "coding", "makes"], word1 = "coding", word2 = "practice" Output: 3 Example 2...
shortestDistance(wordsDict: list_str, word1: str, word2: str) -> int
pub fn shortest_distance(wordsDict: &[Vec<u8>], word1: &[u8], word2: &[u8]) -> i64
Aegis.ShortestDistance.shortest_distance
fn bytes_eq(a: &Vec<u8>, b: &[u8]) -> bool { if a.len() != b.len() { return false; } let mut i: usize = 0; while i < a.len() { if a[i] != b[i] { return false; } i += 1; } true } pub fn shortest_distance(wordsDict: &[Vec<u8>], word1: &[u8], word2: &[...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [shortest_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 lin...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [shortest_distance]: function definitions module public import Aeneas public import Aegis.ShortestDistance.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.ShortestDistance.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.ShortestDistance.shortest_distance (Slice.from [(alloc.vec.Vec.from [112#u8, 114#u8, 97#u8, 99#u8, 116#u8, 105#u8, 99#u8, 101#u8] (by scalar_tac...
[ { "input": "[[\"practice\", \"makes\", \"perfect\", \"coding\", \"makes\"], \"coding\", \"practice\"]", "output": "3" }, { "input": "[[\"hello\", \"world\", \"hello\", \"world\", \"hello\"], \"hello\", \"world\"]", "output": "1" }, { "input": "[[\"practice\", \"makes\", \"perfect\", \"co...
108
false
108
verified
10
10
1
1,520
[ { "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.ShortestDistance.Code.Funs /-! # Specifications of `Aegis.ShortestDistance.shortest_distance` LeetCode problem `shortest-word-distance`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.ShortestDistance def wordAt (wordsDict : Slice (all...
10
shortest-word-distance-iii
245
Medium
[ "Array", "String" ]
Given an array of strings wordsDict and two strings that already exist in the array word1 and word2, return the shortest distance between the occurrence of these two words in the list. Note that word1 and word2 may be the same. It is guaranteed that they represent two individual words in the list.   Example 1: Input: w...
shortestWordDistance(wordsDict: list_str, word1: str, word2: str) -> int
pub fn shortest_word_distance(wordsDict: &[Vec<u8>], word1: &[u8], word2: &[u8]) -> i64
Aegis.ShortestWordDistance.shortest_word_distance
fn bytes_eq(a: &[u8], b: &[u8]) -> bool { if a.len() != b.len() { return false; } let mut i: usize = 0; while i < a.len() { if a[i] != b[i] { return false; } i += 1; } true } fn word_eq_vec(w: &Vec<u8>, target: &[u8]) -> bool { if w.len() != targe...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [shortest_word_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_optio...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [shortest_word_distance]: function definitions module public import Aeneas public import Aegis.ShortestWordDistance.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand...
import Aegis.ShortestWordDistance.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.ShortestWordDistance.shortest_word_distance (Slice.from [(alloc.vec.Vec.from [97#u8] (by scalar_tac) : alloc.vec.Vec Std.U8), (alloc.vec.Vec...
[ { "input": "[[\"a\", \"b\", \"a\"], \"a\", \"a\"]", "output": "2" }, { "input": "[[\"hello\", \"world\", \"hello\", \"world\"], \"hello\", \"world\"]", "output": "1" }, { "input": "[[\"a\", \"a\", \"b\", \"b\"], \"a\", \"b\"]", "output": "1" }, { "input": "[[\"hello\", \"worl...
104
false
104
verified
10
10
1
1,921
[ { "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.ShortestWordDistance.Code.Funs /-! # Specifications of `Aegis.ShortestWordDistance.shortest_word_distance` LeetCode problem `shortest-word-distance-iii`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.ShortestWordDistance open Aegis.Sh...
12
strobogrammatic-number
246
Easy
[ "Hash Table", "Two Pointers", "String" ]
Given a string num which represents an integer, return true if num is a strobogrammatic number. A strobogrammatic number is a number that looks the same when rotated 180 degrees (looked at upside down).   Example 1: Input: num = "69" Output: true Example 2: Input: num = "88" Output: true Example 3: Input: num = "9...
isStrobogrammatic(num: str) -> bool
pub fn is_strobogrammatic(num: &[u8]) -> bool
Aegis.IsStrobogrammatic.is_strobogrammatic
pub fn is_strobogrammatic(num: &[u8]) -> bool { let n: usize = num.len(); let mut result: bool = true; if n == 0 { result = true; } else { let mut left: usize = 0; let mut right: usize = n - 1; while left < right { let a: u8 = num[left]; let b: u...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [is_strobogrammatic]: 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 -- [is_strobogrammatic]: function definitions module public import Aeneas public import Aegis.IsStrobogrammatic.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false ...
import Aegis.IsStrobogrammatic.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.IsStrobogrammatic.is_strobogrammatic (Slice.from [57#u8] (by scalar_tac) : Slice Std.U8)) (false))}") #eval (s!"CASE 1 {(Result.reducesTo (Aegi...
[ { "input": "[\"9\"]", "output": "false" }, { "input": "[\"69\"]", "output": "true" }, { "input": "[\"808\"]", "output": "true" }, { "input": "[\"609\"]", "output": "true" }, { "input": "[\"3\"]", "output": "false" }, { "input": "[\"18181\"]", "outp...
180
false
180
verified
10
10
2
1,094
[ { "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.IsStrobogrammatic.Code.Funs /-! # Specifications of `Aegis.IsStrobogrammatic.is_strobogrammatic` LeetCode problem `strobogrammatic-number`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.IsStrobogrammatic def IsDigitCode (b : U8) : Pro...
10
strobogrammatic-number-ii
247
Medium
[ "Recursion", "Array", "String" ]
Given an integer n, return all the strobogrammatic numbers that are of length n. You may return the answer in any order. A strobogrammatic number is a number that looks the same when rotated 180 degrees (looked at upside down).   Example 1: Input: n = 2 Output: ["11","69","88","96"] Example 2: Input: n = 1 Output: ["0"...
findStrobogrammatic(n: int) -> list_str
pub fn find_strobogrammatic(n: i64) -> Vec<Vec<u8>>
Aegis.FindStrobogrammatic.find_strobogrammatic
pub fn find_strobogrammatic(n: i64) -> Vec<Vec<u8>> { let mut out: Vec<Vec<u8>> = Vec::new(); let pairs: usize = (n / 2) as usize; let odd: bool = n % 2 == 1; // Total number of outputs, computed from the mixed-radix representation. let mut total: i64 = 1; let mut l: usize = 0; while l < p...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [find_strobogrammatic]: 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_strobogrammatic]: function definitions module public import Aeneas public import Aegis.FindStrobogrammatic.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand fa...
import Aegis.FindStrobogrammatic.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 a...
[ { "input": "[1]", "output": "[\"0\", \"1\", \"8\"]" }, { "input": "[2]", "output": "[\"11\", \"88\", \"69\", \"96\"]" }, { "input": "[3]", "output": "[\"101\", \"808\", \"609\", \"906\", \"111\", \"818\", \"619\", \"916\", \"181\", \"888\", \"689\", \"986\"]" }, { "input": "[...
8
true
8
verified_partial
8
4
2
22,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.FindStrobogrammatic.Code.Funs /-! # Specifications of `Aegis.FindStrobogrammatic.find_strobogrammatic` LeetCode problem `strobogrammatic-number-ii`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.FindStrobogrammatic abbrev ByteVect...
11
strobogrammatic-number-iii
248
Hard
[ "Recursion", "Array", "String" ]
Given two strings low and high that represent two integers low and high where low <= high, return the number of strobogrammatic numbers in the range [low, high]. A strobogrammatic number is a number that looks the same when rotated 180 degrees (looked at upside down).   Example 1: Input: low = "50", high = "100" Output...
strobogrammaticInRange(low: str, high: str) -> int
pub fn strobogrammatic_in_range(low: &[u8], high: &[u8]) -> i64
Aegis.StrobogrammaticInRange.strobogrammatic_in_range
fn parse_num(s: &[u8]) -> i64 { let mut v: i64 = 0; let mut i: usize = 0; while i < s.len() { let d: i64 = (s[i] - b'0') as i64; v = v * 10 + d; i += 1; } v } fn right_of(d: i64) -> i64 { if d == 0 { 0 } else if d == 1 { 1 } else if d == 6 { ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [strobogrammatic_in_range]: 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_opt...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [strobogrammatic_in_range]: function definitions module public import Aeneas public import Aegis.StrobogrammaticInRange.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCom...
import Aegis.StrobogrammaticInRange.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.StrobogrammaticInRange.strobogrammatic_in_range (Slice.from [49#u8] (by scalar_tac) : Slice Std.U8) (Slice.from [49#u8, 48#u8] (by scalar_...
[ { "input": "[\"1\", \"10\"]", "output": "2" }, { "input": "[\"1000000000\", \"9999999999\"]", "output": "2500" }, { "input": "[\"0\", \"150\"]", "output": "9" }, { "input": "[\"100\", \"200\"]", "output": "3" }, { "input": "[\"500\", \"1000\"]", "output": "9" ...
107
false
107
verified
10
10
1
13,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.StrobogrammaticInRange.Code.Funs /-! # Specifications of `Aegis.StrobogrammaticInRange.strobogrammatic_in_range` LeetCode problem `strobogrammatic-number-iii`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result ControlFlow Error open Aegis.StrobogrammaticInRang...
11
count-univalue-subtrees
250
Medium
[ "Tree", "Depth-First Search", "Binary Tree" ]
Given the root of a binary tree, return the number of uni-value subtrees. A uni-value subtree means all nodes of the subtree have the same value.   Example 1: Input: root = [5,1,5,5,5,null,5] Output: 4 Example 2: Input: root = [] Output: 0 Example 3: Input: root = [5,5,5,5,5,null,5] Output: 6   Constraints: The...
countUnivalSubtrees(root: tree) -> int
pub fn count_unival_subtrees(root: &Tree) -> i64
Aegis.CountUnivalSubtrees.count_unival_subtrees
pub fn count_unival_subtrees(root: &Tree) -> i64 { count_in_subtree(root) } fn count_in_subtree(t: &Tree) -> i64 { match t { Tree::Null => 0, Tree::Node(value, left, right) => { let mut count: i64 = 0; if all_equal(t, *value) { count += 1; } ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [count_unival_subtrees]: 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 -- [count_unival_subtrees]: function definitions module public import Aeneas public import Aegis.CountUnivalSubtrees.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand f...
import Aegis.CountUnivalSubtrees.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.CountUnivalSubtrees.count_unival_subtrees ((.Null) : Aegis.CountUnivalSubtrees.Tree)) (0#i64))}") #eval (s!"CASE 1 {(Result.reducesTo (Aegis....
[ { "input": "[[]]", "output": "0" }, { "input": "[[0]]", "output": "1" }, { "input": "[[1, 2, 3]]", "output": "2" }, { "input": "[[2, 2, 2, 5, 2]]", "output": "3" }, { "input": "[[1, 2, 3, 4, 5, 6, 7]]", "output": "4" }, { "input": "[[1, 1, 1, 1, 1, 1, ...
43
false
43
verified
10
10
1
4,754
[ { "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.CountUnivalSubtrees.Code.Funs /-! # Specifications of `Aegis.CountUnivalSubtrees.count_unival_subtrees` LeetCode problem `count-univalue-subtrees`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result Aegis.CountUnivalSubtrees namespace AegisSpec.CountUnivalSu...
11
meeting-rooms
252
Easy
[ "Array", "Sorting" ]
Given an array of meeting time intervals where intervals[i] = [starti, endi], determine if a person could attend all meetings.   Example 1: Input: intervals = [[0,30],[5,10],[15,20]] Output: false Example 2: Input: intervals = [[7,10],[2,4]] Output: true   Constraints: 0 <= intervals.length <= 104 intervals[i].length...
canAttendMeetings(intervals: list_list_int) -> bool
pub fn can_attend_meetings(intervals: &[Vec<i64>]) -> bool
Aegis.CanAttendMeetings.can_attend_meetings
pub fn can_attend_meetings(intervals: &[Vec<i64>]) -> bool { let n = intervals.len(); if n <= 1 { return true; } let mut starts: Vec<i64> = Vec::new(); let mut ends: Vec<i64> = Vec::new(); let mut i = 0; while i < n { let row = &intervals[i]; starts.push(row[0]); ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [can_attend_meetings]: 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 -- [can_attend_meetings]: function definitions module public import Aeneas public import Aegis.CanAttendMeetings.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false...
import Aegis.CanAttendMeetings.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.CanAttendMeetings.can_attend_meetings (Slice.from [] (by scalar_tac) : Slice (alloc.vec.Vec Std.I64))) (true))}") #eval (s!"CASE 1 {(Result.red...
[ { "input": "[[]]", "output": "true" }, { "input": "[[[1, 2]]]", "output": "true" }, { "input": "[[[1, 10]]]", "output": "true" }, { "input": "[[[1, 5], [2, 3]]]", "output": "false" }, { "input": "[[[1, 2], [2, 3]]]", "output": "true" }, { "input": "[[[...
101
false
101
verified
10
10
1
2,154
[ { "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.CanAttendMeetings.Code.Funs /-! # Specifications of `Aegis.CanAttendMeetings.can_attend_meetings` LeetCode problem `meeting-rooms`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.CanAttendMeetings def rows (intervals : Slice (alloc.vec...
13
meeting-rooms-ii
253
Medium
[ "Greedy", "Array", "Two Pointers", "Prefix Sum", "Sorting", "Heap (Priority Queue)" ]
Given an array of meeting time intervals intervals where intervals[i] = [starti, endi], return the minimum number of conference rooms required.   Example 1: Input: intervals = [[0,30],[5,10],[15,20]] Output: 2 Example 2: Input: intervals = [[7,10],[2,4]] Output: 1   Constraints: 1 <= intervals.length <= 104 0 <= star...
minMeetingRooms(intervals: list_list_int) -> int
pub fn min_meeting_rooms(intervals: &[Vec<i64>]) -> i64
Aegis.MinMeetingRooms.min_meeting_rooms
pub fn min_meeting_rooms(intervals: &[Vec<i64>]) -> i64 { let n: usize = intervals.len(); if n == 0 { return 0; } let mut min_start: i64 = intervals[0][0]; let mut max_end: i64 = intervals[0][1]; let mut i: usize = 1; while i < n { let s: i64 = intervals[i][0]; let ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [min_meeting_rooms]: 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 -- [min_meeting_rooms]: function definitions module public import Aeneas public import Aegis.MinMeetingRooms.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.MinMeetingRooms.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.MinMeetingRooms.min_meeting_rooms (Slice.from [(alloc.vec.Vec.from [7#i64, 10#i64] (by scalar_tac) : alloc.vec.Vec Std.I64), (alloc.vec.Vec.from ...
[ { "input": "[[[7, 10], [2, 4]]]", "output": "1" }, { "input": "[[[5, 8], [6, 8]]]", "output": "2" }, { "input": "[[[1, 2], [2, 3], [3, 4]]]", "output": "1" }, { "input": "[[[2, 11], [6, 16], [11, 16]]]", "output": "2" }, { "input": "[[[1, 5], [8, 9], [8, 9]]]", ...
107
false
107
verified
10
10
1
3,299
[ { "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.MinMeetingRooms.Code.Funs import Mathlib.Data.Real.Basic /-! # Specifications of `Aegis.MinMeetingRooms.min_meeting_rooms` LeetCode problem `meeting-rooms-ii`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.MinMeetingRooms def vecStart...
9
factor-combinations
254
Medium
[ "Backtracking" ]
Numbers can be regarded as the product of their factors. For example, 8 = 2 x 2 x 2 = 2 x 4. Given an integer n, return all possible combinations of its factors. You may return the answer in any order. Note that the factors should be in the range [2, n - 1].   Example 1: Input: n = 1 Output: [] Example 2: Input: n...
getFactors(n: int) -> list_list_int
pub fn get_factors(n: i64) -> Vec<Vec<i64>>
Aegis.GetFactors.get_factors
pub fn get_factors(n: i64) -> Vec<Vec<i64>> { let mut res: Vec<Vec<i64>> = Vec::new(); if n < 4 { return res; } let mut q_rem: Vec<i64> = Vec::new(); let mut q_start: Vec<i64> = Vec::new(); let mut q_path: Vec<Vec<i64>> = Vec::new(); q_rem.push(n); q_start.push(2); q_path....
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [get_factors]: 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 -- [get_factors]: function definitions module public import Aeneas public import Aegis.GetFactors.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.GetFactors.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 aegisCase ...
[ { "input": "[97]", "output": "[]" }, { "input": "[37]", "output": "[]" }, { "input": "[7]", "output": "[]" }, { "input": "[1]", "output": "[]" }, { "input": "[29]", "output": "[]" }, { "input": "[9973]", "output": "[]" }, { "input": "[4999]...
53
true
53
verified
10
10
7
120,660
[ { "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.GetFactors.Code.Funs /-! # Specifications of `Aegis.GetFactors.get_factors` LeetCode problem `factor-combinations`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.GetFactors open Aegis.GetFactors (get_factors) def rowEntries (ro...
11
paint-house
256
Medium
[ "Array", "Dynamic Programming" ]
There is a row of n houses, where each house can be painted one of three colors: red, blue, or green. The cost of painting each house with a certain color is different. You have to paint all the houses such that no two adjacent houses have the same color. The cost of painting each house with a certain color is represen...
minCost(costs: list_list_int) -> int
pub fn min_cost(costs: &[Vec<i64>]) -> i64
Aegis.MinCost.min_cost
pub fn min_cost(costs: &[Vec<i64>]) -> i64 { let n = costs.len(); if n == 0 { return 0; } let mut red: i64 = costs[0][0]; let mut blue: i64 = costs[0][1]; let mut green: i64 = costs[0][2]; let mut i: usize = 1; while i < n { let cost_red = costs[i][0]; let cost_...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [min_cost]: 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 -- [min_cost]: function definitions module public import Aeneas public import Aegis.MinCost.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.MinCost.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.MinCost.min_cost (Slice.from [(alloc.vec.Vec.from [7#i64, 6#i64, 2#i64] (by scalar_tac) : alloc.vec.Vec Std.I64)] (by scalar_tac) : Slice (alloc.vec.Vec ...
[ { "input": "[[[7, 6, 2]]]", "output": "2" }, { "input": "[[[11, 11, 13], [8, 12, 18], [9, 10, 3]]]", "output": "22" }, { "input": "[[[1, 2, 3], [4, 5, 6], [7, 8, 9]]]", "output": "13" }, { "input": "[[[5, 8, 6], [19, 14, 13], [7, 5, 12]]]", "output": "23" }, { "in...
96
false
96
verified
10
10
1
608
[ { "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.MinCost.Code.Funs /-! # Specifications of `Aegis.MinCost.min_cost` LeetCode problem `paint-house`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.MinCost namespace AegisSpec.MinCost def rows (costs : Slice (alloc.vec.Vec Std.I64)) : List (List ...
12
binary-tree-paths
257
Easy
[ "Tree", "Depth-First Search", "String", "Backtracking", "Binary Tree" ]
Given the root of a binary tree, return all root-to-leaf paths in any order. A leaf is a node with no children.   Example 1: Input: root = [1,2,3,null,5] Output: ["1->2->5","1->3"] Example 2: Input: root = [1] Output: ["1"]   Constraints: The number of nodes in the tree is in the range [1, 100]. -100 <= Node.val ...
binaryTreePaths(root: tree) -> list_str
pub fn binary_tree_paths(root: &Tree) -> Vec<Vec<u8>>
Aegis.BinaryTreePaths.binary_tree_paths
pub fn binary_tree_paths(root: &Tree) -> Vec<Vec<u8>> { let mut out: Vec<Vec<u8>> = Vec::new(); let mut path: Vec<u8> = Vec::new(); collect_paths(root, &path, &mut out); out } fn collect_paths(t: &Tree, path: &[u8], out: &mut Vec<Vec<u8>>) { match t { Tree::Null => {} Tree::Node(v, ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [binary_tree_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 lin...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [binary_tree_paths]: function definitions module public import Aeneas public import Aegis.BinaryTreePaths.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.BinaryTreePaths.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.BinaryTreePaths.binary_tree_paths ((.Node 1#i64 (.Null) (.Null)) : Aegis.BinaryTreePaths.Tree)) ((alloc.vec.Vec.from [(alloc.vec.Vec.from [49#u8]...
[ { "input": "[[1]]", "output": "[\"1\"]" }, { "input": "[[-10, -5, 0, 5, 9]]", "output": "[\"-10->-5->5\", \"-10->-5->9\", \"-10->0\"]" }, { "input": "[[1, 2, 3, 4, 5, 6, 7]]", "output": "[\"1->2->4\", \"1->2->5\", \"1->3->6\", \"1->3->7\"]" }, { "input": "[[1, 2, 2, 3, 4, 4, ...
14
true
14
verified
10
10
1
8,626
[ { "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.BinaryTreePaths.Code.Funs /-! # Specifications of `Aegis.BinaryTreePaths.binary_tree_paths` LeetCode problem `binary-tree-paths`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.BinaryTreePaths open Aegis.BinaryTreePaths abbrev Tree : ...
12
add-digits
258
Easy
[ "Math", "Number Theory", "Simulation" ]
Given an integer num, repeatedly add all its digits until the result has only one digit, and return it.   Example 1: Input: num = 38 Output: 2 Explanation: The process is 38 --> 3 + 8 --> 11 11 --> 1 + 1 --> 2 Since 2 has only one digit, return it. Example 2: Input: num = 0 Output: 0   Constraints: 0 <= num <= 23...
addDigits(num: int) -> int
pub fn add_digits(num: i64) -> i64
Aegis.AddDigits.add_digits
pub fn add_digits(num: i64) -> i64 { if num == 0 { 0 } else { 1 + (num - 1) % 9 } }
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [add_digits]: 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 -- [add_digits]: function definitions module public import Aeneas public import Aegis.AddDigits.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.AddDigits.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.AddDigits.add_digits 10#i64) (1#i64))}") #eval (s!"CASE 1 {(Result.reducesTo (Aegis.AddDigits.add_digits 9#i64) (9#i64))}") #eval (s!"CASE 2 {(Result.r...
[ { "input": "[10]", "output": "1" }, { "input": "[9]", "output": "9" }, { "input": "[111111111]", "output": "9" }, { "input": "[47]", "output": "2" }, { "input": "[456789]", "output": "3" }, { "input": "[38]", "output": "2" }, { "input": "[4...
53
false
53
verified
10
10
1
671
[ { "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.AddDigits.Code.Funs /-! # Specifications of `Aegis.AddDigits.add_digits` LeetCode problem `add-digits`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.AddDigits def i64OfInt (n : ℤ) : Aeneas.Std.I64 := Aeneas.Std.IScalar.mk (BitVec.o...
12
3sum-smaller
259
Medium
[ "Array", "Two Pointers", "Binary Search", "Sorting" ]
Given an array of n integers nums and an integer target, find the number of index triplets i, j, k with 0 <= i < j < k < n that satisfy the condition nums[i] + nums[j] + nums[k] < target.   Example 1: Input: nums = [-2,0,1,3], target = 2 Output: 2 Explanation: Because there are two triplets which sums are less than 2:...
threeSumSmaller(nums: list_int, target: int) -> int
pub fn three_sum_smaller(nums: &[i64], target: i64) -> i64
Aegis.ThreeSumSmaller.three_sum_smaller
pub fn three_sum_smaller(nums: &[i64], target: i64) -> i64 { let n: usize = nums.len(); let mut a: Vec<i64> = Vec::new(); let mut p: usize = 0; while p < n { a.push(nums[p]); p += 1; } // Insertion sort in ascending order. let mut i: usize = 1; while i < n { let...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [three_sum_smaller]: 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 -- [three_sum_smaller]: function definitions module public import Aeneas public import Aegis.ThreeSumSmaller.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.ThreeSumSmaller.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.ThreeSumSmaller.three_sum_smaller (Slice.from [] (by scalar_tac) : Slice Std.I64) 0#i64) (0#i64))}") #eval (s!"CASE 1 {(Result.reducesTo (Aegis.T...
[ { "input": "[[], 0]", "output": "0" }, { "input": "[[0], 0]", "output": "0" }, { "input": "[[5, 2, 3, 1], 7]", "output": "1" }, { "input": "[[-2, 0, 1, 3], 2]", "output": "2" }, { "input": "[[-1, -1, -1, -1], -3]", "output": "0" }, { "input": "[[1, 1, ...
104
false
104
verified
10
10
1
2,567
[ { "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.ThreeSumSmaller.Code.Funs /-! # Specifications of `Aegis.ThreeSumSmaller.three_sum_smaller` LeetCode problem `3sum-smaller`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result ControlFlow Error open Aegis.ThreeSumSmaller namespace AegisSpec.ThreeSumSmaller de...
11
single-number-iii
260
Medium
[ "Bit Manipulation", "Array" ]
Given an integer array nums, in which exactly two elements appear only once and all the other elements appear exactly twice. Find the two elements that appear only once. You can return the answer in any order. You must write an algorithm that runs in linear runtime complexity and uses only constant extra space.   Examp...
singleNumber(nums: list_int) -> list_int
pub fn single_number(nums: &[i64]) -> Vec<i64>
Aegis.SingleNumber.single_number
pub fn single_number(nums: &[i64]) -> Vec<i64> { let n = nums.len(); let mut xor_sum: i64 = 0; let mut i: usize = 0; while i < n { xor_sum = xor_sum ^ nums[i]; i += 1; } let mask: i64 = xor_sum & (-xor_sum); let mut first: i64 = 0; let mut second: i64 = 0; let mut...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [single_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 linter....
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [single_number]: function definitions module public import Aeneas public import Aegis.SingleNumber.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.SingleNumber.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.SingleNumber.single_number (Slice.from [(-1)#i64, 0#i64] (by scalar_tac) : Slice Std.I64)) ((alloc.vec.Vec.from [(-1)#i64, 0#i64] (by scalar_tac) : ...
[ { "input": "[[-1, 0]]", "output": "[-1, 0]" }, { "input": "[[0, 1]]", "output": "[1, 0]" }, { "input": "[[1000000000, 2000000000, 1000000000, 3000000000]]", "output": "[3000000000, 2000000000]" }, { "input": "[[2147483647, -2147483648, 2147483647, -2]]", "output": "[-2, -...
102
true
102
verified
10
10
1
1,982
[ { "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.SingleNumber.Code.Funs /-! # Specifications of `Aegis.SingleNumber.single_number` LeetCode problem `single-number-iii`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.SingleNumber def cnt (v : Int) (l : List Std.I64) : Nat := (l.filter...
11
graph-valid-tree
261
Medium
[ "Depth-First Search", "Breadth-First Search", "Union Find", "Graph" ]
You have a graph of n nodes labeled from 0 to n - 1. You are given an integer n and a list of edges where edges[i] = [ai, bi] indicates that there is an undirected edge between nodes ai and bi in the graph. Return true if the edges of the given graph make up a valid tree, and false otherwise.   Example 1: Input: n = ...
validTree(n: int, edges: list_list_int) -> bool
pub fn valid_tree(n: i64, edges: &[Vec<i64>]) -> bool
Aegis.ValidTree.valid_tree
pub fn valid_tree(n: i64, edges: &[Vec<i64>]) -> bool { if n <= 0 { return edges.len() == 0; } let nn: usize = n as usize; if edges.len() != nn - 1 { return false; } let mut parent: Vec<i64> = Vec::new(); let mut i: usize = 0; while i < nn { parent.push(i as i64...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [valid_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.sty...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [valid_tree]: function definitions module public import Aeneas public import Aegis.ValidTree.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.ValidTree.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.ValidTree.valid_tree 1#i64 (Slice.from [] (by scalar_tac) : Slice (alloc.vec.Vec Std.I64))) (true))}") #eval (s!"CASE 1 {(Result.reducesTo (Aegis.Valid...
[ { "input": "[1, []]", "output": "true" }, { "input": "[2, [[0, 1]]]", "output": "true" }, { "input": "[3, [[0, 1]]]", "output": "false" }, { "input": "[3, [[0, 1], [1, 2]]]", "output": "true" }, { "input": "[4, [[0, 1], [2, 3]]]", "output": "false" }, { ...
85
false
85
verified
10
10
1
3,256
[ { "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.ValidTree.Code.Funs /-! # Specifications of `Aegis.ValidTree.valid_tree` LeetCode problem `graph-valid-tree`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.ValidTree abbrev Edge := alloc.vec.Vec Std.I64 abbrev EdgeList := Slice (allo...
13
ugly-number
263
Easy
[ "Math" ]
An ugly number is a positive integer which does not have a prime factor other than 2, 3, and 5. Given an integer n, return true if n is an ugly number.   Example 1: Input: n = 6 Output: true Explanation: 6 = 2 × 3 Example 2: Input: n = 1 Output: true Explanation: 1 has no prime factors. Example 3: Input: n = 14 Ou...
isUgly(n: int) -> bool
pub fn is_ugly(n: i64) -> bool
Aegis.IsUgly.is_ugly
pub fn is_ugly(n: i64) -> bool { if n <= 0 { return false; } let mut x = n; while x % 2 == 0 { x = x / 2; } while x % 3 == 0 { x = x / 3; } while x % 5 == 0 { x = x / 5; } x == 1 }
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [is_ugly]: 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_ugly]: function definitions module public import Aeneas public import Aegis.IsUgly.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.unus...
import Aegis.IsUgly.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.IsUgly.is_ugly 0#i64) (false))}") #eval (s!"CASE 1 {(Result.reducesTo (Aegis.IsUgly.is_ugly 8#i64) (true))}") #eval (s!"CASE 2 {(Result.reducesTo (Aegis.I...
[ { "input": "[0]", "output": "false" }, { "input": "[8]", "output": "true" }, { "input": "[-2147483648]", "output": "false" }, { "input": "[100000]", "output": "true" }, { "input": "[100]", "output": "true" }, { "input": "[30]", "output": "true" }...
74
false
74
verified
10
10
1
234
[ { "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.IsUgly.Code.Funs /-! # Specifications of `Aegis.IsUgly.is_ugly` LeetCode problem `ugly-number`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.IsUgly def FiveSmooth (n : ℤ) : Prop := 0 < n ∧ ∃ a b c : ℕ, n = 2 ^ a * 3 ^ b * 5 ^ c /-...
9
ugly-number-ii
264
Medium
[ "Hash Table", "Math", "Dynamic Programming", "Heap (Priority Queue)" ]
An ugly number is a positive integer whose prime factors are limited to 2, 3, and 5. Given an integer n, return the nth ugly number.   Example 1: Input: n = 10 Output: 12 Explanation: [1, 2, 3, 4, 5, 6, 8, 9, 10, 12] is the sequence of the first 10 ugly numbers. Example 2: Input: n = 1 Output: 1 Explanation: 1 has n...
nthUglyNumber(n: int) -> int
pub fn nth_ugly_number(n: i64) -> i64
Aegis.NthUglyNumber.nth_ugly_number
pub fn nth_ugly_number(n: i64) -> i64 { let mut dp: Vec<i64> = Vec::new(); dp.push(1); let mut i2: usize = 0; let mut i3: usize = 0; let mut i5: usize = 0; let mut count: i64 = 1; while count < n { let candidate2 = dp[i2] * 2; let candidate3 = dp[i3] * 3; let candi...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [nth_ugly_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 -- [nth_ugly_number]: function definitions module public import Aeneas public import Aegis.NthUglyNumber.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.NthUglyNumber.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.NthUglyNumber.nth_ugly_number 15#i64) (24#i64))}") #eval (s!"CASE 1 {(Result.reducesTo (Aegis.NthUglyNumber.nth_ugly_number 200#i64) (16200#i64))}"...
[ { "input": "[15]", "output": "24" }, { "input": "[200]", "output": "16200" }, { "input": "[1690]", "output": "2123366400" }, { "input": "[1]", "output": "1" }, { "input": "[50]", "output": "243" }, { "input": "[10]", "output": "12" }, { "in...
38
false
38
verified
10
10
1
1,414
[ { "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.NthUglyNumber.Code.Funs /-! # Specifications of `Aegis.NthUglyNumber.nth_ugly_number` LeetCode problem `ugly-number-ii`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.NthUglyNumber def Ugly (k : Int) : Prop := 0 < k ∧ ∀ p : Na...
12
paint-house-ii
265
Hard
[ "Array", "Dynamic Programming" ]
There are a row of n houses, each house can be painted with one of the k colors. The cost of painting each house with a certain color is different. You have to paint all the houses such that no two adjacent houses have the same color. The cost of painting each house with a certain color is represented by an n x k cost ...
minCostII(costs: list_list_int) -> int
pub fn min_cost_ii(costs: &[Vec<i64>]) -> i64
Aegis.MinCostIi.min_cost_ii
pub fn min_cost_ii(costs: &[Vec<i64>]) -> i64 { let n = costs.len(); if n == 0 { return 0; } let k = costs[0].len(); if k == 0 { return 0; } let mut prev: Vec<i64> = Vec::new(); let mut j: usize = 0; while j < k { prev.push(costs[0][j]); j += 1; }...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [min_cost_ii]: 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 -- [min_cost_ii]: function definitions module public import Aeneas public import Aegis.MinCostIi.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.MinCostIi.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.MinCostIi.min_cost_ii (Slice.from [(alloc.vec.Vec.from [1#i64, 3#i64] (by scalar_tac) : alloc.vec.Vec Std.I64), (alloc.vec.Vec.from [2#i64, 4#i64] (by ...
[ { "input": "[[[1, 3], [2, 4]]]", "output": "5" }, { "input": "[[[1, 5, 3], [2, 9, 4]]]", "output": "5" }, { "input": "[[[7, 6, 2], [4, 3, 9], [8, 5, 6]]]", "output": "11" }, { "input": "[[[7, 6, 2], [3, 4, 1], [8, 5, 7]]]", "output": "10" }, { "input": "[[[7, 6, 2...
65
false
65
verified
10
10
2
4,348
[ { "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.MinCostIi.Code.Funs /-! # Specifications of `Aegis.MinCostIi.min_cost_ii` LeetCode problem `paint-house-ii`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.MinCostIi def nrows (costs : Slice (alloc.vec.Vec Std.I64)) : Nat := co...
10
h-index
274
Medium
[ "Array", "Counting Sort", "Sorting" ]
Given an array of integers citations where citations[i] is the number of citations a researcher received for their ith paper, return the researcher's h-index. According to the definition of h-index on Wikipedia: The h-index is defined as the maximum value of h such that the given researcher has published at least h pap...
hIndex(citations: list_int) -> int
pub fn h_index(citations: &[i64]) -> i64
Aegis.HIndex.h_index
pub fn h_index(citations: &[i64]) -> i64 { let n = citations.len(); let mut counts: Vec<i64> = Vec::new(); let mut i: usize = 0; while i <= n { counts.push(0); i += 1; } let n_i64 = n as i64; let mut idx: usize = 0; while idx < n { let c = citations[idx]; ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [h_index]: 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 -- [h_index]: function definitions module public import Aeneas public import Aegis.HIndex.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.unus...
import Aegis.HIndex.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.HIndex.h_index (Slice.from [1#i64] (by scalar_tac) : Slice Std.I64)) (1#i64))}") #eval (s!"CASE 1 {(Result.reducesTo (Aegis.HIndex.h_index (Slice.from [0#...
[ { "input": "[[1]]", "output": "1" }, { "input": "[[0]]", "output": "0" }, { "input": "[[11, 15]]", "output": "2" }, { "input": "[[1, 3, 1]]", "output": "1" }, { "input": "[[1000, 1000, 1000]]", "output": "3" }, { "input": "[[10, 10, 10, 10]]", "out...
79
false
79
verified
10
10
1
1,060
[ { "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.HIndex.Code.Funs /-! # Specifications of `Aegis.HIndex.h_index` LeetCode problem `h-index`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result set_option autoImplicit false namespace AegisSpec.HIndex def countGe (xs : List Aeneas.Std.I64) (h : ℤ) : ℕ := (x...
12
h-index-ii
275
Medium
[ "Array", "Binary Search" ]
Given an array of integers citations where citations[i] is the number of citations a researcher received for their ith paper and citations is sorted in ascending order, return the researcher's h-index. According to the definition of h-index on Wikipedia: The h-index is defined as the maximum value of h such that the gi...
hIndex(citations: list_int) -> int
pub fn h_index(citations: &[i64]) -> i64
Aegis.HIndex.h_index
pub fn h_index(citations: &[i64]) -> i64 { let n: usize = citations.len(); // h-index cannot exceed 1000 because citations[i] <= 1000. // Use an exclusive upper bound 1001. let mut lo: usize = 0; let mut hi: usize = 1001; let mut lo64: i64 = 0; let mut hi64: i64 = 1001; let mut ans: i...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [h_index]: 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 -- [h_index]: function definitions module public import Aeneas public import Aegis.HIndex.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.unus...
import Aegis.HIndex.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 aegisCase "eva...
[ { "input": "[[1]]", "output": "1" }, { "input": "[[100]]", "output": "1" }, { "input": "[[0]]", "output": "0" }, { "input": "[[11, 15]]", "output": "2" }, { "input": "[[1, 2, 100]]", "output": "2" }, { "input": "[[0, 0, 0, 0]]", "output": "0" }, ...
80
false
80
verified
10
10
2
14,747
[ { "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.HIndex.Code.Funs /-! # Specifications of `Aegis.HIndex.h_index` LeetCode problem `h-index-ii`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.HIndex def C (citations : Slice Std.I64) (h : Int) : Nat := (citations.val.filter (fun c =>...
11
paint-fence
276
Medium
[ "Dynamic Programming" ]
You are painting a fence of n posts with k different colors. You must paint the posts following these rules: Every post must be painted exactly one color. There cannot be three or more consecutive posts with the same color. Given the two integers n and k, return the number of ways you can paint the fence.   Example 1...
numWays(n: int, k: int) -> int
pub fn num_ways(n: i64, k: i64) -> i64
Aegis.NumWays.num_ways
pub fn num_ways(n: i64, k: i64) -> i64 { if n <= 0 { return 0; } if n == 1 { return k; } if n == 2 { return k * k; } let mut prev2: i64 = k; let mut prev1: i64 = k * k; let mut i: i64 = 3; while i <= n { let cur: i64 = (k - 1) * (prev1 + prev2); ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [num_ways]: 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 -- [num_ways]: function definitions module public import Aeneas public import Aegis.NumWays.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.NumWays.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.NumWays.num_ways 15#i64 2#i64) (1974#i64))}") #eval (s!"CASE 1 {(Result.reducesTo (Aegis.NumWays.num_ways 1#i64 1#i64) (1#i64))}") #eval (s!"CASE 2 {(Res...
[ { "input": "[15, 2]", "output": "1974" }, { "input": "[1, 1]", "output": "1" }, { "input": "[3, 2]", "output": "6" }, { "input": "[5, 1]", "output": "0" }, { "input": "[10, 3]", "output": "27408" }, { "input": "[7, 2]", "output": "42" }, { ...
49
false
49
verified
10
10
1
1,226
[ { "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.NumWays.Code.Funs /-! # Specifications of `Aegis.NumWays.num_ways` LeetCode problem `paint-fence`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.NumWays abbrev Painting (n k : ℕ) : Type := Fin n → Fin k def HasTriple {n k : ℕ} ...
14
perfect-squares
279
Medium
[ "Breadth-First Search", "Math", "Dynamic Programming" ]
Given an integer n, return the least number of perfect square numbers that sum to n. A perfect square is an integer that is the square of an integer; in other words, it is the product of some integer with itself. For example, 1, 4, 9, and 16 are perfect squares while 3 and 11 are not.   Example 1: Input: n = 12 Output...
numSquares(n: int) -> int
pub fn num_squares(n: i64) -> i64
Aegis.NumSquares.num_squares
pub fn num_squares(n: i64) -> i64 { if n <= 0 { return 0; } // Compute floor(sqrt(n)). let mut b: i64 = 0; while (b + 1) * (b + 1) <= n { b += 1; } // If n is itself a perfect square, the answer is 1. if b * b == n { return 1; } // Legendre's three-squa...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [num_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 linter.st...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [num_squares]: function definitions module public import Aeneas public import Aegis.NumSquares.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.NumSquares.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 aegisCase ...
[ { "input": "[625]", "output": "1" }, { "input": "[8]", "output": "2" }, { "input": "[100]", "output": "1" }, { "input": "[4]", "output": "1" }, { "input": "[12]", "output": "3" }, { "input": "[16]", "output": "1" }, { "input": "[17]", "...
75
false
75
verified
10
10
2
5,219
[ { "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.NumSquares.Code.Funs /-! # Specifications of `Aegis.NumSquares.num_squares` LeetCode problem `perfect-squares`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.NumSquares def IsSumOfSq (n k : ℤ) : Prop := ∃ l : List ℤ, (l.length...
14
word-pattern
290
Easy
[ "Hash Table", "String" ]
Given a pattern and a string s, find if s follows the same pattern. Here follow means a full match, such that there is a bijection between a letter in pattern and a non-empty word in s. Specifically: Each letter in pattern maps to exactly one unique word in s. Each unique word in s maps to exactly one letter in patter...
wordPattern(pattern: str, s: str) -> bool
pub fn word_pattern(pattern: &[u8], s: &[u8]) -> bool
Aegis.WordPattern.word_pattern
pub fn word_pattern(pattern: &[u8], s: &[u8]) -> bool { let mut starts: Vec<i64> = Vec::new(); let mut ends: Vec<i64> = Vec::new(); let mut i: usize = 0; while i < s.len() { if s[i] == b' ' { i += 1; } else { let st: usize = i; while i < s.len() && s[...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [word_pattern]: 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 -- [word_pattern]: function definitions module public import Aeneas public import Aegis.WordPattern.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.WordPattern.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.WordPattern.word_pattern (Slice.from [97#u8, 97#u8, 97#u8, 97#u8] (by scalar_tac) : Slice Std.U8) (Slice.from [100#u8, 111#u8, 103#u8, 32#u8, 99#u8, ...
[ { "input": "[\"aaaa\", \"dog cat cat dog\"]", "output": "false" }, { "input": "[\"abc\", \"dog dog dog\"]", "output": "false" }, { "input": "[\"abcd\", \"dog cat elephant fish\"]", "output": "true" }, { "input": "[\"aaaa\", \"dog dog dog dog\"]", "output": "true" }, {...
147
false
147
verified
10
10
2
4,882
[ { "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.WordPattern.Code.Funs /-! # Specifications of `Aegis.WordPattern.word_pattern` LeetCode problem `word-pattern`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.WordPattern namespace AegisSpec.WordPattern def bytes (sl : Slice Std.U8) : List Nat ...
10
word-pattern-ii
291
Medium
[ "Hash Table", "String", "Backtracking" ]
Given a pattern and a string s, return true if s matches the pattern. A string s matches a pattern if there is some bijective mapping of single characters to non-empty strings such that if each character in pattern is replaced by the string it maps to, then the resulting string is s. A bijective mapping means that no t...
wordPatternMatch(pattern: str, s: str) -> bool
pub fn word_pattern_match(pattern: &[u8], s: &[u8]) -> bool
Aegis.WordPatternMatch.word_pattern_match
pub fn word_pattern_match(pattern: &[u8], s: &[u8]) -> bool { let n = pattern.len(); let m = s.len(); // map[c] is the string currently assigned to byte c. // An empty Vec means c is still unassigned. let mut map: Vec<Vec<u8>> = Vec::new(); let mut i = 0; while i < 256 { map.push(Ve...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [word_pattern_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 li...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [word_pattern_match]: function definitions module public import Aeneas public import Aegis.WordPatternMatch.Code.Types public import Aegis.WordPatternMatch.Code.FunsExternal @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.d...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [word_pattern_match]: external functions. -- This is a template file: rename it to "FunsExternal.lean" and fill the holes. module public import Aeneas public import Aegis.WordPatternMatch.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow ...
import Aegis.WordPatternMatch.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.WordPatternMatch.word_pattern_match (Slice.from [97#u8, 98#u8] (by scalar_tac) : Slice Std.U8) (Slice.from [100#u8, 111#u8, 103#u8, 100#u8, 111#...
[ { "input": "[\"ab\", \"dogdog\"]", "output": "true" }, { "input": "[\"aaaa\", \"catcatcatcat\"]", "output": "true" }, { "input": "[\"aabb\", \"xyzabcxzyabc\"]", "output": "false" }, { "input": "[\"abcd\", \"oneonetwothree\"]", "output": "true" }, { "input": "[\"ab...
150
false
150
verified
10
10
1
15,699
[ { "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.WordPatternMatch.Code.Funs /-! # Specifications of `Aegis.WordPatternMatch.word_pattern_match` LeetCode problem `word-pattern-ii`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.WordPatternMatch open Aegis.WordPatternMatch def s...
12
nim-game
292
Easy
[ "Brainteaser", "Math", "Game Theory" ]
You are playing the following Nim Game with your friend: Initially, there is a heap of stones on the table. You and your friend will alternate taking turns, and you go first. On each turn, the person whose turn it is will remove 1 to 3 stones from the heap. The one who removes the last stone is the winner. Given n, t...
canWinNim(n: int) -> bool
pub fn can_win_nim(n: i64) -> bool
Aegis.CanWinNim.can_win_nim
pub fn can_win_nim(n: i64) -> bool { n % 4 != 0 }
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [can_win_nim]: 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 -- [can_win_nim]: function definitions module public import Aeneas public import Aegis.CanWinNim.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.CanWinNim.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.CanWinNim.can_win_nim 3#i64) (true))}") #eval (s!"CASE 1 {(Result.reducesTo (Aegis.CanWinNim.can_win_nim 21#i64) (true))}") #eval (s!"CASE 2 {(Result.r...
[ { "input": "[3]", "output": "true" }, { "input": "[21]", "output": "true" }, { "input": "[2147483647]", "output": "true" }, { "input": "[104]", "output": "false" }, { "input": "[100]", "output": "false" }, { "input": "[10]", "output": "true" }, ...
114
false
114
verified
10
10
1
156
[ { "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.CanWinNim.Code.Funs /-! # Specifications of `Aegis.CanWinNim.can_win_nim` LeetCode problem `nim-game`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.CanWinNim open Aegis.CanWinNim /-- The function returns an ok Boolean r (it do...
6
flip-game
293
Easy
[ "String" ]
You are playing a Flip Game with your friend. You are given a string currentState that contains only '+' and '-'. You and your friend take turns to flip two consecutive "++" into "--". The game ends when a person can no longer make a move, and therefore the other person will be the winner. Return all possible states of...
generatePossibleNextMoves(currentState: str) -> list_str
pub fn generate_possible_next_moves(currentState: &[u8]) -> Vec<Vec<u8>>
Aegis.GeneratePossibleNextMoves.generate_possible_next_moves
pub fn generate_possible_next_moves(currentState: &[u8]) -> Vec<Vec<u8>> { let n = currentState.len(); let mut result: Vec<Vec<u8>> = Vec::new(); let mut i: usize = 0; while i + 1 < n { if currentState[i] == b'+' && currentState[i + 1] == b'+' { let mut next_state: Vec<u8> = Vec::ne...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [generate_possible_next_moves]: 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...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [generate_possible_next_moves]: function definitions module public import Aeneas public import Aegis.GeneratePossibleNextMoves.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter....
import Aegis.GeneratePossibleNextMoves.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(match (Aegis.GeneratePossibleNextMoves.generate_possible_next_moves (Slice.from [43#u8] (by scalar_tac) : Slice Std.U8)).match with | .ok r => r.val.isPerm ((a...
[ { "input": "[\"+\"]", "output": "[]" }, { "input": "[\"+-+--+-+\"]", "output": "[]" }, { "input": "[\"----\"]", "output": "[]" }, { "input": "[\"+-+--+\"]", "output": "[]" }, { "input": "[\"+-+-+\"]", "output": "[]" }, { "input": "[\"-+-+\"]", "out...
129
true
129
verified
10
10
5
91,466
[ { "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.GeneratePossibleNextMoves.Code.Funs /-! # Specifications of `Aegis.GeneratePossibleNextMoves.generate_possible_next_moves` LeetCode problem `flip-game`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.GeneratePossibleNextMoves def b...
13
flip-game-ii
294
Medium
[ "Memoization", "Math", "Dynamic Programming", "Backtracking", "Game Theory" ]
You are playing a Flip Game with your friend. You are given a string currentState that contains only '+' and '-'. You and your friend take turns to flip two consecutive "++" into "--". The game ends when a person can no longer make a move, and therefore the other person will be the winner. Return true if the starting p...
canWin(currentState: str) -> bool
pub fn can_win(currentState: &[u8]) -> bool
Aegis.CanWin.can_win
fn compute_grundy(n: usize) -> Vec<i64> { let mut g: Vec<i64> = Vec::new(); g.push(0); if n >= 1 { g.push(0); } let mut len = 2; while len <= n { let mut seen: Vec<bool> = Vec::new(); let mut t = 0; while t < 256 { seen.push(false); t += 1...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [can_win]: 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 -- [can_win]: function definitions module public import Aeneas public import Aegis.CanWin.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.unus...
import Aegis.CanWin.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.CanWin.can_win (Slice.from [43#u8, 45#u8, 43#u8, 45#u8, 43#u8, 45#u8, 45#u8] (by scalar_tac) : Slice Std.U8)) (false))}") #eval (s!"CASE 1 {(Result.reduce...
[ { "input": "[\"+-+-+--\"]", "output": "false" }, { "input": "[\"-+-\"]", "output": "false" }, { "input": "[\"++--\"]", "output": "true" }, { "input": "[\"++-++\"]", "output": "false" }, { "input": "[\"++++\"]", "output": "true" }, { "input": "[\"+++\"]...
137
false
137
verified
10
10
1
3,944
[ { "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.CanWin.Code.Funs /-! # Specifications of `Aegis.CanWin.can_win` LeetCode problem `flip-game-ii`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.CanWin namespace AegisSpec.CanWin abbrev plusByte : Std.U8 := 43#u8 abbrev minusByte : Std.U8 := 45...
9
best-meeting-point
296
Hard
[ "Array", "Math", "Matrix", "Sorting" ]
Given an m x n binary grid grid where each 1 marks the home of one friend, return the minimal total travel distance. The total travel distance is the sum of the distances between the houses of the friends and the meeting point. The distance is calculated using Manhattan Distance, where distance(p1, p2) = |p2.x - p1.x| ...
minTotalDistance(grid: list_list_int) -> int
pub fn min_total_distance(grid: &[Vec<i64>]) -> i64
Aegis.MinTotalDistance.min_total_distance
pub fn min_total_distance(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 row_count: Vec<i64> = Vec::new(); let mut i: usize = 0; while i < m { row_count.push(0); i += 1; ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [min_total_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 li...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [min_total_distance]: function definitions module public import Aeneas public import Aegis.MinTotalDistance.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.MinTotalDistance.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.MinTotalDistance.min_total_distance (Slice.from [(alloc.vec.Vec.from [1#i64, 1#i64] (by scalar_tac) : alloc.vec.Vec Std.I64)] (by scalar_tac) : ...
[ { "input": "[[[1, 1]]]", "output": "1" }, { "input": "[[[1, 1, 1, 1, 1], [1, 1, 1, 1, 1]]]", "output": "17" }, { "input": "[[[1, 0, 0, 0, 1], [0, 0, 0, 0, 0], [0, 0, 1, 0, 0]]]", "output": "6" }, { "input": "[[[1, 0, 1, 0, 1], [0, 0, 0, 0, 0], [0, 0, 1, 0, 0]]]", "output"...
68
false
68
verified
10
10
1
3,702
[ { "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.MinTotalDistance.Code.Funs /-! # Specifications of `Aegis.MinTotalDistance.min_total_distance` LeetCode problem `best-meeting-point`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.MinTotalDistance open Aegis.MinTotalDistance abbrev G...
13
binary-tree-longest-consecutive-sequence
298
Medium
[ "Tree", "Depth-First Search", "Binary Tree" ]
Given the root of a binary tree, return the length of the longest consecutive sequence path. A consecutive sequence path is a path where the values increase by one along the path. Note that the path can start at any node in the tree, and you cannot go from a node to its parent in the path.   Example 1: Input: root = ...
longestConsecutive(root: tree) -> int
pub fn longest_consecutive(root: &Tree) -> i64
Aegis.LongestConsecutive.longest_consecutive
fn dfs(node: &Tree, prev: i64, has_prev: bool, prev_len: i64) -> i64 { match node { Tree::Null => 0, Tree::Node(v, left, right) => { let val = *v; let mut cur = 1; if has_prev && val == prev + 1 { cur = prev_len + 1; } let...
-- 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": "2" }, { "input": "[[1, 3, 2]]", "output": "2" }, { "input": "[[1, 2, 3, 4, 5]]", "output": "2" }, { "input": "[[30, 29, 31, 28, 32, 27, 33, 26, 34, 25, 35, 24, 36, 23, 37]]", "output": "...
12
false
12
verified
10
10
1
2,528
[ { "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`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.LongestConsecutive open Aeg...
14
longest-increasing-subsequence
300
Medium
[ "Array", "Binary Search", "Dynamic Programming" ]
Given an integer array nums, return the length of the longest strictly increasing subsequence.   Example 1: Input: nums = [10,9,2,5,3,7,101,18] Output: 4 Explanation: The longest increasing subsequence is [2,3,7,101], therefore the length is 4. Example 2: Input: nums = [0,1,0,3,2,3] Output: 4 Example 3: Input: num...
lengthOfLIS(nums: list_int) -> int
pub fn length_of_lis(nums: &[i64]) -> i64
Aegis.LengthOfLis.length_of_lis
pub fn length_of_lis(nums: &[i64]) -> i64 { let n = nums.len(); if n == 0 { return 0; } let mut dp: Vec<i64> = Vec::new(); let mut i: usize = 0; while i < n { dp.push(1); i += 1; } i = 1; while i < n { let mut j: usize = 0; while j < i { ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [length_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 linter....
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [length_of_lis]: function definitions module public import Aeneas public import Aegis.LengthOfLis.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.LengthOfLis.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.LengthOfLis.length_of_lis (Slice.from [1#i64] (by scalar_tac) : Slice Std.I64)) (1#i64))}") #eval (s!"CASE 1 {(Result.reducesTo (Aegis.LengthOfLis.le...
[ { "input": "[[1]]", "output": "1" }, { "input": "[[0, -1, 1]]", "output": "2" }, { "input": "[[5, 4, 3, 2, 1]]", "output": "1" }, { "input": "[[1, 3, 5, 4, 7]]", "output": "4" }, { "input": "[[1, 2, 3, 4, 5]]", "output": "5" }, { "input": "[[1, 3, 5, 7...
134
false
134
verified
10
10
1
572
[ { "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.LengthOfLis.Code.Funs /-! # Specifications of `Aegis.LengthOfLis.length_of_lis` LeetCode problem `longest-increasing-subsequence`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.LengthOfLis def i64OfInt (x : Int) : I64 := ⟨BitVec.ofInt...
13
number-of-islands-ii
305
Hard
[ "Union Find", "Array", "Hash Table" ]
You are given an empty 2D binary grid grid of size m x n. The grid represents a map where 0's represent water and 1's represent land. Initially, all the cells of grid are water cells (i.e., all the cells are 0's). We may perform an add land operation which turns the water at position into a land. You are given an array...
numIslands2(m: int, n: int, positions: list_list_int) -> list_int
pub fn num_islands2(m: i64, n: i64, positions: &[Vec<i64>]) -> Vec<i64>
Aegis.NumIslands2.num_islands2
fn uf_find(parent: &mut Vec<i64>, x: usize) -> usize { let mut root = x; while parent[root] != root as i64 { root = parent[root] as usize; } let mut cur = x; while parent[cur] != cur as i64 { let next = parent[cur] as usize; parent[cur] = root as i64; cur = next; ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [num_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 linter.s...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [num_islands2]: function definitions module public import Aeneas public import Aegis.NumIslands2.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.NumIslands2.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.NumIslands2.num_islands2 1#i64 1#i64 (Slice.from [(alloc.vec.Vec.from [0#i64, 0#i64] (by scalar_tac) : alloc.vec.Vec Std.I64)] (by scalar_tac) : Slic...
[ { "input": "[1, 1, [[0, 0]]]", "output": "[1]" }, { "input": "[2, 2, [[0, 0], [1, 1], [0, 1], [1, 0]]]", "output": "[1, 2, 1, 1]" }, { "input": "[3, 3, [[0, 0], [0, 1], [1, 0], [1, 1]]]", "output": "[1, 1, 1, 1]" }, { "input": "[3, 3, [[0, 0], [0, 1], [1, 0], [2, 2]]]", "...
81
false
81
verified
10
10
1
3,527
[ { "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.NumIslands2.Code.Funs /-! # Specifications of `Aegis.NumIslands2.num_islands2` LeetCode problem `number-of-islands-ii`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Classical open Aegis.NumIslands2 (num_islands2) namespace AegisSpec.NumIslands2 abb...
14
additive-number
306
Medium
[ "String", "Backtracking" ]
An additive number is a string whose digits can form an additive sequence. A valid additive sequence should contain at least three numbers. Except for the first two numbers, each subsequent number in the sequence must be the sum of the preceding two. Given a string containing only digits, return true if it is an additi...
isAdditiveNumber(num: str) -> bool
pub fn is_additive_number(num: &[u8]) -> bool
Aegis.IsAdditiveNumber.is_additive_number
pub fn is_additive_number(num: &[u8]) -> bool { let n = num.len(); if n < 3 { return false; } let mut result: bool = false; let mut stop: bool = false; let mut first_end: usize = 1; while first_end <= n - 2 && !stop && !result { if first_end > 1 && num[0] == b'0' { ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [is_additive_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 li...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [is_additive_number]: function definitions module public import Aeneas public import Aegis.IsAdditiveNumber.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.IsAdditiveNumber.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.IsAdditiveNumber.is_additive_number (Slice.from [49#u8, 48#u8, 48#u8, 48#u8, 48#u8, 48#u8, 48#u8, 48#u8, 48#u8, 48#u8, 48#u8, 48#u8, 48#u8, 48#u...
[ { "input": "[\"100000000000000000000000000000000000\"]", "output": "false" }, { "input": "[\"1203\"]", "output": "false" }, { "input": "[\"12358132134558914423337761098715972584467376111128914423337761098715972584467376\"]", "output": "false" }, { "input": "[\"000\"]", "o...
93
false
93
verified
10
10
2
19,447
[ { "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.IsAdditiveNumber.Code.Funs /-! # Specifications of `Aegis.IsAdditiveNumber.is_additive_number` LeetCode problem `additive-number`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.IsAdditiveNumber def byteAt (bs : List Aeneas.Std.U8)...
13
best-time-to-buy-and-sell-stock-with-cooldown
309
Medium
[ "Array", "Dynamic Programming" ]
You are given an array prices where prices[i] is the price of a given stock on the ith day. Find the maximum profit you can achieve. You may complete as many transactions as you like (i.e., buy one and sell one share of the stock multiple times) with the following restrictions: After you sell your stock, you cannot bu...
maxProfit(prices: list_int) -> int
pub fn max_profit(prices: &[i64]) -> i64
Aegis.MaxProfit.max_profit
pub fn max_profit(prices: &[i64]) -> i64 { let n = prices.len(); if n == 0 { return 0; } let neg_inf: i64 = -1000000000; let mut hold: i64 = neg_inf; let mut sold: i64 = neg_inf; let mut rest: i64 = 0; let mut i: usize = 0; while i < n { let p = prices[i]; ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [max_profit]: 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 -- [max_profit]: function definitions module public import Aeneas public import Aegis.MaxProfit.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.MaxProfit.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.MaxProfit.max_profit (Slice.from [1#i64] (by scalar_tac) : Slice Std.I64)) (0#i64))}") #eval (s!"CASE 1 {(Result.reducesTo (Aegis.MaxProfit.max_profit ...
[ { "input": "[[1]]", "output": "0" }, { "input": "[[1, 2, 4]]", "output": "3" }, { "input": "[[3, 2, 1]]", "output": "0" }, { "input": "[[5, 4, 3, 2, 1]]", "output": "0" }, { "input": "[[1, 2, 3, 4, 5]]", "output": "4" }, { "input": "[[1, 2, 3, 0, 2]]",...
108
false
108
verified
10
10
1
2,584
[ { "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.MaxProfit.Code.Funs /-! # Specifications of `Aegis.MaxProfit.max_profit` LeetCode problem `best-time-to-buy-and-sell-stock-with-cooldown`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.MaxProfit open Aegis.MaxProfit def valAt (l : Li...
14
sparse-matrix-multiplication
311
Medium
[ "Array", "Hash Table", "Matrix" ]
Given two sparse matrices mat1 of size m x k and mat2 of size k x n, return the result of mat1 x mat2. You may assume that multiplication is always possible.   Example 1: Input: mat1 = [[1,0,0],[-1,0,3]], mat2 = [[7,0,0],[0,0,0],[0,0,1]] Output: [[7,0,0],[-7,0,3]] Example 2: Input: mat1 = [[0]], mat2 = [[0]] Output...
multiply(mat1: list_list_int, mat2: list_list_int) -> list_list_int
pub fn multiply(mat1: &[Vec<i64>], mat2: &[Vec<i64>]) -> Vec<Vec<i64>>
Aegis.Multiply.multiply
pub fn multiply(mat1: &[Vec<i64>], mat2: &[Vec<i64>]) -> Vec<Vec<i64>> { let m = mat1.len(); if m == 0 { return Vec::new(); } let k = mat1[0].len(); let n = mat2[0].len(); let mut out: Vec<Vec<i64>> = Vec::new(); let mut i = 0; while i < m { let mut row: Vec<i64> = Vec...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [multiply]: 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 -- [multiply]: function definitions module public import Aeneas public import Aegis.Multiply.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.u...
import Aegis.Multiply.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.Multiply.multiply (Slice.from [(alloc.vec.Vec.from [0#i64] (by scalar_tac) : alloc.vec.Vec Std.I64)] (by scalar_tac) : Slice (alloc.vec.Vec Std.I64)) (S...
[ { "input": "[[[0]], [[0]]]", "output": "[[0]]" }, { "input": "[[[1, 2], [3, 4]], [[5, 6], [7, 8]]]", "output": "[[19, 22], [43, 50]]" }, { "input": "[[[-1, 2], [-3, 4]], [[5, 6], [7, 8]]]", "output": "[[9, 10], [13, 14]]" }, { "input": "[[[1, 2, 3], [4, 5, 6]], [[7, 8], [9, 1...
88
false
88
verified
10
10
1
721
[ { "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.Multiply.Code.Funs /-! # Specifications of `Aegis.Multiply.multiply` LeetCode problem `sparse-matrix-multiplication`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.Multiply def eltList (rows : List (alloc.vec.Vec Std.I64)) (i j : Nat)...
10
burst-balloons
312
Hard
[ "Array", "Dynamic Programming" ]
You are given n balloons, indexed from 0 to n - 1. Each balloon is painted with a number on it represented by an array nums. You are asked to burst all the balloons. If you burst the ith balloon, you will get nums[i - 1] * nums[i] * nums[i + 1] coins. If i - 1 or i + 1 goes out of bounds of the array, then treat it as ...
maxCoins(nums: list_int) -> int
pub fn max_coins(nums: &[i64]) -> i64
Aegis.MaxCoins.max_coins
pub fn max_coins(nums: &[i64]) -> i64 { let n: usize = nums.len(); if n == 0 { return 0; } let m: usize = n + 2; let mut a: Vec<i64> = Vec::new(); a.push(1); let mut p: usize = 0; while p < n { a.push(nums[p]); p += 1; } a.push(1); let total: usize ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [max_coins]: 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_coins]: function definitions module public import Aeneas public import Aegis.MaxCoins.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.MaxCoins.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.MaxCoins.max_coins (Slice.from [1#i64] (by scalar_tac) : Slice Std.I64)) (1#i64))}") #eval (s!"CASE 1 {(Result.reducesTo (Aegis.MaxCoins.max_coins (Slic...
[ { "input": "[[1]]", "output": "1" }, { "input": "[[100]]", "output": "100" }, { "input": "[[1, 5]]", "output": "10" }, { "input": "[[0, 0, 0]]", "output": "0" }, { "input": "[[3, 1, 5, 8]]", "output": "167" }, { "input": "[[10, 10, 10, 10]]", "outp...
96
false
96
verified
10
10
1
2,643
[ { "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.MaxCoins.Code.Funs /-! # Specifications of `Aegis.MaxCoins.max_coins` LeetCode problem `burst-balloons`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.MaxCoins namespace AegisSpec.MaxCoins def entries (nums : Slice I64) : List ℤ := nums.val.ma...
16
super-ugly-number
313
Medium
[ "Array", "Math", "Dynamic Programming" ]
A super ugly number is a positive integer whose prime factors are in the array primes. Given an integer n and an array of integers primes, return the nth super ugly number. The nth super ugly number is guaranteed to fit in a 32-bit signed integer.   Example 1: Input: n = 12, primes = [2,7,13,19] Output: 32 Explanation...
nthSuperUglyNumber(n: int, primes: list_int) -> int
pub fn nth_super_ugly_number(n: i64, primes: &[i64]) -> i64
Aegis.NthSuperUglyNumber.nth_super_ugly_number
pub fn nth_super_ugly_number(n: i64, primes: &[i64]) -> i64 { let n_usize: usize = n as usize; let k: usize = primes.len(); let mut ugly: Vec<i64> = Vec::new(); ugly.push(1); let mut idx: Vec<usize> = Vec::new(); let mut j: usize = 0; while j < k { idx.push(0); j = j + 1; ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [nth_super_ugly_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...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [nth_super_ugly_number]: function definitions module public import Aeneas public import Aegis.NthSuperUglyNumber.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand fa...
import Aegis.NthSuperUglyNumber.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.NthSuperUglyNumber.nth_super_ugly_number 2#i64 (Slice.from [2#i64, 7#i64] (by scalar_tac) : Slice Std.I64)) (2#i64))}") #eval (s!"CASE 1 {(Res...
[ { "input": "[2, [2, 7]]", "output": "2" }, { "input": "[5, [2, 7, 11]]", "output": "8" }, { "input": "[15, [3, 5, 7]]", "output": "81" }, { "input": "[10, [2, 3, 5]]", "output": "12" }, { "input": "[1, [2, 3, 5]]", "output": "1" }, { "input": "[1000, [...
95
false
95
verified
10
10
1
2,378
[ { "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.NthSuperUglyNumber.Code.Funs /-! # Specifications of `Aegis.NthSuperUglyNumber.nth_super_ugly_number` LeetCode problem `super-ugly-number`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.NthSuperUglyNumber namespace AegisSpec.NthSuperUglyNum...
9
count-of-smaller-numbers-after-self
315
Hard
[ "Binary Indexed Tree", "Segment Tree", "Array", "Binary Search", "Divide and Conquer", "Ordered Set", "Merge Sort" ]
Given an integer array nums, return an integer array counts where counts[i] is the number of smaller elements to the right of nums[i].   Example 1: Input: nums = [5,2,6,1] Output: [2,1,1,0] Explanation: To the right of 5 there are 2 smaller elements (2 and 1). To the right of 2 there is only 1 smaller element (1). To ...
countSmaller(nums: list_int) -> list_int
pub fn count_smaller(nums: &[i64]) -> Vec<i64>
Aegis.CountSmaller.count_smaller
pub fn count_smaller(nums: &[i64]) -> Vec<i64> { let n = nums.len(); let mut result: Vec<i64> = Vec::new(); if n == 0 { return result; } let mut i: usize = 0; while i < n { result.push(0); i += 1; } let mut vals: Vec<i64> = Vec::new(); i = 0; while i < ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [count_smaller]: 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 -- [count_smaller]: function definitions module public import Aeneas public import Aegis.CountSmaller.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.CountSmaller.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.CountSmaller.count_smaller (Slice.from [(-1)#i64] (by scalar_tac) : Slice Std.I64)) ((alloc.vec.Vec.from [0#i64] (by scalar_tac) : alloc.vec.Vec Std...
[ { "input": "[[-1]]", "output": "[0]" }, { "input": "[[1]]", "output": "[0]" }, { "input": "[[-1, -1]]", "output": "[0, 0]" }, { "input": "[[3, 2, 1]]", "output": "[2, 1, 0]" }, { "input": "[[1, 2, 3]]", "output": "[0, 0, 0]" }, { "input": "[[2, 0, 1]]"...
135
false
135
verified
10
10
1
5,029
[ { "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.CountSmaller.Code.Funs /-! # Specifications of `Aegis.CountSmaller.count_smaller` LeetCode problem `count-of-smaller-numbers-after-self`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.CountSmaller def valAt (l : List Std.I64) (j :...
10
shortest-distance-from-all-buildings
317
Hard
[ "Breadth-First Search", "Array", "Matrix" ]
You are given an m x n grid grid of values 0, 1, or 2, where: each 0 marks an empty land that you can pass by freely, each 1 marks a building that you cannot pass through, and each 2 marks an obstacle that you cannot pass through. You want to build a house on an empty land that reaches all buildings in the shortest t...
shortestDistance(grid: list_list_int) -> int
pub fn shortest_distance(grid: &[Vec<i64>]) -> i64
Aegis.ShortestDistance.shortest_distance
pub fn shortest_distance(grid: &[Vec<i64>]) -> i64 { let m = grid.len(); if m == 0 { return -1; } let n = grid[0].len(); if n == 0 { return -1; } let mut total: Vec<Vec<i64>> = Vec::new(); let mut reach: Vec<Vec<i64>> = Vec::new(); let mut i = 0; while i < m { ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [shortest_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 lin...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [shortest_distance]: function definitions module public import Aeneas public import Aegis.ShortestDistance.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.ShortestDistance.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.ShortestDistance.shortest_distance (Slice.from [(alloc.vec.Vec.from [1#i64] (by scalar_tac) : alloc.vec.Vec Std.I64)] (by scalar_tac) : Slice (a...
[ { "input": "[[[1]]]", "output": "-1" }, { "input": "[[[1, 0]]]", "output": "1" }, { "input": "[[[1, 0, 1, 0, 1, 0, 1]]]", "output": "-1" }, { "input": "[[[0, 2, 1], [1, 0, 2], [0, 1, 0]]]", "output": "-1" }, { "input": "[[[0, 1, 0], [1, 0, 1], [0, 1, 0]]]", "o...
86
false
86
verified
10
10
1
5,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.ShortestDistance.Code.Funs /-! # Specifications of `Aegis.ShortestDistance.shortest_distance` LeetCode problem `shortest-distance-from-all-buildings`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Classical namespace AegisSpec.ShortestDistance def g...
10
maximum-product-of-word-lengths
318
Medium
[ "Bit Manipulation", "Array", "String" ]
Given a string array words, return the maximum value of length(word[i]) * length(word[j]) where the two words do not share common letters. If no such two words exist, return 0.   Example 1: Input: words = ["abcw","baz","foo","bar","xtfn","abcdef"] Output: 16 Explanation: The two words can be "abcw", "xtfn". Example 2...
maxProduct(words: list_str) -> int
pub fn max_product(words: &[Vec<u8>]) -> i64
Aegis.MaxProduct.max_product
pub fn max_product(words: &[Vec<u8>]) -> i64 { let n = words.len(); let mut masks: Vec<i64> = Vec::new(); let mut lens: Vec<i64> = Vec::new(); let mut i = 0; while i < n { let word = &words[i]; let mut mask: i64 = 0; let mut k = 0; while k < word.len() { ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [max_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 linter.st...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [max_product]: function definitions module public import Aeneas public import Aegis.MaxProduct.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.MaxProduct.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.MaxProduct.max_product (Slice.from [(alloc.vec.Vec.from [97#u8, 98#u8, 99#u8] (by scalar_tac) : alloc.vec.Vec Std.U8), (alloc.vec.Vec.from [100#u8, 10...
[ { "input": "[[\"abc\", \"def\", \"ghi\"]]", "output": "9" }, { "input": "[[\"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\", \"bbaacceegghhkkllmmnnooppqqrrssttuuvvwwxxyyzz\", \"ccaabbeegghhkkllmmnnooppqqrrssttuuvvwwxxyyzz\"]]", "output": "0" }, { "input": "[[\"abcdefghijklmnopqrs...
67
false
67
verified
10
10
1
2,021
[ { "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.MaxProduct.Code.Funs /-! # Specifications of `Aegis.MaxProduct.max_product` LeetCode problem `maximum-product-of-word-lengths`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.MaxProduct open Aegis.MaxProduct def letters (w : alloc.vec...
14
bulb-switcher
319
Medium
[ "Brainteaser", "Math" ]
There are n bulbs that are initially off. You first turn on all the bulbs, then you turn off every second bulb. On the third round, you toggle every third bulb (turning on if it's off or turning off if it's on). For the ith round, you toggle every i bulb. For the nth round, you only toggle the last bulb. Return the num...
bulbSwitch(n: int) -> int
pub fn bulb_switch(n: i64) -> i64
Aegis.BulbSwitch.bulb_switch
pub fn bulb_switch(n: i64) -> i64 { if n <= 0 { return 0; } let mut r: i64 = 0; while (r + 1) * (r + 1) <= n { r += 1; } r }
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [bulb_switch]: 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 -- [bulb_switch]: function definitions module public import Aeneas public import Aegis.BulbSwitch.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.BulbSwitch.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.BulbSwitch.bulb_switch 0#i64) (0#i64))}") #eval (s!"CASE 1 {(Result.reducesTo (Aegis.BulbSwitch.bulb_switch 3#i64) (1#i64))}") #eval (s!"CASE 2 {(Resu...
[ { "input": "[0]", "output": "0" }, { "input": "[3]", "output": "1" }, { "input": "[100]", "output": "10" }, { "input": "[4]", "output": "2" }, { "input": "[16]", "output": "4" }, { "input": "[9]", "output": "3" }, { "input": "[1000000]", ...
85
false
85
verified
10
10
1
619
[ { "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.BulbSwitch.Code.Funs /-! # Specifications of `Aegis.BulbSwitch.bulb_switch` LeetCode problem `bulb-switcher`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.BulbSwitch open Aegis.BulbSwitch (bulb_switch) def isSquare (z : ℤ) : Prop :=...
10
generalized-abbreviation
320
Medium
[ "Bit Manipulation", "String", "Backtracking" ]
A word's generalized abbreviation can be constructed by taking any number of non-overlapping and non-adjacent substrings and replacing them with their respective lengths. For example, "abcde" can be abbreviated into: "a3e" ("bcd" turned into "3") "1bcd1" ("a" and "e" both turned into "1") "5" ("abcde" turned into "...
generateAbbreviations(word: str) -> list_str
pub fn generate_abbreviations(word: &[u8]) -> Vec<Vec<u8>>
Aegis.GenerateAbbreviations.generate_abbreviations
fn append_number(out: &mut Vec<u8>, count: usize) { let mut digits: Vec<u8> = Vec::new(); let mut n = count; if n == 0 { digits.push(b'0'); } else { while n > 0 { let d = (n % 10) as u8; digits.push(b'0' + d); n = n / 10; } } let mut ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [generate_abbreviations]: 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 -- [generate_abbreviations]: function definitions module public import Aeneas public import Aegis.GenerateAbbreviations.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashComman...
import Aegis.GenerateAbbreviations.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.GenerateAbbreviations.generate_abbreviations (Slice.from [97#u8] (by scalar_tac) : Slice Std.U8)) ((alloc.vec.Vec.from [(alloc.vec.Vec.from...
[ { "input": "[\"a\"]", "output": "[\"a\", \"1\"]" }, { "input": "[\"ab\"]", "output": "[\"ab\", \"a1\", \"1b\", \"2\"]" }, { "input": "[\"abc\"]", "output": "[\"abc\", \"ab1\", \"a1c\", \"a2\", \"1bc\", \"1b1\", \"2c\", \"3\"]" }, { "input": "[\"qwen\"]", "output": "[\"qwe...
39
true
39
verified
10
10
1
6,598
[ { "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.GenerateAbbreviations.Code.Funs /-! # Specifications of `Aegis.GenerateAbbreviations.generate_abbreviations` LeetCode problem `generalized-abbreviation`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.GenerateAbbreviations def isDigitB...
14
coin-change
322
Medium
[ "Breadth-First Search", "Array", "Dynamic Programming" ]
You are given an integer array coins representing coins of different denominations and an integer amount representing a total amount of money. Return the fewest number of coins that you need to make up that amount. If that amount of money cannot be made up by any combination of the coins, return -1. You may assume that...
coinChange(coins: list_int, amount: int) -> int
pub fn coin_change(coins: &[i64], amount: i64) -> i64
Aegis.CoinChange.coin_change
fn gcd_i64(a0: i64, b0: i64) -> i64 { let mut a = a0; let mut b = b0; if a < 0 { a = -a; } if b < 0 { b = -b; } while b != 0 { let r = a % b; a = b; b = r; } a } fn mod_inv(a0: i64, m: i64) -> i64 { let mut old_r = a0 % m; let mut r = ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [coin_change]: 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 -- [coin_change]: function definitions module public import Aeneas public import Aegis.CoinChange.Code.Types public import Aegis.CoinChange.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 -- [coin_change]: external functions. -- This is a template file: rename it to "FunsExternal.lean" and fill the holes. module public import Aeneas public import Aegis.CoinChange.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_opt...
import Aegis.CoinChange.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 aegisCase ...
[ { "input": "[[1], 0]", "output": "0" }, { "input": "[[2], 3]", "output": "-1" }, { "input": "[[1], 10000]", "output": "10000" }, { "input": "[[7], 100]", "output": "-1" }, { "input": "[[5, 7], 15]", "output": "3" }, { "input": "[[3, 5], 11]", "outp...
127
false
127
verified
10
10
3
45,356
[ { "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.CoinChange.Code.Funs /-! # Specifications of `Aegis.CoinChange.coin_change` LeetCode problem `coin-change`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.CoinChange namespace AegisSpec.CoinChange def coinValue (coins : Slice Std.I64) (i ...
11
number-of-connected-components-in-an-undirected-graph
323
Medium
[ "Depth-First Search", "Breadth-First Search", "Union Find", "Graph" ]
You have a graph of n nodes. You are given an integer n and an array edges where edges[i] = [ai, bi] indicates that there is an edge between ai and bi in the graph. Return the number of connected components in the graph.   Example 1: Input: n = 5, edges = [[0,1],[1,2],[3,4]] Output: 2 Example 2: Input: n = 5, edge...
countComponents(n: int, edges: list_list_int) -> int
pub fn count_components(n: i64, edges: &[Vec<i64>]) -> i64
Aegis.CountComponents.count_components
fn find(parent: &mut Vec<i64>, x: i64) -> i64 { let mut r = x; while parent[r as usize] != r { r = parent[r as usize]; } let root = r; let mut y = x; while parent[y as usize] != root { let next = parent[y as usize]; parent[y as usize] = root; y = next; } ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [count_components]: 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_components]: function definitions module public import Aeneas public import Aegis.CountComponents.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.CountComponents.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.CountComponents.count_components 3#i64 (Slice.from [(alloc.vec.Vec.from [0#i64, 1#i64] (by scalar_tac) : alloc.vec.Vec Std.I64)] (by scalar_tac) ...
[ { "input": "[3, [[0, 1]]]", "output": "2" }, { "input": "[4, [[0, 1], [2, 3]]]", "output": "2" }, { "input": "[6, [[0, 1], [2, 3], [4, 5]]]", "output": "3" }, { "input": "[5, [[0, 1], [1, 2], [3, 4]]]", "output": "2" }, { "input": "[6, [[0, 1], [1, 2], [3, 4], [4,...
71
false
71
verified
10
10
1
1,795
[ { "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.CountComponents.Code.Funs /-! # Specifications of `Aegis.CountComponents.count_components` LeetCode problem `number-of-connected-components-in-an-undirected-graph`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.CountComponents open Classical na...
12
maximum-size-subarray-sum-equals-k
325
Medium
[ "Array", "Hash Table", "Prefix Sum" ]
Given an integer array nums and an integer k, return the maximum length of a subarray that sums to k. If there is not one, return 0 instead.   Example 1: Input: nums = [1,-1,5,-2,3], k = 3 Output: 4 Explanation: The subarray [1, -1, 5, -2] sums to 3 and is the longest. Example 2: Input: nums = [-2,-1,2,1], k = 1 Out...
maxSubArrayLen(nums: list_int, k: int) -> int
pub fn max_sub_array_len(nums: &[i64], k: i64) -> i64
Aegis.MaxSubArrayLen.max_sub_array_len
fn lower_bound(xs: &[i64], target: i64) -> usize { let mut lo: usize = 0; let mut hi: usize = xs.len(); while lo < hi { let mid = lo + (hi - lo) / 2; if xs[mid] < target { lo = mid + 1; } else { hi = mid; } } lo } fn merge_sort_i64(a: &mut V...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [max_sub_array_len]: 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_sub_array_len]: function definitions module public import Aeneas public import Aegis.MaxSubArrayLen.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.MaxSubArrayLen.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.MaxSubArrayLen.max_sub_array_len (Slice.from [1#i64, 0#i64, (-1)#i64] (by scalar_tac) : Slice Std.I64) 0#i64) (3#i64))}") #eval (s!"CASE 1 {(Resul...
[ { "input": "[[1, 0, -1], 0]", "output": "3" }, { "input": "[[-2, -1, 2, 1], 1]", "output": "2" }, { "input": "[[1, 2, 3, 4, 5], 100]", "output": "0" }, { "input": "[[5, 5, 5, 5, 5], 10]", "output": "2" }, { "input": "[[1, 2, 3, 4, 5], 9]", "output": "3" }, ...
118
false
118
verified
10
10
1
6,269
[ { "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.MaxSubArrayLen.Code.Funs /-! # Specifications of `Aegis.MaxSubArrayLen.max_sub_array_len` LeetCode problem `maximum-size-subarray-sum-equals-k`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.MaxSubArrayLen (max_sub_array_len) namespace AegisSpe...
12
power-of-three
326
Easy
[ "Recursion", "Math" ]
Given an integer n, return true if it is a power of three. Otherwise, return false. An integer n is a power of three, if there exists an integer x such that n == 3x.   Example 1: Input: n = 27 Output: true Explanation: 27 = 33 Example 2: Input: n = 0 Output: false Explanation: There is no x where 3x = 0. Example 3:...
isPowerOfThree(n: int) -> bool
pub fn is_power_of_three(n: i64) -> bool
Aegis.IsPowerOfThree.is_power_of_three
pub fn is_power_of_three(n: i64) -> bool { if n <= 0 { return false; } let mut m = n; while m % 3 == 0 { m = m / 3; } m == 1 }
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [is_power_of_three]: 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 -- [is_power_of_three]: function definitions module public import Aeneas public import Aegis.IsPowerOfThree.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.IsPowerOfThree.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.IsPowerOfThree.is_power_of_three 3#i64) (true))}") #eval (s!"CASE 1 {(Result.reducesTo (Aegis.IsPowerOfThree.is_power_of_three 45#i64) (false))}")...
[ { "input": "[3]", "output": "true" }, { "input": "[45]", "output": "false" }, { "input": "[729]", "output": "true" }, { "input": "[2147483647]", "output": "false" }, { "input": "[19683]", "output": "true" }, { "input": "[100]", "output": "false" ...
74
false
74
verified
10
10
1
376
[ { "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.IsPowerOfThree.Code.Funs /-! # Specifications of `Aegis.IsPowerOfThree.is_power_of_three` LeetCode problem `power-of-three`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.IsPowerOfThree open Aegis.IsPowerOfThree (is_power_of_three...
11
count-of-range-sum
327
Hard
[ "Binary Indexed Tree", "Segment Tree", "Array", "Binary Search", "Divide and Conquer", "Ordered Set", "Merge Sort" ]
Given an integer array nums and two integers lower and upper, return the number of range sums that lie in [lower, upper] inclusive. Range sum S(i, j) is defined as the sum of the elements in nums between indices i and j inclusive, where i <= j.   Example 1: Input: nums = [-2,5,-1], lower = -2, upper = 2 Output: 3 Expl...
countRangeSum(nums: list_int, lower: int, upper: int) -> int
pub fn count_range_sum(nums: &[i64], lower: i64, upper: i64) -> i64
Aegis.CountRangeSum.count_range_sum
fn count_leq_bound(arr: &[i64], lo: usize, mid: usize, hi: usize, bound: i64) -> i64 { let mut p = lo; let mut j = mid; let mut total: i64 = 0; while j < hi { let target = arr[j] - bound; while p < mid && arr[p] < target { p += 1; } total += (mid - p) as i64;...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [count_range_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 linte...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [count_range_sum]: function definitions module public import Aeneas public import Aegis.CountRangeSum.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.CountRangeSum.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.CountRangeSum.count_range_sum (Slice.from [0#i64] (by scalar_tac) : Slice Std.I64) 0#i64 0#i64) (1#i64))}") #eval (s!"CASE 1 {(Result.reducesTo (Ae...
[ { "input": "[[0], 0, 0]", "output": "1" }, { "input": "[[-2, 5, -1], -2, 2]", "output": "3" }, { "input": "[[1, 2, 3], 3, 6]", "output": "4" }, { "input": "[[1000000000, -1000000000, 1000000000, -1000000000], -2000000000, 2000000000]", "output": "10" }, { "input":...
101
false
101
verified
10
10
1
9,859
[ { "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.CountRangeSum.Code.Funs /-! # Specifications of `Aegis.CountRangeSum.count_range_sum` LeetCode problem `count-of-range-sum`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.CountRangeSum set_option autoImplicit false namespace AegisSpec.CountRan...
12
odd-even-linked-list
328
Medium
[ "Linked List" ]
Given the head of a singly linked list, group all the nodes with odd indices together followed by the nodes with even indices, and return the reordered list. The first node is considered odd, and the second node is even, and so on. Note that the relative order inside both the even and odd groups should remain as it was...
oddEvenList(head: linkedlist) -> linkedlist
pub fn odd_even_list(head: &List) -> List
Aegis.OddEvenList.odd_even_list
fn to_rev_vec(l: &List) -> Vec<i64> { match l { List::Nil => Vec::new(), List::Cons(x, next) => { let mut res = to_rev_vec(next); res.push(*x); res } } } fn build_from(v: &Vec<i64>, i: usize) -> List { if i >= v.len() { List::Nil } els...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [odd_even_list]: 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 -- [odd_even_list]: function definitions module public import Aeneas public import Aegis.OddEvenList.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.OddEvenList.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 deriving instance DecidableEq for Aegis.OddEvenList.List #eval (s!"CASE 0 {(match (Aegis.OddEvenList.odd_even_list ((.Cons 0#i64 (.Nil)) : Aegis.OddEvenList.List)).match with | .ok r => decid...
[ { "input": "[[0]]", "output": "[0]" }, { "input": "[[1]]", "output": "[1]" }, { "input": "[[1, 2]]", "output": "[1, 2]" }, { "input": "[[1, 2, 3]]", "output": "[1, 3, 2]" }, { "input": "[[1, 2, 3, 4]]", "output": "[1, 3, 2, 4]" }, { "input": "[[1, 2, 3...
85
false
85
verified
10
10
2
9,955
[ { "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.OddEvenList.Code.Funs /-! # Specifications of `Aegis.OddEvenList.odd_even_list` LeetCode problem `odd-even-linked-list`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.OddEvenList open Aegis.OddEvenList (odd_even_list) abbrev RL...
9
longest-increasing-path-in-a-matrix
329
Hard
[ "Depth-First Search", "Breadth-First Search", "Graph", "Topological Sort", "Memoization", "Array", "Dynamic Programming", "Matrix" ]
Given an m x n integers matrix, return the length of the longest increasing path in matrix. From each cell, you can either move in four directions: left, right, up, or down. You may not move diagonally or move outside the boundary (i.e., wrap-around is not allowed).   Example 1: Input: matrix = [[9,9,4],[6,6,8],[2,1,...
longestIncreasingPath(matrix: list_list_int) -> int
pub fn longest_increasing_path(matrix: &[Vec<i64>]) -> i64
Aegis.LongestIncreasingPath.longest_increasing_path
fn merge_sort(values: &mut Vec<i64>) { let len = values.len(); if len <= 1 { return; } let mut buffer: Vec<i64> = Vec::new(); let mut i: usize = 0; while i < len { buffer.push(0); i += 1; } let mut width: usize = 1; while width < len { let mut left: ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [longest_increasing_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_opti...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [longest_increasing_path]: function definitions module public import Aeneas public import Aegis.LongestIncreasingPath.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashComma...
import Aegis.LongestIncreasingPath.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.LongestIncreasingPath.longest_increasing_path (Slice.from [(alloc.vec.Vec.from [1#i64] (by scalar_tac) : alloc.vec.Vec Std.I64)] (by scalar...
[ { "input": "[[[1]]]", "output": "1" }, { "input": "[[[1, 2], [3, 4], [5, 6]]]", "output": "4" }, { "input": "[[[1, 2, 3], [6, 5, 4], [7, 8, 9]]]", "output": "9" }, { "input": "[[[7, 8, 9], [9, 7, 8], [8, 9, 7]]]", "output": "3" }, { "input": "[[[1, 2, 3], [4, 5, 6...
88
false
88
verified
10
10
1
5,769
[ { "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.LongestIncreasingPath.Code.Funs /-! # Specifications of `Aegis.LongestIncreasingPath.longest_increasing_path` LeetCode problem `longest-increasing-path-in-a-matrix`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.LongestIncreasingPath ...
13
patching-array
330
Hard
[ "Greedy", "Array" ]
Given a sorted integer array nums and an integer n, add/patch elements to the array such that any number in the range [1, n] inclusive can be formed by the sum of some elements in the array. Return the minimum number of patches required.   Example 1: Input: nums = [1,3], n = 6 Output: 1 Explanation: Combinations of nu...
minPatches(nums: list_int, n: int) -> int
pub fn min_patches(nums: &[i64], n: i64) -> i64
Aegis.MinPatches.min_patches
pub fn min_patches(nums: &[i64], n: i64) -> i64 { let mut patches: i64 = 0; let mut miss: i64 = 1; let mut i: usize = 0; let len = nums.len(); while miss <= n { if i < len && nums[i] <= miss { miss += nums[i]; i += 1; } else { miss += miss; ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [min_patches]: 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 -- [min_patches]: function definitions module public import Aeneas public import Aegis.MinPatches.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.MinPatches.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.MinPatches.min_patches (Slice.from [] (by scalar_tac) : Slice Std.I64) 8#i64) (4#i64))}") #eval (s!"CASE 1 {(Result.reducesTo (Aegis.MinPatches.min_pa...
[ { "input": "[[], 8]", "output": "4" }, { "input": "[[], 7]", "output": "3" }, { "input": "[[1], 2]", "output": "1" }, { "input": "[[1], 1]", "output": "0" }, { "input": "[[1, 3], 6]", "output": "1" }, { "input": "[[1, 1000000000], 2000000000]", "ou...
105
false
105
verified
10
10
1
487
[ { "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.MinPatches.Code.Funs /-! # Specifications of `Aegis.MinPatches.min_patches` LeetCode problem `patching-array`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.MinPatches def contents (s : Slice Std.I64) : List ℤ := s.val.map (fun x => x...
13
verify-preorder-serialization-of-a-binary-tree
331
Medium
[ "Stack", "Tree", "String", "Binary Tree" ]
One way to serialize a binary tree is to use preorder traversal. When we encounter a non-null node, we record the node's value. If it is a null node, we record using a sentinel value such as '#'. For example, the above binary tree can be serialized to the string "9,3,4,#,#,1,#,#,2,#,6,#,#", where '#' represents a null...
isValidSerialization(preorder: str) -> bool
pub fn is_valid_serialization(preorder: &[u8]) -> bool
Aegis.IsValidSerialization.is_valid_serialization
pub fn is_valid_serialization(preorder: &[u8]) -> bool { let n = preorder.len(); let mut valid: bool = n > 0; let mut slots: i64 = 1; let mut i: usize = 0; while i < n && valid { if slots <= 0 { valid = false; } else { let mut j = i; while j < n ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [is_valid_serialization]: 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 -- [is_valid_serialization]: function definitions module public import Aeneas public import Aegis.IsValidSerialization.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand...
import Aegis.IsValidSerialization.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.IsValidSerialization.is_valid_serialization (Slice.from [49#u8, 44#u8, 50#u8, 44#u8, 35#u8, 44#u8, 35#u8, 44#u8, 51#u8, 44#u8, 52#u8, 44#u8,...
[ { "input": "[\"1,2,#,#,3,4,#,#,5,#,#\"]", "output": "true" }, { "input": "[\"1,2,3,#,#,4,#,#,5,6,#,#,#,#\"]", "output": "false" }, { "input": "[\"1,2,3,#,#,4,5,#,#,#,#,6,7,#,#,#,#\"]", "output": "false" }, { "input": "[\"#\"]", "output": "true" }, { "input": "[\"1...
145
false
145
verified
10
10
2
3,307
[ { "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.IsValidSerialization.Code.Funs /-! # Specifications of `Aegis.IsValidSerialization.is_valid_serialization` LeetCode problem `verify-preorder-serialization-of-a-binary-tree`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.IsValidSerial...
14
largest-bst-subtree
333
Medium
[ "Tree", "Depth-First Search", "Binary Search Tree", "Dynamic Programming", "Binary Tree" ]
Given the root of a binary tree, find the largest subtree, which is also a Binary Search Tree (BST), where the largest means subtree has the largest number of nodes. A Binary Search Tree (BST) is a tree in which all the nodes follow the below-mentioned properties: The left subtree values are less than the value of the...
largestBSTSubtree(root: tree) -> int
pub fn largest_bst_subtree(root: &Tree) -> i64
Aegis.LargestBstSubtree.largest_bst_subtree
const OFF: i64 = 20000; const V_BASE: i64 = 40000; const V2: i64 = 1600000000; const BEST_BASE: i64 = 20000; const BEST_MULT: i64 = 32000000000000; const BST_MULT: i64 = 640000000000000000; // Combine this node's value with the packed results of its two children. // Packed layout (least significant digit first), each ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [largest_bst_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 l...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [largest_bst_subtree]: function definitions module public import Aeneas public import Aegis.LargestBstSubtree.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false...
import Aegis.LargestBstSubtree.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.LargestBstSubtree.largest_bst_subtree ((.Null) : Aegis.LargestBstSubtree.Tree)) (0#i64))}") #eval (s!"CASE 1 {(Result.reducesTo (Aegis.LargestB...
[ { "input": "[[]]", "output": "0" }, { "input": "[[1]]", "output": "1" }, { "input": "[[3, 2, 1]]", "output": "1" }, { "input": "[[2, 1, 3]]", "output": "3" }, { "input": "[[5, 4, 6, 3, 7]]", "output": "3" }, { "input": "[[3, 2, 4, 1, 5]]", "output"...
25
false
25
verified
10
10
3
39,565
[ { "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.LargestBstSubtree.Code.Funs /-! # Specifications of `Aegis.LargestBstSubtree.largest_bst_subtree` LeetCode problem `largest-bst-subtree`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.LargestBstSubtree namespace AegisSpec.LargestBstSubtree ...
12
increasing-triplet-subsequence
334
Medium
[ "Greedy", "Array" ]
Given an integer array nums, return true if there exists a triple of indices (i, j, k) such that i < j < k and nums[i] < nums[j] < nums[k]. If no such indices exists, return false.   Example 1: Input: nums = [1,2,3,4,5] Output: true Explanation: Any triplet where i < j < k is valid. Example 2: Input: nums = [5,4,3,2...
increasingTriplet(nums: list_int) -> bool
pub fn increasing_triplet(nums: &[i64]) -> bool
Aegis.IncreasingTriplet.increasing_triplet
pub fn increasing_triplet(nums: &[i64]) -> bool { let mut first: i64 = i64::MAX; let mut second: i64 = i64::MAX; let mut i: usize = 0; while i < nums.len() { let x = nums[i]; if x > second { return true; } else if x > first { second = x; } else {...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [increasing_triplet]: 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 -- [increasing_triplet]: function definitions module public import Aeneas public import Aegis.IncreasingTriplet.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false ...
import Aegis.IncreasingTriplet.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.IncreasingTriplet.increasing_triplet (Slice.from [1#i64, 2#i64] (by scalar_tac) : Slice Std.I64)) (false))}") #eval (s!"CASE 1 {(Result.reduces...
[ { "input": "[[1, 2]]", "output": "false" }, { "input": "[[0, -1, 1]]", "output": "false" }, { "input": "[[1000000000, 999999999, 1, 1000000001]]", "output": "false" }, { "input": "[[5, 4, 3, 2, 1]]", "output": "false" }, { "input": "[[1, 1, 1, 1, 1]]", "output...
124
false
124
verified
10
10
1
766
[ { "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.IncreasingTriplet.Code.Funs /-! # Specifications of `Aegis.IncreasingTriplet.increasing_triplet` LeetCode problem `increasing-triplet-subsequence`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.IncreasingTriplet def LengthWithinBo...
3
self-crossing
335
Hard
[ "Geometry", "Array", "Math" ]
You are given an array of integers distance. You start at the point (0, 0) on an X-Y plane, and you move distance[0] meters to the north, then distance[1] meters to the west, distance[2] meters to the south, distance[3] meters to the east, and so on. In other words, after each move, your direction changes counter-clock...
isSelfCrossing(distance: list_int) -> bool
pub fn is_self_crossing(distance: &[i64]) -> bool
Aegis.IsSelfCrossing.is_self_crossing
pub fn is_self_crossing(distance: &[i64]) -> bool { let n = distance.len(); let mut i: usize = 3; while i < n { if distance[i] >= distance[i - 2] && distance[i - 1] <= distance[i - 3] { return true; } if i >= 4 { if distance[i - 1] == distance[i - 3] ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [is_self_crossing]: 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 -- [is_self_crossing]: function definitions module public import Aeneas public import Aegis.IsSelfCrossing.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.IsSelfCrossing.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.IsSelfCrossing.is_self_crossing (Slice.from [1#i64, 2#i64, 3#i64, 4#i64] (by scalar_tac) : Slice Std.I64)) (false))}") #eval (s!"CASE 1 {(Result.r...
[ { "input": "[[1, 2, 3, 4]]", "output": "false" }, { "input": "[[2, 1, 1, 2]]", "output": "true" }, { "input": "[[3, 3, 3, 2, 1]]", "output": "false" }, { "input": "[[1, 1, 1, 2, 1]]", "output": "true" }, { "input": "[[1, 2, 3, 4, 5]]", "output": "false" }, ...
113
false
113
verified
10
10
1
2,265
[ { "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.IsSelfCrossing.Code.Funs /-! # Specifications of `Aegis.IsSelfCrossing.is_self_crossing` LeetCode problem `self-crossing`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.IsSelfCrossing def vals (distance : Slice Std.I64) : List ℤ :...
7
house-robber-iii
337
Medium
[ "Tree", "Depth-First Search", "Dynamic Programming", "Binary Tree" ]
The thief has found himself a new place for his thievery again. There is only one entrance to this area, called root. Besides the root, each house has one and only one parent house. After a tour, the smart thief realized that all houses in this place form a binary tree. It will automatically contact the police if two d...
rob(root: tree) -> int
pub fn rob(root: &Tree) -> i64
Aegis.Rob.rob
fn max2(a: i64, b: i64) -> i64 { let mut m: i64 = a; if b > m { m = b; } m } fn dp(t: &Tree) -> Vec<i64> { // Returns [take, skip] for this subtree: // take = best total if we rob this node // skip = best total if we do not rob this node let mut out: Vec<i64> = Vec::new(); ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [rob]: 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.whit...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [rob]: function definitions module public import Aeneas public import Aegis.Rob.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.unusedVaria...
import Aegis.Rob.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.Rob.rob ((.Node 0#i64 (.Null) (.Null)) : Aegis.Rob.Tree)) (0#i64))}") #eval (s!"CASE 1 {(Result.reducesTo (Aegis.Rob.rob ((.Node 3#i64 (.Node 0#i64 (.Null) (...
[ { "input": "[[0]]", "output": "0" }, { "input": "[[3, 0, 0]]", "output": "3" }, { "input": "[[1, 2, 3, 4, 5, 6, 7]]", "output": "23" }, { "input": "[[3, 1, 5, 0, 2, 4, 6]]", "output": "15" }, { "input": "[[100, 90, 80, 70, 60, 50, 40, 30, 20, 10]]", "output": ...
19
false
19
verified
10
10
2
14,825
[ { "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.Rob.Code.Funs /-! # Specifications of `Aegis.Rob.rob` LeetCode problem `house-robber-iii`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.Rob open Aegis.Rob def IsFiniteTree (_t : Tree) : Prop := True def nodeCount : Tree → N...
13
counting-bits
338
Easy
[ "Bit Manipulation", "Dynamic Programming" ]
Given an integer n, return an array ans of length n + 1 such that for each i (0 <= i <= n), ans[i] is the number of 1's in the binary representation of i.   Example 1: Input: n = 2 Output: [0,1,1] Explanation: 0 --> 0 1 --> 1 2 --> 10 Example 2: Input: n = 5 Output: [0,1,1,2,1,2] Explanation: 0 --> 0 1 --> 1 2 --> 1...
countBits(n: int) -> list_int
pub fn count_bits(n: i64) -> Vec<i64>
Aegis.CountBits.count_bits
pub fn count_bits(n: i64) -> Vec<i64> { if n < 0 { return Vec::new(); } let mut ans: Vec<i64> = Vec::new(); ans.push(0); let n_usize = n as usize; let mut i: usize = 1; while i <= n_usize { let prev = ans[i / 2]; let bit = (i % 2) as i64; ans.push(prev + bi...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [count_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 linter.sty...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [count_bits]: function definitions module public import Aeneas public import Aegis.CountBits.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.CountBits.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.CountBits.count_bits 0#i64) ((alloc.vec.Vec.from [0#i64] (by scalar_tac) : alloc.vec.Vec Std.I64)))}") #eval (s!"CASE 1 {(Result.reducesTo (Aegis.Count...
[ { "input": "[0]", "output": "[0]" }, { "input": "[1]", "output": "[0, 1]" }, { "input": "[2]", "output": "[0, 1, 1]" }, { "input": "[5]", "output": "[0, 1, 1, 2, 1, 2]" }, { "input": "[7]", "output": "[0, 1, 1, 2, 1, 2, 2, 3]" }, { "input": "[10]", ...
21
false
21
verified
10
10
1
770
[ { "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.CountBits.Code.Funs /-! # Specifications of `Aegis.CountBits.count_bits` LeetCode problem `counting-bits`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.CountBits open Aegis.CountBits def onesCount (i : ℤ) : ℕ := ((Finset.range (i....
10
longest-substring-with-at-most-k-distinct-characters
340
Medium
[ "Hash Table", "String", "Sliding Window" ]
Given a string s and an integer k, return the length of the longest substring of s that contains at most k distinct characters.   Example 1: Input: s = "eceba", k = 2 Output: 3 Explanation: The substring is "ece" with length 3. Example 2: Input: s = "aa", k = 1 Output: 2 Explanation: The substring is "aa" with length...
lengthOfLongestSubstringKDistinct(s: str, k: int) -> int
pub fn length_of_longest_substring_k_distinct(s: &[u8], k: i64) -> i64
Aegis.LengthOfLongestSubstringKDistinct.length_of_longest_substring_k_distinct
pub fn length_of_longest_substring_k_distinct(s: &[u8], k: i64) -> i64 { if s.len() == 0 { return 0; } if k <= 0 { return 0; } let mut counts: Vec<i64> = Vec::new(); let mut i: usize = 0; while i < 256 { counts.push(0); i += 1; } let mut left: usize ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [length_of_longest_substring_k_distinct]: 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...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [length_of_longest_substring_k_distinct]: function definitions module public import Aeneas public import Aegis.LengthOfLongestSubstringKDistinct.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false ...
import Aegis.LengthOfLongestSubstringKDistinct.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.LengthOfLongestSubstringKDistinct.length_of_longest_substring_k_distinct (Slice.from [97#u8, 98#u8, 99#u8, 100#u8, 101#u8, 102#...
[ { "input": "[\"abcdefgh\", 5]", "output": "5" }, { "input": "[\"aabacbebebe\", 3]", "output": "7" }, { "input": "[\"\", 0]", "output": "0" }, { "input": "[\"eceba\", 2]", "output": "3" }, { "input": "[\"\", 1]", "output": "0" }, { "input": "[\"aabbcc\"...
118
false
118
verified
10
10
1
999
[ { "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.LengthOfLongestSubstringKDistinct.Code.Funs /-! # Specifications of `Aegis.LengthOfLongestSubstringKDistinct.length_of_longest_substring_k_distinct` LeetCode problem `longest-substring-with-at-most-k-distinct-characters`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas...
15
integer-break
343
Medium
[ "Math", "Dynamic Programming" ]
Given an integer n, break it into the sum of k positive integers, where k >= 2, and maximize the product of those integers. Return the maximum product you can get.   Example 1: Input: n = 2 Output: 1 Explanation: 2 = 1 + 1, 1 × 1 = 1. Example 2: Input: n = 10 Output: 36 Explanation: 10 = 3 + 3 + 4, 3 × 3 × 4 = 36. ...
integerBreak(n: int) -> int
pub fn integer_break(n: i64) -> i64
Aegis.IntegerBreak.integer_break
pub fn integer_break(n: i64) -> i64 { let m = n as usize; let mut dp: Vec<i64> = Vec::new(); let mut i = 0usize; while i <= m { dp.push(0); i += 1; } dp[1] = 1; i = 2; while i <= m { let mut best = 0i64; let mut j = 1usize; while j < i { ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [integer_break]: 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 -- [integer_break]: function definitions module public import Aeneas public import Aegis.IntegerBreak.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.IntegerBreak.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.IntegerBreak.integer_break 11#i64) (54#i64))}") #eval (s!"CASE 1 {(Result.reducesTo (Aegis.IntegerBreak.integer_break 30#i64) (59049#i64))}") #eval ...
[ { "input": "[11]", "output": "54" }, { "input": "[30]", "output": "59049" }, { "input": "[20]", "output": "1458" }, { "input": "[2]", "output": "1" }, { "input": "[10]", "output": "36" }, { "input": "[58]", "output": "1549681956" }, { "inpu...
30
false
30
verified
10
10
1
1,256
[ { "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.IntegerBreak.Code.Funs /-! # Specifications of `Aegis.IntegerBreak.integer_break` LeetCode problem `integer-break`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.IntegerBreak open Aegis.IntegerBreak def IsDecomposition (n : ℤ) (l : L...
13