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
minimum-ascii-delete-sum-for-two-strings
712
Medium
[ "String", "Dynamic Programming" ]
Given two strings s1 and s2, return the lowest ASCII sum of deleted characters to make two strings equal.   Example 1: Input: s1 = "sea", s2 = "eat" Output: 231 Explanation: Deleting "s" from "sea" adds the ASCII value of "s" (115) to the sum. Deleting "t" from "eat" adds 116 to the sum. At the end, both strings are e...
minimumDeleteSum(s1: str, s2: str) -> int
pub fn minimum_delete_sum(s1: &[u8], s2: &[u8]) -> i64
Aegis.MinimumDeleteSum.minimum_delete_sum
pub fn minimum_delete_sum(s1: &[u8], s2: &[u8]) -> i64 { let m = s1.len(); let n = s2.len(); let mut prev: Vec<i64> = Vec::new(); prev.push(0); let mut j: usize = 1; while j <= n { prev.push(prev[j - 1] + (s2[j - 1] as i64)); j += 1; } let mut i: usize = 1; while i...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [minimum_delete_sum]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option li...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [minimum_delete_sum]: function definitions module public import Aeneas public import Aegis.MinimumDeleteSum.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.MinimumDeleteSum.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.MinimumDeleteSum.minimum_delete_sum (Slice.from [100#u8, 101#u8, 108#u8, 101#u8, 116#u8, 101#u8] (by scalar_tac) : Slice Std.U8) (Slice.from [10...
[ { "input": "[\"delete\", \"leet\"]", "output": "403" }, { "input": "[\"aaa\", \"aa\"]", "output": "97" }, { "input": "[\"abc\", \"abcde\"]", "output": "201" }, { "input": "[\"\", \"abc\"]", "output": "294" }, { "input": "[\"abc\", \"\"]", "output": "294" }, ...
115
false
115
verified
10
10
1
1,366
[ { "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.MinimumDeleteSum.Code.Funs /-! # Specifications of `Aegis.MinimumDeleteSum.minimum_delete_sum` LeetCode problem `minimum-ascii-delete-sum-for-two-strings`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.MinimumDeleteSum namespace AegisSpec.Minim...
13
best-time-to-buy-and-sell-stock-with-transaction-fee
714
Medium
[ "Greedy", "Array", "Dynamic Programming" ]
You are given an array prices where prices[i] is the price of a given stock on the ith day, and an integer fee representing a transaction fee. Find the maximum profit you can achieve. You may complete as many transactions as you like, but you need to pay the transaction fee for each transaction. Note: You may not enga...
maxProfit(prices: list_int, fee: int) -> int
pub fn max_profit(prices: &[i64], fee: i64) -> i64
Aegis.MaxProfit.max_profit
pub fn max_profit(prices: &[i64], fee: i64) -> i64 { let n = prices.len(); if n == 0 { return 0; } let mut cash: i64 = 0; let mut hold: i64 = -prices[0]; let mut i: usize = 1; while i < n { let price = prices[i]; let old_cash = cash; let sell_value = hold +...
-- 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 [10#i64, 20#i64, 30#i64, 40#i64, 50#i64] (by scalar_tac) : Slice Std.I64) 5#i64) (35#i64))}") #eval (s!"CASE 1 {(Resul...
[ { "input": "[[10, 20, 30, 40, 50], 5]", "output": "35" }, { "input": "[[1, 2, 3, 4, 5], 1]", "output": "3" }, { "input": "[[50, 40, 30, 20, 10], 5]", "output": "0" }, { "input": "[[5, 4, 3, 2, 1], 1]", "output": "0" }, { "input": "[[1, 2, 3, 4, 5], 0]", "outpu...
107
false
107
verified
10
10
1
1,200
[ { "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-transaction-fee`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.MaxProfit (max_profit) namespace AegisSpec.MaxPr...
11
1-bit-and-2-bit-characters
717
Easy
[ "Array" ]
We have two special characters: The first character can be represented by one bit 0. The second character can be represented by two bits (10 or 11). Given a binary array bits that ends with 0, return true if the last character must be a one-bit character.   Example 1: Input: bits = [1,0,0] Output: true Explanation: ...
isOneBitCharacter(bits: list_int) -> bool
pub fn is_one_bit_character(bits: &[i64]) -> bool
Aegis.IsOneBitCharacter.is_one_bit_character
pub fn is_one_bit_character(bits: &[i64]) -> bool { let n = bits.len(); let mut i: usize = 0; while i + 1 < n { if bits[i] == 0 { i += 1; } else { i += 2; } } i + 1 == n }
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [is_one_bit_character]: 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_bit_character]: function definitions module public import Aeneas public import Aegis.IsOneBitCharacter.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand fals...
import Aegis.IsOneBitCharacter.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.IsOneBitCharacter.is_one_bit_character (Slice.from [0#i64] (by scalar_tac) : Slice Std.I64)) (true))}") #eval (s!"CASE 1 {(Result.reducesTo (Ae...
[ { "input": "[[0]]", "output": "true" }, { "input": "[[1, 0, 0]]", "output": "true" }, { "input": "[[1, 1, 1, 0]]", "output": "false" }, { "input": "[[0, 0, 0, 0]]", "output": "true" }, { "input": "[[1, 0, 1, 0]]", "output": "false" }, { "input": "[[1, ...
95
false
95
verified
10
10
1
1,046
[ { "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.IsOneBitCharacter.Code.Funs /-! # Specifications of `Aegis.IsOneBitCharacter.is_one_bit_character` LeetCode problem `1-bit-and-2-bit-characters`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.IsOneBitCharacter def bitAt (l : List Std....
10
maximum-length-of-repeated-subarray
718
Medium
[ "Array", "Binary Search", "Dynamic Programming", "Sliding Window", "Hash Function", "Rolling Hash" ]
Given two integer arrays nums1 and nums2, return the maximum length of a subarray that appears in both arrays.   Example 1: Input: nums1 = [1,2,3,2,1], nums2 = [3,2,1,4,7] Output: 3 Explanation: The repeated subarray with maximum length is [3,2,1]. Example 2: Input: nums1 = [0,0,0,0,0], nums2 = [0,0,0,0,0] Output: 5...
findLength(nums1: list_int, nums2: list_int) -> int
pub fn find_length(nums1: &[i64], nums2: &[i64]) -> i64
Aegis.FindLength.find_length
pub fn find_length(nums1: &[i64], nums2: &[i64]) -> i64 { let n = nums1.len(); let m = nums2.len(); let mut dp: Vec<i64> = Vec::new(); let mut k: usize = 0; while k <= m { dp.push(0); k += 1; } let mut best: i64 = 0; let mut i: usize = 1; while i <= n { let...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [find_length]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter.st...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [find_length]: function definitions module public import Aeneas public import Aegis.FindLength.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.FindLength.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.FindLength.find_length (Slice.from [1#i64] (by scalar_tac) : Slice Std.I64) (Slice.from [2#i64] (by scalar_tac) : Slice Std.I64)) (0#i64))}") #eval (s...
[ { "input": "[[1], [2]]", "output": "0" }, { "input": "[[1], [1]]", "output": "1" }, { "input": "[[1, 2, 3], [3, 4, 5]]", "output": "1" }, { "input": "[[1, 2, 3], [3, 2, 1]]", "output": "1" }, { "input": "[[1, 2, 2, 1], [2, 2]]", "output": "2" }, { "inp...
110
false
110
verified
10
10
1
1,039
[ { "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.FindLength.Code.Funs /-! # Specifications of `Aegis.FindLength.find_length` LeetCode problem `maximum-length-of-repeated-subarray`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.FindLength namespace AegisSpec.FindLength def MatchAt (xs ys : Li...
12
find-k-th-smallest-pair-distance
719
Hard
[ "Array", "Two Pointers", "Binary Search", "Sorting" ]
The distance of a pair of integers a and b is defined as the absolute difference between a and b. Given an integer array nums and an integer k, return the kth smallest distance among all the pairs nums[i] and nums[j] where 0 <= i < j < nums.length.   Example 1: Input: nums = [1,3,1], k = 1 Output: 0 Explanation: Here ...
smallestDistancePair(nums: list_int, k: int) -> int
pub fn smallest_distance_pair(nums: &[i64], k: i64) -> i64
Aegis.SmallestDistancePair.smallest_distance_pair
pub fn smallest_distance_pair(nums: &[i64], k: i64) -> i64 { let n = nums.len(); let mut sorted: Vec<i64> = Vec::new(); let mut i = 0; while i < n { sorted.push(nums[i]); i += 1; } // Iterative merge sort of sorted. if n > 1 { let mut temp: Vec<i64> = Vec::new(); ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [smallest_distance_pair]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_optio...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [smallest_distance_pair]: function definitions module public import Aeneas public import Aegis.SmallestDistancePair.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand...
import Aegis.SmallestDistancePair.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.SmallestDistancePair.smallest_distance_pair (Slice.from [1#i64, 3#i64, 1#i64] (by scalar_tac) : Slice Std.I64) 1#i64) (0#i64))}") #eval (s!"...
[ { "input": "[[1, 3, 1], 1]", "output": "0" }, { "input": "[[1, 6, 1], 3]", "output": "5" }, { "input": "[[1, 1, 1], 2]", "output": "0" }, { "input": "[[4, 2, 1, 3], 5]", "output": "2" }, { "input": "[[1, 2, 3, 4, 5], 10]", "output": "4" }, { "input": "...
76
false
76
verified
10
10
1
4,519
[ { "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.SmallestDistancePair.Code.Funs /-! # Specifications of `Aegis.SmallestDistancePair.smallest_distance_pair` LeetCode problem `find-k-th-smallest-pair-distance`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.SmallestDistancePair def...
15
remove-comments
722
Medium
[ "Array", "String" ]
Given a C++ program, remove comments from it. The program source is an array of strings source where source[i] is the ith line of the source code. This represents the result of splitting the original source code string by the newline character '\ '. In C++, there are two types of comments, line comments, and block comm...
removeComments(source: list_str) -> list_str
pub fn remove_comments(source: &[Vec<u8>]) -> Vec<Vec<u8>>
Aegis.RemoveComments.remove_comments
// The harness's generated tests compare an empty expected result via `vec![]`. // For a `Vec<Vec<u8>>` result that literal is ambiguous (Vec<u8> has multiple // PartialEq impls). Shadowing `vec!` lets the empty form pick the concrete // element type so those comparisons resolve, while the comma-list form keeps // norm...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [remove_comments]: 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_comments]: function definitions module public import Aeneas public import Aegis.RemoveComments.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.RemoveComments.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.RemoveComments.remove_comments (Slice.from [(alloc.vec.Vec.from [47#u8, 42#u8] (by scalar_tac) : alloc.vec.Vec Std.U8), (alloc.vec.Vec.from [98#u8...
[ { "input": "[[\"/*\", \"block comment\", \"*/\"]]", "output": "[]" }, { "input": "[[\"/* Start of block comment \\n /* nested block comment \\n still in block comment */\", \"int x = 10;\"]]", "output": "[\"int x = 10;\"]" }, { "input": "[[\"/* Comment with \\\"escaped quote\\\" inside *...
102
false
102
verified
10
10
4
92,564
[ { "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.RemoveComments.Code.Funs /-! # Specifications of `Aegis.RemoveComments.remove_comments` LeetCode problem `remove-comments`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.RemoveComments open Aegis.RemoveComments def nlByte : U8 := 10#...
11
candy-crush
723
Medium
[ "Array", "Two Pointers", "Matrix", "Simulation" ]
This question is about implementing a basic elimination algorithm for Candy Crush. Given an m x n integer array board representing the grid of candy where board[i][j] represents the type of candy. A value of board[i][j] == 0 represents that the cell is empty. The given board represents the state of the game following t...
candyCrush(board: list_list_int) -> list_list_int
pub fn candy_crush(board: &[Vec<i64>]) -> Vec<Vec<i64>>
Aegis.CandyCrush.candy_crush
pub fn candy_crush(board: &[Vec<i64>]) -> Vec<Vec<i64>> { let m = board.len(); let mut n: usize = 0; if m > 0 { n = board[0].len(); } let mut b: Vec<Vec<i64>> = Vec::new(); let mut i = 0; while i < m { let mut row: Vec<i64> = Vec::new(); let mut j = 0; while ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [candy_crush]: 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 -- [candy_crush]: function definitions module public import Aeneas public import Aegis.CandyCrush.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.CandyCrush.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.CandyCrush.candy_crush (Slice.from [(alloc.vec.Vec.from [1#i64, 2#i64, 3#i64, 4#i64, 5#i64] (by scalar_tac) : alloc.vec.Vec Std.I64), (alloc.vec.Vec.f...
[ { "input": "[[[1, 2, 3, 4, 5], [6, 7, 8, 9, 10], [1, 2, 3, 4, 5], [6, 7, 8, 9, 10], [1, 2, 3, 4, 5]]]", "output": "[[1, 2, 3, 4, 5], [6, 7, 8, 9, 10], [1, 2, 3, 4, 5], [6, 7, 8, 9, 10], [1, 2, 3, 4, 5]]" }, { "input": "[[[1, 2, 3, 4, 5], [1, 2, 3, 4, 5], [1, 2, 3, 4, 5], [1, 2, 3, 4, 5], [1, 2, 3, 4...
94
false
94
verified
10
10
1
9,169
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.CandyCrush.Code.Funs /-! # Specifications of `Aegis.CandyCrush.candy_crush` LeetCode problem `candy-crush`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.CandyCrush namespace AegisSpec.CandyCrush attribute [local instance] Classical.propDecida...
12
find-pivot-index
724
Easy
[ "Array", "Prefix Sum" ]
Given an array of integers nums, calculate the pivot index of this array. The pivot index is the index where the sum of all the numbers strictly to the left of the index is equal to the sum of all the numbers strictly to the index's right. If the index is on the left edge of the array, then the left sum is 0 because th...
pivotIndex(nums: list_int) -> int
pub fn pivot_index(nums: &[i64]) -> i64
Aegis.PivotIndex.pivot_index
pub fn pivot_index(nums: &[i64]) -> i64 { let n = nums.len(); if n == 0 { return -1; } let mut total: i64 = 0; let mut i: usize = 0; while i < n { total += nums[i]; i += 1; } let mut left_sum: i64 = 0; i = 0; while i < n { let right_sum = total -...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [pivot_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.st...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [pivot_index]: function definitions module public import Aeneas public import Aegis.PivotIndex.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.PivotIndex.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.PivotIndex.pivot_index (Slice.from [1#i64] (by scalar_tac) : Slice Std.I64)) (0#i64))}") #eval (s!"CASE 1 {(Result.reducesTo (Aegis.PivotIndex.pivot_i...
[ { "input": "[[1]]", "output": "0" }, { "input": "[[1000, -1000]]", "output": "-1" }, { "input": "[[1, 0]]", "output": "0" }, { "input": "[[1, 2, 1]]", "output": "1" }, { "input": "[[2, 1, -1]]", "output": "0" }, { "input": "[[0, 1, 0]]", "output": ...
95
false
95
verified
10
10
1
258
[ { "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.PivotIndex.Code.Funs /-! # Specifications of `Aegis.PivotIndex.pivot_index` LeetCode problem `find-pivot-index`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.PivotIndex def vals (nums : Slice Std.I64) : List Int := nums.val.map (fun ...
9
self-dividing-numbers
728
Easy
[ "Math" ]
A self-dividing number is a number that is divisible by every digit it contains. For example, 128 is a self-dividing number because 128 % 1 == 0, 128 % 2 == 0, and 128 % 8 == 0. A self-dividing number is not allowed to contain the digit zero. Given two integers left and right, return a list of all the self-dividing n...
selfDividingNumbers(left: int, right: int) -> list_int
pub fn self_dividing_numbers(left: i64, right: i64) -> Vec<i64>
Aegis.SelfDividingNumbers.self_dividing_numbers
fn is_self_dividing(n: i64) -> bool { let mut x = n; while x > 0 { let d = x % 10; if d == 0 { return false; } if n % d != 0 { return false; } x = x / 10; } true } pub fn self_dividing_numbers(left: i64, right: i64) -> Vec<i64> { ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [self_dividing_numbers]: 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 -- [self_dividing_numbers]: function definitions module public import Aeneas public import Aegis.SelfDividingNumbers.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand f...
import Aegis.SelfDividingNumbers.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.SelfDividingNumbers.self_dividing_numbers 1000#i64 1100#i64) ((alloc.vec.Vec.from [] (by scalar_tac) : alloc.vec.Vec Std.I64)))}") #eval (s!"...
[ { "input": "[1000, 1100]", "output": "[]" }, { "input": "[6000, 6100]", "output": "[]" }, { "input": "[5600, 5700]", "output": "[]" }, { "input": "[10000, 10400]", "output": "[]" }, { "input": "[10000, 10050]", "output": "[]" }, { "input": "[1024, 1024...
82
false
82
verified
10
10
1
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.SelfDividingNumbers.Code.Funs /-! # Specifications of `Aegis.SelfDividingNumbers.self_dividing_numbers` LeetCode problem `self-dividing-numbers`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.SelfDividingNumbers def decimalDigitsA...
15
count-different-palindromic-subsequences
730
Hard
[ "String", "Dynamic Programming" ]
Given a string s, return the number of different non-empty palindromic subsequences in s. Since the answer may be very large, return it modulo 109 + 7. A subsequence of a string is obtained by deleting zero or more characters from the string. A sequence is palindromic if it is equal to the sequence reversed. Two sequen...
countPalindromicSubsequences(s: str) -> int
pub fn count_palindromic_subsequences(s: &[u8]) -> i64
Aegis.CountPalindromicSubsequences.count_palindromic_subsequences
const MOD: i64 = 1000000007; fn norm(x: i64) -> i64 { let mut y = x % MOD; if y < 0 { y += MOD; } y } pub fn count_palindromic_subsequences(s: &[u8]) -> i64 { let n = s.len(); if n == 0 { return 0; } let mut next_pos: Vec<Vec<i64>> = Vec::new(); let mut init_i = 0;...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [count_palindromic_subsequences]: 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 s...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [count_palindromic_subsequences]: function definitions module public import Aeneas public import Aegis.CountPalindromicSubsequences.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option li...
import Aegis.CountPalindromicSubsequences.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.CountPalindromicSubsequences.count_palindromic_subsequences (Slice.from [97#u8, 98#u8, 98#u8, 97#u8] (by scalar_tac) : Slice Std.U8)...
[ { "input": "[\"abba\"]", "output": "6" }, { "input": "[\"abccba\"]", "output": "14" }, { "input": "[\"abcba\"]", "output": "10" }, { "input": "[\"abac\"]", "output": "5" }, { "input": "[\"a\"]", "output": "1" }, { "input": "[\"abcdabcdabcdabcdabcdabcda...
79
false
79
verified
10
10
1
10,799
[ { "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.CountPalindromicSubsequences.Code.Funs /-! # Specifications of `Aegis.CountPalindromicSubsequences.count_palindromic_subsequences` LeetCode problem `count-different-palindromic-subsequences`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace Aegis...
8
flood-fill
733
Easy
[ "Depth-First Search", "Breadth-First Search", "Array", "Matrix" ]
You are given an image represented by an m x n grid of integers image, where image[i][j] represents the pixel value of the image. You are also given three integers sr, sc, and color. Your task is to perform a flood fill on the image starting from the pixel image[sr][sc]. To perform a flood fill: Begin with the startin...
floodFill(image: list_list_int, sr: int, sc: int, color: int) -> list_list_int
pub fn flood_fill(image: &[Vec<i64>], sr: i64, sc: i64, color: i64) -> Vec<Vec<i64>>
Aegis.FloodFill.flood_fill
pub fn flood_fill(image: &[Vec<i64>], sr: i64, sc: i64, color: i64) -> Vec<Vec<i64>> { let m = image.len(); if m == 0 { return Vec::new(); } let n = image[0].len(); let mut out: Vec<Vec<i64>> = Vec::new(); let mut i: usize = 0; while i < m { let mut row: Vec<i64> = Vec::new(...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [flood_fill]: 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 -- [flood_fill]: function definitions module public import Aeneas public import Aegis.FloodFill.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.FloodFill.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.FloodFill.flood_fill (Slice.from [(alloc.vec.Vec.from [0#i64, 0#i64, 0#i64] (by scalar_tac) : alloc.vec.Vec Std.I64), (alloc.vec.Vec.from [0#i64, 0#i64...
[ { "input": "[[[0, 0, 0], [0, 0, 0]], 0, 0, 0]", "output": "[[0, 0, 0], [0, 0, 0]]" }, { "input": "[[[1, 1, 1], [1, 1, 1], [1, 1, 1]], 0, 0, 3]", "output": "[[3, 3, 3], [3, 3, 3], [3, 3, 3]]" }, { "input": "[[[1, 1, 1], [1, 1, 1], [1, 1, 1]], 2, 2, 4]", "output": "[[4, 4, 4], [4, 4, 4...
88
false
88
verified
10
10
1
3,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.FloodFill.Code.Funs /-! # Specifications of `Aegis.FloodFill.flood_fill` LeetCode problem `flood-fill`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.FloodFill namespace AegisSpec.FloodFill abbrev Image := Slice (alloc.vec.Vec Std.I64) ...
12
asteroid-collision
735
Medium
[ "Stack", "Array", "Simulation" ]
We are given an array asteroids of integers representing asteroids in a row. The indices of the asteriod in the array represent their relative position in space. For each asteroid, the absolute value represents its size, and the sign represents its direction (positive meaning right, negative meaning left). Each asteroi...
asteroidCollision(asteroids: list_int) -> list_int
pub fn asteroid_collision(asteroids: &[i64]) -> Vec<i64>
Aegis.AsteroidCollision.asteroid_collision
pub fn asteroid_collision(asteroids: &[i64]) -> Vec<i64> { let mut stack: Vec<i64> = Vec::new(); let n: usize = asteroids.len(); let mut i: usize = 0; while i < n { let a: i64 = asteroids[i]; if a > 0 { stack.push(a); } else { let mut alive: bool = true;...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [asteroid_collision]: 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 -- [asteroid_collision]: function definitions module public import Aeneas public import Aegis.AsteroidCollision.Code.Types public import Aegis.AsteroidCollision.Code.FunsExternal @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [asteroid_collision]: external functions. -- This is a template file: rename it to "FunsExternal.lean" and fill the holes. module public import Aeneas public import Aegis.AsteroidCollision.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow...
import Aegis.AsteroidCollision.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.AsteroidCollision.asteroid_collision (Slice.from [8#i64, (-8)#i64] (by scalar_tac) : Slice Std.I64)) ((alloc.vec.Vec.from [] (by scalar_tac) : ...
[ { "input": "[[8, -8]]", "output": "[]" }, { "input": "[[1000, -1000]]", "output": "[]" }, { "input": "[[-1000, 1000]]", "output": "[-1000, 1000]" }, { "input": "[[10, 2, -5]]", "output": "[10]" }, { "input": "[[5, 10, -10, -5]]", "output": "[]" }, { "i...
123
false
123
verified
10
10
1
1,756
[ { "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.AsteroidCollision.Code.Funs /-! # Specifications of `Aegis.AsteroidCollision.asteroid_collision` LeetCode problem `asteroid-collision`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas open Aeneas.Std open Result namespace AegisSpec.AsteroidCollision def CollisionStep (L L' ...
12
monotone-increasing-digits
738
Medium
[ "Greedy", "Math" ]
An integer has monotone increasing digits if and only if each pair of adjacent digits x and y satisfy x <= y. Given an integer n, return the largest number that is less than or equal to n with monotone increasing digits.   Example 1: Input: n = 10 Output: 9 Example 2: Input: n = 1234 Output: 1234 Example 3: Input:...
monotoneIncreasingDigits(n: int) -> int
pub fn monotone_increasing_digits(n: i64) -> i64
Aegis.MonotoneIncreasingDigits.monotone_increasing_digits
pub fn monotone_increasing_digits(n: i64) -> i64 { let mut digits: Vec<i64> = Vec::new(); let mut x: i64 = n; if x == 0 { digits.push(0); } else { while x > 0 { digits.push(x % 10); x = x / 10; } } let len: usize = digits.len(); // Reverse t...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [monotone_increasing_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_o...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [monotone_increasing_digits]: function definitions module public import Aeneas public import Aegis.MonotoneIncreasingDigits.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.has...
import Aegis.MonotoneIncreasingDigits.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.MonotoneIncreasingDigits.monotone_increasing_digits 999999999#i64) (999999999#i64))}") #eval (s!"CASE 1 {(Result.reducesTo (Aegis.Monoto...
[ { "input": "[999999999]", "output": "999999999" }, { "input": "[111]", "output": "111" }, { "input": "[100]", "output": "99" }, { "input": "[1000]", "output": "999" }, { "input": "[222]", "output": "222" }, { "input": "[333]", "output": "333" }, ...
107
false
107
verified
10
10
1
4,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.MonotoneIncreasingDigits.Code.Funs /-! # Specifications of `Aegis.MonotoneIncreasingDigits.monotone_increasing_digits` LeetCode problem `monotone-increasing-digits`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.MonotoneIncreasingDig...
11
daily-temperatures
739
Medium
[ "Stack", "Array", "Monotonic Stack" ]
Given an array of integers temperatures represents the daily temperatures, return an array answer such that answer[i] is the number of days you have to wait after the ith day to get a warmer temperature. If there is no future day for which this is possible, keep answer[i] == 0 instead.   Example 1: Input: temperatures ...
dailyTemperatures(temperatures: list_int) -> list_int
pub fn daily_temperatures(temperatures: &[i64]) -> Vec<i64>
Aegis.DailyTemperatures.daily_temperatures
pub fn daily_temperatures(temperatures: &[i64]) -> Vec<i64> { let n = temperatures.len(); // Initialize the answer array with zeros. let mut ans: Vec<i64> = Vec::new(); let mut i: usize = 0; while i < n { ans.push(0); i += 1; } // Monotonic decreasing stack of indices into ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [daily_temperatures]: 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 -- [daily_temperatures]: function definitions module public import Aeneas public import Aegis.DailyTemperatures.Code.Types public import Aegis.DailyTemperatures.Code.FunsExternal @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [daily_temperatures]: external functions. -- This is a template file: rename it to "FunsExternal.lean" and fill the holes. module public import Aeneas public import Aegis.DailyTemperatures.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow...
import Aegis.DailyTemperatures.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.DailyTemperatures.daily_temperatures (Slice.from [30#i64, 60#i64, 90#i64] (by scalar_tac) : Slice Std.I64)) ((alloc.vec.Vec.from [1#i64, 1#i64,...
[ { "input": "[[30, 60, 90]]", "output": "[1, 1, 0]" }, { "input": "[[30, 30, 30, 30]]", "output": "[0, 0, 0, 0]" }, { "input": "[[30, 40, 50, 60]]", "output": "[1, 1, 1, 0]" }, { "input": "[[70, 70, 70, 71]]", "output": "[3, 2, 1, 0]" }, { "input": "[[70, 69, 68, 6...
107
false
107
verified
10
10
1
1,576
[ { "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.DailyTemperatures.Code.Funs /-! # Specifications of `Aegis.DailyTemperatures.daily_temperatures` LeetCode problem `daily-temperatures`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.DailyTemperatures def elem (l : List Std.I64) (i...
13
delete-and-earn
740
Medium
[ "Array", "Hash Table", "Dynamic Programming" ]
You are given an integer array nums. You want to maximize the number of points you get by performing the following operation any number of times: Pick any nums[i] and delete it to earn nums[i] points. Afterwards, you must delete every element equal to nums[i] - 1 and every element equal to nums[i] + 1. Return the max...
deleteAndEarn(nums: list_int) -> int
pub fn delete_and_earn(nums: &[i64]) -> i64
Aegis.DeleteAndEarn.delete_and_earn
pub fn delete_and_earn(nums: &[i64]) -> i64 { let n = nums.len(); if n == 0 { return 0; } // Copy into an owned vector (position-indexed, size n). let mut s: Vec<i64> = Vec::new(); let mut i: usize = 0; while i < n { s.push(nums[i]); i += 1; } // Selection s...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [delete_and_earn]: 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 -- [delete_and_earn]: function definitions module public import Aeneas public import Aegis.DeleteAndEarn.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.DeleteAndEarn.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": "[[1]]", "output": "1" }, { "input": "[[10000]]", "output": "10000" }, { "input": "[[1, 10000]]", "output": "10001" }, { "input": "[[10000, 10000, 10000]]", "output": "30000" }, { "input": "[[3, 4, 2]]", "output": "6" }, { "input": "[[10000,...
115
false
115
verified
10
10
5
64,578
[ { "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.DeleteAndEarn.Code.Funs /-! # Specifications of `Aegis.DeleteAndEarn.delete_and_earn` LeetCode problem `delete-and-earn`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.DeleteAndEarn open scoped BigOperators def count (nums : Sl...
11
cherry-pickup
741
Hard
[ "Array", "Dynamic Programming", "Matrix" ]
You are given an n x n grid representing a field of cherries, each cell is one of three possible integers. 0 means the cell is empty, so you can pass through, 1 means the cell contains a cherry that you can pick up and pass through, or -1 means the cell contains a thorn that blocks your way. Return the maximum number...
cherryPickup(grid: list_list_int) -> int
pub fn cherry_pickup(grid: &[Vec<i64>]) -> i64
Aegis.CherryPickup.cherry_pickup
pub fn cherry_pickup(grid: &[Vec<i64>]) -> i64 { let n = grid.len(); if n == 0 { return 0; } if grid[0][0] == -1 || grid[n - 1][n - 1] == -1 { return 0; } if n == 1 { return grid[0][0]; } let neg: i64 = -1000000000; let size = n * n; let mut prev: Vec<i6...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [cherry_pickup]: 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 -- [cherry_pickup]: function definitions module public import Aeneas public import Aegis.CherryPickup.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.CherryPickup.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.CherryPickup.cherry_pickup (Slice.from [(alloc.vec.Vec.from [0#i64, 1#i64, (-1)#i64] (by scalar_tac) : alloc.vec.Vec Std.I64), (alloc.vec.Vec.from [...
[ { "input": "[[[0, 1, -1], [1, 0, -1], [1, 1, 1]]]", "output": "5" }, { "input": "[[[1, 1, -1], [1, -1, 1], [-1, 1, 1]]]", "output": "0" }, { "input": "[[[0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0]]]", "output": "0" }, { "input": "[[[1, 1, 1, 1], [1, 0, 1, 1], [1, 1...
77
false
77
verified
10
10
1
5,594
[ { "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.CherryPickup.Code.Funs /-! # Specifications of `Aegis.CherryPickup.cherry_pickup` LeetCode problem `cherry-pickup`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.CherryPickup set_option maxHeartbeats 1000000 namespace AegisSpec.CherryPickup a...
14
closest-leaf-in-a-binary-tree
742
Medium
[ "Tree", "Depth-First Search", "Breadth-First Search", "Binary Tree" ]
Given the root of a binary tree where every node has a unique value and a target integer k, return the value of the nearest leaf node to the target k in the tree. Nearest to a leaf means the least number of edges traveled on the binary tree to reach any leaf of the tree. Also, a node is called a leaf if it has no child...
findClosestLeaf(root: tree, k: int) -> int
pub fn find_closest_leaf(root: &Tree, k: i64) -> i64
Aegis.FindClosestLeaf.find_closest_leaf
fn child_value(t: &Tree) -> i64 { match t { Tree::Null => 0, Tree::Node(v, _, _) => *v, } } fn fill(t: &Tree, parent: i64, arr: &mut Vec<i64>) { match t { Tree::Null => {} Tree::Node(v, l, r) => { let val = *v; let b = (val as usize) * 3; ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [find_closest_leaf]: 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_closest_leaf]: function definitions module public import Aeneas public import Aegis.FindClosestLeaf.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.FindClosestLeaf.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.FindClosestLeaf.find_closest_leaf ((.Node 1#i64 (.Null) (.Null)) : Aegis.FindClosestLeaf.Tree) 1#i64) (1#i64))}") #eval (s!"CASE 1 {(Result.reduc...
[ { "input": "[[1], 1]", "output": "1" }, { "input": "[[1, 3, 2], 1]", "output": "3" }, { "input": "[[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15], 8]", "output": "8" }, { "input": "[[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15], 7]", "output": "14" }, { ...
17
false
17
verified
10
10
2
19,890
[ { "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.FindClosestLeaf.Code.Funs /-! # Specifications of `Aegis.FindClosestLeaf.find_closest_leaf` LeetCode problem `closest-leaf-in-a-binary-tree`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.FindClosestLeaf open Aegis.FindClosestLeaf (Tr...
12
network-delay-time
743
Medium
[ "Depth-First Search", "Breadth-First Search", "Graph", "Shortest Path", "Heap (Priority Queue)" ]
You are given a network of n nodes, labeled from 1 to n. You are also given times, a list of travel times as directed edges times[i] = (ui, vi, wi), where ui is the source node, vi is the target node, and wi is the time it takes for a signal to travel from source to target. We will send a signal from a given node k. Re...
networkDelayTime(times: list_list_int, n: int, k: int) -> int
pub fn network_delay_time(times: &[Vec<i64>], n: i64, k: i64) -> i64
Aegis.NetworkDelayTime.network_delay_time
pub fn network_delay_time(times: &[Vec<i64>], n: i64, k: i64) -> i64 { let nn: usize = n as usize; let inf: i64 = 1_000_000_000; let mut dist: Vec<i64> = Vec::new(); let mut i: usize = 0; while i < nn { dist.push(inf); i += 1; } let start: usize = (k - 1) as usize; dist...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [network_delay_time]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option li...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [network_delay_time]: function definitions module public import Aeneas public import Aegis.NetworkDelayTime.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.NetworkDelayTime.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.NetworkDelayTime.network_delay_time (Slice.from [(alloc.vec.Vec.from [1#i64, 2#i64, 1#i64] (by scalar_tac) : alloc.vec.Vec Std.I64)] (by scalar_...
[ { "input": "[[[1, 2, 1]], 2, 1]", "output": "1" }, { "input": "[[[1, 2, 1]], 2, 2]", "output": "-1" }, { "input": "[[[1, 2, 1], [2, 1, 3]], 2, 1]", "output": "1" }, { "input": "[[[1, 2, 10], [2, 3, 10], [1, 3, 1]], 3, 1]", "output": "10" }, { "input": "[[[1, 2, 1]...
100
false
100
verified
10
10
1
1,442
[ { "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.NetworkDelayTime.Code.Funs /-! # Specifications of `Aegis.NetworkDelayTime.network_delay_time` LeetCode problem `network-delay-time`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.NetworkDelayTime structure Edge where src : Int tg...
12
min-cost-climbing-stairs
746
Easy
[ "Array", "Dynamic Programming" ]
You are given an integer array cost where cost[i] is the cost of ith step on a staircase. Once you pay the cost, you can either climb one or two steps. You can either start from the step with index 0, or the step with index 1. Return the minimum cost to reach the top of the floor.   Example 1: Input: cost = [10,15,20]...
minCostClimbingStairs(cost: list_int) -> int
pub fn min_cost_climbing_stairs(cost: &[i64]) -> i64
Aegis.MinCostClimbingStairs.min_cost_climbing_stairs
pub fn min_cost_climbing_stairs(cost: &[i64]) -> i64 { let n = cost.len(); let mut prev2 = cost[0]; let mut prev1 = cost[1]; let mut i: usize = 2; while i < n { let better = if prev1 < prev2 { prev1 } else { prev2 }; let cur = cost[i] + better; prev2 = prev1; prev1...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [min_cost_climbing_stairs]: 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 -- [min_cost_climbing_stairs]: function definitions module public import Aeneas public import Aegis.MinCostClimbingStairs.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashComm...
import Aegis.MinCostClimbingStairs.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.MinCostClimbingStairs.min_cost_climbing_stairs (Slice.from [1#i64, 2#i64] (by scalar_tac) : Slice Std.I64)) (1#i64))}") #eval (s!"CASE 1 {(...
[ { "input": "[[1, 2]]", "output": "1" }, { "input": "[[10, 15]]", "output": "10" }, { "input": "[[10, 15]]", "output": "10" }, { "input": "[[999, 999]]", "output": "999" }, { "input": "[[10, 15, 20]]", "output": "15" }, { "input": "[[999, 999, 999, 999]...
102
false
102
verified
10
10
1
860
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MinCostClimbingStairs.Code.Funs /-! # Specifications of `Aegis.MinCostClimbingStairs.min_cost_climbing_stairs` LeetCode problem `min-cost-climbing-stairs`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.MinCostClimbingStairs def co...
12
largest-number-at-least-twice-of-others
747
Easy
[ "Array", "Sorting" ]
You are given an integer array nums where the largest integer is unique. Determine whether the largest element in the array is at least twice as much as every other number in the array. If it is, return the index of the largest element, or return -1 otherwise.   Example 1: Input: nums = [3,6,1,0] Output: 1 Explanation...
dominantIndex(nums: list_int) -> int
pub fn dominant_index(nums: &[i64]) -> i64
Aegis.DominantIndex.dominant_index
pub fn dominant_index(nums: &[i64]) -> i64 { let n = nums.len(); let mut max_val = nums[0]; let mut max_idx: usize = 0; let mut i: usize = 1; while i < n { if nums[i] > max_val { max_val = nums[i]; max_idx = i; } i += 1; } let mut j: usize =...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [dominant_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...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [dominant_index]: function definitions module public import Aeneas public import Aegis.DominantIndex.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.DominantIndex.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.DominantIndex.dominant_index (Slice.from [10#i64, 20#i64] (by scalar_tac) : Slice Std.I64)) (1#i64))}") #eval (s!"CASE 1 {(Result.reducesTo (Aegis....
[ { "input": "[[10, 20]]", "output": "1" }, { "input": "[[10, 5, 2]]", "output": "0" }, { "input": "[[1, 2, 0]]", "output": "1" }, { "input": "[[1, 2, 3, 6]]", "output": "3" }, { "input": "[[3, 6, 1, 0]]", "output": "1" }, { "input": "[[7, 1, 3, 2]]", ...
142
false
142
verified
10
10
1
570
[ { "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.DominantIndex.Code.Funs /-! # Specifications of `Aegis.DominantIndex.dominant_index` LeetCode problem `largest-number-at-least-twice-of-others`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.DominantIndex def atv (nums : Slice Std...
10
number-of-corner-rectangles
750
Medium
[ "Array", "Math", "Dynamic Programming", "Matrix" ]
Given an m x n integer matrix grid where each entry is only 0 or 1, return the number of corner rectangles. A corner rectangle is four distinct 1's on the grid that forms an axis-aligned rectangle. Note that only the corners need to have the value 1. Also, all four 1's used must be distinct.   Example 1: Input: grid ...
countCornerRectangles(grid: list_list_int) -> int
pub fn count_corner_rectangles(grid: &[Vec<i64>]) -> i64
Aegis.CountCornerRectangles.count_corner_rectangles
pub fn count_corner_rectangles(grid: &[Vec<i64>]) -> i64 { let m = grid.len(); if m == 0 { return 0; } let n = grid[0].len(); let mut total: i64 = 0; let mut r1: usize = 0; while r1 < m { let mut r2: usize = r1 + 1; while r2 < m { let mut common: i64 = 0...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [count_corner_rectangles]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_opti...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [count_corner_rectangles]: function definitions module public import Aeneas public import Aegis.CountCornerRectangles.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashComma...
import Aegis.CountCornerRectangles.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.CountCornerRectangles.count_corner_rectangles (Slice.from [(alloc.vec.Vec.from [1#i64] (by scalar_tac) : alloc.vec.Vec Std.I64)] (by scalar...
[ { "input": "[[[1]]]", "output": "0" }, { "input": "[[[1, 0], [0, 1]]]", "output": "0" }, { "input": "[[[1, 1, 1, 1]]]", "output": "0" }, { "input": "[[[1, 1], [1, 1], [1, 1]]]", "output": "3" }, { "input": "[[[1, 1, 1], [1, 1, 1], [1, 1, 1]]]", "output": "9" ...
82
false
82
verified
10
10
1
893
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.CountCornerRectangles.Code.Funs /-! # Specifications of `Aegis.CountCornerRectangles.count_corner_rectangles` LeetCode problem `number-of-corner-rectangles`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.CountCornerRectangles def toMa...
17
ip-to-cidr
751
Medium
[ "Bit Manipulation", "String" ]
An IP address is a formatted 32-bit unsigned integer where each group of 8 bits is printed as a decimal number and the dot character '.' splits the groups. For example, the binary number 00001111 10001000 11111111 01101011 (spaces added for clarity) formatted as an IP address would be "15.136.255.107". A CIDR block i...
ipToCIDR(ip: str, n: int) -> list_str
pub fn ip_to_cidr(ip: &[u8], n: i64) -> Vec<Vec<u8>>
Aegis.IpToCidr.ip_to_cidr
fn number_bytes(mut x: i64) -> Vec<u8> { let mut digits: Vec<u8> = Vec::new(); if x == 0 { digits.push(b'0'); return digits; } let mut rev: Vec<u8> = Vec::new(); while x > 0 { let d: u8 = (x % 10) as u8; rev.push(b'0' + d); x = x / 10; } let mut k: u...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [ip_to_cidr]: 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 -- [ip_to_cidr]: function definitions module public import Aeneas public import Aegis.IpToCidr.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.IpToCidr.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.IpToCidr.ip_to_cidr (Slice.from [49#u8, 46#u8, 50#u8, 46#u8, 51#u8, 46#u8, 52#u8] (by scalar_tac) : Slice Std.U8) 4#i64) ((alloc.vec.Vec.from [(alloc.ve...
[ { "input": "[\"1.2.3.4\", 4]", "output": "[\"1.2.3.4/30\"]" }, { "input": "[\"255.255.255.252\", 4]", "output": "[\"255.255.255.252/30\"]" }, { "input": "[\"192.168.1.0\", 16]", "output": "[\"192.168.1.0/28\"]" }, { "input": "[\"172.16.0.0\", 2048]", "output": "[\"172.16....
132
false
132
verified
10
10
1
8,205
[ { "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.IpToCidr.Code.Funs /-! # Specifications of `Aegis.IpToCidr.ip_to_cidr` LeetCode problem `ip-to-cidr`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.IpToCidr namespace AegisSpec.IpToCidr def byteOf (c : ℕ) : U8 := ⟨BitVec.ofNat 8 c⟩ def dotByt...
14
reach-a-number
754
Medium
[ "Math", "Binary Search" ]
You are standing at position 0 on an infinite number line. There is a destination at position target. You can make some number of moves numMoves so that: On each move, you can either go left or right. During the ith move (starting from i == 1 to i == numMoves), you take i steps in the chosen direction. Given the inte...
reachNumber(target: int) -> int
pub fn reach_number(target: i64) -> i64
Aegis.ReachNumber.reach_number
pub fn reach_number(target: i64) -> i64 { let mut n = target; if n < 0 { n = -n; } let mut k: i64 = 0; let mut sum: i64 = 0; while sum < n || (sum - n) % 2 != 0 { k += 1; sum += k; } k }
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [reach_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.s...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [reach_number]: function definitions module public import Aeneas public import Aegis.ReachNumber.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.ReachNumber.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.ReachNumber.reach_number 2#i64) (3#i64))}") #eval (s!"CASE 1 {(Result.reducesTo (Aegis.ReachNumber.reach_number (-20)#i64) (7#i64))}") #eval (s!"CASE...
[ { "input": "[2]", "output": "3" }, { "input": "[-20]", "output": "7" }, { "input": "[15]", "output": "5" }, { "input": "[10]", "output": "4" }, { "input": "[-5]", "output": "5" }, { "input": "[1]", "output": "1" }, { "input": "[-1]", "o...
70
false
70
verified
10
10
1
910
[ { "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.ReachNumber.Code.Funs /-! # Specifications of `Aegis.ReachNumber.reach_number` LeetCode problem `reach-a-number`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.ReachNumber def T (n : ℤ) : ℤ := n * (n + 1) / 2 def IsLeastReach (...
12
pour-water
755
Medium
[ "Array", "Simulation" ]
You are given an elevation map represents as an integer array heights where heights[i] representing the height of the terrain at index i. The width at each index is 1. You are also given two integers volume and k. volume units of water will fall at index k. Water first drops at the index k and rests on top of the highe...
pourWater(heights: list_int, volume: int, k: int) -> list_int
pub fn pour_water(heights: &[i64], volume: i64, k: i64) -> Vec<i64>
Aegis.PourWater.pour_water
pub fn pour_water(heights: &[i64], volume: i64, k: i64) -> Vec<i64> { let n = heights.len(); let mut water: Vec<i64> = Vec::new(); let mut i = 0usize; while i < n { water.push(heights[i]); i += 1; } let start = k as usize; let mut dropped: i64 = 0; while dropped < volu...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [pour_water]: 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 -- [pour_water]: function definitions module public import Aeneas public import Aegis.PourWater.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.PourWater.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.PourWater.pour_water (Slice.from [3#i64, 1#i64, 3#i64] (by scalar_tac) : Slice Std.I64) 5#i64 1#i64) ((alloc.vec.Vec.from [4#i64, 4#i64, 4#i64] (by sca...
[ { "input": "[[3, 1, 3], 5, 1]", "output": "[4, 4, 4]" }, { "input": "[[99, 99, 99], 0, 1]", "output": "[99, 99, 99]" }, { "input": "[[1, 2, 3, 4], 2, 2]", "output": "[2, 3, 3, 4]" }, { "input": "[[1, 1, 1, 1, 1], 5, 2]", "output": "[2, 2, 2, 2, 2]" }, { "input": "...
120
false
120
verified
10
10
1
12,860
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.PourWater.Code.Funs /-! # Specifications of `Aegis.PourWater.pour_water` LeetCode problem `pour-water`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.PourWater (pour_water) namespace AegisSpec.PourWater def i64At (xs : List Std.I64) (i : Nat) ...
13
pyramid-transition-matrix
756
Medium
[ "Bit Manipulation", "Depth-First Search", "Breadth-First Search" ]
You are stacking blocks to form a pyramid. Each block has a color, which is represented by a single letter. Each row of blocks contains one less block than the row beneath it and is centered on top. To make the pyramid aesthetically pleasing, there are only specific triangular patterns that are allowed. A triangular pa...
pyramidTransition(bottom: str, allowed: list_str) -> bool
pub fn pyramid_transition(bottom: &[u8], allowed: &[Vec<u8>]) -> bool
Aegis.PyramidTransition.pyramid_transition
fn build_parents(enc: i64, width: usize, base: i64, ppow: &[i64], allow: &[bool]) -> Vec<i64> { // rows[k] = true iff partial parent encoding `k` (of current length) is valid let mut rows: Vec<bool> = Vec::new(); rows.push(true); let mut pow: i64 = 1; // = base^i, current length of partial encodings ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [pyramid_transition]: 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 -- [pyramid_transition]: function definitions module public import Aeneas public import Aegis.PyramidTransition.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false ...
import Aegis.PyramidTransition.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.PyramidTransition.pyramid_transition (Slice.from [65#u8, 66#u8] (by scalar_tac) : Slice Std.U8) (Slice.from [(alloc.vec.Vec.from [65#u8, 66#u8,...
[ { "input": "[\"AB\", [\"ABA\", \"ABB\"]]", "output": "true" }, { "input": "[\"ABC\", [\"ABD\", \"BCE\", \"DEF\"]]", "output": "true" }, { "input": "[\"AFA\", [\"AFF\", \"FAA\", \"FFF\"]]", "output": "true" }, { "input": "[\"ABC\", [\"ABA\", \"BCB\", \"ACA\"]]", "output": ...
73
false
73
verified
10
10
5
55,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.PyramidTransition.Code.Funs /-! # Specifications of `Aegis.PyramidTransition.pyramid_transition` LeetCode problem `pyramid-transition-matrix`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.PyramidTransition namespace AegisSpec.PyramidTransi...
7
set-intersection-size-at-least-two
757
Hard
[ "Greedy", "Array", "Sorting" ]
You are given a 2D integer array intervals where intervals[i] = [starti, endi] represents all the integers from starti to endi inclusively. A containing set is an array nums where each interval from intervals has at least two integers in nums. For example, if intervals = [[1,3], [3,7], [8,9]], then [1,2,4,7,8,9] and [...
intersectionSizeTwo(intervals: list_list_int) -> int
pub fn intersection_size_two(intervals: &[Vec<i64>]) -> i64
Aegis.IntersectionSizeTwo.intersection_size_two
pub fn intersection_size_two(intervals: &[Vec<i64>]) -> i64 { let n = intervals.len(); let mut starts: Vec<i64> = Vec::new(); let mut ends: Vec<i64> = Vec::new(); let mut i = 0usize; while i < n { starts.push(intervals[i][0]); ends.push(intervals[i][1]); i += 1; } ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [intersection_size_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...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [intersection_size_two]: function definitions module public import Aeneas public import Aegis.IntersectionSizeTwo.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand f...
import Aegis.IntersectionSizeTwo.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.IntersectionSizeTwo.intersection_size_two (Slice.from [(alloc.vec.Vec.from [1#i64, 2#i64] (by scalar_tac) : alloc.vec.Vec Std.I64), (alloc.ve...
[ { "input": "[[[1, 2], [2, 3]]]", "output": "3" }, { "input": "[[[1, 10], [5, 10], [7, 15]]]", "output": "2" }, { "input": "[[[1, 3], [3, 7], [8, 9]]]", "output": "5" }, { "input": "[[[1, 2], [3, 4], [5, 6]]]", "output": "6" }, { "input": "[[[1, 5], [2, 4], [3, 6]]...
90
false
90
verified
10
10
1
4,370
[ { "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.IntersectionSizeTwo.Code.Funs /-! # Specifications of `Aegis.IntersectionSizeTwo.intersection_size_two` LeetCode problem `set-intersection-size-at-least-two`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.IntersectionSizeTwo open ...
12
prime-number-of-set-bits-in-binary-representation
762
Easy
[ "Bit Manipulation", "Math" ]
Given two integers left and right, return the count of numbers in the inclusive range [left, right] having a prime number of set bits in their binary representation. Recall that the number of set bits an integer has is the number of 1's present when written in binary. For example, 21 written in binary is 10101, which ...
countPrimeSetBits(left: int, right: int) -> int
pub fn count_prime_set_bits(left: i64, right: i64) -> i64
Aegis.CountPrimeSetBits.count_prime_set_bits
pub fn count_prime_set_bits(left: i64, right: i64) -> i64 { let mut ans: i64 = 0; let mut n: i64 = left; while n <= right { let mut x: i64 = n; let mut bits: i64 = 0; while x > 0 { if x % 2 == 1 { bits += 1; } x = x / 2; }...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [count_prime_set_bits]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [count_prime_set_bits]: function definitions module public import Aeneas public import Aegis.CountPrimeSetBits.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand fals...
import Aegis.CountPrimeSetBits.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.CountPrimeSetBits.count_prime_set_bits 100#i64 105#i64) (3#i64))}") #eval (s!"CASE 1 {(Result.reducesTo (Aegis.CountPrimeSetBits.count_prime_se...
[ { "input": "[100, 105]", "output": "3" }, { "input": "[500, 1000]", "output": "253" }, { "input": "[1, 100]", "output": "65" }, { "input": "[6, 10]", "output": "4" }, { "input": "[999900, 1000000]", "output": "30" }, { "input": "[1, 20]", "output":...
79
false
79
verified
10
10
1
962
[ { "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.CountPrimeSetBits.Code.Funs /-! # Specifications of `Aegis.CountPrimeSetBits.count_prime_set_bits` LeetCode problem `prime-number-of-set-bits-in-binary-representation`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.CountPrimeSetBits namespa...
10
partition-labels
763
Medium
[ "Greedy", "Hash Table", "Two Pointers", "String" ]
You are given a string s. We want to partition the string into as many parts as possible so that each letter appears in at most one part. For example, the string "ababcc" can be partitioned into ["abab", "cc"], but partitions such as ["aba", "bcc"] or ["ab", "ab", "cc"] are invalid. Note that the partition is done so t...
partitionLabels(s: str) -> list_int
pub fn partition_labels(s: &[u8]) -> Vec<i64>
Aegis.PartitionLabels.partition_labels
pub fn partition_labels(s: &[u8]) -> Vec<i64> { let n: usize = s.len(); let mut last: Vec<i64> = Vec::new(); let mut k: usize = 0; while k < 26 { last.push(-1); k += 1; } let mut i: usize = 0; while i < n { let b: u8 = s[i]; let idx: usize = (b - b'a') as us...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [partition_labels]: 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 -- [partition_labels]: function definitions module public import Aeneas public import Aegis.PartitionLabels.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.PartitionLabels.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.PartitionLabels.partition_labels (Slice.from [120#u8, 121#u8, 122#u8, 120#u8, 121#u8, 122#u8, 120#u8, 121#u8, 122#u8] (by scalar_tac) : Slice Std...
[ { "input": "[\"xyzxyzxyz\"]", "output": "[9]" }, { "input": "[\"abcdabcdeabcdabcde\"]", "output": "[18]" }, { "input": "[\"a\"]", "output": "[1]" }, { "input": "[\"zabbcdefghijklmnopqrstuvwxyz\"]", "output": "[28]" }, { "input": "[\"abcdcba\"]", "output": "[7]...
64
false
64
verified
10
10
1
1,535
[ { "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.PartitionLabels.Code.Funs /-! # Specifications of `Aegis.PartitionLabels.partition_labels` LeetCode problem `partition-labels`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.PartitionLabels namespace AegisSpec.PartitionLabels def prefixSum (r ...
12
largest-plus-sign
764
Medium
[ "Array", "Dynamic Programming" ]
You are given an integer n. You have an n x n binary grid grid with all values initially 1's except for some indices given in the array mines. The ith element of the array mines is defined as mines[i] = [xi, yi] where grid[xi][yi] == 0. Return the order of the largest axis-aligned plus sign of 1's contained in grid. If...
orderOfLargestPlusSign(n: int, mines: list_list_int) -> int
pub fn order_of_largest_plus_sign(n: i64, mines: &[Vec<i64>]) -> i64
Aegis.OrderOfLargestPlusSign.order_of_largest_plus_sign
fn bit_add(tree: &mut Vec<i64>, n: usize, idx: usize, delta: i64) { let mut i: usize = idx + 1; while i <= n { tree[i] = tree[i] + delta; let lb: usize = i & (i ^ (i - 1)); i += lb; } } fn bit_sum(tree: &Vec<i64>, i0: usize) -> i64 { let mut i: usize = i0; let mut s: i64 = 0...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [order_of_largest_plus_sign]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_o...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [order_of_largest_plus_sign]: function definitions module public import Aeneas public import Aegis.OrderOfLargestPlusSign.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashC...
import Aegis.OrderOfLargestPlusSign.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}" #eva...
[ { "input": "[500, []]", "output": "250" }, { "input": "[4, []]", "output": "2" }, { "input": "[3, []]", "output": "2" }, { "input": "[1, [[0, 0]]]", "output": "0" }, { "input": "[500, [[250, 250]]]", "output": "250" }, { "input": "[3, [[1, 1]]]", "...
91
false
91
verified
10
10
3
59,186
[ { "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.OrderOfLargestPlusSign.Code.Funs /-! # Specifications of `Aegis.OrderOfLargestPlusSign.order_of_largest_plus_sign` LeetCode problem `largest-plus-sign`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.OrderOfLargestPlusSign def mineCoor...
12
toeplitz-matrix
766
Easy
[ "Array", "Matrix" ]
Given an m x n matrix, return true if the matrix is Toeplitz. Otherwise, return false. A matrix is Toeplitz if every diagonal from top-left to bottom-right has the same elements.   Example 1: Input: matrix = [[1,2,3,4],[5,1,2,3],[9,5,1,2]] Output: true Explanation: In the above grid, the diagonals are: "[9]", "[5, 5]...
isToeplitzMatrix(matrix: list_list_int) -> bool
pub fn is_toeplitz_matrix(matrix: &[Vec<i64>]) -> bool
Aegis.IsToeplitzMatrix.is_toeplitz_matrix
pub fn is_toeplitz_matrix(matrix: &[Vec<i64>]) -> bool { let m = matrix.len(); if m == 0 { return true; } let n = matrix[0].len(); let mut ok: bool = true; let mut i: usize = 1; while i < m { let mut j: usize = 1; while j < n { if matrix[i][j] != matrix...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [is_toeplitz_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 li...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [is_toeplitz_matrix]: function definitions module public import Aeneas public import Aegis.IsToeplitzMatrix.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.IsToeplitzMatrix.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.IsToeplitzMatrix.is_toeplitz_matrix (Slice.from [(alloc.vec.Vec.from [1#i64] (by scalar_tac) : alloc.vec.Vec Std.I64)] (by scalar_tac) : Slice (...
[ { "input": "[[[1]]]", "output": "true" }, { "input": "[[[1, 2], [3, 4]]]", "output": "false" }, { "input": "[[[1, 2], [2, 2]]]", "output": "false" }, { "input": "[[[9], [8], [7], [6], [5]]]", "output": "true" }, { "input": "[[[5], [4], [3], [2], [1]]]", "outpu...
84
false
84
verified
10
10
2
975
[ { "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.IsToeplitzMatrix.Code.Funs /-! # Specifications of `Aegis.IsToeplitzMatrix.is_toeplitz_matrix` LeetCode problem `toeplitz-matrix`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.IsToeplitzMatrix def nrows (matrix : Slice (alloc.vec.Vec...
8
max-chunks-to-make-sorted-ii
768
Hard
[ "Stack", "Greedy", "Array", "Sorting", "Monotonic Stack" ]
You are given an integer array arr. We split arr into some number of chunks (i.e., partitions), and individually sort each chunk. After concatenating them, the result should equal the sorted array. Return the largest number of chunks we can make to sort the array.   Example 1: Input: arr = [5,4,3,2,1] Output: 1 Explan...
maxChunksToSorted(arr: list_int) -> int
pub fn max_chunks_to_sorted(arr: &[i64]) -> i64
Aegis.MaxChunksToSorted.max_chunks_to_sorted
pub fn max_chunks_to_sorted(arr: &[i64]) -> i64 { let n = arr.len(); if n == 0 { return 0; } let mut suffix_min: Vec<i64> = Vec::new(); let mut i: usize = 0; while i < n { suffix_min.push(0); i += 1; } let mut cur_min = arr[n - 1]; let mut j = n; while j...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [max_chunks_to_sorted]: 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 -- [max_chunks_to_sorted]: function definitions module public import Aeneas public import Aegis.MaxChunksToSorted.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand fals...
import Aegis.MaxChunksToSorted.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.MaxChunksToSorted.max_chunks_to_sorted (Slice.from [4#i64, 3#i64, 2#i64, 1#i64, 0#i64] (by scalar_tac) : Slice Std.I64)) (1#i64))}") #eval (s!"...
[ { "input": "[[4, 3, 2, 1, 0]]", "output": "1" }, { "input": "[[5, 4, 3, 2, 1]]", "output": "1" }, { "input": "[[3, 2, 1, 4, 5]]", "output": "3" }, { "input": "[[1, 2, 3, 4, 5]]", "output": "5" }, { "input": "[[4, 2, 2, 1, 3]]", "output": "1" }, { "inpu...
149
false
149
verified
10
10
1
1,658
[ { "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.MaxChunksToSorted.Code.Funs /-! # Specifications of `Aegis.MaxChunksToSorted.max_chunks_to_sorted` LeetCode problem `max-chunks-to-make-sorted-ii`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.MaxChunksToSorted def value (arr : Slice...
12
max-chunks-to-make-sorted
769
Medium
[ "Stack", "Greedy", "Array", "Sorting", "Monotonic Stack" ]
You are given an integer array arr of length n that represents a permutation of the integers in the range [0, n - 1]. We split arr into some number of chunks (i.e., partitions), and individually sort each chunk. After concatenating them, the result should equal the sorted array. Return the largest number of chunks we c...
maxChunksToSorted(arr: list_int) -> int
pub fn max_chunks_to_sorted(arr: &[i64]) -> i64
Aegis.MaxChunksToSorted.max_chunks_to_sorted
pub fn max_chunks_to_sorted(arr: &[i64]) -> i64 { let n = arr.len(); let mut chunks: i64 = 0; let mut max_so_far: i64 = -1; let mut i: usize = 0; while i < n { if arr[i] > max_so_far { max_so_far = arr[i]; } if max_so_far == i as i64 { chunks += 1; ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [max_chunks_to_sorted]: 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 -- [max_chunks_to_sorted]: function definitions module public import Aeneas public import Aegis.MaxChunksToSorted.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand fals...
import Aegis.MaxChunksToSorted.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.MaxChunksToSorted.max_chunks_to_sorted (Slice.from [1#i64, 2#i64, 0#i64, 3#i64, 4#i64] (by scalar_tac) : Slice Std.I64)) (3#i64))}") #eval (s!"...
[ { "input": "[[1, 2, 0, 3, 4]]", "output": "3" }, { "input": "[[3, 1, 0, 2, 4]]", "output": "2" }, { "input": "[[2, 0, 1, 3, 4]]", "output": "3" }, { "input": "[[2, 1, 0, 3, 4]]", "output": "3" }, { "input": "[[4, 3, 2, 1, 0]]", "output": "1" }, { "inpu...
127
false
127
verified
10
10
1
312
[ { "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.MaxChunksToSorted.Code.Funs /-! # Specifications of `Aegis.MaxChunksToSorted.max_chunks_to_sorted` LeetCode problem `max-chunks-to-make-sorted`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.MaxChunksToSorted namespace AegisSpec.MaxChunksToSort...
9
jewels-and-stones
771
Easy
[ "Hash Table", "String" ]
You're given strings jewels representing the types of stones that are jewels, and stones representing the stones you have. Each character in stones is a type of stone you have. You want to know how many of the stones you have are also jewels. Letters are case sensitive, so "a" is considered a different type of stone fr...
numJewelsInStones(jewels: str, stones: str) -> int
pub fn num_jewels_in_stones(jewels: &[u8], stones: &[u8]) -> i64
Aegis.NumJewelsInStones.num_jewels_in_stones
pub fn num_jewels_in_stones(jewels: &[u8], stones: &[u8]) -> i64 { let mut count: i64 = 0; let mut i: usize = 0; while i < stones.len() { let stone = stones[i]; let mut is_jewel: bool = false; let mut j: usize = 0; while j < jewels.len() { if jewels[j] == stone ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [num_jewels_in_stones]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [num_jewels_in_stones]: function definitions module public import Aeneas public import Aegis.NumJewelsInStones.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand fals...
import Aegis.NumJewelsInStones.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.NumJewelsInStones.num_jewels_in_stones (Slice.from [97#u8, 65#u8] (by scalar_tac) : Slice Std.U8) (Slice.from [97#u8, 65#u8, 65#u8, 98#u8, 98#u...
[ { "input": "[\"aA\", \"aAAbbbb\"]", "output": "3" }, { "input": "[\"xyz\", \"aabbcc\"]", "output": "0" }, { "input": "[\"xyz\", \"\"]", "output": "0" }, { "input": "[\"aA\", \"\"]", "output": "0" }, { "input": "[\"abcdefg\", \"aghfbadcegf\"]", "output": "10" ...
103
false
103
verified
10
10
1
384
[ { "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.NumJewelsInStones.Code.Funs /-! # Specifications of `Aegis.NumJewelsInStones.num_jewels_in_stones` LeetCode problem `jewels-and-stones`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.NumJewelsInStones def isLetter (b : Std.U8) : Prop ...
11
sliding-puzzle
773
Hard
[ "Breadth-First Search", "Memoization", "Array", "Dynamic Programming", "Backtracking", "Matrix" ]
On an 2 x 3 board, there are five tiles labeled from 1 to 5, and an empty square represented by 0. A move consists of choosing 0 and a 4-directionally adjacent number and swapping it. The state of the board is solved if and only if the board is [[1,2,3],[4,5,0]]. Given the puzzle board board, return the least number of...
slidingPuzzle(board: list_list_int) -> int
pub fn sliding_puzzle(board: &[Vec<i64>]) -> i64
Aegis.SlidingPuzzle.sliding_puzzle
fn pid3(a: i64, b: i64, c: i64) -> i64 { let mut o: i64 = 0; if a < b { if b < c { o = 0; } else if a < c { o = 1; } else { o = 2; } } else if a < c { o = 3; } else if b < c { o = 4; } else { o = 5; } ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [sliding_puzzle]: 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 -- [sliding_puzzle]: function definitions module public import Aeneas public import Aegis.SlidingPuzzle.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.SlidingPuzzle.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": "[[[4, 1, 2], [0, 5, 3]]]", "output": "4" }, { "input": "[[[3, 2, 4], [1, 5, 0]]]", "output": "14" }, { "input": "[[[0, 1, 2], [4, 5, 3]]]", "output": "3" }, { "input": "[[[1, 2, 3], [4, 0, 5]]]", "output": "1" }, { "input": "[[[1, 2, 0], [3, 4, 5]]]", ...
78
false
78
verified
10
10
5
112,602
[ { "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.SlidingPuzzle.Code.Funs /-! # Specifications of `Aegis.SlidingPuzzle.sliding_puzzle` LeetCode problem `sliding-puzzle`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.SlidingPuzzle def rowList (board : Slice (alloc.vec.Vec Std.I64)...
13
swap-adjacent-in-lr-string
777
Medium
[ "Two Pointers", "String" ]
In a string composed of 'L', 'R', and 'X' characters, like "RXXLRXRXL", a move consists of either replacing one occurrence of "XL" with "LX", or replacing one occurrence of "RX" with "XR". Given the starting string start and the ending string result, return True if and only if there exists a sequence of moves to transf...
canTransform(start: str, result: str) -> bool
pub fn can_transform(start: &[u8], result: &[u8]) -> bool
Aegis.CanTransform.can_transform
pub fn can_transform(start: &[u8], result: &[u8]) -> bool { if start.len() != result.len() { return false; } let n: usize = start.len(); let mut i: usize = 0; let mut j: usize = 0; while i < n || j < n { // advance i to the next non-'X' byte in start while i < n && start[...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [can_transform]: 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 -- [can_transform]: function definitions module public import Aeneas public import Aegis.CanTransform.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.CanTransform.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.CanTransform.can_transform (Slice.from [88#u8, 88#u8, 76#u8] (by scalar_tac) : Slice Std.U8) (Slice.from [76#u8, 88#u8, 88#u8] (by scalar_tac) : Sli...
[ { "input": "[\"XXL\", \"LXX\"]", "output": "true" }, { "input": "[\"RXXLRXRXL\", \"XRLXXRRLX\"]", "output": "true" }, { "input": "[\"LLR\", \"RRL\"]", "output": "false" }, { "input": "[\"RXXL\", \"XRXL\"]", "output": "true" }, { "input": "[\"XRXL\", \"LXXR\"]", ...
257
false
257
verified
10
10
1
945
[ { "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.CanTransform.Code.Funs /-! # Specifications of `Aegis.CanTransform.can_transform` LeetCode problem `swap-adjacent-in-lr-string`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.CanTransform def IsLRX (l : List Std.U8) : Prop := ∀ b ∈ ...
11
k-th-symbol-in-grammar
779
Medium
[ "Bit Manipulation", "Recursion", "Math" ]
We build a table of n rows (1-indexed). We start by writing 0 in the 1st row. Now in every subsequent row, we look at the previous row and replace each occurrence of 0 with 01, and each occurrence of 1 with 10. For example, for n = 3, the 1st row is 0, the 2nd row is 01, and the 3rd row is 0110. Given two integer n a...
kthGrammar(n: int, k: int) -> int
pub fn kth_grammar(n: i64, k: i64) -> i64
Aegis.KthGrammar.kth_grammar
pub fn kth_grammar(n: i64, k: i64) -> i64 { let mut half: i64 = 1; let mut i: i64 = 2; while i < n { half = half * 2; i = i + 1; } let mut ans: i64 = 0; let mut nn: i64 = n; let mut kk: i64 = k; while nn > 1 { if kk > half { ans = 1 - ans; ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [kth_grammar]: 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 -- [kth_grammar]: function definitions module public import Aeneas public import Aegis.KthGrammar.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.KthGrammar.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.KthGrammar.kth_grammar 4#i64 8#i64) (1#i64))}") #eval (s!"CASE 1 {(Result.reducesTo (Aegis.KthGrammar.kth_grammar 5#i64 26#i64) (0#i64))}") #eval (s!"...
[ { "input": "[4, 8]", "output": "1" }, { "input": "[5, 26]", "output": "0" }, { "input": "[5, 21]", "output": "0" }, { "input": "[5, 19]", "output": "0" }, { "input": "[30, 536870912]", "output": "1" }, { "input": "[3, 2]", "output": "1" }, { ...
86
false
86
verified
10
10
1
11,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.KthGrammar.Code.Funs /-! # Specifications of `Aegis.KthGrammar.kth_grammar` LeetCode problem `k-th-symbol-in-grammar`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Classical namespace AegisSpec.KthGrammar def zpow2 (e : ℤ) : ℤ := 2 ^ e.toNat ...
13
reaching-points
780
Hard
[ "Math" ]
Given four integers sx, sy, tx, and ty, return true if it is possible to convert the point (sx, sy) to the point (tx, ty) through some operations, or false otherwise. The allowed operation on some point (x, y) is to convert it to either (x, x + y) or (x + y, y).   Example 1: Input: sx = 1, sy = 1, tx = 3, ty = 5 Outpu...
reachingPoints(sx: int, sy: int, tx: int, ty: int) -> bool
pub fn reaching_points(sx: i64, sy: i64, tx: i64, ty: i64) -> bool
Aegis.ReachingPoints.reaching_points
pub fn reaching_points(sx: i64, sy: i64, tx: i64, ty: i64) -> bool { let mut x = tx; let mut y = ty; while x >= sx && y >= sy { if x == sx && y == sy { return true; } if x > y { if y == sy { return (x - sx) % y == 0; } ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [reaching_points]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linte...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [reaching_points]: function definitions module public import Aeneas public import Aegis.ReachingPoints.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.ReachingPoints.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.ReachingPoints.reaching_points 1#i64 1#i64 3#i64 5#i64) (true))}") #eval (s!"CASE 1 {(Result.reducesTo (Aegis.ReachingPoints.reaching_points 3#i64...
[ { "input": "[1, 1, 3, 5]", "output": "true" }, { "input": "[3, 4, 3, 12]", "output": "false" }, { "input": "[3, 7, 31, 19]", "output": "false" }, { "input": "[1, 1, 1000000000, 1000000000]", "output": "false" }, { "input": "[5, 5, 5, 5]", "output": "true" },...
101
false
101
verified
10
10
1
2,919
[ { "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.ReachingPoints.Code.Funs /-! # Specifications of `Aegis.ReachingPoints.reaching_points` LeetCode problem `reaching-points`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.ReachingPoints (reaching_points) namespace AegisSpec.ReachingPoints ...
13
rabbits-in-forest
781
Medium
[ "Greedy", "Array", "Hash Table", "Math" ]
There is a forest with an unknown number of rabbits. We asked n rabbits "How many rabbits have the same color as you?" and collected the answers in an integer array answers where answers[i] is the answer of the ith rabbit. Given the array answers, return the minimum number of rabbits that could be in the forest.   Exam...
numRabbits(answers: list_int) -> int
pub fn num_rabbits(answers: &[i64]) -> i64
Aegis.NumRabbits.num_rabbits
pub fn num_rabbits(answers: &[i64]) -> i64 { let mut counts: Vec<i64> = Vec::new(); let mut i: usize = 0; while i < 1000 { counts.push(0); i += 1; } let n = answers.len(); let mut j: usize = 0; while j < n { let a = answers[j] as usize; counts[a] = counts[a] ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [num_rabbits]: 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_rabbits]: function definitions module public import Aeneas public import Aegis.NumRabbits.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.NumRabbits.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.NumRabbits.num_rabbits (Slice.from [1#i64, 1#i64, 2#i64] (by scalar_tac) : Slice Std.I64)) (5#i64))}") #eval (s!"CASE 1 {(Result.reducesTo (Aegis.NumR...
[ { "input": "[[1, 1, 2]]", "output": "5" }, { "input": "[[999, 999, 999]]", "output": "1000" }, { "input": "[[0, 0, 0]]", "output": "3" }, { "input": "[[10, 10, 10]]", "output": "11" }, { "input": "[[1, 2, 3, 4, 5]]", "output": "20" }, { "input": "[[0, ...
66
false
66
verified
10
10
1
1,541
[ { "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.NumRabbits.Code.Funs /-! # Specifications of `Aegis.NumRabbits.num_rabbits` LeetCode problem `rabbits-in-forest`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.NumRabbits open scoped BigOperators def count (answers : Slice Std.I64) (...
12
transform-to-chessboard
782
Hard
[ "Bit Manipulation", "Array", "Math", "Matrix" ]
You are given an n x n binary grid board. In each move, you can swap any two rows with each other, or any two columns with each other. Return the minimum number of moves to transform the board into a chessboard board. If the task is impossible, return -1. A chessboard board is a board where no 0's and no 1's are 4-dire...
movesToChessboard(board: list_list_int) -> int
pub fn moves_to_chessboard(board: &[Vec<i64>]) -> i64
Aegis.MovesToChessboard.moves_to_chessboard
fn min_line_swaps(count_ones: i64, mismatch0: i64, n: i64) -> i64 { if n % 2 == 0 { let half = n / 2; if count_ones != half { return -1; } let mut best_mismatch = mismatch0; let other = n - mismatch0; if other < best_mismatch { best_mismatch =...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [moves_to_chessboard]: 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 -- [moves_to_chessboard]: function definitions module public import Aeneas public import Aegis.MovesToChessboard.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false...
import Aegis.MovesToChessboard.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.MovesToChessboard.moves_to_chessboard (Slice.from [(alloc.vec.Vec.from [1#i64, 0#i64] (by scalar_tac) : alloc.vec.Vec Std.I64), (alloc.vec.Vec....
[ { "input": "[[[1, 0], [1, 0]]]", "output": "-1" }, { "input": "[[[0, 1], [1, 0]]]", "output": "0" }, { "input": "[[[0, 0], [0, 0]]]", "output": "-1" }, { "input": "[[[1, 1], [1, 1]]]", "output": "-1" }, { "input": "[[[1, 1, 0], [0, 0, 1], [0, 1, 0]]]", "output...
75
false
75
verified
10
10
2
12,963
[ { "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.MovesToChessboard.Code.Funs /-! # Specifications of `Aegis.MovesToChessboard.moves_to_chessboard` LeetCode problem `transform-to-chessboard`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.MovesToChessboard namespace AegisSpec.MovesToChessboard ...
16
minimum-distance-between-bst-nodes
783
Easy
[ "Tree", "Depth-First Search", "Breadth-First Search", "Binary Search Tree", "Binary Tree" ]
Given the root of a Binary Search Tree (BST), return the minimum difference between the values of any two different nodes in the tree.   Example 1: Input: root = [4,2,6,1,3] Output: 1 Example 2: Input: root = [1,0,48,null,null,12,49] Output: 1   Constraints: The number of nodes in the tree is in the range [2, 10...
minDiffInBST(root: tree) -> int
pub fn min_diff_in_bst(root: &Tree) -> i64
Aegis.MinDiffInBst.min_diff_in_bst
fn collect_inorder(t: &Tree) -> Vec<i64> { let mut out: Vec<i64> = Vec::new(); match t { Tree::Null => {} Tree::Node(v, l, r) => { let left = collect_inorder(&**l); let mut i: usize = 0; while i < left.len() { out.push(left[i]); ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [min_diff_in_bst]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linte...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [min_diff_in_bst]: function definitions module public import Aeneas public import Aegis.MinDiffInBst.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.MinDiffInBst.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.MinDiffInBst.min_diff_in_bst ((.Node 2#i64 (.Node 1#i64 (.Null) (.Null)) (.Node 3#i64 (.Null) (.Null))) : Aegis.MinDiffInBst.Tree)) (1#i64))}") #eva...
[ { "input": "[[2, 1, 3]]", "output": "1" }, { "input": "[[4, 2, 6, 1, 3]]", "output": "1" }, { "input": "[[4, 2, 7, 1, 3, 6, 9]]", "output": "1" }, { "input": "[[5, 3, 8, 1, 4, 7, 9]]", "output": "1" }, { "input": "[[1, 2, 4, 3, 5, 7, 9, 6, 8, 10]]", "output": ...
50
false
50
verified
10
10
1
8,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.MinDiffInBst.Code.Funs /-! # Specifications of `Aegis.MinDiffInBst.min_diff_in_bst` LeetCode problem `minimum-distance-between-bst-nodes`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.MinDiffInBst namespace AegisSpec.MinDiffInBst def nodeVals...
8
letter-case-permutation
784
Medium
[ "Bit Manipulation", "String", "Backtracking" ]
Given a string s, you can transform every letter individually to be lowercase or uppercase to create another string. Return a list of all possible strings we could create. Return the output in any order.   Example 1: Input: s = "a1b2" Output: ["a1b2","a1B2","A1b2","A1B2"] Example 2: Input: s = "3z4" Output: ["3z4","...
letterCasePermutation(s: str) -> list_str
pub fn letter_case_permutation(s: &[u8]) -> Vec<Vec<u8>>
Aegis.LetterCasePermutation.letter_case_permutation
pub fn letter_case_permutation(s: &[u8]) -> Vec<Vec<u8>> { let mut res: Vec<Vec<u8>> = Vec::new(); let mut empty: Vec<u8> = Vec::new(); res.push(empty); let n = s.len(); let mut i = 0; while i < n { let c = s[i]; let is_lower = c >= b'a' && c <= b'z'; let is_upper = c >=...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [letter_case_permutation]: 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 -- [letter_case_permutation]: function definitions module public import Aeneas public import Aegis.LetterCasePermutation.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashComma...
import Aegis.LetterCasePermutation.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(match (Aegis.LetterCasePermutation.letter_case_permutation (Slice.from [49#u8, 50#u8, 51#u8, 52#u8, 53#u8, 54#u8, 55#u8, 56#u8, 57#u8, 48#u8] (by scalar_tac) : Sli...
[ { "input": "[\"1234567890\"]", "output": "[\"1234567890\"]" }, { "input": "[\"\"]", "output": "[\"\"]" }, { "input": "[\"1\"]", "output": "[\"1\"]" }, { "input": "[\"123\"]", "output": "[\"123\"]" }, { "input": "[\"0000\"]", "output": "[\"0000\"]" }, { ...
102
true
102
verified
10
10
1
2,904
[ { "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.LetterCasePermutation.Code.Funs /-! # Specifications of `Aegis.LetterCasePermutation.letter_case_permutation` LeetCode problem `letter-case-permutation`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.LetterCasePermutation open Aegis.L...
8
k-th-smallest-prime-fraction
786
Medium
[ "Array", "Two Pointers", "Binary Search", "Sorting", "Heap (Priority Queue)" ]
You are given a sorted integer array arr containing 1 and prime numbers, where all the integers of arr are unique. You are also given an integer k. For every i and j where 0 <= i < j < arr.length, we consider the fraction arr[i] / arr[j]. Return the kth smallest fraction considered. Return your answer as an array of in...
kthSmallestPrimeFraction(arr: list_int, k: int) -> list_int
pub fn kth_smallest_prime_fraction(arr: &[i64], k: i64) -> Vec<i64>
Aegis.KthSmallestPrimeFraction.kth_smallest_prime_fraction
fn fraction_le(a: i64, b: i64, arr: &[i64], n: i64) -> bool { let i1 = (a / n) as usize; let j1 = (a % n) as usize; let i2 = (b / n) as usize; let j2 = (b % n) as usize; arr[i1] * arr[j2] <= arr[i2] * arr[j1] } pub fn kth_smallest_prime_fraction(arr: &[i64], k: i64) -> Vec<i64> { let n_usize = ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [kth_smallest_prime_fraction]: 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 -- [kth_smallest_prime_fraction]: function definitions module public import Aeneas public import Aegis.KthSmallestPrimeFraction.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.ha...
import Aegis.KthSmallestPrimeFraction.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.KthSmallestPrimeFraction.kth_smallest_prime_fraction (Slice.from [1#i64, 7#i64] (by scalar_tac) : Slice Std.I64) 1#i64) ((alloc.vec.Vec....
[ { "input": "[[1, 7], 1]", "output": "[1, 7]" }, { "input": "[[1, 2, 3, 5], 3]", "output": "[2, 5]" }, { "input": "[[1, 3, 7, 11, 13], 5]", "output": "[3, 11]" }, { "input": "[[1, 2, 5, 13, 17, 19], 10]", "output": "[5, 13]" }, { "input": "[[1, 2, 5, 11, 17, 23], 1...
51
false
51
verified
10
10
1
5,491
[ { "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.KthSmallestPrimeFraction.Code.Funs /-! # Specifications of `Aegis.KthSmallestPrimeFraction.kth_smallest_prime_fraction` LeetCode problem `k-th-smallest-prime-fraction`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.KthSmallestPrimeFraction ...
11
cheapest-flights-within-k-stops
787
Medium
[ "Depth-First Search", "Breadth-First Search", "Graph", "Dynamic Programming", "Shortest Path", "Heap (Priority Queue)" ]
There are n cities connected by some number of flights. You are given an array flights where flights[i] = [fromi, toi, pricei] indicates that there is a flight from city fromi to city toi with cost pricei. You are also given three integers src, dst, and k, return the cheapest price from src to dst with at most k stops....
findCheapestPrice(n: int, flights: list_list_int, src: int, dst: int, k: int) -> int
pub fn find_cheapest_price(n: i64, flights: &[Vec<i64>], src: i64, dst: i64, k: i64) -> i64
Aegis.FindCheapestPrice.find_cheapest_price
pub fn find_cheapest_price(n: i64, flights: &[Vec<i64>], src: i64, dst: i64, k: i64) -> i64 { let n_us = n as usize; let inf: i64 = 1_000_000_000_000_000_000; let mut dist: Vec<i64> = Vec::new(); let mut i = 0; while i < n_us { dist.push(inf); i += 1; } dist[src as usize] = ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [find_cheapest_price]: 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_cheapest_price]: function definitions module public import Aeneas public import Aegis.FindCheapestPrice.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false...
import Aegis.FindCheapestPrice.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.FindCheapestPrice.find_cheapest_price 2#i64 (Slice.from [(alloc.vec.Vec.from [0#i64, 1#i64, 100#i64] (by scalar_tac) : alloc.vec.Vec Std.I64)] ...
[ { "input": "[2, [[0, 1, 100]], 0, 1, 0]", "output": "100" }, { "input": "[3, [[0, 1, 100], [1, 2, 100]], 0, 2, 2]", "output": "200" }, { "input": "[3, [[0, 1, 100], [1, 2, 100]], 0, 2, 0]", "output": "-1" }, { "input": "[3, [[0, 1, 100], [1, 2, 100], [0, 2, 500]], 0, 2, 1]", ...
94
false
94
verified
10
10
1
1,655
[ { "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.FindCheapestPrice.Code.Funs /-! # Specifications of `Aegis.FindCheapestPrice.find_cheapest_price` LeetCode problem `cheapest-flights-within-k-stops`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.FindCheapestPrice (find_cheapest_price) name...
15
rotated-digits
788
Medium
[ "Math", "Dynamic Programming" ]
An integer x is a good if after rotating each digit individually by 180 degrees, we get a valid number that is different from x. Each digit must be rotated - we cannot choose to leave it alone. A number is valid if each digit remains a digit after rotation. For example: 0, 1, and 8 rotate to themselves, 2 and 5 rotate...
rotatedDigits(n: int) -> int
pub fn rotated_digits(n: i64) -> i64
Aegis.RotatedDigits.rotated_digits
fn is_good(mut x: i64) -> bool { let mut valid: bool = true; let mut changed: bool = false; while x > 0 { let d = x % 10; if d == 3 || d == 4 || d == 7 { valid = false; x = 0; } else { if d == 2 || d == 5 || d == 6 || d == 9 { cha...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [rotated_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...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [rotated_digits]: function definitions module public import Aeneas public import Aegis.RotatedDigits.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.RotatedDigits.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.RotatedDigits.rotated_digits 100#i64) (40#i64))}") #eval (s!"CASE 1 {(Result.reducesTo (Aegis.RotatedDigits.rotated_digits 10000#i64) (2320#i64))}"...
[ { "input": "[100]", "output": "40" }, { "input": "[10000]", "output": "2320" }, { "input": "[104]", "output": "41" }, { "input": "[20]", "output": "9" }, { "input": "[2]", "output": "1" }, { "input": "[1]", "output": "0" }, { "input": "[100...
55
false
55
verified
10
10
1
1,126
[ { "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.RotatedDigits.Code.Funs /-! # Specifications of `Aegis.RotatedDigits.rotated_digits` LeetCode problem `rotated-digits`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.RotatedDigits def digitsFuel : Nat → Nat → List Nat | 0, _ =...
10
escape-the-ghosts
789
Medium
[ "Array", "Math" ]
You are playing a simplified PAC-MAN game on an infinite 2-D grid. You start at the point [0, 0], and you are given a destination point target = [xtarget, ytarget] that you are trying to get to. There are several ghosts on the map with their starting positions given as a 2D array ghosts, where ghosts[i] = [xi, yi] repr...
escapeGhosts(ghosts: list_list_int, target: list_int) -> bool
pub fn escape_ghosts(ghosts: &[Vec<i64>], target: &[i64]) -> bool
Aegis.EscapeGhosts.escape_ghosts
fn abs_i64(x: i64) -> i64 { if x < 0 { -x } else { x } } pub fn escape_ghosts(ghosts: &[Vec<i64>], target: &[i64]) -> bool { let tx = target[0]; let ty = target[1]; let player_dist = abs_i64(tx) + abs_i64(ty); let mut i: usize = 0; while i < ghosts.len() { let ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [escape_ghosts]: 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 -- [escape_ghosts]: function definitions module public import Aeneas public import Aegis.EscapeGhosts.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.EscapeGhosts.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.EscapeGhosts.escape_ghosts (Slice.from [(alloc.vec.Vec.from [(-1)#i64, (-1)#i64] (by scalar_tac) : alloc.vec.Vec Std.I64)] (by scalar_tac) : Slice (...
[ { "input": "[[[-1, -1]], [0, 0]]", "output": "true" }, { "input": "[[[-10000, -10000]], [-9999, -9999]]", "output": "false" }, { "input": "[[[100, 100]], [-100, -100]]", "output": "true" }, { "input": "[[[10000, 10000]], [-10000, -10000]]", "output": "true" }, { "...
138
false
138
verified
10
10
1
663
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.EscapeGhosts.Code.Funs /-! # Specifications of `Aegis.EscapeGhosts.escape_ghosts` LeetCode problem `escape-the-ghosts`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.EscapeGhosts def inRange (x : ℤ) : Prop := -10000 ≤ x ∧ x ≤ 10000 d...
8
domino-and-tromino-tiling
790
Medium
[ "Dynamic Programming" ]
You have two types of tiles: a 2 x 1 domino shape and a tromino shape. You may rotate these shapes. Given an integer n, return the number of ways to tile an 2 x n board. Since the answer may be very large, return it modulo 109 + 7. In a tiling, every square must be covered by a tile. Two tilings are different if and o...
numTilings(n: int) -> int
pub fn num_tilings(n: i64) -> i64
Aegis.NumTilings.num_tilings
pub fn num_tilings(n: i64) -> i64 { let md: i64 = 1000000007; if n == 0 { return 1; } if n == 1 { return 1; } if n == 2 { return 2; } let n_usize: usize = n as usize; // History vector: dp[k] = number of tilings of a 2 x k board. let mut dp: Vec<i64> = ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [num_tilings]: 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_tilings]: function definitions module public import Aeneas public import Aegis.NumTilings.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.NumTilings.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.NumTilings.num_tilings 3#i64) (5#i64))}") #eval (s!"CASE 1 {(Result.reducesTo (Aegis.NumTilings.num_tilings 100#i64) (190242381#i64))}") #eval (s!"CAS...
[ { "input": "[3]", "output": "5" }, { "input": "[100]", "output": "190242381" }, { "input": "[4]", "output": "11" }, { "input": "[2]", "output": "2" }, { "input": "[1]", "output": "1" }, { "input": "[500]", "output": "603582422" }, { "input"...
30
false
30
verified
10
10
2
15,551
[ { "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.NumTilings.Code.Funs /-! # Specifications of `Aegis.NumTilings.num_tilings` LeetCode problem `domino-and-tromino-tiling`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.NumTilings def i64OfInt (v : ℤ) : Std.I64 := ⟨BitVec.ofInt 64 v⟩ ...
4
number-of-matching-subsequences
792
Medium
[ "Trie", "Array", "Hash Table", "String", "Binary Search", "Dynamic Programming", "Sorting" ]
Given a string s and an array of strings words, return the number of words[i] that is a subsequence of s. A subsequence of a string is a new string generated from the original string with some characters (can be none) deleted without changing the relative order of the remaining characters. For example, "ace" is a subs...
numMatchingSubseq(s: str, words: list_str) -> int
pub fn num_matching_subseq(s: &[u8], words: &[Vec<u8>]) -> i64
Aegis.NumMatchingSubseq.num_matching_subseq
pub fn num_matching_subseq(s: &[u8], words: &[Vec<u8>]) -> i64 { let n = s.len(); let m = words.len(); let mut ans: i64 = 0; let mut k: usize = 0; while k < m { let w = &words[k]; let wl = w.len(); let mut i: usize = 0; let mut j: usize = 0; while i < n && ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [num_matching_subseq]: 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 -- [num_matching_subseq]: function definitions module public import Aeneas public import Aegis.NumMatchingSubseq.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false...
import Aegis.NumMatchingSubseq.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.NumMatchingSubseq.num_matching_subseq (Slice.from [100#u8, 115#u8, 97#u8, 104#u8, 106#u8, 112#u8, 106#u8, 97#u8, 117#u8, 102#u8] (by scalar_tac...
[ { "input": "[\"dsahjpjauf\", [\"ahjpjau\", \"ja\", \"ahbwzgqnuk\", \"tnmlanowax\"]]", "output": "2" }, { "input": "[\"abcde\", [\"a\", \"bb\", \"acd\", \"ace\"]]", "output": "3" }, { "input": "[\"abcdefghijklmnopqrstuvwxyz\", [\"abc\", \"xyz\", \"mnopqr\", \"uvw\", \"zabcdefghijklmnopqrs...
56
false
56
verified
10
10
1
1,317
[ { "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.NumMatchingSubseq.Code.Funs /-! # Specifications of `Aegis.NumMatchingSubseq.num_matching_subseq` LeetCode problem `number-of-matching-subsequences`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.NumMatchingSubseq open Classical namespace Aegis...
14
preimage-size-of-factorial-zeroes-function
793
Hard
[ "Math", "Binary Search" ]
Let f(x) be the number of zeroes at the end of x!. Recall that x! = 1 * 2 * 3 * ... * x and by convention, 0! = 1. For example, f(3) = 0 because 3! = 6 has no zeroes at the end, while f(11) = 2 because 11! = 39916800 has two zeroes at the end. Given an integer k, return the number of non-negative integers x have the ...
preimageSizeFZF(k: int) -> int
pub fn preimage_size_fzf(k: i64) -> i64
Aegis.PreimageSizeFzf.preimage_size_fzf
fn trailing_zeroes(x: i64) -> i64 { let mut n = x; let mut count: i64 = 0; while n > 0 { n = n / 5; count += n; } count } pub fn preimage_size_fzf(k: i64) -> i64 { let mut lo: i64 = 0; let mut hi: i64 = 5 * k; while lo < hi { let mid: i64 = lo + (hi - lo) / 2; ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [preimage_size_fzf]: 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 -- [preimage_size_fzf]: function definitions module public import Aeneas public import Aegis.PreimageSizeFzf.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.PreimageSizeFzf.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.PreimageSizeFzf.preimage_size_fzf 100#i64) (5#i64))}") #eval (s!"CASE 1 {(Result.reducesTo (Aegis.PreimageSizeFzf.preimage_size_fzf 1#i64) (5#i64...
[ { "input": "[100]", "output": "5" }, { "input": "[1]", "output": "5" }, { "input": "[10000]", "output": "5" }, { "input": "[1000000]", "output": "5" }, { "input": "[3]", "output": "5" }, { "input": "[0]", "output": "5" }, { "input": "[1000]...
104
false
104
verified
10
10
1
910
[ { "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.PreimageSizeFzf.Code.Funs /-! # Specifications of `Aegis.PreimageSizeFzf.preimage_size_fzf` LeetCode problem `preimage-size-of-factorial-zeroes-function`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aeneas.Std.Result namespace AegisSpec.Preimag...
9
valid-tic-tac-toe-state
794
Medium
[ "Array", "Matrix" ]
Given a Tic-Tac-Toe board as a string array board, return true if and only if it is possible to reach this board position during the course of a valid tic-tac-toe game. The board is a 3 x 3 array that consists of characters ' ', 'X', and 'O'. The ' ' character represents an empty square. Here are the rules of Tic-Tac-T...
validTicTacToe(board: list_str) -> bool
pub fn valid_tic_tac_toe(board: &[Vec<u8>]) -> bool
Aegis.ValidTicTacToe.valid_tic_tac_toe
fn has_won(board: &[Vec<u8>], p: u8) -> bool { let mut won = false; let mut i: usize = 0; while i < 3 { if board[i][0] == p && board[i][1] == p && board[i][2] == p { won = true; } i += 1; } let mut j: usize = 0; while j < 3 { if board[0][j] == p && b...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [valid_tic_tac_toe]: 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 -- [valid_tic_tac_toe]: function definitions module public import Aeneas public import Aegis.ValidTicTacToe.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.ValidTicTacToe.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.ValidTicTacToe.valid_tic_tac_toe (Slice.from [(alloc.vec.Vec.from [88#u8, 79#u8, 88#u8] (by scalar_tac) : alloc.vec.Vec Std.U8), (alloc.vec.Vec.fr...
[ { "input": "[[\"XOX\", \"O O\", \"XOX\"]]", "output": "true" }, { "input": "[[\"X \", \"X \", \"X \"]]", "output": "false" }, { "input": "[[\"XOX\", \"O O\", \"XOX\"]]", "output": "true" }, { "input": "[[\"XXX\", \" \", \"O O\"]]", "output": "true" }, { "inpu...
91
false
91
verified
10
10
2
2,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.ValidTicTacToe.Code.Funs /-! # Specifications of `Aegis.ValidTicTacToe.valid_tic_tac_toe` LeetCode problem `valid-tic-tac-toe-state`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result set_option maxHeartbeats 1000000 namespace AegisSpec.ValidTicTacToe open ...
13
number-of-subarrays-with-bounded-maximum
795
Medium
[ "Array", "Two Pointers" ]
Given an integer array nums and two integers left and right, return the number of contiguous non-empty subarrays such that the value of the maximum array element in that subarray is in the range [left, right]. The test cases are generated so that the answer will fit in a 32-bit integer.   Example 1: Input: nums = [2,1...
numSubarrayBoundedMax(nums: list_int, left: int, right: int) -> int
pub fn num_subarray_bounded_max(nums: &[i64], left: i64, right: i64) -> i64
Aegis.NumSubarrayBoundedMax.num_subarray_bounded_max
pub fn num_subarray_bounded_max(nums: &[i64], left: i64, right: i64) -> i64 { let n = nums.len(); let mut ans: i64 = 0; let mut last_bad: i64 = -1; let mut last_good: i64 = -1; let mut i: usize = 0; while i < n { let x = nums[i]; if x > right { last_bad = i as i64; ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [num_subarray_bounded_max]: 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 -- [num_subarray_bounded_max]: function definitions module public import Aeneas public import Aegis.NumSubarrayBoundedMax.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashComm...
import Aegis.NumSubarrayBoundedMax.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.NumSubarrayBoundedMax.num_subarray_bounded_max (Slice.from [5#i64, 2#i64, 1#i64] (by scalar_tac) : Slice Std.I64) 1#i64 5#i64) (6#i64))}") ...
[ { "input": "[[5, 2, 1], 1, 5]", "output": "6" }, { "input": "[[10, 20, 30], 25, 25]", "output": "0" }, { "input": "[[1, 2, 3], 1, 3]", "output": "6" }, { "input": "[[2, 1, 4, 3], 2, 3]", "output": "3" }, { "input": "[[10, 20, 30, 40, 50], 15, 45]", "output": "...
101
false
101
verified
10
10
1
760
[ { "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.NumSubarrayBoundedMax.Code.Funs /-! # Specifications of `Aegis.NumSubarrayBoundedMax.num_subarray_bounded_max` LeetCode problem `number-of-subarrays-with-bounded-maximum`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.NumSubarrayBoundedMax ...
13
rotate-string
796
Easy
[ "String", "String Matching" ]
Given two strings s and goal, return true if and only if s can become goal after some number of shifts on s. A shift on s consists of moving the leftmost character of s to the rightmost position. For example, if s = "abcde", then it will be "bcdea" after one shift.   Example 1: Input: s = "abcde", goal = "cdeab" Outp...
rotateString(s: str, goal: str) -> bool
pub fn rotate_string(s: &[u8], goal: &[u8]) -> bool
Aegis.RotateString.rotate_string
pub fn rotate_string(s: &[u8], goal: &[u8]) -> bool { let n = s.len(); let m = goal.len(); if n != m { return false; } if n == 0 { return true; } let mut shift: usize = 0; while shift < n { let mut j: usize = 0; let mut idx: usize = shift; let m...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [rotate_string]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter....
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [rotate_string]: function definitions module public import Aeneas public import Aegis.RotateString.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.RotateString.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.RotateString.rotate_string (Slice.from [97#u8, 97#u8, 97#u8] (by scalar_tac) : Slice Std.U8) (Slice.from [97#u8, 97#u8, 97#u8] (by scalar_tac) : Sli...
[ { "input": "[\"aaa\", \"aaa\"]", "output": "true" }, { "input": "[\"abcdefg\", \"efgabcd\"]", "output": "true" }, { "input": "[\"abab\", \"abba\"]", "output": "false" }, { "input": "[\"abcd\", \"dcba\"]", "output": "false" }, { "input": "[\"abcd\", \"dabc\"]", ...
113
false
113
verified
10
10
1
796
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.RotateString.Code.Funs /-! # Specifications of `Aegis.RotateString.rotate_string` LeetCode problem `rotate-string`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.RotateString def byteLen (t : Slice U8) : ℕ := (Slice.len t).val ...
9
all-paths-from-source-to-target
797
Medium
[ "Depth-First Search", "Breadth-First Search", "Graph", "Backtracking" ]
Given a directed acyclic graph (DAG) of n nodes labeled from 0 to n - 1, find all possible paths from node 0 to node n - 1 and return them in any order. The graph is given as follows: graph[i] is a list of all nodes you can visit from node i (i.e., there is a directed edge from node i to node graph[i][j]).   Example 1:...
allPathsSourceTarget(graph: list_list_int) -> list_list_int
pub fn all_paths_source_target(graph: &[Vec<i64>]) -> Vec<Vec<i64>>
Aegis.AllPathsSourceTarget.all_paths_source_target
pub fn all_paths_source_target(graph: &[Vec<i64>]) -> Vec<Vec<i64>> { let n = graph.len(); let mut out: Vec<Vec<i64>> = Vec::new(); if n == 0 { return out; } let target: usize = n - 1; // Preallocated explicit DFS stacks. stack_len is the number of active frames. let mut stack_nod...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [all_paths_source_target]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_opti...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [all_paths_source_target]: function definitions module public import Aeneas public import Aegis.AllPathsSourceTarget.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashComman...
import Aegis.AllPathsSourceTarget.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(match (Aegis.AllPathsSourceTarget.all_paths_source_target (Slice.from [(alloc.vec.Vec.from [1#i64] (by scalar_tac) : alloc.vec.Vec Std.I64), (alloc.vec.Vec.from [] ...
[ { "input": "[[[1], []]]", "output": "[[0, 1]]" }, { "input": "[[[1], [2], []]]", "output": "[[0, 1, 2]]" }, { "input": "[[[1, 2], [3], [], [4]]]", "output": "[[0, 1, 3]]" }, { "input": "[[[1], [2, 3], [3, 4], [4], [], [6], [7], []]]", "output": "[]" }, { "input": ...
71
true
71
verified
10
10
1
11,426
[ { "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.AllPathsSourceTarget.Code.Funs /-! # Specifications of `Aegis.AllPathsSourceTarget.all_paths_source_target` LeetCode problem `all-paths-from-source-to-target`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.AllPathsSourceTarget open Ae...
12
bricks-falling-when-hit
803
Hard
[ "Union Find", "Array", "Matrix" ]
You are given an m x n binary grid, where each 1 represents a brick and 0 represents an empty space. A brick is stable if: It is directly connected to the top of the grid, or At least one other brick in its four adjacent cells is stable. You are also given an array hits, which is a sequence of erasures we want to app...
hitBricks(grid: list_list_int, hits: list_list_int) -> list_int
pub fn hit_bricks(grid: &[Vec<i64>], hits: &[Vec<i64>]) -> Vec<i64>
Aegis.HitBricks.hit_bricks
pub fn hit_bricks(grid: &[Vec<i64>], hits: &[Vec<i64>]) -> Vec<i64> { let m = grid.len(); let n = grid[0].len(); let total = m * n; let top = total; let mut active: Vec<i64> = Vec::new(); let mut i = 0; while i < m { let mut j = 0; while j < n { active.push(grid[...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [hit_bricks]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter.sty...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [hit_bricks]: function definitions module public import Aeneas public import Aegis.HitBricks.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.HitBricks.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.HitBricks.hit_bricks (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)...
[ { "input": "[[[0]], [[0, 0]]]", "output": "[0]" }, { "input": "[[[1]], [[0, 0]]]", "output": "[0]" }, { "input": "[[[1, 0], [1, 0]], [[1, 0]]]", "output": "[0]" }, { "input": "[[[1, 0], [0, 1]], [[0, 0], [1, 1]]]", "output": "[0, 0]" }, { "input": "[[[1, 0, 0, 0],...
155
false
155
verified
10
10
1
15,956
[ { "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.HitBricks.Code.Funs /-! # Specifications of `Aegis.HitBricks.hit_bricks` LeetCode problem `bricks-falling-when-hit`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.HitBricks noncomputable section open Classical abbrev Pos : T...
8
unique-morse-code-words
804
Easy
[ "Array", "Hash Table", "String" ]
International Morse Code defines a standard encoding where each letter is mapped to a series of dots and dashes, as follows: 'a' maps to ".-", 'b' maps to "-...", 'c' maps to "-.-.", and so on. For convenience, the full table for the 26 letters of the English alphabet is given below: [".-","-...","-.-.","-..",".","....
uniqueMorseRepresentations(words: list_str) -> int
pub fn unique_morse_representations(words: &[Vec<u8>]) -> i64
Aegis.UniqueMorseRepresentations.unique_morse_representations
pub fn unique_morse_representations(words: &[Vec<u8>]) -> i64 { let mut morse: Vec<Vec<u8>> = Vec::new(); let mut c0: Vec<u8> = Vec::new(); c0.push(b'.'); c0.push(b'-'); morse.push(c0); let mut c1: Vec<u8> = Vec::new(); c1.push(b'-'); c1.push(b'.'); c1.push(b'.'); c1.push(b'.')...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [unique_morse_representations]: 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 -- [unique_morse_representations]: function definitions module public import Aeneas public import Aegis.UniqueMorseRepresentations.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter...
import Aegis.UniqueMorseRepresentations.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.UniqueMorseRepresentations.unique_morse_representations (Slice.from [(alloc.vec.Vec.from [97#u8] (by scalar_tac) : alloc.vec.Vec Std.U...
[ { "input": "[[\"a\"]]", "output": "1" }, { "input": "[[\"abcdefghijklmnopqrstuvwxyz\"]]", "output": "1" }, { "input": "[[\"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\"]]", "output": "1" }, { "input": "[[\"hello\", \"world\"]]", "output": "2" }, { "input"...
82
false
82
verified
10
10
1
6,027
[ { "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.UniqueMorseRepresentations.Code.Funs /-! # Specifications of `Aegis.UniqueMorseRepresentations.unique_morse_representations` LeetCode problem `unique-morse-code-words`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.UniqueMorseReprese...
7
split-array-with-same-average
805
Hard
[ "Bit Manipulation", "Array", "Math", "Dynamic Programming", "Bitmask" ]
You are given an integer array nums. You should move each element of nums into one of the two arrays A and B such that A and B are non-empty, and average(A) == average(B). Return true if it is possible to achieve that and false otherwise. Note that for an array arr, average(arr) is the sum of all the elements of arr ov...
splitArraySameAverage(nums: list_int) -> bool
pub fn split_array_same_average(nums: &[i64]) -> bool
Aegis.SplitArraySameAverage.split_array_same_average
pub fn split_array_same_average(nums: &[i64]) -> bool { let n = nums.len(); if n < 2 { return false; } let mut total: i64 = 0; let mut i: usize = 0; while i < n { total += nums[i]; i += 1; } let max_k = n / 2; let n_i64 = n as i64; let mut max_sum: i64 ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [split_array_same_average]: 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 -- [split_array_same_average]: function definitions module public import Aeneas public import Aegis.SplitArraySameAverage.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashComm...
import Aegis.SplitArraySameAverage.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.SplitArraySameAverage.split_array_same_average (Slice.from [3#i64, 1#i64] (by scalar_tac) : Slice Std.I64)) (false))}") #eval (s!"CASE 1 {(...
[ { "input": "[[3, 1]]", "output": "false" }, { "input": "[[10, 20, 30]]", "output": "true" }, { "input": "[[10000, 10000, 10000]]", "output": "true" }, { "input": "[[1, 2, 3]]", "output": "true" }, { "input": "[[1, 1, 1, 1]]", "output": "true" }, { "inp...
100
false
100
verified
10
10
1
17,673
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.SplitArraySameAverage.Code.Funs /-! # Specifications of `Aegis.SplitArraySameAverage.split_array_same_average` LeetCode problem `split-array-with-same-average`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.SplitArraySameAverage d...
8
number-of-lines-to-write-string
806
Easy
[ "Array", "String" ]
You are given a string s of lowercase English letters and an array widths denoting how many pixels wide each lowercase English letter is. Specifically, widths[0] is the width of 'a', widths[1] is the width of 'b', and so on. You are trying to write s across several lines, where each line is no longer than 100 pixels. S...
numberOfLines(widths: list_int, s: str) -> list_int
pub fn number_of_lines(widths: &[i64], s: &[u8]) -> Vec<i64>
Aegis.NumberOfLines.number_of_lines
pub fn number_of_lines(widths: &[i64], s: &[u8]) -> Vec<i64> { let mut lines: i64 = 1; let mut current_width: i64 = 0; let mut i: usize = 0; while i < s.len() { let letter_index: usize = (s[i] - b'a') as usize; let width: i64 = widths[letter_index]; if current_width + width > 1...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [number_of_lines]: 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 -- [number_of_lines]: function definitions module public import Aeneas public import Aegis.NumberOfLines.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.NumberOfLines.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.NumberOfLines.number_of_lines (Slice.from [2#i64, 3#i64, 4#i64, 5#i64, 6#i64, 7#i64, 8#i64, 9#i64, 10#i64, 1#i64, 2#i64, 3#i64, 4#i64, 5#i64, 6#i64...
[ { "input": "[[2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7], \"examplestring\"]", "output": "[1, 76]" }, { "input": "[[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], \"bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb\"]", "output": "[1...
46
false
46
verified
10
10
1
658
[ { "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.NumberOfLines.Code.Funs /-! # Specifications of `Aegis.NumberOfLines.number_of_lines` LeetCode problem `number-of-lines-to-write-string`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.NumberOfLines def byteAt (s : Slice Std.U8) (t : ℕ...
12
max-increase-to-keep-city-skyline
807
Medium
[ "Greedy", "Array", "Matrix" ]
There is a city composed of n x n blocks, where each block contains a single building shaped like a vertical square prism. You are given a 0-indexed n x n integer matrix grid where grid[r][c] represents the height of the building located in the block at row r and column c. A city's skyline is the outer contour formed b...
maxIncreaseKeepingSkyline(grid: list_list_int) -> int
pub fn max_increase_keeping_skyline(grid: &[Vec<i64>]) -> i64
Aegis.MaxIncreaseKeepingSkyline.max_increase_keeping_skyline
pub fn max_increase_keeping_skyline(grid: &[Vec<i64>]) -> i64 { let n = grid.len(); if n == 0 { return 0; } let m = grid[0].len(); let mut row_max: Vec<i64> = Vec::new(); let mut col_max: Vec<i64> = Vec::new(); let mut j = 0; while j < m { col_max.push(0); j +=...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [max_increase_keeping_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...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [max_increase_keeping_skyline]: function definitions module public import Aeneas public import Aegis.MaxIncreaseKeepingSkyline.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter....
import Aegis.MaxIncreaseKeepingSkyline.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.MaxIncreaseKeepingSkyline.max_increase_keeping_skyline (Slice.from [(alloc.vec.Vec.from [1#i64, 2#i64] (by scalar_tac) : alloc.vec.Vec ...
[ { "input": "[[[1, 2], [3, 4]]]", "output": "1" }, { "input": "[[[50, 50], [50, 50]]]", "output": "0" }, { "input": "[[[1, 1, 1], [1, 1, 1], [1, 1, 1]]]", "output": "0" }, { "input": "[[[5, 5, 5], [5, 5, 5], [5, 5, 5]]]", "output": "0" }, { "input": "[[[1, 2, 3], [...
69
false
69
verified
10
10
1
952
[ { "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.MaxIncreaseKeepingSkyline.Code.Funs /-! # Specifications of `Aegis.MaxIncreaseKeepingSkyline.max_increase_keeping_skyline` LeetCode problem `max-increase-to-keep-city-skyline`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.MaxIncreaseK...
12
expressive-words
809
Medium
[ "Array", "Two Pointers", "String" ]
Sometimes people repeat letters to represent extra feeling. For example: "hello" -> "heeellooo" "hi" -> "hiiii" In these strings like "heeellooo", we have groups of adjacent letters that are all the same: "h", "eee", "ll", "ooo". You are given a string s and an array of query strings words. A query word is stretchy i...
expressiveWords(s: str, words: list_str) -> int
pub fn expressive_words(s: &[u8], words: &[Vec<u8>]) -> i64
Aegis.ExpressiveWords.expressive_words
fn is_stretchy(s: &[u8], w: &[u8]) -> bool { let n = s.len(); let m = w.len(); let mut i: usize = 0; let mut j: usize = 0; while i < n && j < m { if s[i] != w[j] { return false; } let ch = s[i]; let mut i2 = i; while i2 < n && s[i2] == ch { ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [expressive_words]: 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 -- [expressive_words]: function definitions module public import Aeneas public import Aegis.ExpressiveWords.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.ExpressiveWords.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.ExpressiveWords.expressive_words (Slice.from [97#u8, 98#u8, 99#u8, 100#u8] (by scalar_tac) : Slice Std.U8) (Slice.from [(alloc.vec.Vec.from [97#u...
[ { "input": "[\"abcd\", [\"abc\", \"abcd\", \"abcde\"]]", "output": "1" }, { "input": "[\"aaabbbcccddd\", [\"aabbccddd\", \"aabbbcccddd\", \"aabbbcccdd\"]]", "output": "3" }, { "input": "[\"aabbcc\", [\"aabbcc\", \"aabbc\", \"aaabc\"]]", "output": "1" }, { "input": "[\"heeello...
71
false
71
verified
10
10
1
3,220
[ { "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.ExpressiveWords.Code.Funs /-! # Specifications of `Aegis.ExpressiveWords.expressive_words` LeetCode problem `expressive-words`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.ExpressiveWords def sliceBytes (s : Slice Std.U8) : List...
13
chalkboard-xor-game
810
Hard
[ "Bit Manipulation", "Brainteaser", "Array", "Math", "Game Theory" ]
You are given an array of integers nums represents the numbers written on a chalkboard. Alice and Bob take turns erasing exactly one number from the chalkboard, with Alice starting first. If erasing a number causes the bitwise XOR of all the elements of the chalkboard to become 0, then that player loses. The bitwise XO...
xorGame(nums: list_int) -> bool
pub fn xor_game(nums: &[i64]) -> bool
Aegis.XorGame.xor_game
pub fn xor_game(nums: &[i64]) -> bool { let mut total: i64 = 0; let mut i: usize = 0; while i < nums.len() { total = total ^ nums[i]; i += 1; } total == 0 || nums.len() % 2 == 0 }
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [xor_game]: 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 -- [xor_game]: function definitions module public import Aeneas public import Aegis.XorGame.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.XorGame.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.XorGame.xor_game (Slice.from [1#i64] (by scalar_tac) : Slice Std.I64)) (false))}") #eval (s!"CASE 1 {(Result.reducesTo (Aegis.XorGame.xor_game (Slice.fro...
[ { "input": "[[1]]", "output": "false" }, { "input": "[[0, 1]]", "output": "true" }, { "input": "[[2, 2]]", "output": "true" }, { "input": "[[1, 1, 2]]", "output": "false" }, { "input": "[[1, 2, 3]]", "output": "true" }, { "input": "[[1, 2, 2, 3]]", ...
122
false
122
verified
10
10
1
350
[ { "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.XorGame.Code.Funs /-! # Specifications of `Aegis.XorGame.xor_game` LeetCode problem `chalkboard-xor-game`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.XorGame def xorAll (l : List Std.I64) : ℕ := l.foldr (fun x acc => x.val.toNat ...
9
subdomain-visit-count
811
Medium
[ "Array", "Hash Table", "String", "Counting" ]
A website domain "discuss.leetcode.com" consists of various subdomains. At the top level, we have "com", at the next level, we have "leetcode.com" and at the lowest level, "discuss.leetcode.com". When we visit a domain like "discuss.leetcode.com", we will also visit the parent domains "leetcode.com" and "com" implicitl...
subdomainVisits(cpdomains: list_str) -> list_str
pub fn subdomain_visits(cpdomains: &[Vec<u8>]) -> Vec<Vec<u8>>
Aegis.SubdomainVisits.subdomain_visits
pub fn subdomain_visits(cpdomains: &[Vec<u8>]) -> Vec<Vec<u8>> { let mut keys: Vec<Vec<u8>> = Vec::new(); let mut vals: Vec<i64> = Vec::new(); let mut idx = 0; while idx < cpdomains.len() { let s = &cpdomains[idx]; let mut p = 0; let mut num: i64 = 0; while p < s.len() ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [subdomain_visits]: 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 -- [subdomain_visits]: function definitions module public import Aeneas public import Aegis.SubdomainVisits.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.SubdomainVisits.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(match (Aegis.SubdomainVisits.subdomain_visits (Slice.from [(alloc.vec.Vec.from [57#u8, 48#u8, 48#u8, 49#u8, 32#u8, 100#u8, 105#u8, 115#u8, 99#u8, 117#u8, 115#u8, 115#u8,...
[ { "input": "[[\"9001 discuss.leetcode.com\"]]", "output": "[\"9001 discuss.leetcode.com\", \"9001 leetcode.com\", \"9001 com\"]" }, { "input": "[[\"1 x.y.z\", \"2 y.z\", \"3 z\"]]", "output": "[\"1 x.y.z\", \"3 y.z\", \"6 z\"]" }, { "input": "[[\"1 a.com\", \"2 b.a.com\", \"3 c.b.a.com\"...
68
true
68
verified
10
10
3
54,490
[ { "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.SubdomainVisits.Code.Funs /-! # Specifications of `Aegis.SubdomainVisits.subdomain_visits` LeetCode problem `subdomain-visit-count`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result Aeneas.Std.alloc.vec namespace AegisSpec.SubdomainVisits set_option maxHear...
12
binary-tree-pruning
814
Medium
[ "Tree", "Depth-First Search", "Binary Tree" ]
Given the root of a binary tree, return the same tree where every subtree (of the given tree) not containing a 1 has been removed. A subtree of a node node is node plus every node that is a descendant of node.   Example 1: Input: root = [1,null,0,0,1] Output: [1,null,0,null,1] Explanation: Only the red nodes satisfy...
pruneTree(root: tree) -> tree
pub fn prune_tree(root: &Tree) -> Tree
Aegis.PruneTree.prune_tree
fn has_one(t: &Tree) -> bool { match t { Tree::Null => false, Tree::Node(v, l, r) => { if *v == 1 { true } else if has_one(&**l) { true } else { has_one(&**r) } } } } fn prune_impl(t: &Tree) ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [prune_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 -- [prune_tree]: function definitions module public import Aeneas public import Aegis.PruneTree.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.PruneTree.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 instance...
[ { "input": "[[1]]", "output": "[1]" }, { "input": "[[1, 1, 1]]", "output": "[1, 1, 1]" }, { "input": "[[1, 0, 1, 0, 0, 0, 1]]", "output": "[1, null, 1, null, 1]" }, { "input": "[[1, 1, 0, 1, 1, 0, 1, 0]]", "output": "[1, 1, 0, 1, 1, null, 1]" }, { "input": "[[1, 0...
73
false
73
verified
10
10
4
25,772
[ { "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.PruneTree.Code.Funs /-! # Specifications of `Aegis.PruneTree.prune_tree` LeetCode problem `binary-tree-pruning`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.PruneTree open Aegis.PruneTree inductive Dir where | L : Dir ...
11
bus-routes
815
Hard
[ "Breadth-First Search", "Array", "Hash Table" ]
You are given an array routes representing bus routes where routes[i] is a bus route that the ith bus repeats forever. For example, if routes[0] = [1, 5, 7], this means that the 0th bus travels in the sequence 1 -> 5 -> 7 -> 1 -> 5 -> 7 -> 1 -> ... forever. You will start at the bus stop source (You are not on any bu...
numBusesToDestination(routes: list_list_int, source: int, target: int) -> int
pub fn num_buses_to_destination(routes: &[Vec<i64>], source: i64, target: i64) -> i64
Aegis.NumBusesToDestination.num_buses_to_destination
fn find_index(xs: &[i64], x: i64) -> i64 { let mut lo: usize = 0; let mut hi: usize = xs.len(); while lo < hi { let mid = lo + (hi - lo) / 2; if xs[mid] < x { lo = mid + 1; } else { hi = mid; } } if lo < xs.len() { if xs[lo] == x { ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [num_buses_to_destination]: 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 -- [num_buses_to_destination]: function definitions module public import Aeneas public import Aegis.NumBusesToDestination.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashComm...
import Aegis.NumBusesToDestination.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.NumBusesToDestination.num_buses_to_destination (Slice.from [(alloc.vec.Vec.from [1#i64, 7#i64] (by scalar_tac) : alloc.vec.Vec Std.I64), (a...
[ { "input": "[[[1, 7], [3, 5]], 5, 7]", "output": "-1" }, { "input": "[[[1, 2, 3, 4, 5]], 1, 5]", "output": "1" }, { "input": "[[[1, 2, 3], [4, 5, 6]], 1, 6]", "output": "-1" }, { "input": "[[[1, 2, 7], [3, 6, 7]], 1, 6]", "output": "2" }, { "input": "[[[1, 7], [3,...
77
false
77
verified
10
10
2
17,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.NumBusesToDestination.Code.Funs /-! # Specifications of `Aegis.NumBusesToDestination.num_buses_to_destination` LeetCode problem `bus-routes`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.NumBusesToDestination def routesView (routes :...
12
ambiguous-coordinates
816
Medium
[ "String", "Backtracking", "Enumeration" ]
We had some 2-dimensional coordinates, like "(1, 3)" or "(2, 0.5)". Then, we removed all commas, decimal points, and spaces and ended up with the string s. For example, "(1, 3)" becomes s = "(13)" and "(2, 0.5)" becomes s = "(205)". Return a list of strings representing all possibilities for what our original coordin...
ambiguousCoordinates(s: str) -> list_str
pub fn ambiguous_coordinates(s: &[u8]) -> Vec<Vec<u8>>
Aegis.AmbiguousCoordinates.ambiguous_coordinates
fn reps(s: &[u8], start: usize, end: usize) -> Vec<Vec<u8>> { let mut out: Vec<Vec<u8>> = Vec::new(); if start >= end { return out; } let len = end - start; // Decimal representations first, matching the usual expected order. let mut p: usize = 1; while p < len { let int_o...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [ambiguous_coordinates]: 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 -- [ambiguous_coordinates]: function definitions module public import Aeneas public import Aegis.AmbiguousCoordinates.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand ...
import Aegis.AmbiguousCoordinates.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(match (Aegis.AmbiguousCoordinates.ambiguous_coordinates (Slice.from [40#u8, 48#u8, 48#u8, 48#u8, 48#u8, 41#u8] (by scalar_tac) : Slice Std.U8)).match with | .ok r =...
[ { "input": "[\"(0000)\"]", "output": "[]" }, { "input": "[\"(00100)\"]", "output": "[]" }, { "input": "[\"(000100)\"]", "output": "[]" }, { "input": "[\"(000000)\"]", "output": "[]" }, { "input": "[\"(000000000000)\"]", "output": "[]" }, { "input": "[\...
93
true
93
verified
10
10
1
9,494
[ { "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.AmbiguousCoordinates.Code.Funs /-! # Specifications of `Aegis.AmbiguousCoordinates.ambiguous_coordinates` LeetCode problem `ambiguous-coordinates`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.AmbiguousCoordinates def IsDigitByte (b ...
15
race-car
818
Hard
[ "Dynamic Programming" ]
Your car starts at position 0 and speed +1 on an infinite number line. Your car can go into negative positions. Your car drives automatically according to a sequence of instructions 'A' (accelerate) and 'R' (reverse): When you get an instruction 'A', your car does the following: position += speed speed *= 2 When ...
racecar(target: int) -> int
pub fn racecar(target: i64) -> i64
Aegis.Racecar.racecar
fn dp_solve(s_val: i64, d: i64, smax: i64) -> i64 { let cmax: i64 = 4; let emax: usize = 20; let inf: i64 = 1_000_000_000; let vn: usize = (2 * cmax + 1) as usize; let sn: usize = (2 * smax + 1) as usize; let total: usize = vn * sn; let mut dp: Vec<i64> = Vec::new(); let mut i: usize =...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [racecar]: 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 -- [racecar]: function definitions module public import Aeneas public import Aegis.Racecar.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.unu...
import Aegis.Racecar.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": "[3]", "output": "2" }, { "input": "[6]", "output": "5" }, { "input": "[4]", "output": "5" }, { "input": "[10]", "output": "7" }, { "input": "[1]", "output": "1" }, { "input": "[100]", "output": "19" }, { "input": "[15]", "ou...
49
false
49
verified
10
10
2
67,432
[ { "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.Racecar.Code.Funs /-! # Specifications of `Aegis.Racecar.racecar` LeetCode problem `race-car`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.Racecar inductive Instr where | A : Instr | R : Instr deriving DecidableEq, R...
7
short-encoding-of-words
820
Medium
[ "Trie", "Array", "Hash Table", "String" ]
A valid encoding of an array of words is any reference string s and array of indices indices such that: words.length == indices.length The reference string s ends with the '#' character. For each index indices[i], the substring of s starting from indices[i] and up to (but not including) the next '#' character is equal...
minimumLengthEncoding(words: list_str) -> int
pub fn minimum_length_encoding(words: &[Vec<u8>]) -> i64
Aegis.MinimumLengthEncoding.minimum_length_encoding
pub fn minimum_length_encoding(words: &[Vec<u8>]) -> i64 { let n = words.len(); let mut keep: Vec<bool> = Vec::new(); let mut i = 0; while i < n { keep.push(true); i += 1; } i = 0; while i < n { let mut j = 0; while j < n { if i != j { ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [minimum_length_encoding]: 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 -- [minimum_length_encoding]: function definitions module public import Aeneas public import Aegis.MinimumLengthEncoding.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashComma...
import Aegis.MinimumLengthEncoding.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.MinimumLengthEncoding.minimum_length_encoding (Slice.from [(alloc.vec.Vec.from [116#u8] (by scalar_tac) : alloc.vec.Vec Std.U8)] (by scalar...
[ { "input": "[[\"t\"]]", "output": "2" }, { "input": "[[\"aaa\", \"aa\", \"a\"]]", "output": "4" }, { "input": "[[\"aa\", \"aaa\", \"aaaa\"]]", "output": "5" }, { "input": "[[\"hello\", \"world\", \"hold\"]]", "output": "17" }, { "input": "[[\"time\", \"me\", \"bel...
116
false
116
verified
10
10
1
3,019
[ { "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.MinimumLengthEncoding.Code.Funs /-! # Specifications of `Aegis.MinimumLengthEncoding.minimum_length_encoding` LeetCode problem `short-encoding-of-words`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.MinimumLengthEncoding namespace AegisSpe...
14
shortest-distance-to-a-character
821
Easy
[ "Array", "Two Pointers", "String" ]
Given a string s and a character c that occurs in s, return an array of integers answer where answer.length == s.length and answer[i] is the distance from index i to the closest occurrence of character c in s. The distance between two indices i and j is abs(i - j), where abs is the absolute value function.   Example 1:...
shortestToChar(s: str, c: str) -> list_int
pub fn shortest_to_char(s: &[u8], c: &[u8]) -> Vec<i64>
Aegis.ShortestToChar.shortest_to_char
pub fn shortest_to_char(s: &[u8], c: &[u8]) -> Vec<i64> { let n = s.len(); let target = c[0]; let mut ans: Vec<i64> = Vec::new(); let mut k: usize = 0; while k < n { ans.push(1000000000); k += 1; } let mut last: usize = n; let mut i: usize = 0; while i < n { ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [shortest_to_char]: 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 -- [shortest_to_char]: function definitions module public import Aeneas public import Aegis.ShortestToChar.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.ShortestToChar.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.ShortestToChar.shortest_to_char (Slice.from [97#u8] (by scalar_tac) : Slice Std.U8) (Slice.from [97#u8] (by scalar_tac) : Slice Std.U8)) ((alloc.v...
[ { "input": "[\"a\", \"a\"]", "output": "[0]" }, { "input": "[\"abba\", \"a\"]", "output": "[0, 1, 1, 0]" }, { "input": "[\"zzzz\", \"z\"]", "output": "[0, 0, 0, 0]" }, { "input": "[\"aaab\", \"b\"]", "output": "[3, 2, 1, 0]" }, { "input": "[\"abba\", \"b\"]", ...
118
false
118
verified
10
10
1
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.ShortestToChar.Code.Funs /-! # Specifications of `Aegis.ShortestToChar.shortest_to_char` LeetCode problem `shortest-distance-to-a-character`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.ShortestToChar abbrev Byte := Aeneas.Std.U8 a...
11
card-flipping-game
822
Medium
[ "Array", "Hash Table" ]
You are given two 0-indexed integer arrays fronts and backs of length n, where the ith card has the positive integer fronts[i] printed on the front and backs[i] printed on the back. Initially, each card is placed on a table such that the front number is facing up and the other is facing down. You may flip over any numb...
flipgame(fronts: list_int, backs: list_int) -> int
pub fn flipgame(fronts: &[i64], backs: &[i64]) -> i64
Aegis.Flipgame.flipgame
pub fn flipgame(fronts: &[i64], backs: &[i64]) -> i64 { let n = fronts.len(); let mut x: i64 = 1; while x <= 2000 { let mut appears = false; let mut forbidden = false; let mut i: usize = 0; while i < n { if fronts[i] == x || backs[i] == x { appea...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [flipgame]: 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 -- [flipgame]: function definitions module public import Aeneas public import Aegis.Flipgame.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.Flipgame.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.Flipgame.flipgame (Slice.from [1#i64] (by scalar_tac) : Slice Std.I64) (Slice.from [1#i64] (by scalar_tac) : Slice Std.I64)) (0#i64))}") #eval (s!"CASE ...
[ { "input": "[[1], [1]]", "output": "0" }, { "input": "[[1000, 2000], [2000, 1000]]", "output": "1000" }, { "input": "[[1000, 1000, 1000], [1001, 1002, 1003]]", "output": "1000" }, { "input": "[[1, 2, 3], [3, 2, 1]]", "output": "1" }, { "input": "[[1, 2, 3], [3, 2,...
107
false
107
verified
10
10
1
1,429
[ { "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.Flipgame.Code.Funs /-! # Specifications of `Aegis.Flipgame.flipgame` LeetCode problem `card-flipping-game`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.Flipgame def vals (s : Slice Std.I64) : List Int := s.val.map fun v => v.val...
11
binary-trees-with-factors
823
Medium
[ "Array", "Hash Table", "Dynamic Programming", "Sorting" ]
Given an array of unique integers, arr, where each integer arr[i] is strictly greater than 1. We make a binary tree using these integers, and each number may be used for any number of times. Each non-leaf node's value should be equal to the product of the values of its children. Return the number of binary trees we can...
numFactoredBinaryTrees(arr: list_int) -> int
pub fn num_factored_binary_trees(arr: &[i64]) -> i64
Aegis.NumFactoredBinaryTrees.num_factored_binary_trees
fn find_index(vals: &[i64], x: i64) -> usize { let n = vals.len(); let mut lo: usize = 0; let mut hi: usize = n; while lo < hi { let mid = (lo + hi) / 2; if vals[mid] == x { return mid; } if vals[mid] < x { lo = mid + 1; } else { ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [num_factored_binary_trees]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_op...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [num_factored_binary_trees]: function definitions module public import Aeneas public import Aegis.NumFactoredBinaryTrees.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCo...
import Aegis.NumFactoredBinaryTrees.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.NumFactoredBinaryTrees.num_factored_binary_trees (Slice.from [2#i64, 4#i64] (by scalar_tac) : Slice Std.I64)) (3#i64))}") #eval (s!"CASE 1...
[ { "input": "[[2, 4]]", "output": "3" }, { "input": "[[3, 6, 9]]", "output": "4" }, { "input": "[[2, 3, 6]]", "output": "5" }, { "input": "[[10, 20, 40, 80]]", "output": "4" }, { "input": "[[2, 4, 5, 10]]", "output": "7" }, { "input": "[[2, 3, 6, 18]]",...
104
false
104
verified
10
10
1
3,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.NumFactoredBinaryTrees.Code.Funs /-! # Specifications of `Aegis.NumFactoredBinaryTrees.num_factored_binary_trees` LeetCode problem `binary-trees-with-factors`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.NumFactoredBinaryTrees d...
7
friends-of-appropriate-ages
825
Medium
[ "Array", "Two Pointers", "Binary Search", "Sorting" ]
There are n persons on a social media website. You are given an integer array ages where ages[i] is the age of the ith person. A Person x will not send a friend request to a person y (x != y) if any of the following conditions is true: age[y] <= 0.5 * age[x] + 7 age[y] > age[x] age[y] > 100 && age[x] < 100 Otherwise,...
numFriendRequests(ages: list_int) -> int
pub fn num_friend_requests(ages: &[i64]) -> i64
Aegis.NumFriendRequests.num_friend_requests
pub fn num_friend_requests(ages: &[i64]) -> i64 { let mut cnt: Vec<i64> = Vec::new(); let mut i: usize = 0; while i < 121 { cnt.push(0); i += 1; } let n = ages.len(); let mut p: usize = 0; while p < n { let a = ages[p]; let mut idx: usize = 1; let mu...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [num_friend_requests]: 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 -- [num_friend_requests]: function definitions module public import Aeneas public import Aegis.NumFriendRequests.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false...
import Aegis.NumFriendRequests.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.NumFriendRequests.num_friend_requests (Slice.from [16#i64, 16#i64] (by scalar_tac) : Slice Std.I64)) (2#i64))}") #eval (s!"CASE 1 {(Result.redu...
[ { "input": "[[16, 16]]", "output": "2" }, { "input": "[[15, 15, 15]]", "output": "6" }, { "input": "[[16, 17, 18]]", "output": "2" }, { "input": "[[15, 15, 15, 15]]", "output": "12" }, { "input": "[[15, 15, 15, 15, 15]]", "output": "20" }, { "input": "...
102
false
102
verified
10
10
1
4,708
[ { "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.NumFriendRequests.Code.Funs /-! # Specifications of `Aegis.NumFriendRequests.num_friend_requests` LeetCode problem `friends-of-appropriate-ages`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.NumFriendRequests open Aegis.NumFriend...
12
most-profit-assigning-work
826
Medium
[ "Greedy", "Array", "Two Pointers", "Binary Search", "Sorting" ]
You have n jobs and m workers. You are given three arrays: difficulty, profit, and worker where: difficulty[i] and profit[i] are the difficulty and the profit of the ith job, and worker[j] is the ability of jth worker (i.e., the jth worker can only complete a job with difficulty at most worker[j]). Every worker can b...
maxProfitAssignment(difficulty: list_int, profit: list_int, worker: list_int) -> int
pub fn max_profit_assignment(difficulty: &[i64], profit: &[i64], worker: &[i64]) -> i64
Aegis.MaxProfitAssignment.max_profit_assignment
pub fn max_profit_assignment(difficulty: &[i64], profit: &[i64], worker: &[i64]) -> i64 { let n = difficulty.len(); let m = worker.len(); let mut diff: Vec<i64> = Vec::new(); let mut prof: Vec<i64> = Vec::new(); let mut i: usize = 0; while i < n { diff.push(difficulty[i]); prof....
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [max_profit_assignment]: 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 -- [max_profit_assignment]: function definitions module public import Aeneas public import Aegis.MaxProfitAssignment.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand f...
import Aegis.MaxProfitAssignment.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": "[[100], [100], [100]]", "output": "100" }, { "input": "[[100000], [100000], [100000]]", "output": "100000" }, { "input": "[[10, 15, 25], [100, 150, 250], [20, 25, 30]]", "output": "650" }, { "input": "[[10, 20, 30], [60, 50, 40], [40, 25, 20]]", "output": "180...
106
false
106
verified
10
10
2
10,606
[ { "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.MaxProfitAssignment.Code.Funs /-! # Specifications of `Aegis.MaxProfitAssignment.max_profit_assignment` LeetCode problem `most-profit-assigning-work`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.MaxProfitAssignment namespace AegisSpec.MaxProf...
15
making-a-large-island
827
Hard
[ "Depth-First Search", "Breadth-First Search", "Union Find", "Array", "Matrix" ]
You are given an n x n binary matrix grid. You are allowed to change at most one 0 to be 1. Return the size of the largest island in grid after applying this operation. An island is a 4-directionally connected group of 1s.   Example 1: Input: grid = [[1,0],[0,1]] Output: 3 Explanation: Change one 0 to 1 and connect tw...
largestIsland(grid: list_list_int) -> int
pub fn largest_island(grid: &[Vec<i64>]) -> i64
Aegis.LargestIsland.largest_island
fn contains(v: &Vec<i64>, id: i64) -> bool { let mut k: usize = 0; while k < v.len() { if v[k] == id { return true; } k += 1; } false } fn flood_fill( grid: &[Vec<i64>], labels: &mut Vec<i64>, queue: &mut Vec<usize>, n: usize, start: usize, id...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [largest_island]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [largest_island]: function definitions module public import Aeneas public import Aegis.LargestIsland.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.LargestIsland.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.LargestIsland.largest_island (Slice.from [(alloc.vec.Vec.from [1#i64, 1#i64] (by scalar_tac) : alloc.vec.Vec Std.I64), (alloc.vec.Vec.from [1#i64, ...
[ { "input": "[[[1, 1], [1, 0]]]", "output": "4" }, { "input": "[[[1, 0], [0, 1]]]", "output": "3" }, { "input": "[[[1, 1], [1, 1]]]", "output": "4" }, { "input": "[[[1, 1, 1], [1, 0, 1], [1, 1, 1]]]", "output": "9" }, { "input": "[[[0, 0, 0], [0, 0, 0], [0, 0, 0]]]...
81
false
81
verified
10
10
2
25,811
[ { "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.LargestIsland.Code.Funs /-! # Specifications of `Aegis.LargestIsland.largest_island` LeetCode problem `making-a-large-island`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.LargestIsland def matOf (grid : Slice (alloc.vec.Vec Std....
16
consecutive-numbers-sum
829
Hard
[ "Math", "Enumeration" ]
Given an integer n, return the number of ways you can write n as the sum of consecutive positive integers.   Example 1: Input: n = 5 Output: 2 Explanation: 5 = 2 + 3 Example 2: Input: n = 9 Output: 3 Explanation: 9 = 4 + 5 = 2 + 3 + 4 Example 3: Input: n = 15 Output: 4 Explanation: 15 = 8 + 7 = 4 + 5 + 6 = 1 + 2 +...
consecutiveNumbersSum(n: int) -> int
pub fn consecutive_numbers_sum(n: i64) -> i64
Aegis.ConsecutiveNumbersSum.consecutive_numbers_sum
pub fn consecutive_numbers_sum(n: i64) -> i64 { let mut count: i64 = 0; let mut d: i64 = 1; while d * d <= n { if n % d == 0 { if d % 2 == 1 { count += 1; } let q = n / d; if q != d && q % 2 == 1 { count += 1; ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [consecutive_numbers_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_opti...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [consecutive_numbers_sum]: function definitions module public import Aeneas public import Aegis.ConsecutiveNumbersSum.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashComma...
import Aegis.ConsecutiveNumbersSum.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.ConsecutiveNumbersSum.consecutive_numbers_sum 100#i64) (3#i64))}") #eval (s!"CASE 1 {(Result.reducesTo (Aegis.ConsecutiveNumbersSum.consecu...
[ { "input": "[100]", "output": "3" }, { "input": "[15]", "output": "4" }, { "input": "[9]", "output": "3" }, { "input": "[1000000]", "output": "7" }, { "input": "[25]", "output": "3" }, { "input": "[1]", "output": "1" }, { "input": "[1000000...
53
false
53
verified
10
10
1
862
[ { "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.ConsecutiveNumbersSum.Code.Funs /-! # Specifications of `Aegis.ConsecutiveNumbersSum.consecutive_numbers_sum` LeetCode problem `consecutive-numbers-sum`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.ConsecutiveNumbersSum (consecutive_numbers_su...
14
positions-of-large-groups
830
Easy
[ "String" ]
In a string s of lowercase letters, these letters form consecutive groups of the same character. For example, a string like s = "abbxxxxzyy" has the groups "a", "bb", "xxxx", "z", and "yy". A group is identified by an interval [start, end], where start and end denote the start and end indices (inclusive) of the group. ...
largeGroupPositions(s: str) -> list_list_int
pub fn large_group_positions(s: &[u8]) -> Vec<Vec<i64>>
Aegis.LargeGroupPositions.large_group_positions
pub fn large_group_positions(s: &[u8]) -> Vec<Vec<i64>> { let n: usize = s.len(); let mut out: Vec<Vec<i64>> = Vec::new(); let mut i: usize = 0; while i < n { let mut j: usize = i + 1; while j < n && s[j] == s[i] { j += 1; } if j - i >= 3 { let m...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [large_group_positions]: 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 -- [large_group_positions]: function definitions module public import Aeneas public import Aegis.LargeGroupPositions.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand f...
import Aegis.LargeGroupPositions.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.LargeGroupPositions.large_group_positions (Slice.from [97#u8, 98#u8, 99#u8, 100#u8, 101#u8, 102#u8, 103#u8, 104#u8, 105#u8, 106#u8, 107#u8] (...
[ { "input": "[\"abcdefghijk\"]", "output": "[]" }, { "input": "[\"aabbaa\"]", "output": "[]" }, { "input": "[\"a\"]", "output": "[]" }, { "input": "[\"aa\"]", "output": "[]" }, { "input": "[\"abc\"]", "output": "[]" }, { "input": "[\"abcd\"]", "outp...
54
false
54
verified
10
10
3
74,141
[ { "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.LargeGroupPositions.Code.Funs /-! # Specifications of `Aegis.LargeGroupPositions.large_group_positions` LeetCode problem `positions-of-large-groups`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.LargeGroupPositions def byteAt (s ...
15
sum-of-distances-in-tree
834
Hard
[ "Tree", "Depth-First Search", "Graph", "Dynamic Programming" ]
There is an undirected connected tree with n nodes labeled from 0 to n - 1 and n - 1 edges. You are given the integer n and the array edges where edges[i] = [ai, bi] indicates that there is an edge between nodes ai and bi in the tree. Return an array answer of length n where answer[i] is the sum of the distances betwee...
sumOfDistancesInTree(n: int, edges: list_list_int) -> list_int
pub fn sum_of_distances_in_tree(n: i64, edges: &[Vec<i64>]) -> Vec<i64>
Aegis.SumOfDistancesInTree.sum_of_distances_in_tree
pub fn sum_of_distances_in_tree(n: i64, edges: &[Vec<i64>]) -> Vec<i64> { let nn = n as usize; let mut adj: Vec<Vec<i64>> = Vec::new(); let mut i = 0; while i < nn { let row: Vec<i64> = Vec::new(); adj.push(row); i += 1; } let m = edges.len(); i = 0; while i < m...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [sum_of_distances_in_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_opt...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [sum_of_distances_in_tree]: function definitions module public import Aeneas public import Aegis.SumOfDistancesInTree.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashComma...
import Aegis.SumOfDistancesInTree.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.SumOfDistancesInTree.sum_of_distances_in_tree 1#i64 (Slice.from [] (by scalar_tac) : Slice (alloc.vec.Vec Std.I64))) ((alloc.vec.Vec.from [0...
[ { "input": "[1, []]", "output": "[0]" }, { "input": "[2, [[1, 0]]]", "output": "[1, 1]" }, { "input": "[3, [[0, 1], [0, 2]]]", "output": "[2, 3, 3]" }, { "input": "[4, [[0, 1], [1, 2], [1, 3]]]", "output": "[5, 3, 5, 5]" }, { "input": "[4, [[0, 1], [0, 2], [1, 3]]...
40
false
40
verified
10
10
1
4,200
[ { "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.SumOfDistancesInTree.Code.Funs /-! # Specifications of `Aegis.SumOfDistancesInTree.sum_of_distances_in_tree` LeetCode problem `sum-of-distances-in-tree`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.SumOfDistancesInTree (sum_of_distances_in_tre...
17
image-overlap
835
Medium
[ "Array", "Matrix" ]
You are given two images, img1 and img2, represented as binary, square matrices of size n x n. A binary matrix has only 0s and 1s as values. We translate one image however we choose by sliding all the 1 bits left, right, up, and/or down any number of units. We then place it on top of the other image. We can then calcul...
largestOverlap(img1: list_list_int, img2: list_list_int) -> int
pub fn largest_overlap(img1: &[Vec<i64>], img2: &[Vec<i64>]) -> i64
Aegis.LargestOverlap.largest_overlap
pub fn largest_overlap(img1: &[Vec<i64>], img2: &[Vec<i64>]) -> i64 { let n = img1.len(); if n == 0 { return 0; } let shifts = 2 * n - 1; let mut best: i64 = 0; let mut vr: usize = 0; while vr < shifts { let mut a: usize = 0; let mut b: usize = 0; let mut ro...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [largest_overlap]: 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 -- [largest_overlap]: function definitions module public import Aeneas public import Aegis.LargestOverlap.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.LargestOverlap.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.LargestOverlap.largest_overlap (Slice.from [(alloc.vec.Vec.from [1#i64] (by scalar_tac) : alloc.vec.Vec Std.I64)] (by scalar_tac) : Slice (alloc.v...
[ { "input": "[[[1]], [[1]]]", "output": "1" }, { "input": "[[[0]], [[0]]]", "output": "0" }, { "input": "[[[1, 0], [0, 1]], [[1, 1], [1, 1]]]", "output": "2" }, { "input": "[[[1, 1], [1, 1]], [[0, 0], [0, 0]]]", "output": "0" }, { "input": "[[[1, 0], [0, 1]], [[1, ...
75
false
75
verified
10
10
1
4,101
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.LargestOverlap.Code.Funs /-! # Specifications of `Aegis.LargestOverlap.largest_overlap` LeetCode problem `image-overlap`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result ControlFlow Error open Aeneas.Std.Result namespace AegisSpec.LargestOverlap def row (i...
14
rectangle-overlap
836
Easy
[ "Geometry", "Math" ]
An axis-aligned rectangle is represented as a list [x1, y1, x2, y2], where (x1, y1) is the coordinate of its bottom-left corner, and (x2, y2) is the coordinate of its top-right corner. Its top and bottom edges are parallel to the X-axis, and its left and right edges are parallel to the Y-axis. Two rectangles overlap if...
isRectangleOverlap(rec1: list_int, rec2: list_int) -> bool
pub fn is_rectangle_overlap(rec1: &[i64], rec2: &[i64]) -> bool
Aegis.IsRectangleOverlap.is_rectangle_overlap
pub fn is_rectangle_overlap(rec1: &[i64], rec2: &[i64]) -> bool { let x_overlap: bool = rec1[0] < rec2[2] && rec2[0] < rec1[2]; let y_overlap: bool = rec1[1] < rec2[3] && rec2[1] < rec1[3]; x_overlap && y_overlap }
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [is_rectangle_overlap]: 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_rectangle_overlap]: function definitions module public import Aeneas public import Aegis.IsRectangleOverlap.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand fal...
import Aegis.IsRectangleOverlap.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.IsRectangleOverlap.is_rectangle_overlap (Slice.from [(-5)#i64, (-5)#i64, (-3)#i64, (-3)#i64] (by scalar_tac) : Slice Std.I64) (Slice.from [(-4...
[ { "input": "[[-5, -5, -3, -3], [-4, -4, -2, -2]]", "output": "true" }, { "input": "[[1, 1, 5, 5], [4, 4, 8, 8]]", "output": "true" }, { "input": "[[-5, -5, -2, -2], [-4, -4, -1, -1]]", "output": "true" }, { "input": "[[-2, -2, 0, 0], [-1, -1, 1, 1]]", "output": "true" }...
117
false
117
verified
10
10
1
180
[ { "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.IsRectangleOverlap.Code.Funs /-! # Specifications of `Aegis.IsRectangleOverlap.is_rectangle_overlap` LeetCode problem `rectangle-overlap`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.IsRectangleOverlap namespace AegisSpec.IsRectangleOverlap ...
14
similar-string-groups
839
Hard
[ "Depth-First Search", "Breadth-First Search", "Union Find", "Array", "Hash Table", "String" ]
Two strings, X and Y, are considered similar if either they are identical or we can make them equivalent by swapping at most two letters (in distinct positions) within the string X. For example, "tars" and "rats" are similar (swapping at positions 0 and 2), and "rats" and "arts" are similar, but "star" is not similar t...
numSimilarGroups(strs: list_str) -> int
pub fn num_similar_groups(strs: &[Vec<u8>]) -> i64
Aegis.NumSimilarGroups.num_similar_groups
pub fn num_similar_groups(strs: &[Vec<u8>]) -> i64 { let n = strs.len(); let mut parent: Vec<i64> = Vec::new(); let mut i: usize = 0; while i < n { parent.push(i as i64); i += 1; } let mut i: usize = 0; while i < n { let mut j: usize = i + 1; while j < n { ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [num_similar_groups]: 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 -- [num_similar_groups]: function definitions module public import Aeneas public import Aegis.NumSimilarGroups.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.NumSimilarGroups.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.NumSimilarGroups.num_similar_groups (Slice.from [(alloc.vec.Vec.from [111#u8, 109#u8, 118#u8] (by scalar_tac) : alloc.vec.Vec Std.U8), (alloc.ve...
[ { "input": "[[\"omv\", \"ovm\"]]", "output": "1" }, { "input": "[[\"abcdefghijklmnopqrstuvwxyz\", \"bcadefghijklmnopqrstuvwxyza\", \"cdefghijklmnopqrstuvwxyzab\"]]", "output": "3" }, { "input": "[[\"tars\", \"rats\", \"arts\", \"star\"]]", "output": "2" }, { "input": "[[\"ab\...
57
false
57
verified
10
10
1
9,896
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.NumSimilarGroups.Code.Funs /-! # Specifications of `Aegis.NumSimilarGroups.num_similar_groups` LeetCode problem `similar-string-groups`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.NumSimilarGroups abbrev ByteString : Type := List S...
14
magic-squares-in-grid
840
Medium
[ "Array", "Hash Table", "Math", "Matrix" ]
A 3 x 3 magic square is a 3 x 3 grid filled with distinct numbers from 1 to 9 such that each row, column, and both diagonals all have the same sum. Given a row x col grid of integers, how many 3 x 3 magic square subgrids are there? Note: while a magic square can only contain numbers from 1 to 9, grid may contain number...
numMagicSquaresInside(grid: list_list_int) -> int
pub fn num_magic_squares_inside(grid: &[Vec<i64>]) -> i64
Aegis.NumMagicSquaresInside.num_magic_squares_inside
pub fn num_magic_squares_inside(grid: &[Vec<i64>]) -> i64 { let rows = grid.len(); if rows < 3 { return 0; } let cols = grid[0].len(); if cols < 3 { return 0; } let mut ans: i64 = 0; let mut i: usize = 0; while i + 2 < rows { let mut j: usize = 0; ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [num_magic_squares_inside]: 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 -- [num_magic_squares_inside]: function definitions module public import Aeneas public import Aegis.NumMagicSquaresInside.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashComm...
import Aegis.NumMagicSquaresInside.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.NumMagicSquaresInside.num_magic_squares_inside (Slice.from [(alloc.vec.Vec.from [8#i64] (by scalar_tac) : alloc.vec.Vec Std.I64)] (by scala...
[ { "input": "[[[8]]]", "output": "0" }, { "input": "[[[7, 0, 5], [3, 5, 1], [6, 4, 3]]]", "output": "0" }, { "input": "[[[5, 5, 5], [5, 5, 5], [5, 5, 5]]]", "output": "0" }, { "input": "[[[10, 11, 12], [13, 14, 15], [16, 17, 18]]]", "output": "0" }, { "input": "[[[...
82
false
82
verified
10
10
2
4,097
[ { "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.NumMagicSquaresInside.Code.Funs /-! # Specifications of `Aegis.NumMagicSquaresInside.num_magic_squares_inside` LeetCode problem `magic-squares-in-grid`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.NumMagicSquaresInside def ncols...
7
keys-and-rooms
841
Medium
[ "Depth-First Search", "Breadth-First Search", "Graph" ]
There are n rooms labeled from 0 to n - 1 and all the rooms are locked except for room 0. Your goal is to visit all the rooms. However, you cannot enter a locked room without having its key. When you visit a room, you may find a set of distinct keys in it. Each key has a number on it, denoting which room it unlocks, an...
canVisitAllRooms(rooms: list_list_int) -> bool
pub fn can_visit_all_rooms(rooms: &[Vec<i64>]) -> bool
Aegis.CanVisitAllRooms.can_visit_all_rooms
pub fn can_visit_all_rooms(rooms: &[Vec<i64>]) -> bool { let n = rooms.len(); if n == 0 { return true; } let mut visited: Vec<bool> = Vec::new(); let mut i: usize = 0; while i < n { visited.push(false); i += 1; } visited[0] = true; let mut count: usize = 1; ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [can_visit_all_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 l...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [can_visit_all_rooms]: function definitions module public import Aeneas public import Aegis.CanVisitAllRooms.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false ...
import Aegis.CanVisitAllRooms.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.CanVisitAllRooms.can_visit_all_rooms (Slice.from [(alloc.vec.Vec.from [1#i64] (by scalar_tac) : alloc.vec.Vec Std.I64), (alloc.vec.Vec.from [0#i...
[ { "input": "[[[1], [0], [], []]]", "output": "false" }, { "input": "[[[1], [2], [], [3]]]", "output": "false" }, { "input": "[[[1, 2, 3], [], [], []]]", "output": "true" }, { "input": "[[[1], [2], [3], []]]", "output": "true" }, { "input": "[[[1, 2], [3], [], []]]...
86
false
86
verified
10
10
1
2,082
[ { "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.CanVisitAllRooms.Code.Funs /-! # Specifications of `Aegis.CanVisitAllRooms.can_visit_all_rooms` LeetCode problem `keys-and-rooms`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.CanVisitAllRooms open Aegis.CanVisitAllRooms (can_visit_a...
10
split-array-into-fibonacci-sequence
842
Medium
[ "String", "Backtracking" ]
You are given a string of digits num, such as "123456579". We can split it into a Fibonacci-like sequence [123, 456, 579]. Formally, a Fibonacci-like sequence is a list f of non-negative integers such that: 0 <= f[i] < 231, (that is, each integer fits in a 32-bit signed integer type), f.length >= 3, and f[i] + f[i + 1...
splitIntoFibonacci(num: str) -> list_int
pub fn split_into_fibonacci(num: &[u8]) -> Vec<i64>
Aegis.SplitIntoFibonacci.split_into_fibonacci
fn parse_num(num: &[u8], start: usize, len: usize) -> i64 { if len == 0 { return -1; } if num[start] == b'0' && len > 1 { return -1; } let mut val: i64 = 0; let mut i: usize = 0; let mut ok: bool = true; while i < len && ok { let d: i64 = (num[start + i] - b'0') ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [split_into_fibonacci]: 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 -- [split_into_fibonacci]: function definitions module public import Aeneas public import Aegis.SplitIntoFibonacci.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand fal...
import Aegis.SplitIntoFibonacci.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.SplitIntoFibonacci.split_into_fibonacci (Slice.from [49#u8, 48#u8] (by scalar_tac) : Slice Std.U8)) ((alloc.vec.Vec.from [] (by scalar_tac) : ...
[ { "input": "[\"10\"]", "output": "[]" }, { "input": "[\"1203\"]", "output": "[]" }, { "input": "[\"101001011001101110000110011100011010011110000\"]", "output": "[]" }, { "input": "[\"0123\"]", "output": "[]" }, { "input": "[\"53983465721539834678539834699107966937...
78
false
78
verified
10
10
2
24,306
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.SplitIntoFibonacci.Code.Funs /-! # Specifications of `Aegis.SplitIntoFibonacci.split_into_fibonacci` LeetCode problem `split-array-into-fibonacci-sequence`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.SplitIntoFibonacci open Aen...
14
backspace-string-compare
844
Easy
[ "Stack", "Two Pointers", "String", "Simulation" ]
Given two strings s and t, return true if they are equal when both are typed into empty text editors. '#' means a backspace character. Note that after backspacing an empty text, the text will continue empty.   Example 1: Input: s = "ab#c", t = "ad#c" Output: true Explanation: Both s and t become "ac". Example 2: Inp...
backspaceCompare(s: str, t: str) -> bool
pub fn backspace_compare(s: &[u8], t: &[u8]) -> bool
Aegis.BackspaceCompare.backspace_compare
pub fn backspace_compare(s: &[u8], t: &[u8]) -> bool { let mut rs: Vec<u8> = Vec::new(); let mut ls: usize = 0; let mut i: usize = 0; while i < s.len() { if s[i] == b'#' { if ls > 0 { ls -= 1; } } else { if ls < rs.len() { ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [backspace_compare]: 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 -- [backspace_compare]: function definitions module public import Aeneas public import Aegis.BackspaceCompare.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.BackspaceCompare.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.BackspaceCompare.backspace_compare (Slice.from [35#u8, 35#u8, 35#u8] (by scalar_tac) : Slice Std.U8) (Slice.from [] (by scalar_tac) : Slice Std....
[ { "input": "[\"###\", \"\"]", "output": "true" }, { "input": "[\"#a#c\", \"c\"]", "output": "true" }, { "input": "[\"xywrrmp\", \"xywrrmu#p\"]", "output": "true" }, { "input": "[\"bbbextm#w\", \"bb#bbbextm#w\"]", "output": "false" }, { "input": "[\"ab\", \"a#b\"]"...
109
false
109
verified
10
10
2
4,415
[ { "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.BackspaceCompare.Code.Funs /-! # Specifications of `Aegis.BackspaceCompare.backspace_compare` LeetCode problem `backspace-string-compare`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.BackspaceCompare namespace AegisSpec.BackspaceCompare ...
14
longest-mountain-in-array
845
Medium
[ "Array", "Two Pointers", "Dynamic Programming", "Enumeration" ]
You may recall that an array arr is a mountain array if and only if: arr.length >= 3 There exists some index i (0-indexed) with 0 < i < arr.length - 1 such that: arr[0] < arr[1] < ... < arr[i - 1] < arr[i] arr[i] > arr[i + 1] > ... > arr[arr.length - 1] Given an integer array arr, return the length of the longest...
longestMountain(arr: list_int) -> int
pub fn longest_mountain(arr: &[i64]) -> i64
Aegis.LongestMountain.longest_mountain
pub fn longest_mountain(arr: &[i64]) -> i64 { let n = arr.len(); if n < 3 { return 0; } let mut best: i64 = 0; let mut i: usize = 1; while i + 1 < n { if arr[i] > arr[i - 1] && arr[i] > arr[i + 1] { let mut left: usize = i; while left > 0 && arr[left - 1...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [longest_mountain]: 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 -- [longest_mountain]: function definitions module public import Aeneas public import Aegis.LongestMountain.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.LongestMountain.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.LongestMountain.longest_mountain (Slice.from [1#i64, 2#i64, 3#i64] (by scalar_tac) : Slice Std.I64)) (0#i64))}") #eval (s!"CASE 1 {(Result.reduce...
[ { "input": "[[1, 2, 3]]", "output": "0" }, { "input": "[[1, 3, 1]]", "output": "3" }, { "input": "[[2, 2, 2]]", "output": "0" }, { "input": "[[1, 2, 2, 1]]", "output": "0" }, { "input": "[[0, 2, 1, 0]]", "output": "4" }, { "input": "[[5, 4, 3, 2, 1]]",...
160
false
160
verified
10
10
1
1,658
[ { "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.LongestMountain.Code.Funs /-! # Specifications of `Aegis.LongestMountain.longest_mountain` LeetCode problem `longest-mountain-in-array`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.LongestMountain def vals (arr : Slice Std.I64) ...
12
hand-of-straights
846
Medium
[ "Greedy", "Array", "Hash Table", "Sorting" ]
Alice has some number of cards and she wants to rearrange the cards into groups so that each group is of size groupSize, and consists of groupSize consecutive cards. Given an integer array hand where hand[i] is the value written on the ith card and an integer groupSize, return true if she can rearrange the cards, or fa...
isNStraightHand(hand: list_int, groupSize: int) -> bool
pub fn is_n_straight_hand(hand: &[i64], groupSize: i64) -> bool
Aegis.IsNStraightHand.is_n_straight_hand
pub fn is_n_straight_hand(hand: &[i64], group_size: i64) -> bool { let n = hand.len(); // Basic feasibility checks (outside of any loop, so early return is fine). if group_size <= 0 { return false; } let g = group_size as usize; if g > n { return false; } if n % g != 0 {...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [is_n_straight_hand]: 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_n_straight_hand]: function definitions module public import Aeneas public import Aegis.IsNStraightHand.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.IsNStraightHand.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.IsNStraightHand.is_n_straight_hand (Slice.from [8#i64, 10#i64, 12#i64] (by scalar_tac) : Slice Std.I64) 3#i64) (false))}") #eval (s!"CASE 1 {(Res...
[ { "input": "[[8, 10, 12], 3]", "output": "false" }, { "input": "[[1, 2, 3, 4, 5], 4]", "output": "false" }, { "input": "[[1, 2, 3, 4, 5, 6], 2]", "output": "true" }, { "input": "[[1, 1, 2, 2, 3, 3], 3]", "output": "true" }, { "input": "[[1, 2, 3, 4, 5, 6], 3]", ...
81
false
81
verified
10
10
3
28,713
[ { "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.IsNStraightHand.Code.Funs /-! # Specifications of `Aegis.IsNStraightHand.is_n_straight_hand` LeetCode problem `hand-of-straights`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.IsNStraightHand def countVal (l : List Std.I64) (v : ℤ) :...
13
shortest-path-visiting-all-nodes
847
Hard
[ "Bit Manipulation", "Breadth-First Search", "Graph", "Dynamic Programming", "Bitmask" ]
You have an undirected, connected graph of n nodes labeled from 0 to n - 1. You are given an array graph where graph[i] is a list of all the nodes connected with node i by an edge. Return the length of the shortest path that visits every node. You may start and stop at any node, you may revisit nodes multiple times, an...
shortestPathLength(graph: list_list_int) -> int
pub fn shortest_path_length(graph: &[Vec<i64>]) -> i64
Aegis.ShortestPathLength.shortest_path_length
pub fn shortest_path_length(graph: &[Vec<i64>]) -> i64 { let n = graph.len(); if n <= 1 { return 0; } let n_i = n as i64; let state_count = (1usize << n) * n; let mut dist: Vec<i64> = Vec::new(); let mut idx = 0usize; while idx < state_count { dist.push(-1); id...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [shortest_path_length]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [shortest_path_length]: function definitions module public import Aeneas public import Aegis.ShortestPathLength.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand fal...
import Aegis.ShortestPathLength.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.ShortestPathLength.shortest_path_length (Slice.from [(alloc.vec.Vec.from [1#i64, 2#i64] (by scalar_tac) : alloc.vec.Vec Std.I64), (alloc.vec.V...
[ { "input": "[[[1, 2], [0], [0]]]", "output": "2" }, { "input": "[[[1, 2, 3], [0], [0], [0]]]", "output": "4" }, { "input": "[[[1, 2], [0, 2, 3], [0, 1], [1]]]", "output": "3" }, { "input": "[[[1], [0, 2, 4], [1, 3, 4], [2], [1, 2]]]", "output": "4" }, { "input": "...
63
false
63
verified
10
10
1
4,161
[ { "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.ShortestPathLength.Code.Funs /-! # Specifications of `Aegis.ShortestPathLength.shortest_path_length` LeetCode problem `shortest-path-visiting-all-nodes`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.ShortestPathLength def nOf (gr...
10
maximize-distance-to-closest-person
849
Medium
[ "Array" ]
You are given an array representing a row of seats where seats[i] = 1 represents a person sitting in the ith seat, and seats[i] = 0 represents that the ith seat is empty (0-indexed). There is at least one empty seat, and at least one person sitting. Alex wants to sit in the seat such that the distance between him and t...
maxDistToClosest(seats: list_int) -> int
pub fn max_dist_to_closest(seats: &[i64]) -> i64
Aegis.MaxDistToClosest.max_dist_to_closest
pub fn max_dist_to_closest(seats: &[i64]) -> i64 { let n: usize = seats.len(); let mut ans: i64 = 0; let mut last: i64 = -1; for i in 0..n { if seats[i] == 1 { let idx: i64 = i as i64; if last == -1 { if idx > ans { ans = idx; ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [max_dist_to_closest]: 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 -- [max_dist_to_closest]: function definitions module public import Aeneas public import Aegis.MaxDistToClosest.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false ...
import Aegis.MaxDistToClosest.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.MaxDistToClosest.max_dist_to_closest (Slice.from [0#i64, 1#i64] (by scalar_tac) : Slice Std.I64)) (1#i64))}") #eval (s!"CASE 1 {(Result.reducesT...
[ { "input": "[[0, 1]]", "output": "1" }, { "input": "[[1, 0, 0, 0]]", "output": "3" }, { "input": "[[0, 0, 0, 1]]", "output": "3" }, { "input": "[[0, 0, 0, 1, 0, 0, 0]]", "output": "3" }, { "input": "[[1, 0, 0, 0, 0, 0, 1]]", "output": "3" }, { "input":...
120
false
120
verified
10
10
1
1,075
[ { "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.MaxDistToClosest.Code.Funs /-! # Specifications of `Aegis.MaxDistToClosest.max_dist_to_closest` LeetCode problem `maximize-distance-to-closest-person`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.MaxDistToClosest (max_dist_to_closest) nam...
13
rectangle-area-ii
850
Hard
[ "Segment Tree", "Array", "Ordered Set", "Line Sweep" ]
You are given a 2D array of axis-aligned rectangles. Each rectangle[i] = [xi1, yi1, xi2, yi2] denotes the ith rectangle where (xi1, yi1) are the coordinates of the bottom-left corner, and (xi2, yi2) are the coordinates of the top-right corner. Calculate the total area covered by all rectangles in the plane. Any area co...
rectangleArea(rectangles: list_list_int) -> int
pub fn rectangle_area(rectangles: &[Vec<i64>]) -> i64
Aegis.RectangleArea.rectangle_area
pub fn rectangle_area(rectangles: &[Vec<i64>]) -> i64 { let n = rectangles.len(); let mut xs: Vec<i64> = Vec::new(); let mut i = 0usize; while i < n { let r = &rectangles[i]; xs.push(r[0]); xs.push(r[2]); i += 1; } let mut a = 1usize; while a < xs.len() { ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [rectangle_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...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [rectangle_area]: function definitions module public import Aeneas public import Aegis.RectangleArea.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.RectangleArea.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.RectangleArea.rectangle_area (Slice.from [(alloc.vec.Vec.from [0#i64, 0#i64, 1000000000#i64, 1000000000#i64] (by scalar_tac) : alloc.vec.Vec Std.I6...
[ { "input": "[[[0, 0, 1000000000, 1000000000]]]", "output": "49" }, { "input": "[[[0, 0, 1000000000, 1000000000], [1000000000, 0, 2000000000, 1000000000]]]", "output": "98" }, { "input": "[[[0, 0, 1000000000, 1000000000], [500000000, 500000000, 1500000000, 1500000000]]]", "output": "7...
105
false
105
verified
10
10
1
10,124
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Mathlib.Basic.Real.Basic import Aegis.RectangleArea.Code.Funs /-! # Specifications of `Aegis.RectangleArea.rectangle_area` LeetCode problem `rectangle-area-ii`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.RectangleArea (rectangle_area) namespace Ae...
10
score-of-parentheses
856
Medium
[ "Stack", "String" ]
Given a balanced parentheses string s, return the score of the string. The score of a balanced parentheses string is based on the following rule: "()" has score 1. AB has score A + B, where A and B are balanced parentheses strings. (A) has score 2 * A, where A is a balanced parentheses string.   Example 1: Input: s ...
scoreOfParentheses(s: str) -> int
pub fn score_of_parentheses(s: &[u8]) -> i64
Aegis.ScoreOfParentheses.score_of_parentheses
pub fn score_of_parentheses(s: &[u8]) -> i64 { let mut score: i64 = 0; let mut depth: i64 = 0; let mut i: usize = 0; while i < s.len() { if s[i] == b'(' { depth += 1; } else { depth -= 1; if i > 0 && s[i - 1] == b'(' { let mut add: i64...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [score_of_parentheses]: 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 -- [score_of_parentheses]: function definitions module public import Aeneas public import Aegis.ScoreOfParentheses.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand fal...
import Aegis.ScoreOfParentheses.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.ScoreOfParentheses.score_of_parentheses (Slice.from [40#u8, 40#u8, 41#u8, 40#u8, 41#u8, 41#u8] (by scalar_tac) : Slice Std.U8)) (4#i64))}") #e...
[ { "input": "[\"(()())\"]", "output": "4" }, { "input": "[\"(()(()))\"]", "output": "6" }, { "input": "[\"()\"]", "output": "1" }, { "input": "[\"((()))\"]", "output": "4" }, { "input": "[\"((()()()))\"]", "output": "12" }, { "input": "[\"()()(())\"]", ...
55
false
55
verified
10
10
1
1,744
[ { "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.ScoreOfParentheses.Code.Funs /-! # Specifications of `Aegis.ScoreOfParentheses.score_of_parentheses` LeetCode problem `score-of-parentheses`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.ScoreOfParentheses namespace AegisSpec.ScoreOfParent...
11
mirror-reflection
858
Medium
[ "Geometry", "Math", "Number Theory" ]
There is a special square room with mirrors on each of the four walls. Except for the southwest corner, there are receptors on each of the remaining corners, numbered 0, 1, and 2. The square room has walls of length p and a laser ray from the southwest corner first meets the east wall at a distance q from the 0th recep...
mirrorReflection(p: int, q: int) -> int
pub fn mirror_reflection(p: i64, q: i64) -> i64
Aegis.MirrorReflection.mirror_reflection
pub fn mirror_reflection(p: i64, q: i64) -> i64 { let mut a = p; let mut b = q; while b != 0 { let t = a % b; a = b; b = t; } let g = a; let reduced_p = p / g; let reduced_q = q / g; if reduced_p % 2 == 0 { return 2; } if reduced_q % 2 == 0 { ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [mirror_reflection]: 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 -- [mirror_reflection]: function definitions module public import Aeneas public import Aegis.MirrorReflection.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.MirrorReflection.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.MirrorReflection.mirror_reflection 2#i64 1#i64) (2#i64))}") #eval (s!"CASE 1 {(Result.reducesTo (Aegis.MirrorReflection.mirror_reflection 10#i64...
[ { "input": "[2, 1]", "output": "2" }, { "input": "[10, 3]", "output": "2" }, { "input": "[6, 2]", "output": "1" }, { "input": "[4, 2]", "output": "2" }, { "input": "[10, 4]", "output": "0" }, { "input": "[5, 3]", "output": "1" }, { "input":...
84
false
84
verified
10
10
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.MirrorReflection.Code.Funs /-! # Specifications of `Aegis.MirrorReflection.mirror_reflection` LeetCode problem `mirror-reflection`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.MirrorReflection def v2 (n : Int) : Nat := Nat.findGreat...
10
buddy-strings
859
Easy
[ "Hash Table", "String" ]
Given two strings s and goal, return true if you can swap two letters in s so the result is equal to goal, otherwise, return false. Swapping letters is defined as taking two indices i and j (0-indexed) such that i != j and swapping the characters at s[i] and s[j]. For example, swapping at indices 0 and 2 in "abcd" res...
buddyStrings(s: str, goal: str) -> bool
pub fn buddy_strings(s: &[u8], goal: &[u8]) -> bool
Aegis.BuddyStrings.buddy_strings
pub fn buddy_strings(s: &[u8], goal: &[u8]) -> bool { let n = s.len(); if n != goal.len() { return false; } // Find the index of the first mismatch (n means "none"). let mut first: usize = n; let mut i: usize = 0; while i < n { if s[i] != goal[i] && first == n { ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [buddy_strings]: 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 -- [buddy_strings]: function definitions module public import Aeneas public import Aegis.BuddyStrings.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.BuddyStrings.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.BuddyStrings.buddy_strings (Slice.from [97#u8, 98#u8, 99#u8, 100#u8] (by scalar_tac) : Slice Std.U8) (Slice.from [100#u8, 99#u8, 98#u8, 97#u8] (by s...
[ { "input": "[\"abcd\", \"dcba\"]", "output": "false" }, { "input": "[\"xyy\", \"xyx\"]", "output": "false" }, { "input": "[\"abac\", \"abad\"]", "output": "false" }, { "input": "[\"aa\", \"aa\"]", "output": "true" }, { "input": "[\"abcde\", \"edcba\"]", "outpu...
126
false
126
verified
10
10
3
11,304
[ { "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.BuddyStrings.Code.Funs /-! # Specifications of `Aegis.BuddyStrings.buddy_strings` LeetCode problem `buddy-strings`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.BuddyStrings open Aeneas.Std open Aegis.BuddyStrings def byte ...
13
lemonade-change
860
Easy
[ "Greedy", "Array" ]
At a lemonade stand, each lemonade costs $5. Customers are standing in a queue to buy from you and order one at a time (in the order specified by bills). Each customer will only buy one lemonade and pay with either a $5, $10, or $20 bill. You must provide the correct change to each customer so that the net transaction ...
lemonadeChange(bills: list_int) -> bool
pub fn lemonade_change(bills: &[i64]) -> bool
Aegis.LemonadeChange.lemonade_change
pub fn lemonade_change(bills: &[i64]) -> bool { let mut fives: i64 = 0; let mut tens: i64 = 0; let mut i: usize = 0; while i < bills.len() { let bill = bills[i]; if bill == 5 { fives += 1; } else if bill == 10 { if fives == 0 { return fal...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [lemonade_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 linte...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [lemonade_change]: function definitions module public import Aeneas public import Aegis.LemonadeChange.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.LemonadeChange.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.LemonadeChange.lemonade_change (Slice.from [10#i64, 10#i64] (by scalar_tac) : Slice Std.I64)) (false))}") #eval (s!"CASE 1 {(Result.reducesTo (Aeg...
[ { "input": "[[10, 10]]", "output": "false" }, { "input": "[[5, 5, 10]]", "output": "true" }, { "input": "[[5, 10, 5, 20]]", "output": "true" }, { "input": "[[5, 5, 10, 10, 20]]", "output": "false" }, { "input": "[[5, 10, 5, 5, 20]]", "output": "true" }, { ...
106
false
106
verified
10
10
1
472
[ { "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.LemonadeChange.Code.Funs /-! # Specifications of `Aegis.LemonadeChange.lemonade_change` LeetCode problem `lemonade-change`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.LemonadeChange def vals (bills : Slice Std.I64) : List ℤ := bill...
11
score-after-flipping-matrix
861
Medium
[ "Greedy", "Bit Manipulation", "Array", "Matrix" ]
You are given an m x n binary matrix grid. A move consists of choosing any row or column and toggling each value in that row or column (i.e., changing all 0's to 1's, and all 1's to 0's). Every row of the matrix is interpreted as a binary number, and the score of the matrix is the sum of these numbers. Return the highe...
matrixScore(grid: list_list_int) -> int
pub fn matrix_score(grid: &[Vec<i64>]) -> i64
Aegis.MatrixScore.matrix_score
pub fn matrix_score(grid: &[Vec<i64>]) -> i64 { let m = grid.len(); let n = grid[0].len(); let mut m_i: i64 = 0; let mut t: usize = 0; while t < m { m_i += 1; t += 1; } let mut weight: i64 = 1; let mut k: usize = 1; while k < n { weight *= 2; k += 1;...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [matrix_score]: 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 -- [matrix_score]: function definitions module public import Aeneas public import Aegis.MatrixScore.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.MatrixScore.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.MatrixScore.matrix_score (Slice.from [(alloc.vec.Vec.from [0#i64] (by scalar_tac) : alloc.vec.Vec Std.I64)] (by scalar_tac) : Slice (alloc.vec.Vec St...
[ { "input": "[[[0]]]", "output": "1" }, { "input": "[[[1, 0, 0], [0, 1, 1], [1, 1, 0]]]", "output": "19" }, { "input": "[[[1, 1, 1], [0, 0, 0], [1, 0, 1]]]", "output": "19" }, { "input": "[[[0, 0, 0], [0, 0, 0], [0, 0, 0]]]", "output": "21" }, { "input": "[[[1, 0, ...
80
false
80
verified
10
10
1
2,803
[ { "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.MatrixScore.Code.Funs /-! # Specifications of `Aegis.MatrixScore.matrix_score` LeetCode problem `score-after-flipping-matrix`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.MatrixScore (matrix_score) namespace AegisSpec.MatrixScore def rows (g...
13
shortest-subarray-with-sum-at-least-k
862
Hard
[ "Queue", "Array", "Binary Search", "Prefix Sum", "Sliding Window", "Monotonic Queue", "Heap (Priority Queue)" ]
Given an integer array nums and an integer k, return the length of the shortest non-empty subarray of nums with a sum of at least k. If there is no such subarray, return -1. A subarray is a contiguous part of an array.   Example 1: Input: nums = [1], k = 1 Output: 1 Example 2: Input: nums = [1,2], k = 4 Output: -1 Exam...
shortestSubarray(nums: list_int, k: int) -> int
pub fn shortest_subarray(nums: &[i64], k: i64) -> i64
Aegis.ShortestSubarray.shortest_subarray
pub fn shortest_subarray(nums: &[i64], k: i64) -> i64 { let n = nums.len(); let mut prefix: Vec<i64> = Vec::new(); prefix.push(0); let mut i: usize = 0; while i < n { let s = prefix[i] + nums[i]; prefix.push(s); i += 1; } let mut dq: Vec<i64> = Vec::new(); let ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [shortest_subarray]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option lin...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [shortest_subarray]: function definitions module public import Aeneas public import Aegis.ShortestSubarray.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.ShortestSubarray.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.ShortestSubarray.shortest_subarray (Slice.from [1#i64] (by scalar_tac) : Slice Std.I64) 1#i64) (1#i64))}") #eval (s!"CASE 1 {(Result.reducesTo (...
[ { "input": "[[1], 1]", "output": "1" }, { "input": "[[8], 8]", "output": "1" }, { "input": "[[8], 10]", "output": "-1" }, { "input": "[[5], 5]", "output": "1" }, { "input": "[[100000], 100000]", "output": "1" }, { "input": "[[-1, 2], 2]", "output":...
127
false
127
verified
10
10
1
4,247
[ { "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.ShortestSubarray.Code.Funs /-! # Specifications of `Aegis.ShortestSubarray.shortest_subarray` LeetCode problem `shortest-subarray-with-sum-at-least-k`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.ShortestSubarray def intSum (l :...
12
smallest-subtree-with-all-the-deepest-nodes
865
Medium
[ "Tree", "Depth-First Search", "Breadth-First Search", "Hash Table", "Binary Tree" ]
Given the root of a binary tree, the depth of each node is the shortest distance to the root. Return the smallest subtree such that it contains all the deepest nodes in the original tree. A node is called the deepest if it has the largest depth possible among any node in the entire tree. The subtree of a node is a tree...
subtreeWithAllDeepest(root: tree) -> tree
pub fn subtree_with_all_deepest(root: &Tree) -> Tree
Aegis.SubtreeWithAllDeepest.subtree_with_all_deepest
fn max_depth(t: &Tree) -> i64 { match t { Tree::Null => 0, Tree::Node(_v, l, r) => { let left: &Tree = &**l; let right: &Tree = &**r; let lh = max_depth(left); let rh = max_depth(right); if lh > rh { lh + 1 } els...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [subtree_with_all_deepest]: 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 -- [subtree_with_all_deepest]: function definitions module public import Aeneas public import Aegis.SubtreeWithAllDeepest.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashComm...
import Aegis.SubtreeWithAllDeepest.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 deriving instance DecidableEq for Aegis.SubtreeWithAllDeepest.Tree #eval (s!"CASE 0 {(match (Aegis.SubtreeWithAllDeepest.subtree_with_all_deepest ((.Node 1#i64 (.Null) (.Null)) : Ae...
[ { "input": "[[1]]", "output": "[1]" }, { "input": "[[2, 7, 4]]", "output": "[2, 7, 4]" }, { "input": "[[2, 1, 3]]", "output": "[2, 1, 3]" }, { "input": "[[1, 2, 3, 4, 5, 6, 7]]", "output": "[1, 2, 3, 4, 5, 6, 7]" }, { "input": "[[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11,...
14
false
14
verified
10
10
1
5,310
[ { "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.SubtreeWithAllDeepest.Code.Funs /-! # Specifications of `Aegis.SubtreeWithAllDeepest.subtree_with_all_deepest` LeetCode problem `smallest-subtree-with-all-the-deepest-nodes`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.SubtreeWithAll...
13
binary-gap
868
Easy
[ "Bit Manipulation" ]
Given a positive integer n, find and return the longest distance between any two adjacent 1's in the binary representation of n. If there are no two adjacent 1's, return 0. Two 1's are adjacent if there are only 0's separating them (possibly no 0's). The distance between two 1's is the absolute difference between their...
binaryGap(n: int) -> int
pub fn binary_gap(n: i64) -> i64
Aegis.BinaryGap.binary_gap
pub fn binary_gap(n: i64) -> i64 { let mut m = n; let mut pos = 0i64; let mut last = -1i64; let mut best = 0i64; while m > 0 { if m % 2 == 1 { if last >= 0 { let distance = pos - last; if distance > best { best = distance; ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [binary_gap]: 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 -- [binary_gap]: function definitions module public import Aeneas public import Aegis.BinaryGap.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.BinaryGap.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.BinaryGap.binary_gap 8#i64) (0#i64))}") #eval (s!"CASE 1 {(Result.reducesTo (Aegis.BinaryGap.binary_gap 3#i64) (1#i64))}") #eval (s!"CASE 2 {(Result.re...
[ { "input": "[8]", "output": "0" }, { "input": "[3]", "output": "1" }, { "input": "[1041]", "output": "6" }, { "input": "[15]", "output": "1" }, { "input": "[22]", "output": "2" }, { "input": "[32]", "output": "0" }, { "input": "[6]", "o...
61
false
61
verified
10
10
1
440
[ { "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.BinaryGap.Code.Funs /-! # Specifications of `Aegis.BinaryGap.binary_gap` LeetCode problem `binary-gap`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.BinaryGap def IsOneBit (N k : ℕ) : Prop := N.testBit k = true def oneBitPosit...
8
minimum-number-of-refueling-stops
871
Hard
[ "Greedy", "Array", "Dynamic Programming", "Heap (Priority Queue)" ]
A car travels from a starting position to a destination which is target miles east of the starting position. There are gas stations along the way. The gas stations are represented as an array stations where stations[i] = [positioni, fueli] indicates that the ith gas station is positioni miles east of the starting posit...
minRefuelStops(target: int, startFuel: int, stations: list_list_int) -> int
pub fn min_refuel_stops(target: i64, startFuel: i64, stations: &[Vec<i64>]) -> i64
Aegis.MinRefuelStops.min_refuel_stops
pub fn min_refuel_stops(target: i64, start_fuel: i64, stations: &[Vec<i64>]) -> i64 { let n = stations.len(); let mut dp: Vec<i64> = Vec::new(); let mut i = 0; while i <= n { if i == 0 { dp.push(start_fuel); } else { dp.push(0); } i = i + 1; }...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [min_refuel_stops]: 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 -- [min_refuel_stops]: function definitions module public import Aeneas public import Aegis.MinRefuelStops.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.MinRefuelStops.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.MinRefuelStops.min_refuel_stops 1#i64 1#i64 (Slice.from [] (by scalar_tac) : Slice (alloc.vec.Vec Std.I64))) (0#i64))}") #eval (s!"CASE 1 {(Result...
[ { "input": "[1, 1, []]", "output": "0" }, { "input": "[100, 1, [[10, 100]]]", "output": "-1" }, { "input": "[150, 100, [[50, 30], [100, 20]]]", "output": "2" }, { "input": "[150, 50, [[25, 25], [50, 50], [75, 25]]]", "output": "3" }, { "input": "[100, 50, [[25, 25...
96
false
96
verified
10
10
1
2,277
[ { "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.MinRefuelStops.Code.Funs /-! # Specifications of `Aegis.MinRefuelStops.min_refuel_stops` LeetCode problem `minimum-number-of-refueling-stops`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.MinRefuelStops open Aegis.MinRefuelStops ...
16
leaf-similar-trees
872
Easy
[ "Tree", "Depth-First Search", "Binary Tree" ]
Consider all the leaves of a binary tree, from left to right order, the values of those leaves form a leaf value sequence. For example, in the given tree above, the leaf value sequence is (6, 7, 4, 9, 8). Two binary trees are considered leaf-similar if their leaf value sequence is the same. Return true if and only if ...
leafSimilar(root1: tree, root2: tree) -> bool
pub fn leaf_similar(root1: &Tree, root2: &Tree) -> bool
Aegis.LeafSimilar.leaf_similar
fn collect_leaves(t: &Tree, out: &mut Vec<i64>) { match t { Tree::Null => {} Tree::Node(v, left, right) => { let left_is_null = match &**left { Tree::Null => true, Tree::Node(_, _, _) => false, }; let right_is_null = match &**right ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [leaf_similar]: 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 -- [leaf_similar]: function definitions module public import Aeneas public import Aegis.LeafSimilar.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.LeafSimilar.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.LeafSimilar.leaf_similar ((.Node 1#i64 (.Null) (.Null)) : Aegis.LeafSimilar.Tree) ((.Node 1#i64 (.Null) (.Null)) : Aegis.LeafSimilar.Tree)) (true))}"...
[ { "input": "[[1], [1]]", "output": "true" }, { "input": "[[1, 2, 3], [1, 3, 2]]", "output": "false" }, { "input": "[[4, 2, 7, 1, 3, 6, 9], [4, 2, 7, 1, 3, 9, 6]]", "output": "false" }, { "input": "[[4, 2, 7, 1, 3, 6, 9], [4, 2, 7, 3, 1, 9, 6]]", "output": "false" }, {...
16
false
16
verified
10
10
1
2,235
[ { "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.LeafSimilar.Code.Funs /-! # Specifications of `Aegis.LeafSimilar.leaf_similar` LeetCode problem `leaf-similar-trees`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.LeafSimilar open Aegis.LeafSimilar def numNodes : Tree → Nat | Tree...
9
length-of-longest-fibonacci-subsequence
873
Medium
[ "Array", "Hash Table", "Dynamic Programming" ]
A sequence x1, x2, ..., xn is Fibonacci-like if: n >= 3 xi + xi+1 == xi+2 for all i + 2 <= n Given a strictly increasing array arr of positive integers forming a sequence, return the length of the longest Fibonacci-like subsequence of arr. If one does not exist, return 0. A subsequence is derived from another sequenc...
lenLongestFibSubseq(arr: list_int) -> int
pub fn len_longest_fib_subseq(arr: &[i64]) -> i64
Aegis.LenLongestFibSubseq.len_longest_fib_subseq
pub fn len_longest_fib_subseq(arr: &[i64]) -> i64 { let n = arr.len(); if n < 3 { return 0; } let total = n * n; let mut dp: Vec<i64> = Vec::new(); let mut t: usize = 0; while t < total { dp.push(0); t += 1; } let mut ans: i64 = 0; let mut i: usize = 1; ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [len_longest_fib_subseq]: 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 -- [len_longest_fib_subseq]: function definitions module public import Aeneas public import Aegis.LenLongestFibSubseq.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand ...
import Aegis.LenLongestFibSubseq.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.LenLongestFibSubseq.len_longest_fib_subseq (Slice.from [1#i64, 4#i64, 7#i64, 10#i64, 13#i64, 16#i64, 19#i64] (by scalar_tac) : Slice Std.I64)...
[ { "input": "[[1, 4, 7, 10, 13, 16, 19]]", "output": "0" }, { "input": "[[1, 3, 7, 11, 12, 14, 18]]", "output": "3" }, { "input": "[[1, 2, 4, 8, 13, 21, 34]]", "output": "4" }, { "input": "[[1, 2, 3, 5, 8, 13, 21]]", "output": "7" }, { "input": "[[1, 2, 4, 7, 11, 1...
122
false
122
verified
10
10
1
3,869
[ { "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.LenLongestFibSubseq.Code.Funs /-! # Specifications of `Aegis.LenLongestFibSubseq.len_longest_fib_subseq` LeetCode problem `length-of-longest-fibonacci-subsequence`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.LenLongestFibSubseq def...
10
walking-robot-simulation
874
Medium
[ "Array", "Hash Table", "Simulation" ]
A robot on an infinite XY-plane starts at point (0, 0) facing north. The robot receives an array of integers commands, which represents a sequence of moves that it needs to execute. There are only three possible types of instructions the robot can receive: -2: Turn left 90 degrees. -1: Turn right 90 degrees. 1 <= k <=...
robotSim(commands: list_int, obstacles: list_list_int) -> int
pub fn robot_sim(commands: &[i64], obstacles: &[Vec<i64>]) -> i64
Aegis.RobotSim.robot_sim
pub fn robot_sim(commands: &[i64], obstacles: &[Vec<i64>]) -> i64 { let offset: i64 = 1_000_000; let base: i64 = 10_000_000; let mut keys: Vec<i64> = Vec::new(); let mut i: usize = 0; while i < obstacles.len() { let ox = obstacles[i][0]; let oy = obstacles[i][1]; let key = (...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [robot_sim]: 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 -- [robot_sim]: function definitions module public import Aeneas public import Aegis.RobotSim.Code.Types public import Aegis.RobotSim.Code.FunsExternal @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_opt...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [robot_sim]: external functions. -- This is a template file: rename it to "FunsExternal.lean" and fill the holes. module public import Aeneas public import Aegis.RobotSim.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option ...
import Aegis.RobotSim.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.RobotSim.robot_sim (Slice.from [4#i64, (-1)#i64, 3#i64] (by scalar_tac) : Slice Std.I64) (Slice.from [] (by scalar_tac) : Slice (alloc.vec.Vec Std.I64))...
[ { "input": "[[4, -1, 3], []]", "output": "25" }, { "input": "[[-2, -2, -2, -2], []]", "output": "0" }, { "input": "[[-2, -1, 10], [[1, 0]]]", "output": "100" }, { "input": "[[1, 1, 1, 1], [[1, 1]]]", "output": "16" }, { "input": "[[6, -1, -1, 6], [[0, 0]]]", "...
114
false
114
verified
10
10
1
5,658
[ { "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.RobotSim.Code.Funs /-! # Specifications of `Aegis.RobotSim.robot_sim` LeetCode problem `walking-robot-simulation`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.RobotSim abbrev Pos : Type := Int × Int def vecCoords (v : alloc.vec.Vec...
10
middle-of-the-linked-list
876
Easy
[ "Linked List", "Two Pointers" ]
Given the head of a singly linked list, return the middle node of the linked list. If there are two middle nodes, return the second middle node.   Example 1: Input: head = [1,2,3,4,5] Output: [3,4,5] Explanation: The middle node of the list is node 3. Example 2: Input: head = [1,2,3,4,5,6] Output: [4,5,6] Explanat...
middleNode(head: linkedlist) -> linkedlist
pub fn middle_node(head: &List) -> List
Aegis.MiddleNode.middle_node
fn list_len(l: &List) -> i64 { match l { List::Nil => 0, List::Cons(_, next) => 1 + list_len(&**next), } } fn copy_list(l: &List) -> List { match l { List::Nil => List::Nil, List::Cons(v, next) => List::Cons(*v, Box::new(copy_list(&**next))), } } fn drop_first(l: &List,...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [middle_node]: 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 -- [middle_node]: function definitions module public import Aeneas public import Aegis.MiddleNode.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.MiddleNode.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 deriving instance DecidableEq for Aegis.MiddleNode.List #eval (s!"CASE 0 {(match (Aegis.MiddleNode.middle_node ((.Cons 1#i64 (.Nil)) : Aegis.MiddleNode.List)).match with | .ok r => decide (r =...
[ { "input": "[[1]]", "output": "[1]" }, { "input": "[[42]]", "output": "[42]" }, { "input": "[[5]]", "output": "[5]" }, { "input": "[[7]]", "output": "[7]" }, { "input": "[[1, 2]]", "output": "[2]" }, { "input": "[[1, 2, 3]]", "output": "[2, 3]" }...
76
false
76
verified
10
10
1
1,885
[ { "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.MiddleNode.Code.Funs /-! # Specifications of `Aegis.MiddleNode.middle_node` LeetCode problem `middle-of-the-linked-list`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace Aegis.MiddleNode.List def val : List → _root_.List Int | Nil => [] | Con...
12
stone-game
877
Medium
[ "Array", "Math", "Dynamic Programming", "Game Theory" ]
Alice and Bob play a game with piles of stones. There are an even number of piles arranged in a row, and each pile has a positive integer number of stones piles[i]. The objective of the game is to end with the most stones. The total number of stones across all the piles is odd, so there are no ties. Alice and Bob take ...
stoneGame(piles: list_int) -> bool
pub fn stone_game(piles: &[i64]) -> bool
Aegis.StoneGame.stone_game
pub fn stone_game(piles: &[i64]) -> bool { let n = piles.len(); if n == 0 { return false; } // dp[i] stores the optimal score difference (current player - other player) // for the current interval length starting at i. let mut dp: Vec<i64> = Vec::new(); let mut i: usize = 0; wh...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [stone_game]: 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 -- [stone_game]: function definitions module public import Aeneas public import Aegis.StoneGame.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.StoneGame.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.StoneGame.stone_game (Slice.from [8#i64, 15#i64, 3#i64, 7#i64] (by scalar_tac) : Slice Std.I64)) (true))}") #eval (s!"CASE 1 {(Result.reducesTo (Aegis....
[ { "input": "[[8, 15, 3, 7]]", "output": "true" }, { "input": "[[10, 20, 30, 40]]", "output": "true" }, { "input": "[[1, 2, 3, 4]]", "output": "true" }, { "input": "[[8, 9, 7, 6]]", "output": "false" }, { "input": "[[1, 2, 100, 3]]", "output": "true" }, { ...
119
false
119
verified
10
10
1
3,368
[ { "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.StoneGame.Code.Funs /-! # Specifications of `Aegis.StoneGame.stone_game` LeetCode problem `stone-game`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.StoneGame def vals (piles : Slice Std.I64) : List Int := piles.val.map (fun x => (x ...
10