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
count-vowels-permutation
1,220
Hard
[ "Dynamic Programming" ]
Given an integer n, your task is to count how many strings of length n can be formed under the following rules: Each character is a lower case vowel ('a', 'e', 'i', 'o', 'u') Each vowel 'a' may only be followed by an 'e'. Each vowel 'e' may only be followed by an 'a' or an 'i'. Each vowel 'i' may not be followed by an...
countVowelPermutation(n: int) -> int
pub fn count_vowel_permutation(n: i64) -> i64
Aegis.CountVowelPermutation.count_vowel_permutation
pub fn count_vowel_permutation(n: i64) -> i64 { let modulus: i64 = 1000000007; if n <= 0 { return 0; } // Counts of valid strings of current length ending in a, e, i, o, u. let mut a: i64 = 1; let mut e: i64 = 1; let mut i: i64 = 1; let mut o: i64 = 1; let mut u: i64 = 1; ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [count_vowel_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 -- [count_vowel_permutation]: function definitions module public import Aeneas public import Aegis.CountVowelPermutation.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashComma...
import Aegis.CountVowelPermutation.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.CountVowelPermutation.count_vowel_permutation 1000#i64) (89945857#i64))}") #eval (s!"CASE 1 {(Result.reducesTo (Aegis.CountVowelPermutation...
[ { "input": "[1000]", "output": "89945857" }, { "input": "[100]", "output": "173981881" }, { "input": "[20000]", "output": "759959057" }, { "input": "[200]", "output": "670333618" }, { "input": "[10000]", "output": "76428576" }, { "input": "[5000]", ...
26
false
26
verified
10
10
1
1,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.CountVowelPermutation.Code.Funs /-! # Specifications of `Aegis.CountVowelPermutation.count_vowel_permutation` LeetCode problem `count-vowels-permutation`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.CountVowelPermutation open Aegis....
4
split-a-string-in-balanced-strings
1,221
Easy
[ "Greedy", "String", "Counting" ]
Balanced strings are those that have an equal quantity of 'L' and 'R' characters. Given a balanced string s, split it into some number of substrings such that: Each substring is balanced. Return the maximum number of balanced strings you can obtain.   Example 1: Input: s = "RLRRLLRLRL" Output: 4 Explanation: s can b...
balancedStringSplit(s: str) -> int
pub fn balanced_string_split(s: &[u8]) -> i64
Aegis.BalancedStringSplit.balanced_string_split
pub fn balanced_string_split(s: &[u8]) -> i64 { let n = s.len(); let mut balance: i64 = 0; let mut count: i64 = 0; let mut i: usize = 0; while i < n { if s[i] == b'L' { balance = balance + 1; } else { balance = balance - 1; } if balance == 0 { ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [balanced_string_split]: type definitions module public import Aeneas @[expose] public section 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 -- [balanced_string_split]: function definitions module public import Aeneas public import Aegis.BalancedStringSplit.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand f...
import Aegis.BalancedStringSplit.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.BalancedStringSplit.balanced_string_split (Slice.from [82#u8, 82#u8, 76#u8, 76#u8, 82#u8, 82#u8, 76#u8, 76#u8] (by scalar_tac) : Slice Std.U8...
[ { "input": "[\"RRLLRRLL\"]", "output": "2" }, { "input": "[\"RLRRRLLRLL\"]", "output": "2" }, { "input": "[\"RRRRLLLLRRRRLLLL\"]", "output": "2" }, { "input": "[\"LRRLLRRL\"]", "output": "4" }, { "input": "[\"LLLLRRRRLLRRRR\"]", "output": "2" }, { "inp...
118
false
118
verified
10
10
1
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.BalancedStringSplit.Code.Funs /-! # Specifications of `Aegis.BalancedStringSplit.balanced_string_split` LeetCode problem `split-a-string-in-balanced-strings`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.BalancedStringSplit namespace Aegis...
12
queens-that-can-attack-the-king
1,222
Medium
[ "Array", "Matrix", "Simulation" ]
On a 0-indexed 8 x 8 chessboard, there can be multiple black queens and one white king. You are given a 2D integer array queens where queens[i] = [xQueeni, yQueeni] represents the position of the ith black queen on the chessboard. You are also given an integer array king of length 2 where king = [xKing, yKing] represen...
queensAttacktheKing(queens: list_list_int, king: list_int) -> list_list_int
pub fn queens_attackthe_king(queens: &[Vec<i64>], king: &[i64]) -> Vec<Vec<i64>>
Aegis.QueensAttacktheKing.queens_attackthe_king
pub fn queens_attackthe_king(queens: &[Vec<i64>], king: &[i64]) -> Vec<Vec<i64>> { let kx: i64 = king[0]; let ky: i64 = king[1]; let mut attack: Vec<bool> = Vec::new(); let mut i: i64 = 0; while i < 64 { attack.push(false); i += 1; } let mut dx: i64 = -1; while dx <= 1 ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [queens_attackthe_king]: type definitions module public import Aeneas @[expose] public section 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 -- [queens_attackthe_king]: function definitions module public import Aeneas public import Aegis.QueensAttacktheKing.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand f...
import Aegis.QueensAttacktheKing.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(match (Aegis.QueensAttacktheKing.queens_attackthe_king (Slice.from [(alloc.vec.Vec.from [0#i64, 7#i64] (by scalar_tac) : alloc.vec.Vec Std.I64), (alloc.vec.Vec.from ...
[ { "input": "[[[0, 7], [7, 0]], [3, 3]]", "output": "[]" }, { "input": "[[[0, 0], [7, 7], [0, 7], [7, 0]], [3, 3]]", "output": "[[0, 0], [7, 7]]" }, { "input": "[[[0, 3], [1, 4], [2, 5], [3, 6], [4, 7]], [3, 3]]", "output": "[[0, 3], [3, 6]]" }, { "input": "[[[0, 3], [6, 3], [...
102
true
102
verified
10
10
1
8,609
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.QueensAttacktheKing.Code.Funs /-! # Specifications of `Aegis.QueensAttacktheKing.queens_attackthe_king` LeetCode problem `queens-that-can-attack-the-king`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.QueensAttacktheKing set_option autoImplici...
15
dice-roll-simulation
1,223
Hard
[ "Array", "Dynamic Programming" ]
A die simulator generates a random number from 1 to 6 for each roll. You introduced a constraint to the generator such that it cannot roll the number i more than rollMax[i] (1-indexed) consecutive times. Given an array of integers rollMax and an integer n, return the number of distinct sequences that can be obtained wi...
dieSimulator(n: int, rollMax: list_int) -> int
pub fn die_simulator(n: i64, rollMax: &[i64]) -> i64
Aegis.DieSimulator.die_simulator
fn make_zeros(size: usize) -> Vec<i64> { let mut v: Vec<i64> = Vec::new(); let mut i: usize = 0; while i < size { v.push(0); i += 1; } v } pub fn die_simulator(n: i64, rollMax: &[i64]) -> i64 { let modulo: i64 = 1000000007; let faces: usize = rollMax.len(); let stride: u...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [die_simulator]: type definitions module public import Aeneas @[expose] public section 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 -- [die_simulator]: function definitions module public import Aeneas public import Aegis.DieSimulator.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.DieSimulator.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.DieSimulator.die_simulator 5#i64 (Slice.from [2#i64, 2#i64, 2#i64, 2#i64, 2#i64, 2#i64] (by scalar_tac) : Slice Std.I64)) (7200#i64))}") #eval (s!"C...
[ { "input": "[5, [2, 2, 2, 2, 2, 2]]", "output": "7200" }, { "input": "[1, [1, 1, 1, 1, 1, 1]]", "output": "6" }, { "input": "[1, [15, 15, 15, 15, 15, 15]]", "output": "6" }, { "input": "[10, [2, 3, 4, 5, 6, 7]]", "output": "58240426" }, { "input": "[2, [1, 1, 2, 2...
41
false
41
verified
10
10
1
5,808
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.DieSimulator.Code.Funs /-! # Specifications of `Aegis.DieSimulator.die_simulator` LeetCode problem `dice-roll-simulation`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.DieSimulator abbrev modulus : Int := 1000000007 def rollMaxEntry...
9
maximum-equal-frequency
1,224
Hard
[ "Array", "Hash Table" ]
Given an array nums of positive integers, return the longest possible length of an array prefix of nums, such that it is possible to remove exactly one element from this prefix so that every number that has appeared in it will have the same number of occurrences. If after removing one element there are no remaining ele...
maxEqualFreq(nums: list_int) -> int
pub fn max_equal_freq(nums: &[i64]) -> i64
Aegis.MaxEqualFreq.max_equal_freq
pub fn max_equal_freq(nums: &[i64]) -> i64 { let n = nums.len(); if n == 0 { return 0; } let mut max_val: usize = 0; let mut i: usize = 0; while i < n { let v = nums[i] as usize; if v > max_val { max_val = v; } i += 1; } let mut count...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [max_equal_freq]: type definitions module public import Aeneas @[expose] public section 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 -- [max_equal_freq]: function definitions module public import Aeneas public import Aegis.MaxEqualFreq.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_optio...
import Aegis.MaxEqualFreq.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.MaxEqualFreq.max_equal_freq (Slice.from [1#i64, 2#i64, 2#i64, 2#i64, 1#i64, 1#i64] (by scalar_tac) : Slice Std.I64)) (5#i64))}") #eval (s!"CASE 1 {(...
[ { "input": "[[1, 2, 2, 2, 1, 1]]", "output": "5" }, { "input": "[[2, 2, 1, 1, 5, 3, 3, 5]]", "output": "7" }, { "input": "[[10, 10, 10, 10, 1, 1, 1, 2, 2, 3]]", "output": "7" }, { "input": "[[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]]", "output": "10" }, { "input": "[[10, 10...
104
false
104
verified
10
10
1
7,460
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MaxEqualFreq.Code.Funs /-! # Specifications of `Aegis.MaxEqualFreq.max_equal_freq` LeetCode problem `maximum-equal-frequency`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.MaxEqualFreq namespace AegisSpec.MaxEqualFreq def vals (nums : Slice S...
11
missing-number-in-arithmetic-progression
1,228
Easy
[ "Array", "Math" ]
In some array arr, the values were in arithmetic progression: the values arr[i + 1] - arr[i] are all equal for every 0 <= i < arr.length - 1. A value from arr was removed that was not the first or last value in the array. Given arr, return the removed value.   Example 1: Input: arr = [5,7,11,13] Output: 9 Explanation:...
missingNumber(arr: list_int) -> int
pub fn missing_number(arr: &[i64]) -> i64
Aegis.MissingNumber.missing_number
pub fn missing_number(arr: &[i64]) -> i64 { let n = arr.len(); let mut sum: i64 = 0; let mut i = 0usize; while i < n { sum += arr[i]; i += 1; } // The original array had (n + 1) terms forming an arithmetic progression // with the same first and last values as `arr`. Its tot...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [missing_number]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [missing_number]: function definitions module public import Aeneas public import Aegis.MissingNumber.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.MissingNumber.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.MissingNumber.missing_number (Slice.from [15#i64, 13#i64, 12#i64] (by scalar_tac) : Slice Std.I64)) (14#i64))}") #eval (s!"CASE 1 {(Result.reducesT...
[ { "input": "[[15, 13, 12]]", "output": "14" }, { "input": "[[2, 4, 8, 16]]", "output": "15" }, { "input": "[[3, 6, 9, 15]]", "output": "12" }, { "input": "[[1, 3, 5, 9]]", "output": "7" }, { "input": "[[100, 200, 300, 500]]", "output": "400" }, { "inpu...
147
false
147
verified
10
10
2
3,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.MissingNumber.Code.Funs /-! # Specifications of `Aegis.MissingNumber.missing_number` LeetCode problem `missing-number-in-arithmetic-progression`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result Aegis.MissingNumber namespace AegisSpec.MissingNumber def ...
12
meeting-scheduler
1,229
Medium
[ "Array", "Two Pointers", "Sorting" ]
Given the availability time slots arrays slots1 and slots2 of two people and a meeting duration duration, return the earliest time slot that works for both of them and is of duration duration. If there is no common time slot that satisfies the requirements, return an empty array. The format of a time slot is an array o...
minAvailableDuration(slots1: list_list_int, slots2: list_list_int, duration: int) -> list_int
pub fn min_available_duration(slots1: &[Vec<i64>], slots2: &[Vec<i64>], duration: i64) -> Vec<i64>
Aegis.MinAvailableDuration.min_available_duration
fn sort_slots(slots: &[Vec<i64>]) -> Vec<Vec<i64>> { let n = slots.len(); let mut starts: Vec<i64> = Vec::new(); let mut ends: Vec<i64> = Vec::new(); let mut i: usize = 0; while i < n { starts.push(slots[i][0]); ends.push(slots[i][1]); i += 1; } let mut width: usize...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [min_available_duration]: type definitions module public import Aeneas @[expose] public 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 -- [min_available_duration]: function definitions module public import Aeneas public import Aegis.MinAvailableDuration.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand...
import Aegis.MinAvailableDuration.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.MinAvailableDuration.min_available_duration (Slice.from [(alloc.vec.Vec.from [1#i64, 1000000000#i64] (by scalar_tac) : alloc.vec.Vec Std.I64...
[ { "input": "[[[1, 1000000000]], [[1, 1000000000]], 1000000000]", "output": "[]" }, { "input": "[[[1, 5]], [[6, 10]], 1]", "output": "[]" }, { "input": "[[[1, 10]], [[10, 20]], 1]", "output": "[]" }, { "input": "[[[10, 50]], [[50, 100]], 5]", "output": "[]" }, { "i...
117
false
117
verified
10
10
1
7,898
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MinAvailableDuration.Code.Funs /-! # Specifications of `Aegis.MinAvailableDuration.min_available_duration` LeetCode problem `meeting-scheduler`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.MinAvailableDuration namespace AegisSpec.MinAvailable...
12
divide-chocolate
1,231
Hard
[ "Array", "Binary Search" ]
You have one chocolate bar that consists of some chunks. Each chunk has its own sweetness given by the array sweetness. You want to share the chocolate with your k friends so you start cutting the chocolate bar into k + 1 pieces using k cuts, each piece consists of some consecutive chunks. Being generous, you will eat ...
maximizeSweetness(sweetness: list_int, k: int) -> int
pub fn maximize_sweetness(sweetness: &[i64], k: i64) -> i64
Aegis.MaximizeSweetness.maximize_sweetness
fn can_form(sweetness: &[i64], pieces: i64, target: i64) -> bool { let n = sweetness.len(); let mut count: i64 = 0; let mut current: i64 = 0; let mut i: usize = 0; while i < n { current += sweetness[i]; if current >= target { count += 1; if count >= pieces {...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [maximize_sweetness]: type definitions module public import Aeneas @[expose] public section 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 -- [maximize_sweetness]: function definitions module public import Aeneas public import Aegis.MaximizeSweetness.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false ...
import Aegis.MaximizeSweetness.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.MaximizeSweetness.maximize_sweetness (Slice.from [100000#i64] (by scalar_tac) : Slice Std.I64) 0#i64) (100000#i64))}") #eval (s!"CASE 1 {(Resul...
[ { "input": "[[100000], 0]", "output": "100000" }, { "input": "[[1, 3, 1, 5, 2], 2]", "output": "2" }, { "input": "[[100000, 100000, 100000, 100000, 100000], 2]", "output": "100000" }, { "input": "[[9, 7, 5, 3, 1], 2]", "output": "7" }, { "input": "[[100000, 100000...
77
false
77
verified
10
10
1
2,225
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MaximizeSweetness.Code.Funs /-! # Specifications of `Aegis.MaximizeSweetness.maximize_sweetness` LeetCode problem `divide-chocolate`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.MaximizeSweetness def getVal (s : Slice Std.I64) (...
11
check-if-it-is-a-straight-line
1,232
Easy
[ "Geometry", "Array", "Math" ]
You are given an array coordinates, coordinates[i] = [x, y], where [x, y] represents the coordinate of a point. Check if these points make a straight line in the XY plane.     Example 1: Input: coordinates = [[1,2],[2,3],[3,4],[4,5],[5,6],[6,7]] Output: true Example 2: Input: coordinates = [[1,1],[2,2],[3,4],[4,5]...
checkStraightLine(coordinates: list_list_int) -> bool
pub fn check_straight_line(coordinates: &[Vec<i64>]) -> bool
Aegis.CheckStraightLine.check_straight_line
pub fn check_straight_line(coordinates: &[Vec<i64>]) -> bool { let n = coordinates.len(); if n <= 2 { return true; } let x0 = coordinates[0][0]; let y0 = coordinates[0][1]; let x1 = coordinates[1][0]; let y1 = coordinates[1][1]; let dx = x1 - x0; let dy = y1 - y0; let ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [check_straight_line]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option l...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [check_straight_line]: function definitions module public import Aeneas public import Aegis.CheckStraightLine.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false...
import Aegis.CheckStraightLine.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.CheckStraightLine.check_straight_line (Slice.from [(alloc.vec.Vec.from [(-10000)#i64, (-10000)#i64] (by scalar_tac) : alloc.vec.Vec Std.I64), (...
[ { "input": "[[[-10000, -10000], [0, 0], [10000, 10000]]]", "output": "true" }, { "input": "[[[1, 1], [2, 2], [3, 5]]]", "output": "false" }, { "input": "[[[1, 1], [2, 2], [2, 3]]]", "output": "false" }, { "input": "[[[1, 2], [2, 3], [3, 5]]]", "output": "false" }, { ...
124
false
124
verified
10
10
1
553
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.CheckStraightLine.Code.Funs /-! # Specifications of `Aegis.CheckStraightLine.check_straight_line` LeetCode problem `check-if-it-is-a-straight-line`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.CheckStraightLine open Aegis.CheckS...
9
remove-sub-folders-from-the-filesystem
1,233
Medium
[ "Depth-First Search", "Trie", "Array", "String" ]
Given a list of folders folder, return the folders after removing all sub-folders in those folders. You may return the answer in any order. If a folder[i] is located within another folder[j], it is called a sub-folder of it. A sub-folder of folder[j] must start with folder[j], followed by a "/". For example, "/a/b" is ...
removeSubfolders(folder: list_str) -> list_str
pub fn remove_subfolders(folder: &[Vec<u8>]) -> Vec<Vec<u8>>
Aegis.RemoveSubfolders.remove_subfolders
pub fn remove_subfolders(folder: &[Vec<u8>]) -> Vec<Vec<u8>> { // Trie stored with flat adjacency lists. // head[node] is edge_index + 1, or 0 if there is no child. let mut head: Vec<usize> = Vec::new(); let mut terminals: Vec<bool> = Vec::new(); head.push(0); terminals.push(false); let mu...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [remove_subfolders]: type definitions module public import Aeneas @[expose] public section 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 -- [remove_subfolders]: function definitions module public import Aeneas public import Aegis.RemoveSubfolders.Code.Types public import Aegis.RemoveSubfolders.Code.FunsExternal @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.du...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [remove_subfolders]: external functions. -- This is a template file: rename it to "FunsExternal.lean" and fill the holes. module public import Aeneas public import Aegis.RemoveSubfolders.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow E...
import Aegis.RemoveSubfolders.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(match (Aegis.RemoveSubfolders.remove_subfolders (Slice.from [(alloc.vec.Vec.from [47#u8, 99#u8, 111#u8, 109#u8, 112#u8, 108#u8, 101#u8, 120#u8, 47#u8, 102#u8, 111#u8, 1...
[ { "input": "[[\"/complex/folder/structure/with/deep/nesting/level1/level2/level3/level4/level5/level6/level7/level8/level9/level10/level11/level12/level13/level14/level15/level16/level17/level18/level19/level20\"]]", "output": "[\"/complex/folder/structure/with/deep/nesting/level1/level2/level3/level4/level...
97
true
97
verified
10
10
2
15,149
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.RemoveSubfolders.Code.Funs /-! # Specifications of `Aegis.RemoveSubfolders.remove_subfolders` LeetCode problem `remove-sub-folders-from-the-filesystem`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.RemoveSubfolders def slash : Std.U8...
12
replace-the-substring-for-balanced-string
1,234
Medium
[ "String", "Sliding Window" ]
You are given a string s of length n containing only four kinds of characters: 'Q', 'W', 'E', and 'R'. A string is said to be balanced if each of its characters appears n / 4 times where n is the length of the string. Return the minimum length of the substring that can be replaced with any other string of the same leng...
balancedString(s: str) -> int
pub fn balanced_string(s: &[u8]) -> i64
Aegis.BalancedString.balanced_string
pub fn balanced_string(s: &[u8]) -> i64 { let n: usize = s.len(); let target: i64 = (n as i64) / 4; let mut cq: i64 = 0; let mut cw: i64 = 0; let mut ce: i64 = 0; let mut cr: i64 = 0; let mut i: usize = 0; while i < n { let ch: u8 = s[i]; if ch == b'Q' { cq ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [balanced_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 linte...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [balanced_string]: function definitions module public import Aeneas public import Aegis.BalancedString.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.BalancedString.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.BalancedString.balanced_string (Slice.from [81#u8, 81#u8, 81#u8, 81#u8, 81#u8, 81#u8, 81#u8, 81#u8, 87#u8, 87#u8, 87#u8, 87#u8, 69#u8, 69#u8, 69#u...
[ { "input": "[\"QQQQQQQQWWWWEEEEEEEERRRRRRRR\"]", "output": "14" }, { "input": "[\"QQQQWWER\"]", "output": "2" }, { "input": "[\"WQQQQQERQQ\"]", "output": "5" }, { "input": "[\"WWEERRQQQWEEERRQQQWEEERRQQQWEEERR\"]", "output": "5" }, { "input": "[\"QQWQWQQWEEWEEWRRW...
158
false
158
verified
10
10
1
3,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.BalancedString.Code.Funs /-! # Specifications of `Aegis.BalancedString.balanced_string` LeetCode problem `replace-the-substring-for-balanced-string`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.BalancedString namespace AegisSpec.BalancedStrin...
10
maximum-profit-in-job-scheduling
1,235
Hard
[ "Array", "Binary Search", "Dynamic Programming", "Sorting" ]
We have n jobs, where every job is scheduled to be done from startTime[i] to endTime[i], obtaining a profit of profit[i]. You're given the startTime, endTime and profit arrays, return the maximum profit you can take such that there are no two jobs in the subset with overlapping time range. If you choose a job that ends...
jobScheduling(startTime: list_int, endTime: list_int, profit: list_int) -> int
pub fn job_scheduling(startTime: &[i64], endTime: &[i64], profit: &[i64]) -> i64
Aegis.JobScheduling.job_scheduling
pub fn job_scheduling(startTime: &[i64], endTime: &[i64], profit: &[i64]) -> i64 { let n = startTime.len(); let n_i64 = n as i64; // Sort job indices by end time by encoding (endTime, index) into a single i64. let mut keys: Vec<i64> = Vec::new(); let mut i: usize = 0; while i < n { keys...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [job_scheduling]: type definitions module public import Aeneas @[expose] public section 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 -- [job_scheduling]: function definitions module public import Aeneas public import Aegis.JobScheduling.Code.Types public import Aegis.JobScheduling.Code.FunsExternal @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespac...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [job_scheduling]: external functions. -- This is a template file: rename it to "FunsExternal.lean" and fill the holes. module public import Aeneas public import Aegis.JobScheduling.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error s...
import Aegis.JobScheduling.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.JobScheduling.job_scheduling (Slice.from [1#i64] (by scalar_tac) : Slice Std.I64) (Slice.from [2#i64] (by scalar_tac) : Slice Std.I64) (Slice.from ...
[ { "input": "[[1], [2], [5]]", "output": "5" }, { "input": "[[3, 5, 10], [15, 18, 19], [20, 20, 100]]", "output": "100" }, { "input": "[[1, 1, 1], [2, 3, 4], [5, 6, 4]]", "output": "6" }, { "input": "[[100, 200, 300], [200, 300, 400], [1000, 2000, 3000]]", "output": "6000"...
92
false
92
verified
10
10
1
3,530
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.JobScheduling.Code.Funs /-! # Specifications of `Aegis.JobScheduling.job_scheduling` LeetCode problem `maximum-profit-in-job-scheduling`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result ControlFlow Error open Aegis.JobScheduling namespace AegisSpec.JobSched...
12
circular-permutation-in-binary-representation
1,238
Medium
[ "Bit Manipulation", "Math", "Backtracking" ]
Given 2 integers n and start. Your task is return any permutation p of (0,1,2.....,2^n -1) such that :\r \r \r p[0] = start\r p[i] and p[i+1] differ by only one bit in their binary representation.\r p[0] and p[2^n -1] must also differ by only one bit in their binary representation.\r \r \r  \r Example 1:\r \r \r Inp...
circularPermutation(n: int, start: int) -> list_int
pub fn circular_permutation(n: i64, start: i64) -> Vec<i64>
Aegis.CircularPermutation.circular_permutation
pub fn circular_permutation(n: i64, start: i64) -> Vec<i64> { // size = 2^n let mut size: i64 = 1; let mut t: i64 = 0; while t < n { size = size * 2; t += 1; } // Compute k, the index in the Gray-code sequence whose value is `start`. // Inverse Gray code: k = start ^ (start>...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [circular_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_option ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [circular_permutation]: function definitions module public import Aeneas public import Aegis.CircularPermutation.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand fa...
import Aegis.CircularPermutation.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.CircularPermutation.circular_permutation 1#i64 0#i64) ((alloc.vec.Vec.from [0#i64, 1#i64] (by scalar_tac) : alloc.vec.Vec Std.I64)))}") #eval...
[ { "input": "[1, 0]", "output": "[0, 1]" }, { "input": "[1, 1]", "output": "[1, 0]" }, { "input": "[2, 3]", "output": "[3, 2, 0, 1]" }, { "input": "[2, 2]", "output": "[2, 0, 1, 3]" }, { "input": "[3, 2]", "output": "[2, 6, 7, 5, 4, 0, 1, 3]" }, { "inpu...
39
false
39
verified
10
10
2
11,495
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.CircularPermutation.Code.Funs /-! # Specifications of `Aegis.CircularPermutation.circular_permutation` LeetCode problem `circular-permutation-in-binary-representation`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.CircularPermutation ...
12
tiling-a-rectangle-with-the-fewest-squares
1,240
Hard
[ "Backtracking" ]
Given a rectangle of size n x m, return the minimum number of integer-sided squares that tile the rectangle.   Example 1: Input: n = 2, m = 3 Output: 3 Explanation: 3 squares are necessary to cover the rectangle. 2 (squares of 1x1) 1 (square of 2x2) Example 2: Input: n = 5, m = 8 Output: 5 Example 3: Input: n = ...
tilingRectangle(n: int, m: int) -> int
pub fn tiling_rectangle(n: i64, m: i64) -> i64
Aegis.TilingRectangle.tiling_rectangle
fn greedy(mut a: i64, mut b: i64) -> i64 { let mut count: i64 = 0; while a > 0 { if a > b { let t = a; a = b; b = t; } count += b / a; let r = b % a; b = a; a = r; } count } fn lowest_height(state: i64, width: i64, heig...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [tiling_rectangle]: type definitions module public import Aeneas @[expose] public section 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 -- [tiling_rectangle]: function definitions module public import Aeneas public import Aegis.TilingRectangle.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.TilingRectangle.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.TilingRectangle.tiling_rectangle 8#i64 8#i64) (1#i64))}") #eval (s!"CASE 1 {(Result.reducesTo (Aegis.TilingRectangle.tiling_rectangle 1#i64 1#i64...
[ { "input": "[8, 8]", "output": "1" }, { "input": "[1, 1]", "output": "1" }, { "input": "[10, 14]", "output": "5" }, { "input": "[7, 7]", "output": "1" }, { "input": "[9, 10]", "output": "6" }, { "input": "[7, 8]", "output": "7" }, { "input"...
66
false
66
verified
10
10
4
114,253
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.TilingRectangle.Code.Funs /-! # Specifications of `Aegis.TilingRectangle.tiling_rectangle` LeetCode problem `tiling-a-rectangle-with-the-fewest-squares`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.TilingRectangle structure Squa...
13
array-transformation
1,243
Easy
[ "Array", "Simulation" ]
Given an initial array arr, every day you produce a new array using the array of the previous day. On the i-th day, you do the following operations on the array of day i-1 to produce the array of day i: If an element is smaller than both its left neighbor and its right neighbor, then this element is incremented. If an...
transformArray(arr: list_int) -> list_int
pub fn transform_array(arr: &[i64]) -> Vec<i64>
Aegis.TransformArray.transform_array
pub fn transform_array(arr: &[i64]) -> Vec<i64> { let n = arr.len(); let mut cur: Vec<i64> = Vec::new(); let mut idx: usize = 0; while idx < n { cur.push(arr[idx]); idx += 1; } if n < 3 { return cur; } let mut changed = true; while changed { changed...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [transform_array]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linte...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [transform_array]: function definitions module public import Aeneas public import Aegis.TransformArray.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.TransformArray.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.TransformArray.transform_array (Slice.from [6#i64, 2#i64, 3#i64, 4#i64] (by scalar_tac) : Slice Std.I64)) ((alloc.vec.Vec.from [6#i64, 3#i64, 3#i6...
[ { "input": "[[6, 2, 3, 4]]", "output": "[6, 3, 3, 4]" }, { "input": "[[1, 3, 2, 3, 1]]", "output": "[1, 2, 2, 2, 1]" }, { "input": "[[1, 2, 3, 2, 1]]", "output": "[1, 2, 2, 2, 1]" }, { "input": "[[3, 3, 3, 3, 3]]", "output": "[3, 3, 3, 3, 3]" }, { "input": "[[1, 3...
122
false
122
verified
10
10
1
2,545
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.TransformArray.Code.Funs /-! # Specifications of `Aegis.TransformArray.transform_array` LeetCode problem `array-transformation`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.TransformArray open Aegis.TransformArray def arrVals (arr ...
11
tree-diameter
1,245
Medium
[ "Tree", "Depth-First Search", "Breadth-First Search", "Graph", "Topological Sort" ]
The diameter of a tree is the number of edges in the longest path in that tree. There is an undirected tree of n nodes labeled from 0 to n - 1. You are given a 2D array edges where edges.length == n - 1 and edges[i] = [ai, bi] indicates that there is an undirected edge between nodes ai and bi in the tree. Return the di...
treeDiameter(edges: list_list_int) -> int
pub fn tree_diameter(edges: &[Vec<i64>]) -> i64
Aegis.TreeDiameter.tree_diameter
pub fn tree_diameter(edges: &[Vec<i64>]) -> i64 { let n: usize = edges.len() + 1; let mut adj: Vec<Vec<i64>> = Vec::new(); let mut i: usize = 0; while i < n { let row: Vec<i64> = Vec::new(); adj.push(row); i += 1; } let mut e: usize = 0; while e < edges.len() { ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [tree_diameter]: type definitions module public import Aeneas @[expose] public section 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 -- [tree_diameter]: function definitions module public import Aeneas public import Aegis.TreeDiameter.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.TreeDiameter.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.TreeDiameter.tree_diameter (Slice.from [(alloc.vec.Vec.from [0#i64, 1#i64] (by scalar_tac) : alloc.vec.Vec Std.I64)] (by scalar_tac) : Slice (alloc....
[ { "input": "[[[0, 1]]]", "output": "1" }, { "input": "[[[0, 1], [0, 2]]]", "output": "2" }, { "input": "[[[0, 1], [1, 2], [2, 3]]]", "output": "3" }, { "input": "[[[0, 1], [0, 2], [0, 3]]]", "output": "2" }, { "input": "[[[0, 1], [1, 2], [1, 3], [3, 4]]]", "ou...
57
false
57
verified
10
10
1
6,259
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.TreeDiameter.Code.Funs /-! # Specifications of `Aegis.TreeDiameter.tree_diameter` LeetCode problem `tree-diameter`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.TreeDiameter def intVals (e : alloc.vec.Vec I64) : List Int := e.val.map...
12
palindrome-removal
1,246
Hard
[ "Array", "Dynamic Programming" ]
You are given an integer array arr. In one move, you can select a palindromic subarray arr[i], arr[i + 1], ..., arr[j] where i <= j, and remove that subarray from the given array. Note that after removing a subarray, the elements on the left and on the right of that subarray move to fill the gap left by the removal. Re...
minimumMoves(arr: list_int) -> int
pub fn minimum_moves(arr: &[i64]) -> i64
Aegis.MinimumMoves.minimum_moves
pub fn minimum_moves(arr: &[i64]) -> i64 { let n = arr.len(); if n == 0 { return 0; } let mut dp: Vec<Vec<i64>> = Vec::new(); let mut i = 0; while i < n { let mut row: Vec<i64> = Vec::new(); let mut j = 0; while j < n { row.push(0); j += 1...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [minimum_moves]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter....
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [minimum_moves]: function definitions module public import Aeneas public import Aegis.MinimumMoves.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.MinimumMoves.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.MinimumMoves.minimum_moves (Slice.from [1#i64, 2#i64] (by scalar_tac) : Slice Std.I64)) (2#i64))}") #eval (s!"CASE 1 {(Result.reducesTo (Aegis.Minim...
[ { "input": "[[1, 2]]", "output": "2" }, { "input": "[[1, 3, 4, 1, 5]]", "output": "3" }, { "input": "[[1, 2, 3, 4, 5]]", "output": "5" }, { "input": "[[10, 20, 30, 40, 50]]", "output": "5" }, { "input": "[[1, 2, 3, 2, 1]]", "output": "1" }, { "input": ...
104
false
104
verified
10
10
1
9,362
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MinimumMoves.Code.Funs /-! # Specifications of `Aegis.MinimumMoves.minimum_moves` LeetCode problem `palindrome-removal`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.MinimumMoves set_option autoImplicit false namespace AegisSpec.MinimumMoves ...
15
minimum-swaps-to-make-strings-equal
1,247
Medium
[ "Greedy", "Math", "String" ]
You are given two strings s1 and s2 of equal length consisting of letters "x" and "y" only. Your task is to make these two strings equal to each other. You can swap any two characters that belong to different strings, which means: swap s1[i] and s2[j]. Return the minimum number of swaps required to make s1 and s2 equal...
minimumSwap(s1: str, s2: str) -> int
pub fn minimum_swap(s1: &[u8], s2: &[u8]) -> i64
Aegis.MinimumSwap.minimum_swap
pub fn minimum_swap(s1: &[u8], s2: &[u8]) -> i64 { let n = s1.len(); let mut xy: i64 = 0; let mut yx: i64 = 0; let mut i: usize = 0; while i < n { if s1[i] == b'x' && s2[i] == b'y' { xy += 1; } else if s1[i] == b'y' && s2[i] == b'x' { yx += 1; } ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [minimum_swap]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter.s...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [minimum_swap]: function definitions module public import Aeneas public import Aegis.MinimumSwap.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.MinimumSwap.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.MinimumSwap.minimum_swap (Slice.from [120#u8, 121#u8, 121#u8, 121#u8] (by scalar_tac) : Slice Std.U8) (Slice.from [121#u8, 120#u8, 120#u8, 120#u8] (b...
[ { "input": "[\"xyyy\", \"yxxx\"]", "output": "3" }, { "input": "[\"xx\", \"yy\"]", "output": "1" }, { "input": "[\"xxyy\", \"xyxy\"]", "output": "2" }, { "input": "[\"xxyyxyxyxx\", \"xyyxyxxxyx\"]", "output": "4" }, { "input": "[\"xxxyyy\", \"yyyxxx\"]", "outp...
103
false
103
verified
10
10
1
792
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MinimumSwap.Code.Funs /-! # Specifications of `Aegis.MinimumSwap.minimum_swap` LeetCode problem `minimum-swaps-to-make-strings-equal`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.MinimumSwap namespace AegisSpec.MinimumSwap abbrev byteX : Std...
14
count-number-of-nice-subarrays
1,248
Medium
[ "Array", "Hash Table", "Math", "Prefix Sum", "Sliding Window" ]
Given an array of integers nums and an integer k. A continuous subarray is called nice if there are k odd numbers on it. Return the number of nice sub-arrays.   Example 1: Input: nums = [1,1,2,1,1], k = 3 Output: 2 Explanation: The only sub-arrays with 3 odd numbers are [1,1,2,1] and [1,2,1,1]. Example 2: Input: num...
numberOfSubarrays(nums: list_int, k: int) -> int
pub fn number_of_subarrays(nums: &[i64], k: i64) -> i64
Aegis.NumberOfSubarrays.number_of_subarrays
fn at_most(nums: &[i64], k: i64) -> i64 { if k < 0 { return 0; } let n = nums.len(); let mut ans: i64 = 0; let mut left: usize = 0; let mut right: usize = 0; let mut odds: i64 = 0; while right < n { if nums[right] % 2 != 0 { odds += 1; } whi...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [number_of_subarrays]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option l...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [number_of_subarrays]: function definitions module public import Aeneas public import Aegis.NumberOfSubarrays.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false...
import Aegis.NumberOfSubarrays.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.NumberOfSubarrays.number_of_subarrays (Slice.from [2#i64] (by scalar_tac) : Slice Std.I64) 1#i64) (0#i64))}") #eval (s!"CASE 1 {(Result.reduces...
[ { "input": "[[2], 1]", "output": "0" }, { "input": "[[1], 1]", "output": "1" }, { "input": "[[2, 4, 6], 1]", "output": "0" }, { "input": "[[1, 2, 3, 4, 5], 3]", "output": "1" }, { "input": "[[1, 3, 5, 7, 9], 5]", "output": "1" }, { "input": "[[2, 2, 2,...
68
false
68
verified
10
10
2
2,710
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.NumberOfSubarrays.Code.Funs /-! # Specifications of `Aegis.NumberOfSubarrays.number_of_subarrays` LeetCode problem `count-number-of-nice-subarrays`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result Aegis.NumberOfSubarrays namespace AegisSpec.NumberOfSubarr...
13
check-if-it-is-a-good-array
1,250
Hard
[ "Array", "Math", "Number Theory" ]
Given an array nums of positive integers. Your task is to select some subset of nums, multiply each element by an integer and add all these numbers. The array is said to be good if you can obtain a sum of 1 from the array by any possible subset and multiplicand. Return True if the array is good otherwise return False. ...
isGoodArray(nums: list_int) -> bool
pub fn is_good_array(nums: &[i64]) -> bool
Aegis.IsGoodArray.is_good_array
pub fn is_good_array(nums: &[i64]) -> bool { if nums.len() == 0 { return false; } let mut g: i64 = nums[0]; let mut i: usize = 1; while i < nums.len() { g = gcd_i64(g, nums[i]); if g == 1 { return true; } i += 1; } g == 1 } fn gcd_i64(m...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [is_good_array]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter....
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [is_good_array]: function definitions module public import Aeneas public import Aegis.IsGoodArray.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.IsGoodArray.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.IsGoodArray.is_good_array (Slice.from [1#i64] (by scalar_tac) : Slice Std.I64)) (true))}") #eval (s!"CASE 1 {(Result.reducesTo (Aegis.IsGoodArray.is_...
[ { "input": "[[1]]", "output": "true" }, { "input": "[[1000000000]]", "output": "false" }, { "input": "[[5]]", "output": "false" }, { "input": "[[3, 6]]", "output": "false" }, { "input": "[[7, 13, 19]]", "output": "true" }, { "input": "[[29, 6, 10]]", ...
138
false
138
verified
10
10
1
404
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.IsGoodArray.Code.Funs /-! # Specifications of `Aegis.IsGoodArray.is_good_array` LeetCode problem `check-if-it-is-a-good-array`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result ControlFlow Error open Aegis.IsGoodArray (is_good_array) namespace AegisSpec....
12
cells-with-odd-values-in-a-matrix
1,252
Easy
[ "Array", "Math", "Simulation" ]
There is an m x n matrix that is initialized to all 0's. There is also a 2D array indices where each indices[i] = [ri, ci] represents a 0-indexed location to perform some increment operations on the matrix. For each location indices[i], do both of the following: Increment all the cells on row ri. Increment all the cel...
oddCells(m: int, n: int, indices: list_list_int) -> int
pub fn odd_cells(m: i64, n: i64, indices: &[Vec<i64>]) -> i64
Aegis.OddCells.odd_cells
pub fn odd_cells(m: i64, n: i64, indices: &[Vec<i64>]) -> i64 { let m_usize = m as usize; let n_usize = n as usize; let mut row_parity: Vec<bool> = Vec::new(); let mut i = 0; while i < m_usize { row_parity.push(false); i += 1; } let mut col_parity: Vec<bool> = Vec::new(); ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [odd_cells]: type definitions module public import Aeneas @[expose] public section 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 -- [odd_cells]: function definitions module public import Aeneas public import Aegis.OddCells.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.OddCells.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.OddCells.odd_cells 1#i64 1#i64 (Slice.from [(alloc.vec.Vec.from [0#i64, 0#i64] (by scalar_tac) : alloc.vec.Vec Std.I64)] (by scalar_tac) : Slice (alloc....
[ { "input": "[1, 1, [[0, 0]]]", "output": "0" }, { "input": "[2, 3, [[0, 1], [1, 1]]]", "output": "6" }, { "input": "[2, 2, [[1, 1], [0, 0]]]", "output": "0" }, { "input": "[5, 4, [[0, 0], [0, 0], [0, 0]]]", "output": "7" }, { "input": "[4, 5, [[0, 1], [2, 3], [1, ...
75
false
75
verified
10
10
1
1,321
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.OddCells.Code.Funs /-! # Specifications of `Aegis.OddCells.odd_cells` LeetCode problem `cells-with-odd-values-in-a-matrix`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.OddCells open Aegis.OddCells abbrev Idx := Slice (alloc.v...
12
number-of-closed-islands
1,254
Medium
[ "Depth-First Search", "Breadth-First Search", "Union Find", "Array", "Matrix" ]
Given a 2D grid consists of 0s (land) and 1s (water).  An island is a maximal 4-directionally connected group of 0s and a closed island is an island totally (all left, top, right, bottom) surrounded by 1s. Return the number of closed islands.   Example 1: Input: grid = [[1,1,1,1,1,1,1,0],[1,0,0,0,0,1,1,0],[1,0,1,0,1,...
closedIsland(grid: list_list_int) -> int
pub fn closed_island(grid: &[Vec<i64>]) -> i64
Aegis.ClosedIsland.closed_island
pub fn closed_island(grid: &[Vec<i64>]) -> i64 { let n = grid.len(); if n == 0 { return 0; } let m = grid[0].len(); if m == 0 { return 0; } let mut g: Vec<Vec<i64>> = Vec::new(); let mut i: usize = 0; while i < n { let mut row: Vec<i64> = Vec::new(); ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [closed_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 -- [closed_island]: function definitions module public import Aeneas public import Aegis.ClosedIsland.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.ClosedIsland.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.ClosedIsland.closed_island (Slice.from [(alloc.vec.Vec.from [0#i64, 0#i64, 1#i64, 0#i64, 0#i64] (by scalar_tac) : alloc.vec.Vec Std.I64), (alloc.vec...
[ { "input": "[[[0, 0, 1, 0, 0], [0, 1, 0, 1, 0], [0, 1, 1, 1, 0]]]", "output": "1" }, { "input": "[[[0, 0, 0, 0], [0, 1, 0, 0], [0, 1, 0, 0], [0, 0, 0, 0]]]", "output": "0" }, { "input": "[[[1, 1, 0, 1, 1], [1, 0, 0, 0, 1], [1, 0, 1, 0, 1], [1, 0, 0, 0, 1], [1, 1, 0, 1, 1]]]", "output...
63
false
63
verified
10
10
1
7,015
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.ClosedIsland.Code.Funs /-! # Specifications of `Aegis.ClosedIsland.closed_island` LeetCode problem `number-of-closed-islands`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.ClosedIsland abbrev Grid : Type := Slice (alloc.vec.Vec I64) ...
13
maximum-score-words-formed-by-letters
1,255
Hard
[ "Bit Manipulation", "Array", "String", "Dynamic Programming", "Backtracking", "Bitmask" ]
Given a list of words, list of  single letters (might be repeating) and score of every character. Return the maximum score of any valid set of words formed by using the given letters (words[i] cannot be used two or more times). It is not necessary to use all characters in letters and each letter can only be used once. ...
maxScoreWords(words: list_str, letters: list_str, score: list_int) -> int
pub fn max_score_words(words: &[Vec<u8>], letters: &[Vec<u8>], score: &[i64]) -> i64
Aegis.MaxScoreWords.max_score_words
pub fn max_score_words(words: &[Vec<u8>], letters: &[Vec<u8>], score: &[i64]) -> i64 { let n = words.len(); let mut avail: Vec<i64> = Vec::new(); let mut i = 0; while i < 26 { avail.push(0); i += 1; } i = 0; while i < letters.len() { let b = letters[i][0]; l...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [max_score_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 linte...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [max_score_words]: function definitions module public import Aeneas public import Aegis.MaxScoreWords.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.MaxScoreWords.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.MaxScoreWords.max_score_words (Slice.from [(alloc.vec.Vec.from [108#u8, 101#u8, 101#u8, 116#u8, 99#u8, 111#u8, 100#u8, 101#u8] (by scalar_tac) : al...
[ { "input": "[[\"leetcode\"], [\"l\", \"e\", \"t\", \"c\", \"o\", \"d\"], [0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0]]", "output": "0" }, { "input": "[[\"xxxz\", \"ax\", \"bx\", \"cx\"], [\"z\", \"a\", \"b\", \"c\", \"x\", \"x\", \"x\"], [4, 4, 4, 0, 0, 0, 0, 0, 0, ...
76
false
76
verified
10
10
1
4,151
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MaxScoreWords.Code.Funs /-! # Specifications of `Aegis.MaxScoreWords.max_score_words` LeetCode problem `maximum-score-words-formed-by-letters`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.MaxScoreWords open Aegis.MaxScoreWords def ...
14
handshakes-that-dont-cross
1,259
Hard
[ "Math", "Dynamic Programming" ]
You are given an even number of people numPeople that stand around a circle and each person shakes hands with someone else so that there are numPeople / 2 handshakes total. Return the number of ways these handshakes could occur such that none of the handshakes cross. Since the answer could be very large, return it modu...
numberOfWays(numPeople: int) -> int
pub fn number_of_ways(numPeople: i64) -> i64
Aegis.NumberOfWays.number_of_ways
pub fn number_of_ways(numPeople: i64) -> i64 { let n: usize = (numPeople / 2) as usize; let modv: i64 = 1000000007; let mut dp: Vec<i64> = Vec::new(); let mut idx: usize = 0; while idx <= n { dp.push(0); idx += 1; } dp[0] = 1; let mut k: usize = 0; while k < n { ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [number_of_ways]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [number_of_ways]: function definitions module public import Aeneas public import Aegis.NumberOfWays.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_optio...
import Aegis.NumberOfWays.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.NumberOfWays.number_of_ways 18#i64) (4862#i64))}") #eval (s!"CASE 1 {(Result.reducesTo (Aegis.NumberOfWays.number_of_ways 16#i64) (1430#i64))}") #ev...
[ { "input": "[18]", "output": "4862" }, { "input": "[16]", "output": "1430" }, { "input": "[8]", "output": "14" }, { "input": "[12]", "output": "132" }, { "input": "[20]", "output": "16796" }, { "input": "[10]", "output": "42" }, { "input": ...
37
false
37
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.NumberOfWays.Code.Funs /-! # Specifications of `Aegis.NumberOfWays.number_of_ways` LeetCode problem `handshakes-that-dont-cross`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.NumberOfWays def OnClockwiseArc (n a b x : Nat) : Prop := ...
9
shift-2d-grid
1,260
Easy
[ "Array", "Matrix", "Simulation" ]
Given a 2D grid of size m x n and an integer k. You need to shift the grid k times. In one shift operation: Element at grid[i][j] moves to grid[i][j + 1]. Element at grid[i][n - 1] moves to grid[i + 1][0]. Element at grid[m - 1][n - 1] moves to grid[0][0]. Return the 2D grid after applying shift operation k times.   ...
shiftGrid(grid: list_list_int, k: int) -> list_list_int
pub fn shift_grid(grid: &[Vec<i64>], k: i64) -> Vec<Vec<i64>>
Aegis.ShiftGrid.shift_grid
pub fn shift_grid(grid: &[Vec<i64>], k: i64) -> Vec<Vec<i64>> { let m = grid.len(); let n = grid[0].len(); let total = m * n; let total_i = total as i64; let mut kk = k % total_i; if kk < 0 { kk += total_i; } let shift = kk as usize; let mut out: Vec<Vec<i64>> = Vec::new();...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [shift_grid]: type definitions module public import Aeneas @[expose] public section 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 -- [shift_grid]: function definitions module public import Aeneas public import Aegis.ShiftGrid.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.ShiftGrid.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.ShiftGrid.shift_grid (Slice.from [(alloc.vec.Vec.from [1#i64] (by scalar_tac) : alloc.vec.Vec Std.I64)] (by scalar_tac) : Slice (alloc.vec.Vec Std.I64)...
[ { "input": "[[[1]], 0]", "output": "[[1]]" }, { "input": "[[[1]], 100]", "output": "[[1]]" }, { "input": "[[[42]], 0]", "output": "[[42]]" }, { "input": "[[[1000, -1000], [1000, -1000]], 1]", "output": "[[-1000, 1000], [-1000, 1000]]" }, { "input": "[[[1, 2], [3, ...
84
false
84
verified
10
10
1
1,792
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.ShiftGrid.Code.Funs /-! # Specifications of `Aegis.ShiftGrid.shift_grid` LeetCode problem `shift-2d-grid`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.ShiftGrid namespace AegisSpec.ShiftGrid def matOf (rows : List (alloc.vec.Vec I64)) ...
11
greatest-sum-divisible-by-three
1,262
Medium
[ "Greedy", "Array", "Dynamic Programming", "Sorting" ]
Given an integer array nums, return the maximum possible sum of elements of the array such that it is divisible by three.   Example 1: Input: nums = [3,6,5,1,8] Output: 18 Explanation: Pick numbers 3, 6, 1 and 8 their sum is 18 (maximum sum divisible by 3). Example 2: Input: nums = [4] Output: 0 Explanation: Since 4 ...
maxSumDivThree(nums: list_int) -> int
pub fn max_sum_div_three(nums: &[i64]) -> i64
Aegis.MaxSumDivThree.max_sum_div_three
pub fn max_sum_div_three(nums: &[i64]) -> i64 { let mut d0: i64 = 0; let mut d1: i64 = -1; let mut d2: i64 = -1; let mut i: usize = 0; while i < nums.len() { let x = nums[i]; let mut r = x % 3; if r < 0 { r = r + 3; } let mut n0 = d0; let...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [max_sum_div_three]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option lin...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [max_sum_div_three]: function definitions module public import Aeneas public import Aegis.MaxSumDivThree.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.MaxSumDivThree.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.MaxSumDivThree.max_sum_div_three (Slice.from [4#i64] (by scalar_tac) : Slice Std.I64)) (0#i64))}") #eval (s!"CASE 1 {(Result.reducesTo (Aegis.MaxS...
[ { "input": "[[4]]", "output": "0" }, { "input": "[[1, 2, 3]]", "output": "6" }, { "input": "[[10000, 10000, 10000, 10000]]", "output": "30000" }, { "input": "[[2, 3, 5, 7, 11]]", "output": "21" }, { "input": "[[10, 20, 30, 40, 50]]", "output": "150" }, { ...
139
false
139
verified
10
10
1
1,916
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MaxSumDivThree.Code.Funs /-! # Specifications of `Aegis.MaxSumDivThree.max_sum_div_three` LeetCode problem `greatest-sum-divisible-by-three`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.MaxSumDivThree def vals (nums : Slice Std.I64)...
15
minimum-time-visiting-all-points
1,266
Easy
[ "Geometry", "Array", "Math" ]
On a 2D plane, there are n points with integer coordinates points[i] = [xi, yi]. Return the minimum time in seconds to visit all the points in the order given by points. You can move according to these rules: In 1 second, you can either: move vertically by one unit, move horizontally by one unit, or move diagonally...
minTimeToVisitAllPoints(points: list_list_int) -> int
pub fn min_time_to_visit_all_points(points: &[Vec<i64>]) -> i64
Aegis.MinTimeToVisitAllPoints.min_time_to_visit_all_points
pub fn min_time_to_visit_all_points(points: &[Vec<i64>]) -> i64 { let mut total: i64 = 0; let mut i: usize = 1; while i < points.len() { let dx = points[i][0] - points[i - 1][0]; let dy = points[i][1] - points[i - 1][1]; let adx = if dx < 0 { -dx } else { dx }; let ady = if...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [min_time_to_visit_all_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...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [min_time_to_visit_all_points]: function definitions module public import Aeneas public import Aegis.MinTimeToVisitAllPoints.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.ha...
import Aegis.MinTimeToVisitAllPoints.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.MinTimeToVisitAllPoints.min_time_to_visit_all_points (Slice.from [(alloc.vec.Vec.from [3#i64, 2#i64] (by scalar_tac) : alloc.vec.Vec Std....
[ { "input": "[[[3, 2], [-2, 2]]]", "output": "5" }, { "input": "[[[-1000, -1000], [1000, 1000]]]", "output": "2000" }, { "input": "[[[0, 0], [1000, 1000]]]", "output": "1000" }, { "input": "[[[1, 1], [3, 4], [-1, 0]]]", "output": "7" }, { "input": "[[[0, 0], [5, 5]...
120
false
120
verified
10
10
1
372
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MinTimeToVisitAllPoints.Code.Funs /-! # Specifications of `Aegis.MinTimeToVisitAllPoints.min_time_to_visit_all_points` LeetCode problem `minimum-time-visiting-all-points`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.MinTimeToVisitA...
9
count-servers-that-communicate
1,267
Medium
[ "Depth-First Search", "Breadth-First Search", "Union Find", "Array", "Counting", "Matrix" ]
You are given a map of a server center, represented as a m * n integer matrix grid, where 1 means that on that cell there is a server and 0 means that it is no server. Two servers are said to communicate if they are on the same row or on the same column. Return the number of servers that communicate with any other ser...
countServers(grid: list_list_int) -> int
pub fn count_servers(grid: &[Vec<i64>]) -> i64
Aegis.CountServers.count_servers
pub fn count_servers(grid: &[Vec<i64>]) -> i64 { let m = grid.len(); if m == 0 { return 0; } let n = grid[0].len(); if n == 0 { return 0; } let mut row_counts: Vec<i64> = Vec::new(); let mut i = 0; while i < m { row_counts.push(0); i += 1; } ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [count_servers]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter....
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [count_servers]: function definitions module public import Aeneas public import Aegis.CountServers.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.CountServers.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.CountServers.count_servers (Slice.from [(alloc.vec.Vec.from [0#i64] (by scalar_tac) : alloc.vec.Vec Std.I64)] (by scalar_tac) : Slice (alloc.vec.Vec...
[ { "input": "[[[0]]]", "output": "0" }, { "input": "[[[1]]]", "output": "0" }, { "input": "[[[1, 0], [1, 1]]]", "output": "3" }, { "input": "[[[1, 0], [0, 1]]]", "output": "0" }, { "input": "[[[1, 1], [1, 1], [1, 1]]]", "output": "6" }, { "input": "[[[0...
50
false
50
verified
10
10
1
820
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.CountServers.Code.Funs /-! # Specifications of `Aegis.CountServers.count_servers` LeetCode problem `count-servers-that-communicate`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.CountServers namespace AegisSpec.CountServers def numRows ...
16
number-of-ways-to-stay-in-the-same-place-after-some-steps
1,269
Hard
[ "Dynamic Programming" ]
You have a pointer at index 0 in an array of size arrLen. At each step, you can move 1 position to the left, 1 position to the right in the array, or stay in the same place (The pointer should not be placed outside the array at any time). Given two integers steps and arrLen, return the number of ways such that your poi...
numWays(steps: int, arrLen: int) -> int
pub fn num_ways(steps: i64, arrLen: i64) -> i64
Aegis.NumWays.num_ways
pub fn num_ways(steps: i64, arrLen: i64) -> i64 { let modulus: i64 = 1000000007; let steps_usize: usize = steps as usize; let arr_len_usize: usize = arrLen as usize; // Positions farther than steps / 2 can never return to index 0 in time. let max_possible: usize = steps_usize / 2 + 1; let n: u...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [num_ways]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter.style...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [num_ways]: function definitions module public import Aeneas public import Aegis.NumWays.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.un...
import Aegis.NumWays.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.NumWays.num_ways 5#i64 3#i64) (21#i64))}") #eval (s!"CASE 1 {(Result.reducesTo (Aegis.NumWays.num_ways 10#i64 5#i64) (2187#i64))}") #eval (s!"CASE 2 {(Re...
[ { "input": "[5, 3]", "output": "21" }, { "input": "[10, 5]", "output": "2187" }, { "input": "[5, 5]", "output": "21" }, { "input": "[2, 4]", "output": "2" }, { "input": "[3, 2]", "output": "4" }, { "input": "[10, 1]", "output": "1" }, { "in...
65
false
65
verified
10
10
1
2,914
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.NumWays.Code.Funs /-! # Specifications of `Aegis.NumWays.num_ways` LeetCode problem `number-of-ways-to-stay-in-the-same-place-after-some-steps`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.NumWays def stepVal (j : Fin 3) : ℤ := ...
11
remove-interval
1,272
Medium
[ "Array" ]
A set of real numbers can be represented as the union of several disjoint intervals, where each interval is in the form [a, b). A real number x is in the set if one of its intervals [a, b) contains x (i.e. a <= x < b). You are given a sorted list of disjoint intervals intervals representing a set of real numbers as des...
removeInterval(intervals: list_list_int, toBeRemoved: list_int) -> list_list_int
pub fn remove_interval(intervals: &[Vec<i64>], toBeRemoved: &[i64]) -> Vec<Vec<i64>>
Aegis.RemoveInterval.remove_interval
#![allow(non_snake_case)] pub fn remove_interval(intervals: &[Vec<i64>], toBeRemoved: &[i64]) -> Vec<Vec<i64>> { let mut result: Vec<Vec<i64>> = Vec::new(); let remove_start: i64 = toBeRemoved[0]; let remove_end: i64 = toBeRemoved[1]; let n: usize = intervals.len(); let mut i: usize = 0; whi...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [remove_interval]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linte...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [remove_interval]: function definitions module public import Aeneas public import Aegis.RemoveInterval.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.RemoveInterval.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.RemoveInterval.remove_interval (Slice.from [(alloc.vec.Vec.from [(-1000000000)#i64, 1000000000#i64] (by scalar_tac) : alloc.vec.Vec Std.I64)] (by ...
[ { "input": "[[[-1000000000, 1000000000]], [-1000000000, 1000000000]]", "output": "[]" }, { "input": "[[[-10, 10]], [-10, 10]]", "output": "[]" }, { "input": "[[[-1000000000, 0], [0, 1000000000]], [-1000000000, 1000000000]]", "output": "[]" }, { "input": "[[[-1, 1]], [0, 0]]",...
122
false
122
verified
10
10
3
64,356
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.RemoveInterval.Code.Funs /-! # Specifications of `Aegis.RemoveInterval.remove_interval` LeetCode problem `remove-interval`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.RemoveInterval def vvals (v : alloc.vec.Vec Std.I64) : List Int ...
15
delete-tree-nodes
1,273
Medium
[ "Tree", "Depth-First Search", "Breadth-First Search", "Array" ]
A tree rooted at node 0 is given as follows: The number of nodes is nodes; The value of the ith node is value[i]; The parent of the ith node is parent[i]. Remove every subtree whose sum of values of nodes is zero. Return the number of the remaining nodes in the tree.   Example 1: Input: nodes = 7, parent = [-1,0,0,...
deleteTreeNodes(nodes: int, parent: list_int, value: list_int) -> int
pub fn delete_tree_nodes(nodes: i64, parent: &[i64], value: &[i64]) -> i64
Aegis.DeleteTreeNodes.delete_tree_nodes
pub fn delete_tree_nodes(nodes: i64, parent: &[i64], value: &[i64]) -> i64 { let n = nodes as usize; if n == 0 { return 0; } let mut children: Vec<Vec<i64>> = Vec::new(); let mut i = 0; while i < n { children.push(Vec::new()); i += 1; } i = 0; while i < n { ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [delete_tree_nodes]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option lin...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [delete_tree_nodes]: function definitions module public import Aeneas public import Aegis.DeleteTreeNodes.Code.Types public import Aegis.DeleteTreeNodes.Code.FunsExternal @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupN...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [delete_tree_nodes]: external functions. -- This is a template file: rename it to "FunsExternal.lean" and fill the holes. module public import Aeneas public import Aegis.DeleteTreeNodes.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Er...
import Aegis.DeleteTreeNodes.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.DeleteTreeNodes.delete_tree_nodes 1#i64 (Slice.from [(-1)#i64] (by scalar_tac) : Slice Std.I64) (Slice.from [0#i64] (by scalar_tac) : Slice Std.I...
[ { "input": "[1, [-1], [0]]", "output": "0" }, { "input": "[3, [-1, 0, 0], [1, -1, 0]]", "output": "0" }, { "input": "[4, [-1, 0, 0, 1], [1, -1, 1, -1]]", "output": "0" }, { "input": "[5, [-1, 0, 0, 1, 1], [1, -1, 1, -1, -1]]", "output": "5" }, { "input": "[5, [-1,...
76
false
76
verified
10
10
1
3,513
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.DeleteTreeNodes.Code.Funs /-! # Specifications of `Aegis.DeleteTreeNodes.delete_tree_nodes` LeetCode problem `delete-tree-nodes`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Classical noncomputable section open Aegis.DeleteTreeNodes names...
14
number-of-burgers-with-no-waste-of-ingredients
1,276
Medium
[ "Math" ]
Given two integers tomatoSlices and cheeseSlices. The ingredients of different burgers are as follows: Jumbo Burger: 4 tomato slices and 1 cheese slice. Small Burger: 2 Tomato slices and 1 cheese slice. Return [total_jumbo, total_small] so that the number of remaining tomatoSlices equal to 0 and the number of remaini...
numOfBurgers(tomatoSlices: int, cheeseSlices: int) -> list_int
pub fn num_of_burgers(tomatoSlices: i64, cheeseSlices: i64) -> Vec<i64>
Aegis.NumOfBurgers.num_of_burgers
pub fn num_of_burgers(tomatoSlices: i64, cheeseSlices: i64) -> Vec<i64> { if tomatoSlices < 2 * cheeseSlices { return Vec::new(); } if tomatoSlices > 4 * cheeseSlices { return Vec::new(); } if tomatoSlices % 2 != 0 { return Vec::new(); } let jumbo = (tomatoSlices - 2...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [num_of_burgers]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [num_of_burgers]: function definitions module public import Aeneas public import Aegis.NumOfBurgers.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_optio...
import Aegis.NumOfBurgers.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.NumOfBurgers.num_of_burgers 4#i64 17#i64) ((alloc.vec.Vec.from [] (by scalar_tac) : alloc.vec.Vec Std.I64)))}") #eval (s!"CASE 1 {(Result.reducesTo ...
[ { "input": "[4, 17]", "output": "[]" }, { "input": "[17, 4]", "output": "[]" }, { "input": "[22, 5]", "output": "[]" }, { "input": "[1, 1]", "output": "[]" }, { "input": "[15, 5]", "output": "[]" }, { "input": "[7, 2]", "output": "[]" }, { ...
73
false
73
verified
10
10
1
1,210
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.NumOfBurgers.Code.Funs /-! # Specifications of `Aegis.NumOfBurgers.num_of_burgers` LeetCode problem `number-of-burgers-with-no-waste-of-ingredients`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.NumOfBurgers def vecVals (r : allo...
15
count-square-submatrices-with-all-ones
1,277
Medium
[ "Array", "Dynamic Programming", "Matrix" ]
Given a m * n matrix of ones and zeros, return how many square submatrices have all ones.   Example 1: Input: matrix = [   [0,1,1,1],   [1,1,1,1],   [0,1,1,1] ] Output: 15 Explanation: There are 10 squares of side 1. There are 4 squares of side 2. There is 1 square of side 3. Total number of squares = 10 + 4 + 1 = 1...
countSquares(matrix: list_list_int) -> int
pub fn count_squares(matrix: &[Vec<i64>]) -> i64
Aegis.CountSquares.count_squares
pub fn count_squares(matrix: &[Vec<i64>]) -> i64 { let m = matrix.len(); if m == 0 { return 0; } let n = matrix[0].len(); if n == 0 { return 0; } let mut dp: Vec<Vec<i64>> = Vec::new(); let mut i = 0; while i < m { let mut row: Vec<i64> = Vec::new(); ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [count_squares]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter....
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [count_squares]: function definitions module public import Aeneas public import Aegis.CountSquares.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.CountSquares.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.CountSquares.count_squares (Slice.from [(alloc.vec.Vec.from [1#i64] (by scalar_tac) : alloc.vec.Vec Std.I64)] (by scalar_tac) : Slice (alloc.vec.Vec...
[ { "input": "[[[1]]]", "output": "1" }, { "input": "[[[0]]]", "output": "0" }, { "input": "[[[1, 1], [1, 1]]]", "output": "5" }, { "input": "[[[0, 0, 0], [0, 0, 0], [0, 0, 0]]]", "output": "0" }, { "input": "[[[1, 0, 1], [1, 1, 0], [1, 1, 0]]]", "output": "7" ...
67
false
67
verified
10
10
1
1,265
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.CountSquares.Code.Funs /-! # Specifications of `Aegis.CountSquares.count_squares` LeetCode problem `count-square-submatrices-with-all-ones`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.CountSquares open Aegis.CountSquares def...
14
palindrome-partitioning-iii
1,278
Hard
[ "String", "Dynamic Programming" ]
You are given a string s containing lowercase letters and an integer k. You need to : First, change some characters of s to other lowercase English letters. Then divide s into k non-empty disjoint substrings such that each substring is a palindrome. Return the minimal number of characters that you need to change to d...
palindromePartition(s: str, k: int) -> int
pub fn palindrome_partition(s: &[u8], k: i64) -> i64
Aegis.PalindromePartition.palindrome_partition
pub fn palindrome_partition(s: &[u8], k: i64) -> i64 { let n = s.len(); if n == 0 { return 0; } let kk = k as usize; if kk >= n { return 0; } let total = n * n; let mut cost: Vec<i64> = Vec::new(); let mut q = 0; while q < total { cost.push(0); q...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [palindrome_partition]: type definitions module public import Aeneas @[expose] public section 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 -- [palindrome_partition]: function definitions module public import Aeneas public import Aegis.PalindromePartition.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand fa...
import Aegis.PalindromePartition.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.PalindromePartition.palindrome_partition (Slice.from [97#u8, 98#u8, 99#u8] (by scalar_tac) : Slice Std.U8) 2#i64) (1#i64))}") #eval (s!"CASE ...
[ { "input": "[\"abc\", 2]", "output": "1" }, { "input": "[\"abababa\", 4]", "output": "1" }, { "input": "[\"aaaa\", 2]", "output": "0" }, { "input": "[\"leetcode\", 8]", "output": "0" }, { "input": "[\"abcd\", 2]", "output": "1" }, { "input": "[\"raceca...
89
false
89
verified
10
10
1
5,661
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.PalindromePartition.Code.Funs /-! # Specifications of `Aegis.PalindromePartition.palindrome_partition` LeetCode problem `palindrome-partitioning-iii`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.PalindromePartition def mis (s : ...
6
subtract-the-product-and-sum-of-digits-of-an-integer
1,281
Easy
[ "Math" ]
Given an integer number n, return the difference between the product of its digits and the sum of its digits.   Example 1: Input: n = 234 Output: 15 Explanation: Product of digits = 2 * 3 * 4 = 24 Sum of digits = 2 + 3 + 4 = 9 Result = 24 - 9 = 15 Example 2: Input: n = 4421 Output: 21 Explanation: Product of di...
subtractProductAndSum(n: int) -> int
pub fn subtract_product_and_sum(n: i64) -> i64
Aegis.SubtractProductAndSum.subtract_product_and_sum
pub fn subtract_product_and_sum(n: i64) -> i64 { let mut m = n; let mut product: i64 = 1; let mut sum: i64 = 0; while m > 0 { let digit = m % 10; product = product * digit; sum = sum + digit; m = m / 10; } product - sum }
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [subtract_product_and_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_opt...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [subtract_product_and_sum]: function definitions module public import Aeneas public import Aegis.SubtractProductAndSum.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashComm...
import Aegis.SubtractProductAndSum.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.SubtractProductAndSum.subtract_product_and_sum 99999#i64) (59004#i64))}") #eval (s!"CASE 1 {(Result.reducesTo (Aegis.SubtractProductAndSum....
[ { "input": "[99999]", "output": "59004" }, { "input": "[11111]", "output": "-4" }, { "input": "[789]", "output": "480" }, { "input": "[1111]", "output": "-3" }, { "input": "[234]", "output": "15" }, { "input": "[12345]", "output": "105" }, { ...
55
false
55
verified
10
10
1
212
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.SubtractProductAndSum.Code.Funs /-! # Specifications of `Aegis.SubtractProductAndSum.subtract_product_and_sum` LeetCode problem `subtract-the-product-and-sum-of-digits-of-an-integer`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.Subtr...
10
group-the-people-given-the-group-size-they-belong-to
1,282
Medium
[ "Greedy", "Array", "Hash Table" ]
There are n people that are split into some unknown number of groups. Each person is labeled with a unique ID from 0 to n - 1. You are given an integer array groupSizes, where groupSizes[i] is the size of the group that person i is in. For example, if groupSizes[1] = 3, then person 1 must be in a group of size 3. Retur...
groupThePeople(groupSizes: list_int) -> list_list_int
pub fn group_the_people(groupSizes: &[i64]) -> Vec<Vec<i64>>
Aegis.GroupThePeople.group_the_people
pub fn group_the_people(groupSizes: &[i64]) -> Vec<Vec<i64>> { let n = groupSizes.len(); let mut order: Vec<i64> = Vec::new(); let mut i: usize = 0; while i < n { let s = groupSizes[i]; let mut seen: bool = false; let mut j: usize = 0; while j < order.len() { ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [group_the_people]: type definitions module public import Aeneas @[expose] public section 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 -- [group_the_people]: function definitions module public import Aeneas public import Aegis.GroupThePeople.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.GroupThePeople.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.GroupThePeople.group_the_people (Slice.from [1#i64, 2#i64, 2#i64, 1#i64] (by scalar_tac) : Slice Std.I64)) ((alloc.vec.Vec.from [(alloc.vec.Vec.fr...
[ { "input": "[[1, 2, 2, 1]]", "output": "[[0], [3], [1, 2]]" }, { "input": "[[2, 2, 1, 1]]", "output": "[[0, 1], [2], [3]]" }, { "input": "[[4, 4, 4, 4]]", "output": "[[0, 1, 2, 3]]" }, { "input": "[[1, 2, 2, 1, 1]]", "output": "[[0], [3], [4], [1, 2]]" }, { "input...
83
false
83
verified
10
10
1
4,257
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.GroupThePeople.Code.Funs /-! # Specifications of `Aegis.GroupThePeople.group_the_people` LeetCode problem `group-the-people-given-the-group-size-they-belong-to`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.GroupThePeople (group_the_people) n...
11
find-the-smallest-divisor-given-a-threshold
1,283
Medium
[ "Array", "Binary Search" ]
Given an array of integers nums and an integer threshold, we will choose a positive integer divisor, divide all the array by it, and sum the division's result. Find the smallest divisor such that the result mentioned above is less than or equal to threshold. Each result of the division is rounded to the nearest integer...
smallestDivisor(nums: list_int, threshold: int) -> int
pub fn smallest_divisor(nums: &[i64], threshold: i64) -> i64
Aegis.SmallestDivisor.smallest_divisor
pub fn smallest_divisor(nums: &[i64], threshold: i64) -> i64 { let n = nums.len(); // Find the maximum element. let mut maxv: i64 = 1; let mut i: usize = 0; while i < n { if nums[i] > maxv { maxv = nums[i]; } i += 1; } // Use an exclusive upper bound max...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [smallest_divisor]: type definitions module public import Aeneas @[expose] public section 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 -- [smallest_divisor]: function definitions module public import Aeneas public import Aegis.SmallestDivisor.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.SmallestDivisor.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.SmallestDivisor.smallest_divisor (Slice.from [1000000#i64] (by scalar_tac) : Slice Std.I64) 1000000#i64) (1#i64))}") #eval (s!"CASE 1 {(Result.re...
[ { "input": "[[1000000], 1000000]", "output": "1" }, { "input": "[[999999, 999999, 999999], 2999997]", "output": "1" }, { "input": "[[1, 2, 5, 9], 6]", "output": "5" }, { "input": "[[1000000, 999999, 999998, 999997], 3999990]", "output": "2" }, { "input": "[[10, 20...
81
false
81
verified
10
10
4
149,349
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.SmallestDivisor.Code.Funs /-! # Specifications of `Aegis.SmallestDivisor.smallest_divisor` LeetCode problem `find-the-smallest-divisor-given-a-threshold`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.SmallestDivisor def ceilDiv (x d ...
10
minimum-number-of-flips-to-convert-binary-matrix-to-zero-matrix
1,284
Hard
[ "Bit Manipulation", "Breadth-First Search", "Array", "Hash Table", "Matrix" ]
Given a m x n binary matrix mat. In one step, you can choose one cell and flip it and all the four neighbors of it if they exist (Flip is changing 1 to 0 and 0 to 1). A pair of cells are called neighbors if they share one edge. Return the minimum number of steps required to convert mat to a zero matrix or -1 if you can...
minFlips(mat: list_list_int) -> int
pub fn min_flips(mat: &[Vec<i64>]) -> i64
Aegis.MinFlips.min_flips
pub fn min_flips(mat: &[Vec<i64>]) -> i64 { let m = mat.len(); if m == 0 { return 0; } let n = mat[0].len(); if n == 0 { return 0; } let cells = m * n; let mut target: i64 = 0; let mut r: usize = 0; while r < m { let row = &mat[r]; let mut c: us...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [min_flips]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter.styl...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [min_flips]: function definitions module public import Aeneas public import Aegis.MinFlips.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.MinFlips.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.MinFlips.min_flips (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]]]", "output": "0" }, { "input": "[[[0, 0], [0, 1]]]", "output": "3" }, { "input": "[[[1, 1], [1, 1]]]", "output": "4" }, { "input": "[[[1, 0, 0], [1, 0, 0]]]", "output": "-1" }, { "input": "[[[1, 1, 1], [1, 1, 1], [1, 1, 1]]]", "output": "5" ...
53
false
53
verified
10
10
1
2,408
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MinFlips.Code.Funs /-! # Specifications of `Aegis.MinFlips.min_flips` LeetCode problem `minimum-number-of-flips-to-convert-binary-matrix-to-zero-matrix`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.MinFlips namespace AegisSpec.MinFlips ...
17
element-appearing-more-than-25-in-sorted-array
1,287
Easy
[ "Array" ]
Given an integer array sorted in non-decreasing order, there is exactly one integer in the array that occurs more than 25% of the time, return that integer.   Example 1: Input: arr = [1,2,2,6,6,6,6,7,10] Output: 6 Example 2: Input: arr = [1,1] Output: 1   Constraints: 1 <= arr.length <= 104 0 <= arr[i] <= 105
findSpecialInteger(arr: list_int) -> int
pub fn find_special_integer(arr: &[i64]) -> i64
Aegis.FindSpecialInteger.find_special_integer
pub fn find_special_integer(arr: &[i64]) -> i64 { let n: usize = arr.len(); let mut i: usize = 0; while i < n { let mut j: usize = i + 1; while j < n && arr[j] == arr[i] { j += 1; } let count: usize = j - i; if count * 4 > n { return arr[i]; ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [find_special_integer]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [find_special_integer]: function definitions module public import Aeneas public import Aegis.FindSpecialInteger.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand fal...
import Aegis.FindSpecialInteger.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.FindSpecialInteger.find_special_integer (Slice.from [1#i64, 1#i64] (by scalar_tac) : Slice Std.I64)) (1#i64))}") #eval (s!"CASE 1 {(Result.red...
[ { "input": "[[1, 1]]", "output": "1" }, { "input": "[[7, 7, 7, 7, 8, 9, 10]]", "output": "7" }, { "input": "[[1, 2, 2, 2, 3, 4, 5, 6]]", "output": "2" }, { "input": "[[1, 2, 2, 6, 6, 6, 6, 7, 10]]", "output": "6" }, { "input": "[[5, 5, 5, 5, 6, 7, 8, 9, 10]]", ...
83
false
83
verified
10
10
1
353
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.FindSpecialInteger.Code.Funs /-! # Specifications of `Aegis.FindSpecialInteger.find_special_integer` LeetCode problem `element-appearing-more-than-25-in-sorted-array`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result ControlFlow Error namespace AegisSpec.F...
11
remove-covered-intervals
1,288
Medium
[ "Array", "Sorting" ]
Given an array intervals where intervals[i] = [li, ri] represent the interval [li, ri), remove all intervals that are covered by another interval in the list. The interval [a, b) is covered by the interval [c, d) if and only if c <= a and b <= d. Return the number of remaining intervals.   Example 1: Input: intervals ...
removeCoveredIntervals(intervals: list_list_int) -> int
pub fn remove_covered_intervals(intervals: &[Vec<i64>]) -> i64
Aegis.RemoveCoveredIntervals.remove_covered_intervals
pub fn remove_covered_intervals(intervals: &[Vec<i64>]) -> i64 { let n = intervals.len(); if n == 0 { return 0; } let mut starts: Vec<i64> = Vec::new(); let mut ends: Vec<i64> = Vec::new(); let mut i = 0; while i < n { starts.push(intervals[i][0]); ends.push(interva...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [remove_covered_intervals]: type definitions module public import Aeneas @[expose] public 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 -- [remove_covered_intervals]: function definitions module public import Aeneas public import Aegis.RemoveCoveredIntervals.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCom...
import Aegis.RemoveCoveredIntervals.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.RemoveCoveredIntervals.remove_covered_intervals (Slice.from [(alloc.vec.Vec.from [1#i64, 2#i64] (by scalar_tac) : alloc.vec.Vec Std.I64)] ...
[ { "input": "[[[1, 2]]]", "output": "1" }, { "input": "[[[1, 4], [2, 3]]]", "output": "1" }, { "input": "[[[0, 10], [5, 12]]]", "output": "2" }, { "input": "[[[1, 100], [2, 50], [3, 75]]]", "output": "1" }, { "input": "[[[1, 3], [2, 4], [3, 5]]]", "output": "3"...
111
false
111
verified
10
10
1
2,684
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.RemoveCoveredIntervals.Code.Funs /-! # Specifications of `Aegis.RemoveCoveredIntervals.remove_covered_intervals` LeetCode problem `remove-covered-intervals`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.RemoveCoveredIntervals namespace Aeg...
9
convert-binary-number-in-a-linked-list-to-integer
1,290
Easy
[ "Linked List", "Math" ]
Given head which is a reference node to a singly-linked list. The value of each node in the linked list is either 0 or 1. The linked list holds the binary representation of a number. Return the decimal value of the number in the linked list. The most significant bit is at the head of the linked list.   Example 1: Inp...
getDecimalValue(head: linkedlist) -> int
pub fn get_decimal_value(head: &List) -> i64
Aegis.GetDecimalValue.get_decimal_value
fn convert(l: &List, acc: i64) -> i64 { match l { List::Nil => acc, List::Cons(v, next) => convert(&**next, acc * 2 + *v), } } pub fn get_decimal_value(head: &List) -> i64 { convert(head, 0) }
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [get_decimal_value]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option lin...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [get_decimal_value]: function definitions module public import Aeneas public import Aegis.GetDecimalValue.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.GetDecimalValue.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.GetDecimalValue.get_decimal_value ((.Cons 0#i64 (.Nil)) : Aegis.GetDecimalValue.List)) (0#i64))}") #eval (s!"CASE 1 {(Result.reducesTo (Aegis.Get...
[ { "input": "[[0]]", "output": "0" }, { "input": "[[1]]", "output": "1" }, { "input": "[[1, 0, 1]]", "output": "5" }, { "input": "[[1, 1, 1]]", "output": "7" }, { "input": "[[1, 1, 0, 0]]", "output": "12" }, { "input": "[[1, 1, 1, 1]]", "output": "1...
61
false
61
verified
10
10
1
1,447
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.GetDecimalValue.Code.Funs /-! # Specifications of `Aegis.GetDecimalValue.get_decimal_value` LeetCode problem `convert-binary-number-in-a-linked-list-to-integer`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open scoped BigOperators namespace AegisSpec.Ge...
13
sequential-digits
1,291
Medium
[ "Enumeration" ]
An integer has sequential digits if and only if each digit in the number is one more than the previous digit. Return a sorted list of all the integers in the range [low, high] inclusive that have sequential digits.   Example 1: Input: low = 100, high = 300 Output: [123,234] Example 2: Input: low = 1000, high = 13000 Ou...
sequentialDigits(low: int, high: int) -> list_int
pub fn sequential_digits(low: i64, high: i64) -> Vec<i64>
Aegis.SequentialDigits.sequential_digits
pub fn sequential_digits(low: i64, high: i64) -> Vec<i64> { let mut result: Vec<i64> = Vec::new(); let mut length: i64 = 2; while length <= 9 { let mut start: i64 = 1; while start + length - 1 <= 9 { let mut num: i64 = 0; let mut digit: i64 = start; let m...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [sequential_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 lin...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [sequential_digits]: function definitions module public import Aeneas public import Aegis.SequentialDigits.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.SequentialDigits.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.SequentialDigits.sequential_digits 9#i64 10#i64) ((alloc.vec.Vec.from [] (by scalar_tac) : alloc.vec.Vec Std.I64)))}") #eval (s!"CASE 1 {(Result...
[ { "input": "[9, 10]", "output": "[]" }, { "input": "[80000, 85000]", "output": "[]" }, { "input": "[1, 10]", "output": "[]" }, { "input": "[99, 100]", "output": "[]" }, { "input": "[88888888, 99999999]", "output": "[]" }, { "input": "[4000000, 6000000]...
88
false
88
verified
10
10
1
1,181
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.SequentialDigits.Code.Funs /-! # Specifications of `Aegis.SequentialDigits.sequential_digits` LeetCode problem `sequential-digits`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.SequentialDigits namespace AegisSpec.SequentialDigits def IsSeque...
12
maximum-side-length-of-a-square-with-sum-less-than-or-equal-to-threshold
1,292
Medium
[ "Array", "Binary Search", "Matrix", "Prefix Sum" ]
Given a m x n matrix mat and an integer threshold, return the maximum side-length of a square with a sum less than or equal to threshold or return 0 if there is no such square.   Example 1: Input: mat = [[1,1,3,2,4,3,2],[1,1,3,2,4,3,2],[1,1,3,2,4,3,2]], threshold = 4 Output: 2 Explanation: The maximum side length of ...
maxSideLength(mat: list_list_int, threshold: int) -> int
pub fn max_side_length(mat: &[Vec<i64>], threshold: i64) -> i64
Aegis.MaxSideLength.max_side_length
pub fn max_side_length(mat: &[Vec<i64>], threshold: i64) -> i64 { let m = mat.len(); if m == 0 { return 0; } let n = mat[0].len(); if n == 0 { return 0; } let mut prefix: Vec<Vec<i64>> = Vec::new(); let mut i = 0; while i <= m { let mut row: Vec<i64> = Vec::n...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [max_side_length]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linte...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [max_side_length]: function definitions module public import Aeneas public import Aegis.MaxSideLength.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.MaxSideLength.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.MaxSideLength.max_side_length (Slice.from [(alloc.vec.Vec.from [10#i64, 20#i64, 30#i64] (by scalar_tac) : alloc.vec.Vec Std.I64), (alloc.vec.Vec.fr...
[ { "input": "[[[10, 20, 30], [40, 50, 60], [70, 80, 90]], 100]", "output": "1" }, { "input": "[[[1, 2, 3], [4, 5, 6], [7, 8, 9]], 15]", "output": "2" }, { "input": "[[[100, 200, 300], [200, 300, 400], [300, 400, 500]], 600]", "output": "1" }, { "input": "[[[100, 200, 300], [40...
85
false
85
verified
10
10
2
3,875
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MaxSideLength.Code.Funs /-! # Specifications of `Aegis.MaxSideLength.max_side_length` LeetCode problem `maximum-side-length-of-a-square-with-sum-less-than-or-equal-to-threshold`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.MaxSideLen...
9
shortest-path-in-a-grid-with-obstacles-elimination
1,293
Hard
[ "Breadth-First Search", "Array", "Matrix" ]
You are given an m x n integer matrix grid where each cell is either 0 (empty) or 1 (obstacle). You can move up, down, left, or right from and to an empty cell in one step. Return the minimum number of steps to walk from the upper left corner (0, 0) to the lower right corner (m - 1, n - 1) given that you can eliminate ...
shortestPath(grid: list_list_int, k: int) -> int
pub fn shortest_path(grid: &[Vec<i64>], k: i64) -> i64
Aegis.ShortestPath.shortest_path
pub fn shortest_path(grid: &[Vec<i64>], k: i64) -> i64 { let m = grid.len(); if m == 0 { return -1; } let n = grid[0].len(); if n == 0 { return -1; } if m == 1 && n == 1 { return 0; } if k < 0 { return -1; } let max_k_i = (m * n) as i64; l...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [shortest_path]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter....
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [shortest_path]: function definitions module public import Aeneas public import Aegis.ShortestPath.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.ShortestPath.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.ShortestPath.shortest_path (Slice.from [(alloc.vec.Vec.from [0#i64, 0#i64] (by scalar_tac) : alloc.vec.Vec Std.I64), (alloc.vec.Vec.from [1#i64, 0#i...
[ { "input": "[[[0, 0], [1, 0]], 1]", "output": "2" }, { "input": "[[[1, 1, 1], [1, 0, 1], [1, 1, 1]], 2]", "output": "4" }, { "input": "[[[0, 0, 0], [0, 0, 0], [0, 0, 0]], 1]", "output": "4" }, { "input": "[[[0, 1, 1], [1, 1, 1], [1, 0, 0]], 1]", "output": "-1" }, { ...
75
false
75
verified
10
10
1
12,004
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.ShortestPath.Code.Funs /-! # Specifications of `Aegis.ShortestPath.shortest_path` LeetCode problem `shortest-path-in-a-grid-with-obstacles-elimination`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.ShortestPath namespace AegisSpec.ShortestPath...
15
find-numbers-with-even-number-of-digits
1,295
Easy
[ "Array", "Math" ]
Given an array nums of integers, return how many of them contain an even number of digits.   Example 1: Input: nums = [12,345,2,6,7896] Output: 2 Explanation: 12 contains 2 digits (even number of digits).  345 contains 3 digits (odd number of digits).  2 contains 1 digit (odd number of digits).  6 contains 1 digit (o...
findNumbers(nums: list_int) -> int
pub fn find_numbers(nums: &[i64]) -> i64
Aegis.FindNumbers.find_numbers
pub fn find_numbers(nums: &[i64]) -> i64 { let mut count: i64 = 0; let mut i: usize = 0; while i < nums.len() { let mut x: i64 = nums[i]; let mut digits: i64 = 0; while x > 0 { digits += 1; x = x / 10; } if digits % 2 == 0 { coun...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [find_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 linter.s...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [find_numbers]: function definitions module public import Aeneas public import Aegis.FindNumbers.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.FindNumbers.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.FindNumbers.find_numbers (Slice.from [10#i64, 100#i64, 1000#i64, 10000#i64] (by scalar_tac) : Slice Std.I64)) (2#i64))}") #eval (s!"CASE 1 {(Result.r...
[ { "input": "[[10, 100, 1000, 10000]]", "output": "2" }, { "input": "[[555, 901, 482, 1771]]", "output": "1" }, { "input": "[[12345678, 87654321, 11223344, 55667788]]", "output": "4" }, { "input": "[[1234, 123456, 12345678, 1234567890]]", "output": "4" }, { "input"...
110
false
110
verified
10
10
1
336
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.FindNumbers.Code.Funs /-! # Specifications of `Aegis.FindNumbers.find_numbers` LeetCode problem `find-numbers-with-even-number-of-digits`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.FindNumbers namespace AegisSpec.FindNumbers def HasE...
13
divide-array-in-sets-of-k-consecutive-numbers
1,296
Medium
[ "Greedy", "Array", "Hash Table", "Sorting" ]
Given an array of integers nums and a positive integer k, check whether it is possible to divide this array into sets of k consecutive numbers. Return true if it is possible. Otherwise, return false.   Example 1: Input: nums = [1,2,3,3,4,4,5,6], k = 4 Output: true Explanation: Array can be divided into [1,2,3,4] and [...
isPossibleDivide(nums: list_int, k: int) -> bool
pub fn is_possible_divide(nums: &[i64], k: i64) -> bool
Aegis.IsPossibleDivide.is_possible_divide
pub fn is_possible_divide(nums: &[i64], k: i64) -> bool { if k <= 0 { return false; } let n = nums.len(); let kk = k as usize; if n == 0 { return true; } if n % kk != 0 { return false; } if kk == 1 { return true; } // Copy into an owned ve...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [is_possible_divide]: type definitions module public import Aeneas @[expose] public section 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_possible_divide]: function definitions module public import Aeneas public import Aegis.IsPossibleDivide.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.IsPossibleDivide.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.IsPossibleDivide.is_possible_divide (Slice.from [1#i64, 2#i64, 3#i64, 4#i64] (by scalar_tac) : Slice Std.I64) 3#i64) (false))}") #eval (s!"CASE ...
[ { "input": "[[1, 2, 3, 4], 3]", "output": "false" }, { "input": "[[1, 1, 2, 2, 3, 3], 3]", "output": "true" }, { "input": "[[1, 2, 3, 3, 4, 4, 5, 6], 4]", "output": "true" }, { "input": "[[1, 2, 2, 3, 3, 4, 4, 5, 5], 2]", "output": "false" }, { "input": "[[1, 2, 3...
90
false
90
verified
10
10
2
8,625
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.IsPossibleDivide.Code.Funs /-! # Specifications of `Aegis.IsPossibleDivide.is_possible_divide` LeetCode problem `divide-array-in-sets-of-k-consecutive-numbers`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.IsPossibleDivide open A...
12
maximum-number-of-occurrences-of-a-substring
1,297
Medium
[ "Hash Table", "String", "Sliding Window" ]
Given a string s, return the maximum number of occurrences of any substring under the following rules: The number of unique characters in the substring must be less than or equal to maxLetters. The substring size must be between minSize and maxSize inclusive.   Example 1: Input: s = "aababcaab", maxLetters = 2, minS...
maxFreq(s: str, maxLetters: int, minSize: int, maxSize: int) -> int
pub fn max_freq(s: &[u8], maxLetters: i64, minSize: i64, maxSize: i64) -> i64
Aegis.MaxFreq.max_freq
const MOD_VAL: i64 = 1000000007; const BASE_VAL: i64 = 27; fn windows_equal(s: &[u8], a: usize, b: usize, k: usize) -> bool { let mut j: usize = 0; while j < k { if s[a + j] != s[b + j] { return false; } j += 1; } true } pub fn max_freq(s: &[u8], maxLetters: i64, mi...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [max_freq]: type definitions module public import Aeneas @[expose] public section 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 -- [max_freq]: function definitions module public import Aeneas public import Aegis.MaxFreq.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.MaxFreq.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.MaxFreq.max_freq (Slice.from [97#u8, 97#u8, 97#u8, 97#u8] (by scalar_tac) : Slice Std.U8) 1#i64 3#i64 3#i64) (2#i64))}") #eval (s!"CASE 1 {(Result.reduce...
[ { "input": "[\"aaaa\", 1, 3, 3]", "output": "2" }, { "input": "[\"abacabadabacaba\", 3, 3, 5]", "output": "4" }, { "input": "[\"xyzxyzxyz\", 3, 3, 3]", "output": "3" }, { "input": "[\"abacaba\", 2, 2, 5]", "output": "2" }, { "input": "[\"aabcabcabc\", 2, 2, 3]", ...
117
false
117
verified
10
10
1
7,769
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MaxFreq.Code.Funs /-! # Specifications of `Aegis.MaxFreq.max_freq` LeetCode problem `maximum-number-of-occurrences-of-a-substring`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.MaxFreq def toBytes (s : Slice Std.U8) : List Nat := s.v...
16
maximum-candies-you-can-get-from-boxes
1,298
Hard
[ "Breadth-First Search", "Graph", "Array" ]
You have n boxes labeled from 0 to n - 1. You are given four arrays: status, candies, keys, and containedBoxes where: status[i] is 1 if the ith box is open and 0 if the ith box is closed, candies[i] is the number of candies in the ith box, keys[i] is a list of the labels of the boxes you can open after opening the ith...
maxCandies(status: list_int, candies: list_int, keys: list_list_int, containedBoxes: list_list_int, initialBoxes: list_int) -> int
pub fn max_candies(status: &[i64], candies: &[i64], keys: &[Vec<i64>], containedBoxes: &[Vec<i64>], initialBoxes: &[i64]) -> i64
Aegis.MaxCandies.max_candies
pub fn max_candies( status: &[i64], candies: &[i64], keys: &[Vec<i64>], containedBoxes: &[Vec<i64>], initialBoxes: &[i64], ) -> i64 { let n = status.len(); let mut have: Vec<bool> = Vec::new(); let mut used: Vec<bool> = Vec::new(); let mut can_open: Vec<bool> = Vec::new(); let ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [max_candies]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter.st...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [max_candies]: function definitions module public import Aeneas public import Aegis.MaxCandies.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.MaxCandies.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.MaxCandies.max_candies (Slice.from [1#i64, 1#i64, 1#i64] (by scalar_tac) : Slice Std.I64) (Slice.from [5#i64, 10#i64, 15#i64] (by scalar_tac) : Slice ...
[ { "input": "[[1, 1, 1], [5, 10, 15], [[], [2], []], [[1], [], []], [0]]", "output": "15" }, { "input": "[[1, 0, 0], [100, 200, 300], [[1], [], [2]], [[2], [], []], [0]]", "output": "100" }, { "input": "[[0, 0, 0], [10, 20, 30], [[1], [2], []], [[], [], []], [0]]", "output": "0" }, ...
83
false
83
verified
10
10
1
2,887
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MaxCandies.Code.Funs /-! # Specifications of `Aegis.MaxCandies.max_candies` LeetCode problem `maximum-candies-you-can-get-from-boxes`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open scoped Classical namespace AegisSpec.MaxCandies def ivals (l : List ...
13
replace-elements-with-greatest-element-on-right-side
1,299
Easy
[ "Array" ]
Given an array arr, replace every element in that array with the greatest element among the elements to its right, and replace the last element with -1. After doing so, return the array.   Example 1: Input: arr = [17,18,5,4,6,1] Output: [18,6,6,6,1,-1] Explanation: - index 0 --> the greatest element to the right of i...
replaceElements(arr: list_int) -> list_int
pub fn replace_elements(arr: &[i64]) -> Vec<i64>
Aegis.ReplaceElements.replace_elements
pub fn replace_elements(arr: &[i64]) -> Vec<i64> { let n = arr.len(); let mut out: Vec<i64> = Vec::new(); let mut k: usize = 0; while k < n { out.push(0); k = k + 1; } let mut max_right: i64 = -1; let mut i: usize = n; while i > 0 { i = i - 1; let curre...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [replace_elements]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option lint...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [replace_elements]: function definitions module public import Aeneas public import Aegis.ReplaceElements.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.ReplaceElements.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.ReplaceElements.replace_elements (Slice.from [1#i64] (by scalar_tac) : Slice Std.I64)) ((alloc.vec.Vec.from [(-1)#i64] (by scalar_tac) : alloc.ve...
[ { "input": "[[1]]", "output": "[-1]" }, { "input": "[[400]]", "output": "[-1]" }, { "input": "[[100000]]", "output": "[-1]" }, { "input": "[[1, 2]]", "output": "[2, -1]" }, { "input": "[[2, 1]]", "output": "[1, -1]" }, { "input": "[[1, 2, 3]]", "ou...
104
false
104
verified
10
10
1
696
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.ReplaceElements.Code.Funs /-! # Specifications of `Aegis.ReplaceElements.replace_elements` LeetCode problem `replace-elements-with-greatest-element-on-right-side`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result set_option autoImplicit false namespace Aegi...
12
sum-of-mutated-array-closest-to-target
1,300
Medium
[ "Array", "Binary Search", "Sorting" ]
Given an integer array arr and a target value target, return the integer value such that when we change all the integers larger than value in the given array to be equal to value, the sum of the array gets as close as possible (in absolute difference) to target. In case of a tie, return the minimum such integer. Notice...
findBestValue(arr: list_int, target: int) -> int
pub fn find_best_value(arr: &[i64], target: i64) -> i64
Aegis.FindBestValue.find_best_value
fn sum_after_mutate(arr: &[i64], value: i64) -> i64 { let mut sum: i64 = 0; let mut i: usize = 0; while i < arr.len() { if arr[i] < value { sum += arr[i]; } else { sum += value; } i += 1; } sum } fn abs_diff(x: i64, y: i64) -> i64 { if x >...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [find_best_value]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linte...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [find_best_value]: function definitions module public import Aeneas public import Aegis.FindBestValue.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.FindBestValue.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.FindBestValue.find_best_value (Slice.from [2#i64, 3#i64, 5#i64] (by scalar_tac) : Slice Std.I64) 10#i64) (5#i64))}") #eval (s!"CASE 1 {(Result.redu...
[ { "input": "[[2, 3, 5], 10]", "output": "5" }, { "input": "[[10000, 10000, 10000], 10000]", "output": "3333" }, { "input": "[[100000, 100000, 100000], 100000]", "output": "33333" }, { "input": "[[100000, 100000, 100000], 299999]", "output": "100000" }, { "input": ...
113
false
113
verified
10
10
1
2,160
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.FindBestValue.Code.Funs /-! # Specifications of `Aegis.FindBestValue.find_best_value` LeetCode problem `sum-of-mutated-array-closest-to-target`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.FindBestValue namespace AegisSpec.FindBestValue ...
16
deepest-leaves-sum
1,302
Medium
[ "Tree", "Depth-First Search", "Breadth-First Search", "Binary Tree" ]
Given the root of a binary tree, return the sum of values of its deepest leaves.   Example 1: Input: root = [1,2,3,4,5,null,6,7,null,null,null,null,8] Output: 15 Example 2: Input: root = [6,7,8,2,7,1,3,9,null,1,4,null,null,null,5] Output: 19   Constraints: The number of nodes in the tree is in the range [1, 104]....
deepestLeavesSum(root: tree) -> int
pub fn deepest_leaves_sum(root: &Tree) -> i64
Aegis.DeepestLeavesSum.deepest_leaves_sum
fn tree_depth(t: &Tree) -> i64 { match t { Tree::Null => 0, Tree::Node(_, left, right) => { let dl = tree_depth(&**left); let dr = tree_depth(&**right); if dl > dr { dl + 1 } else { dr + 1 } } } }...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [deepest_leaves_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 -- [deepest_leaves_sum]: function definitions module public import Aeneas public import Aegis.DeepestLeavesSum.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.DeepestLeavesSum.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.DeepestLeavesSum.deepest_leaves_sum ((.Node 1#i64 (.Null) (.Null)) : Aegis.DeepestLeavesSum.Tree)) (1#i64))}") #eval (s!"CASE 1 {(Result.reduces...
[ { "input": "[[1]]", "output": "1" }, { "input": "[[1, 2, 3]]", "output": "5" }, { "input": "[[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]]", "output": "92" }, { "input": "[[2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30]]", "output": "184" }, { "inp...
12
false
12
verified
10
10
1
2,590
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.DeepestLeavesSum.Code.Funs /-! # Specifications of `Aegis.DeepestLeavesSum.deepest_leaves_sum` LeetCode problem `deepest-leaves-sum`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.DeepestLeavesSum namespace AegisSpec.DeepestLeavesSum def...
16
find-n-unique-integers-sum-up-to-zero
1,304
Easy
[ "Array", "Math" ]
Given an integer n, return any array containing n unique integers such that they add up to 0.   Example 1: Input: n = 5 Output: [-7,-1,1,3,4] Explanation: These arrays also are accepted [-5,-1,1,2,3] , [-3,-1,2,-2,4]. Example 2: Input: n = 3 Output: [-1,0,1] Example 3: Input: n = 1 Output: [0]   Constraints: 1 <...
sumZero(n: int) -> list_int
pub fn sum_zero(n: i64) -> Vec<i64>
Aegis.SumZero.sum_zero
pub fn sum_zero(n: i64) -> Vec<i64> { let mut result: Vec<i64> = Vec::new(); let pairs: i64 = n / 2; let mut i: i64 = 1; while i <= pairs { result.push(i); result.push(-i); i += 1; } if n % 2 != 0 { result.push(0); } result }
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [sum_zero]: type definitions module public import Aeneas @[expose] public section 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 -- [sum_zero]: function definitions module public import Aeneas public import Aegis.SumZero.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.SumZero.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.SumZero.sum_zero 1#i64) ((alloc.vec.Vec.from [0#i64] (by scalar_tac) : alloc.vec.Vec Std.I64)))}") #eval (s!"CASE 1 {(Result.reducesTo (Aegis.SumZero.sum...
[ { "input": "[1]", "output": "[0]" }, { "input": "[2]", "output": "[1, -1]" }, { "input": "[3]", "output": "[1, -1, 0]" }, { "input": "[4]", "output": "[1, -1, 2, -2]" }, { "input": "[5]", "output": "[1, -1, 2, -2, 0]" }, { "input": "[6]", "output":...
48
false
48
verified
10
10
1
422
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.SumZero.Code.Funs /-! # Specifications of `Aegis.SumZero.sum_zero` LeetCode problem `find-n-unique-integers-sum-up-to-zero`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.SumZero def i64ToInt (x : I64) : ℤ := (x : IScalar IScalarT...
4
all-elements-in-two-binary-search-trees
1,305
Medium
[ "Tree", "Depth-First Search", "Binary Search Tree", "Binary Tree", "Sorting" ]
Given two binary search trees root1 and root2, return a list containing all the integers from both trees sorted in ascending order.   Example 1: Input: root1 = [2,1,4], root2 = [1,0,3] Output: [0,1,1,2,3,4] Example 2: Input: root1 = [1,null,8], root2 = [8,1] Output: [1,1,8,8]   Constraints: The number of nodes i...
getAllElements(root1: tree, root2: tree) -> list_int
pub fn get_all_elements(root1: &Tree, root2: &Tree) -> Vec<i64>
Aegis.GetAllElements.get_all_elements
fn inorder(t: &Tree, out: &mut Vec<i64>) { match t { Tree::Null => {} Tree::Node(v, left, right) => { inorder(left, out); out.push(*v); inorder(right, out); } } } pub fn get_all_elements(root1: &Tree, root2: &Tree) -> Vec<i64> { let mut a: Vec<i64...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [get_all_elements]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option lint...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [get_all_elements]: function definitions module public import Aeneas public import Aegis.GetAllElements.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.GetAllElements.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.GetAllElements.get_all_elements ((.Null) : Aegis.GetAllElements.Tree) ((.Null) : Aegis.GetAllElements.Tree)) ((alloc.vec.Vec.from [] (by scalar_ta...
[ { "input": "[[], []]", "output": "[]" }, { "input": "[[], [5]]", "output": "[5]" }, { "input": "[[5], []]", "output": "[5]" }, { "input": "[[10], [5, 15]]", "output": "[10, 15, 5]" }, { "input": "[[100000, -100000], [50000, -50000]]", "output": "[-100000, -500...
69
false
69
verified
10
10
1
3,371
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.GetAllElements.Code.Funs /-! # Specifications of `Aegis.GetAllElements.get_all_elements` LeetCode problem `all-elements-in-two-binary-search-trees`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.GetAllElements open Aegis.GetAllEle...
13
jump-game-iii
1,306
Medium
[ "Depth-First Search", "Breadth-First Search", "Array" ]
Given an array of non-negative integers arr, you are initially positioned at start index of the array. When you are at index i, you can jump to i + arr[i] or i - arr[i], check if you can reach any index with value 0. Notice that you can not jump outside of the array at any time.   Example 1: Input: arr = [4,2,3,0,3,1,...
canReach(arr: list_int, start: int) -> bool
pub fn can_reach(arr: &[i64], start: i64) -> bool
Aegis.CanReach.can_reach
pub fn can_reach(arr: &[i64], start: i64) -> bool { let n: usize = arr.len(); if n == 0 { return false; } let n_i64: i64 = n as i64; let start_idx: usize = start as usize; if start_idx >= n { return false; } let mut visited: Vec<i64> = Vec::new(); let mut i: usize =...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [can_reach]: type definitions module public import Aeneas @[expose] public section 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 -- [can_reach]: function definitions module public import Aeneas public import Aegis.CanReach.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.CanReach.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.CanReach.can_reach (Slice.from [0#i64, 1#i64] (by scalar_tac) : Slice Std.I64) 1#i64) (true))}") #eval (s!"CASE 1 {(Result.reducesTo (Aegis.CanReach.can...
[ { "input": "[[0, 1], 1]", "output": "true" }, { "input": "[[0, 1, 0, 1, 0], 4]", "output": "true" }, { "input": "[[3, 0, 2, 1, 2], 2]", "output": "false" }, { "input": "[[0, 1, 0, 1, 0], 3]", "output": "true" }, { "input": "[[1, 2, 3, 4, 0], 0]", "output": "fa...
111
false
111
verified
10
10
1
3,292
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.CanReach.Code.Funs /-! # Specifications of `Aegis.CanReach.can_reach` LeetCode problem `jump-game-iii`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.CanReach def arrVals (arr : Slice Std.I64) : List Int := arr.val.map (fun v : St...
8
xor-queries-of-a-subarray
1,310
Medium
[ "Bit Manipulation", "Array", "Prefix Sum" ]
You are given an array arr of positive integers. You are also given the array queries where queries[i] = [lefti, righti]. For each query i compute the XOR of elements from lefti to righti (that is, arr[lefti] XOR arr[lefti + 1] XOR ... XOR arr[righti] ). Return an array answer where answer[i] is the answer to the ith q...
xorQueries(arr: list_int, queries: list_list_int) -> list_int
pub fn xor_queries(arr: &[i64], queries: &[Vec<i64>]) -> Vec<i64>
Aegis.XorQueries.xor_queries
pub fn xor_queries(arr: &[i64], queries: &[Vec<i64>]) -> Vec<i64> { let n = arr.len(); let mut prefix: Vec<i64> = Vec::new(); prefix.push(0); let mut i: usize = 0; while i < n { let prev = prefix[i]; prefix.push(prev ^ arr[i]); i += 1; } let m = queries.len(); ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [xor_queries]: type definitions module public import Aeneas @[expose] public section 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 -- [xor_queries]: function definitions module public import Aeneas public import Aegis.XorQueries.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.XorQueries.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.XorQueries.xor_queries (Slice.from [7#i64, 11#i64, 15#i64] (by scalar_tac) : Slice Std.I64) (Slice.from [(alloc.vec.Vec.from [0#i64, 2#i64] (by scalar...
[ { "input": "[[7, 11, 15], [[0, 2], [0, 0], [1, 1], [2, 2]]]", "output": "[3, 7, 11, 15]" }, { "input": "[[4, 8, 2, 10], [[2, 3], [1, 3], [0, 0], [0, 3]]]", "output": "[8, 0, 4, 4]" }, { "input": "[[5, 2, 3, 9], [[0, 0], [1, 3], [0, 2], [2, 3]]]", "output": "[5, 8, 4, 10]" }, { ...
77
false
77
verified
10
10
1
704
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.XorQueries.Code.Funs /-! # Specifications of `Aegis.XorQueries.xor_queries` LeetCode problem `xor-queries-of-a-subarray`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.XorQueries def bxor (a b : Int) : Int := (BitVec.ofInt 64 a ^^^ Bi...
7
minimum-insertion-steps-to-make-a-string-palindrome
1,312
Hard
[ "String", "Dynamic Programming" ]
Given a string s. In one step you can insert any character at any index of the string. Return the minimum number of steps to make s palindrome. A Palindrome String is one that reads the same backward as well as forward.   Example 1: Input: s = "zzazz" Output: 0 Explanation: The string "zzazz" is already palindrome we ...
minInsertions(s: str) -> int
pub fn min_insertions(s: &[u8]) -> i64
Aegis.MinInsertions.min_insertions
pub fn min_insertions(s: &[u8]) -> i64 { let n = s.len(); if n <= 1 { return 0; } let mut dp: Vec<Vec<i64>> = Vec::new(); let mut i = 0usize; while i < n { let mut row: Vec<i64> = Vec::new(); let mut j = 0usize; while j < n { row.push(0); ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [min_insertions]: type definitions module public import Aeneas @[expose] public section 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 -- [min_insertions]: function definitions module public import Aeneas public import Aegis.MinInsertions.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.MinInsertions.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.MinInsertions.min_insertions (Slice.from [114#u8, 97#u8, 99#u8, 101#u8] (by scalar_tac) : Slice Std.U8)) (3#i64))}") #eval (s!"CASE 1 {(Result.redu...
[ { "input": "[\"race\"]", "output": "3" }, { "input": "[\"noon\"]", "output": "0" }, { "input": "[\"abcba\"]", "output": "0" }, { "input": "[\"abcdef\"]", "output": "5" }, { "input": "[\"zzazz\"]", "output": "0" }, { "input": "[\"google\"]", "output...
123
false
123
verified
10
10
1
1,379
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MinInsertions.Code.Funs /-! # Specifications of `Aegis.MinInsertions.min_insertions` LeetCode problem `minimum-insertion-steps-to-make-a-string-palindrome`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result set_option autoImplicit false namespace AegisSp...
9
decompress-run-length-encoded-list
1,313
Easy
[ "Array" ]
We are given a list nums of integers representing a list compressed with run-length encoding. Consider each adjacent pair of elements [freq, val] = [nums[2*i], nums[2*i+1]] (with i >= 0).  For each such pair, there are freq elements with value val concatenated in a sublist. Concatenate all the sublists from left to rig...
decompressRLElist(nums: list_int) -> list_int
pub fn decompress_rl_elist(nums: &[i64]) -> Vec<i64>
Aegis.DecompressRlElist.decompress_rl_elist
pub fn decompress_rl_elist(nums: &[i64]) -> Vec<i64> { let mut out: Vec<i64> = Vec::new(); let mut i: usize = 0; while i + 1 < nums.len() { let freq = nums[i]; let val = nums[i + 1]; let mut k: i64 = 0; while k < freq { out.push(val); k += 1; ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [decompress_rl_elist]: type definitions module public import Aeneas @[expose] public section 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 -- [decompress_rl_elist]: function definitions module public import Aeneas public import Aegis.DecompressRlElist.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false...
import Aegis.DecompressRlElist.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.DecompressRlElist.decompress_rl_elist (Slice.from [1#i64, 1#i64, 2#i64, 3#i64] (by scalar_tac) : Slice Std.I64)) ((alloc.vec.Vec.from [1#i64, 3...
[ { "input": "[[1, 1, 2, 3]]", "output": "[1, 3, 3]" }, { "input": "[[1, 2, 3, 4]]", "output": "[2, 4, 4, 4]" }, { "input": "[[3, 1, 2, 2]]", "output": "[1, 1, 1, 2, 2]" }, { "input": "[[2, 5, 3, 1]]", "output": "[5, 5, 1, 1, 1]" }, { "input": "[[2, 5, 3, 7]]", ...
86
false
86
verified
10
10
1
695
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.DecompressRlElist.Code.Funs /-! # Specifications of `Aegis.DecompressRlElist.decompress_rl_elist` LeetCode problem `decompress-run-length-encoded-list`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.DecompressRlElist namespace AegisSpec.Dec...
12
matrix-block-sum
1,314
Medium
[ "Array", "Matrix", "Prefix Sum" ]
Given a m x n matrix mat and an integer k, return a matrix answer where each answer[i][j] is the sum of all elements mat[r][c] for: i - k <= r <= i + k, j - k <= c <= j + k, and (r, c) is a valid position in the matrix.   Example 1: Input: mat = [[1,2,3],[4,5,6],[7,8,9]], k = 1 Output: [[12,21,16],[27,45,33],[24,39,...
matrixBlockSum(mat: list_list_int, k: int) -> list_list_int
pub fn matrix_block_sum(mat: &[Vec<i64>], k: i64) -> Vec<Vec<i64>>
Aegis.MatrixBlockSum.matrix_block_sum
pub fn matrix_block_sum(mat: &[Vec<i64>], k: i64) -> Vec<Vec<i64>> { let m = mat.len(); let n = mat[0].len(); // 2-D prefix sums with dimensions (m + 1) x (n + 1). let mut ps: Vec<Vec<i64>> = Vec::new(); let mut zero_row: Vec<i64> = Vec::new(); let mut j = 0; while j <= n { zero_ro...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [matrix_block_sum]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option lint...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [matrix_block_sum]: function definitions module public import Aeneas public import Aegis.MatrixBlockSum.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.MatrixBlockSum.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.MatrixBlockSum.matrix_block_sum (Slice.from [(alloc.vec.Vec.from [5#i64] (by scalar_tac) : alloc.vec.Vec Std.I64)] (by scalar_tac) : Slice (alloc....
[ { "input": "[[[5]], 1]", "output": "[[5]]" }, { "input": "[[[5]], 0]", "output": "[[5]]" }, { "input": "[[[1, 2], [3, 4]], 1]", "output": "[[10, 10], [10, 10]]" }, { "input": "[[[100, 200], [300, 400], [500, 600]], 1]", "output": "[[1000, 1000], [2100, 2100], [1800, 1800]...
88
false
88
verified
10
10
1
4,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.MatrixBlockSum.Code.Funs /-! # Specifications of `Aegis.MatrixBlockSum.matrix_block_sum` LeetCode problem `matrix-block-sum`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.MatrixBlockSum open Aegis.MatrixBlockSum (matrix_block_sum) d...
14
sum-of-nodes-with-even-valued-grandparent
1,315
Medium
[ "Tree", "Depth-First Search", "Breadth-First Search", "Binary Tree" ]
Given the root of a binary tree, return the sum of values of nodes with an even-valued grandparent. If there are no nodes with an even-valued grandparent, return 0. A grandparent of a node is the parent of its parent if it exists.   Example 1: Input: root = [6,7,8,2,7,1,3,9,null,1,4,null,null,null,5] Output: 18 Expla...
sumEvenGrandparent(root: tree) -> int
pub fn sum_even_grandparent(root: &Tree) -> i64
Aegis.SumEvenGrandparent.sum_even_grandparent
fn dfs(t: &Tree, parent_even: bool, grandparent_even: bool) -> i64 { match t { Tree::Null => 0, Tree::Node(v, l, r) => { let mut sum: i64 = 0; if grandparent_even { sum = sum + *v; } let current_even = *v % 2 == 0; sum = ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [sum_even_grandparent]: type definitions module public import Aeneas @[expose] public section 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 -- [sum_even_grandparent]: function definitions module public import Aeneas public import Aegis.SumEvenGrandparent.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand fal...
import Aegis.SumEvenGrandparent.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.SumEvenGrandparent.sum_even_grandparent ((.Node 1#i64 (.Null) (.Null)) : Aegis.SumEvenGrandparent.Tree)) (0#i64))}") #eval (s!"CASE 1 {(Result...
[ { "input": "[[1]]", "output": "0" }, { "input": "[[4, 2, 7, 1, 3, 6, 9]]", "output": "19" }, { "input": "[[2, 3, 4, 5, 6, 7, 8]]", "output": "26" }, { "input": "[[11, 10, 12, 9, 8, 7, 6, 5, 4, 3, 2, 1]]", "output": "15" }, { "input": "[[1, 2, 3, 4, 5, 6, 7, 8, 9, ...
41
false
41
verified
10
10
1
1,400
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.SumEvenGrandparent.Code.Funs /-! # Specifications of `Aegis.SumEvenGrandparent.sum_even_grandparent` LeetCode problem `sum-of-nodes-with-even-valued-grandparent`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.SumEvenGrandparent op...
12
distinct-echo-substrings
1,316
Hard
[ "Trie", "String", "Hash Function", "Rolling Hash" ]
Return the number of distinct non-empty substrings of text that can be written as the concatenation of some string with itself (i.e. it can be written as a + a where a is some string).   Example 1: Input: text = "abcabcabc" Output: 3 Explanation: The 3 substrings are "abcabc", "bcabca" and "cabcab". Example 2: Input...
distinctEchoSubstrings(text: str) -> int
pub fn distinct_echo_substrings(text: &[u8]) -> i64
Aegis.DistinctEchoSubstrings.distinct_echo_substrings
fn suffix_less(i: usize, j: usize, text: &[u8], lcp: &[Vec<usize>]) -> bool { if i == j { return false; } let n = text.len(); let common = lcp[i][j]; let ii = i + common; let jj = j + common; if ii == n { return true; } if jj == n { return false; } ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [distinct_echo_substrings]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_opt...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [distinct_echo_substrings]: function definitions module public import Aeneas public import Aegis.DistinctEchoSubstrings.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCom...
import Aegis.DistinctEchoSubstrings.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.DistinctEchoSubstrings.distinct_echo_substrings (Slice.from [97#u8, 98#u8, 97#u8, 98#u8, 97#u8, 98#u8] (by scalar_tac) : Slice Std.U8)) (2...
[ { "input": "[\"ababab\"]", "output": "2" }, { "input": "[\"\"]", "output": "0" }, { "input": "[\"abcabcabc\"]", "output": "3" }, { "input": "[\"aaaa\"]", "output": "2" }, { "input": "[\"ab\"]", "output": "0" }, { "input": "[\"abbbabbb\"]", "output"...
98
false
98
verified
10
10
1
12,501
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.DistinctEchoSubstrings.Code.Funs /-! # Specifications of `Aegis.DistinctEchoSubstrings.distinct_echo_substrings` LeetCode problem `distinct-echo-substrings`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.DistinctEchoSubstrings namespace Aeg...
14
convert-integer-to-the-sum-of-two-no-zero-integers
1,317
Easy
[ "Math" ]
No-Zero integer is a positive integer that does not contain any 0 in its decimal representation. Given an integer n, return a list of two integers [a, b] where: a and b are No-Zero integers. a + b = n The test cases are generated so that there is at least one valid solution. If there are many valid solutions, you can...
getNoZeroIntegers(n: int) -> list_int
pub fn get_no_zero_integers(n: i64) -> Vec<i64>
Aegis.GetNoZeroIntegers.get_no_zero_integers
fn is_no_zero(mut x: i64) -> bool { while x > 0 { let digit = x % 10; if digit == 0 { return false; } x = x / 10; } true } pub fn get_no_zero_integers(n: i64) -> Vec<i64> { let mut a: i64 = 1; while a < n { let b = n - a; if is_no_zero(a)...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [get_no_zero_integers]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [get_no_zero_integers]: function definitions module public import Aeneas public import Aegis.GetNoZeroIntegers.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand fals...
import Aegis.GetNoZeroIntegers.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.GetNoZeroIntegers.get_no_zero_integers 101#i64) ((alloc.vec.Vec.from [2#i64, 99#i64] (by scalar_tac) : alloc.vec.Vec Std.I64)))}") #eval (s!"CA...
[ { "input": "[101]", "output": "[2, 99]" }, { "input": "[1010]", "output": "[11, 999]" }, { "input": "[11]", "output": "[2, 9]" }, { "input": "[104]", "output": "[5, 99]" }, { "input": "[1001]", "output": "[2, 999]" }, { "input": "[2]", "output": "[...
115
false
115
verified
10
10
1
1,717
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.GetNoZeroIntegers.Code.Funs /-! # Specifications of `Aegis.GetNoZeroIntegers.get_no_zero_integers` LeetCode problem `convert-integer-to-the-sum-of-two-no-zero-integers`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.GetNoZeroIntegers ...
12
minimum-flips-to-make-a-or-b-equal-to-c
1,318
Medium
[ "Bit Manipulation" ]
Given 3 positives numbers a, b and c. Return the minimum flips required in some bits of a and b to make ( a OR b == c ). (bitwise OR operation).\r Flip operation consists of change any single bit 1 to 0 or change the bit 0 to 1 in their binary representation.\r \r  \r Example 1:\r \r \r \r \r Input: a = 2, b = 6, c = 5...
minFlips(a: int, b: int, c: int) -> int
pub fn min_flips(a: i64, b: i64, c: i64) -> i64
Aegis.MinFlips.min_flips
pub fn min_flips(a: i64, b: i64, c: i64) -> i64 { let mut aa = a; let mut bb = b; let mut cc = c; let mut flips = 0; while aa > 0 || bb > 0 || cc > 0 { let abit = aa % 2; let bbit = bb % 2; let cbit = cc % 2; if cbit == 1 { if abit == 0 && bbit == 0 { ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [min_flips]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter.styl...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [min_flips]: function definitions module public import Aeneas public import Aegis.MinFlips.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.MinFlips.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.MinFlips.min_flips 10#i64 15#i64 25#i64) (4#i64))}") #eval (s!"CASE 1 {(Result.reducesTo (Aegis.MinFlips.min_flips 2#i64 6#i64 5#i64) (3#i64))}") #eval ...
[ { "input": "[10, 15, 25]", "output": "4" }, { "input": "[2, 6, 5]", "output": "3" }, { "input": "[1, 2, 3]", "output": "0" }, { "input": "[8, 3, 11]", "output": "0" }, { "input": "[4, 2, 7]", "output": "1" }, { "input": "[1000000000, 1000000000, 1]", ...
92
false
92
verified
10
10
1
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.MinFlips.Code.Funs /-! # Specifications of `Aegis.MinFlips.min_flips` LeetCode problem `minimum-flips-to-make-a-or-b-equal-to-c`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.MinFlips def bit (n : ℤ) (i : ℕ) : ℤ := n / (2 : ℤ) ^ ...
12
number-of-operations-to-make-network-connected
1,319
Medium
[ "Depth-First Search", "Breadth-First Search", "Union Find", "Graph" ]
There are n computers numbered from 0 to n - 1 connected by ethernet cables connections forming a network where connections[i] = [ai, bi] represents a connection between computers ai and bi. Any computer can reach any other computer directly or indirectly through the network. You are given an initial computer network c...
makeConnected(n: int, connections: list_list_int) -> int
pub fn make_connected(n: i64, connections: &[Vec<i64>]) -> i64
Aegis.MakeConnected.make_connected
fn find(parent: &mut Vec<i64>, x: i64) -> i64 { let mut root = x; while parent[root as usize] != root { root = parent[root as usize]; } let mut cur = x; while parent[cur as usize] != cur { let next = parent[cur as usize]; parent[cur as usize] = root; cur = next; ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [make_connected]: type definitions module public import Aeneas @[expose] public section 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 -- [make_connected]: function definitions module public import Aeneas public import Aegis.MakeConnected.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.MakeConnected.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.MakeConnected.make_connected 1#i64 (Slice.from [] (by scalar_tac) : Slice (alloc.vec.Vec Std.I64))) (0#i64))}") #eval (s!"CASE 1 {(Result.reducesTo...
[ { "input": "[1, []]", "output": "0" }, { "input": "[2, [[0, 1]]]", "output": "0" }, { "input": "[5, [[0, 1], [2, 3]]]", "output": "-1" }, { "input": "[3, [[0, 1], [1, 2]]]", "output": "0" }, { "input": "[5, [[0, 1], [1, 2], [3, 4]]]", "output": "-1" }, { ...
89
false
89
verified
10
10
2
1,738
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MakeConnected.Code.Funs /-! # Specifications of `Aegis.MakeConnected.make_connected` LeetCode problem `number-of-operations-to-make-network-connected`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.MakeConnected abbrev Conn := all...
11
minimum-distance-to-type-a-word-using-two-fingers
1,320
Hard
[ "String", "Dynamic Programming" ]
You have a keyboard layout as shown above in the X-Y plane, where each English uppercase letter is located at some coordinate. For example, the letter 'A' is located at coordinate (0, 0), the letter 'B' is located at coordinate (0, 1), the letter 'P' is located at coordinate (2, 3) and the letter 'Z' is located at co...
minimumDistance(word: str) -> int
pub fn minimum_distance(word: &[u8]) -> i64
Aegis.MinimumDistance.minimum_distance
fn letter_distance(a: usize, b: usize) -> i64 { let r1 = (a / 6) as i64; let c1 = (a % 6) as i64; let r2 = (b / 6) as i64; let c2 = (b % 6) as i64; let mut dr = r1 - r2; if dr < 0 { dr = -dr; } let mut dc = c1 - c2; if dc < 0 { dc = -dc; } dr + dc } pub fn...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [minimum_distance]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option lint...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [minimum_distance]: function definitions module public import Aeneas public import Aegis.MinimumDistance.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.MinimumDistance.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.MinimumDistance.minimum_distance (Slice.from [81#u8, 87#u8, 69#u8, 82#u8, 84#u8, 89#u8, 85#u8, 73#u8, 79#u8, 80#u8, 65#u8, 83#u8, 68#u8, 70#u8, 7...
[ { "input": "[\"QWERTYUIOPASDFGHJKLZXCVBNM\"]", "output": "52" }, { "input": "[\"ZZZZZ\"]", "output": "0" }, { "input": "[\"CAKE\"]", "output": "3" }, { "input": "[\"RHYTHM\"]", "output": "9" }, { "input": "[\"FINGER\"]", "output": "8" }, { "input": "[\...
450
false
450
verified
10
10
1
4,685
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MinimumDistance.Code.Funs /-! # Specifications of `Aegis.MinimumDistance.minimum_distance` LeetCode problem `minimum-distance-to-type-a-word-using-two-fingers`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.MinimumDistance namespace AegisSpec.M...
11
print-words-vertically
1,324
Medium
[ "Array", "String", "Simulation" ]
Given a string s. Return all the words vertically in the same order in which they appear in s.\r Words are returned as a list of strings, complete with spaces when is necessary. (Trailing spaces are not allowed).\r Each word would be put on only one column and that in one column there will be only one word.\r \r  \r Ex...
printVertically(s: str) -> list_str
pub fn print_vertically(s: &[u8]) -> Vec<Vec<u8>>
Aegis.PrintVertically.print_vertically
pub fn print_vertically(s: &[u8]) -> Vec<Vec<u8>> { let n: usize = s.len(); // First pass: find the maximum word length. let mut max_len: usize = 0; let mut i: usize = 0; while i < n { while i < n && s[i] == b' ' { i += 1; } if i < n { let start: usiz...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [print_vertically]: type definitions module public import Aeneas @[expose] public section 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 -- [print_vertically]: function definitions module public import Aeneas public import Aegis.PrintVertically.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.PrintVertically.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.PrintVertically.print_vertically (Slice.from [65#u8, 32#u8, 66#u8, 32#u8, 67#u8, 32#u8, 68#u8] (by scalar_tac) : Slice Std.U8)) ((alloc.vec.Vec.f...
[ { "input": "[\"A B C D\"]", "output": "[\"ABCD\"]" }, { "input": "[\"A B C D E\"]", "output": "[\"ABCDE\"]" }, { "input": "[\"A B C\"]", "output": "[\"ABC\"]" }, { "input": "[\"A\"]", "output": "[\"A\"]" }, { "input": "[\"A B C D E F G H I J K L M N O P Q R S T U ...
140
false
140
verified
10
10
1
2,828
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.PrintVertically.Code.Funs /-! # Specifications of `Aegis.PrintVertically.print_vertically` LeetCode problem `print-words-vertically`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.PrintVertically def IsSpace (b : Std.U8) : Prop := b.v...
13
delete-leaves-with-a-given-value
1,325
Medium
[ "Tree", "Depth-First Search", "Binary Tree" ]
Given a binary tree root and an integer target, delete all the leaf nodes with value target. Note that once you delete a leaf node with value target, if its parent node becomes a leaf node and has the value target, it should also be deleted (you need to continue doing that until you cannot).   Example 1: Input: root ...
removeLeafNodes(root: tree, target: int) -> tree
pub fn remove_leaf_nodes(root: &Tree, target: i64) -> Tree
Aegis.RemoveLeafNodes.remove_leaf_nodes
fn is_null(t: &Tree) -> bool { match t { Tree::Null => true, Tree::Node(_, _, _) => false, } } fn dfs(t: &Tree, target: i64) -> Tree { match t { Tree::Null => Tree::Null, Tree::Node(v, left, right) => { let new_left = dfs(&**left, target); let new_rig...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [remove_leaf_nodes]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option lin...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [remove_leaf_nodes]: function definitions module public import Aeneas public import Aegis.RemoveLeafNodes.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.RemoveLeafNodes.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 deriving instance DecidableEq for Aegis.RemoveLeafNodes.Tree #eval (s!"CASE 0 {(match (Aegis.RemoveLeafNodes.remove_leaf_nodes ((.Node 1#i64 (.Node 2#i64 (.Null) (.Null)) (.Node 3#i64 (.N...
[ { "input": "[[1, 2, 3], 4]", "output": "[1, 2, 3]" }, { "input": "[[1, 2, 3], 2]", "output": "[1, null, 3]" }, { "input": "[[1, 3, 3, 3, 2], 3]", "output": "[1, 3, null, null, 2]" }, { "input": "[[1, 2, 3, 2, 2, 2, 2], 2]", "output": "[1, null, 3]" }, { "input": "...
12
false
12
verified
10
10
1
1,814
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.RemoveLeafNodes.Code.Funs /-! # Specifications of `Aegis.RemoveLeafNodes.remove_leaf_nodes` LeetCode problem `delete-leaves-with-a-given-value`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.RemoveLeafNodes namespace AegisSpec.RemoveLeafNod...
11
sort-the-matrix-diagonally
1,329
Medium
[ "Array", "Matrix", "Sorting" ]
A matrix diagonal is a diagonal line of cells starting from some cell in either the topmost row or leftmost column and going in the bottom-right direction until reaching the matrix's end. For example, the matrix diagonal starting from mat[2][0], where mat is a 6 x 3 matrix, includes cells mat[2][0], mat[3][1], and mat[...
diagonalSort(mat: list_list_int) -> list_list_int
pub fn diagonal_sort(mat: &[Vec<i64>]) -> Vec<Vec<i64>>
Aegis.DiagonalSort.diagonal_sort
pub fn diagonal_sort(mat: &[Vec<i64>]) -> Vec<Vec<i64>> { let m = mat.len(); let mut out: Vec<Vec<i64>> = Vec::new(); if m == 0 { return out; } let n = mat[0].len(); let mut i: usize = 0; while i < m { let mut row: Vec<i64> = Vec::new(); let mut j: usize = 0; ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [diagonal_sort]: type definitions module public import Aeneas @[expose] public section 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 -- [diagonal_sort]: function definitions module public import Aeneas public import Aegis.DiagonalSort.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.DiagonalSort.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.DiagonalSort.diagonal_sort (Slice.from [(alloc.vec.Vec.from [1#i64] (by scalar_tac) : alloc.vec.Vec Std.I64)] (by scalar_tac) : Slice (alloc.vec.Vec...
[ { "input": "[[[1]]]", "output": "[[1]]" }, { "input": "[[[37, 71], [58, 62]]]", "output": "[[37, 71], [58, 62]]" }, { "input": "[[[1, 2], [3, 4], [5, 6], [7, 8]]]", "output": "[[1, 2], [3, 4], [5, 6], [7, 8]]" }, { "input": "[[[9, 8, 7], [6, 5, 4], [3, 2, 1]]]", "output":...
81
false
81
verified
10
10
1
5,798
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.DiagonalSort.Code.Funs /-! # Specifications of `Aegis.DiagonalSort.diagonal_sort` LeetCode problem `sort-the-matrix-diagonally`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.DiagonalSort def matVals (mat : Slice (alloc.vec.Vec I6...
12
reverse-subarray-to-maximize-array-value
1,330
Hard
[ "Greedy", "Array", "Math" ]
You are given an integer array nums. The value of this array is defined as the sum of |nums[i] - nums[i + 1]| for all 0 <= i < nums.length - 1. You are allowed to select any subarray of the given array and reverse it. You can perform this operation only once. Find maximum possible value of the final array.   Example 1:...
maxValueAfterReverse(nums: list_int) -> int
pub fn max_value_after_reverse(nums: &[i64]) -> i64
Aegis.MaxValueAfterReverse.max_value_after_reverse
fn abs_i64(x: i64) -> i64 { if x < 0 { -x } else { x } } pub fn max_value_after_reverse(nums: &[i64]) -> i64 { let n = nums.len(); if n < 2 { return 0; } let mut total: i64 = 0; let mut i: usize = 0; while i + 1 < n { total += abs_i64(nums[i + 1] - n...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [max_value_after_reverse]: type definitions module public import Aeneas @[expose] public 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 -- [max_value_after_reverse]: function definitions module public import Aeneas public import Aegis.MaxValueAfterReverse.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashComman...
import Aegis.MaxValueAfterReverse.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.MaxValueAfterReverse.max_value_after_reverse (Slice.from [(-1)#i64, 4#i64, (-2)#i64, 3#i64] (by scalar_tac) : Slice Std.I64)) (16#i64))}") #...
[ { "input": "[[-1, 4, -2, 3]]", "output": "16" }, { "input": "[[-100000, 100000, -100000, 100000]]", "output": "600000" }, { "input": "[[100, -100, 100, -100]]", "output": "600" }, { "input": "[[100000, -100000, 100000, -100000]]", "output": "600000" }, { "input": ...
99
false
99
verified
10
10
1
9,265
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MaxValueAfterReverse.Code.Funs /-! # Specifications of `Aegis.MaxValueAfterReverse.max_value_after_reverse` LeetCode problem `reverse-subarray-to-maximize-array-value`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.MaxValueAfterReverse (max_va...
16
rank-transform-of-an-array
1,331
Easy
[ "Array", "Hash Table", "Sorting" ]
Given an array of integers arr, replace each element with its rank. The rank represents how large the element is. The rank has the following rules: Rank is an integer starting from 1. The larger the element, the larger the rank. If two elements are equal, their rank must be the same. Rank should be as small as possibl...
arrayRankTransform(arr: list_int) -> list_int
pub fn array_rank_transform(arr: &[i64]) -> Vec<i64>
Aegis.ArrayRankTransform.array_rank_transform
pub fn array_rank_transform(arr: &[i64]) -> Vec<i64> { let n: usize = arr.len(); let mut result: Vec<i64> = Vec::new(); if n == 0 { return result; } // Copy input into an owned vector. let mut sorted: Vec<i64> = Vec::new(); let mut i: usize = 0; while i < n { sorted.pus...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [array_rank_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 ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [array_rank_transform]: function definitions module public import Aeneas public import Aegis.ArrayRankTransform.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand fal...
import Aegis.ArrayRankTransform.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.ArrayRankTransform.array_rank_transform (Slice.from [] (by scalar_tac) : Slice Std.I64)) ((alloc.vec.Vec.from [] (by scalar_tac) : alloc.vec.V...
[ { "input": "[[]]", "output": "[]" }, { "input": "[[1]]", "output": "[1]" }, { "input": "[[1000000000, -1000000000, 0]]", "output": "[3, 1, 2]" }, { "input": "[[100, 100, 100]]", "output": "[1, 1, 1]" }, { "input": "[[40, 10, 20, 30]]", "output": "[4, 1, 2, 3]"...
113
false
113
verified
10
10
1
4,875
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.ArrayRankTransform.Code.Funs /-! # Specifications of `Aegis.ArrayRankTransform.array_rank_transform` LeetCode problem `rank-transform-of-an-array`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.ArrayRankTransform namespace AegisSpec.ArrayRa...
14
filter-restaurants-by-vegan-friendly-price-and-distance
1,333
Medium
[ "Array", "Sorting" ]
Given the array restaurants where  restaurants[i] = [idi, ratingi, veganFriendlyi, pricei, distancei]. You have to filter the restaurants using three filters. The veganFriendly filter will be either true (meaning you should only include restaurants with veganFriendlyi set to true) or false (meaning you can include any ...
filterRestaurants(restaurants: list_list_int, veganFriendly: int, maxPrice: int, maxDistance: int) -> list_int
pub fn filter_restaurants(restaurants: &[Vec<i64>], veganFriendly: i64, maxPrice: i64, maxDistance: i64) -> Vec<i64>
Aegis.FilterRestaurants.filter_restaurants
pub fn filter_restaurants( restaurants: &[Vec<i64>], veganFriendly: i64, maxPrice: i64, maxDistance: i64, ) -> Vec<i64> { let mut keys: Vec<i64> = Vec::new(); let n = restaurants.len(); let mut i = 0; while i < n { let r = &restaurants[i]; let id = r[0]; let rati...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [filter_restaurants]: type definitions module public import Aeneas @[expose] public section 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 -- [filter_restaurants]: function definitions module public import Aeneas public import Aegis.FilterRestaurants.Code.Types public import Aegis.FilterRestaurants.Code.FunsExternal @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [filter_restaurants]: external functions. -- This is a template file: rename it to "FunsExternal.lean" and fill the holes. module public import Aeneas public import Aegis.FilterRestaurants.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow...
import Aegis.FilterRestaurants.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.FilterRestaurants.filter_restaurants (Slice.from [(alloc.vec.Vec.from [41#i64, 2#i64, 0#i64, 45#i64, 10#i64] (by scalar_tac) : alloc.vec.Vec St...
[ { "input": "[[[41, 2, 0, 45, 10], [42, 8, 1, 35, 9], [43, 7, 1, 30, 8], [44, 9, 0, 25, 7], [45, 6, 1, 20, 6]], 1, 30, 7]", "output": "[45]" }, { "input": "[[[601, 9, 1, 10, 1], [602, 8, 0, 15, 2], [603, 7, 1, 20, 3], [604, 6, 0, 25, 4], [605, 5, 1, 12, 5]], 1, 15, 4]", "output": "[601]" }, {...
90
false
90
verified
10
10
1
1,320
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.FilterRestaurants.Code.Funs /-! # Specifications of `Aegis.FilterRestaurants.filter_restaurants` LeetCode problem `filter-restaurants-by-vegan-friendly-price-and-distance`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.FilterRestaura...
15
find-the-city-with-the-smallest-number-of-neighbors-at-a-threshold-distance
1,334
Medium
[ "Graph", "Dynamic Programming", "Shortest Path" ]
There are n cities numbered from 0 to n-1. Given the array edges where edges[i] = [fromi, toi, weighti] represents a bidirectional and weighted edge between cities fromi and toi, and given the integer distanceThreshold. Return the city with the smallest number of cities that are reachable through some path and whose di...
findTheCity(n: int, edges: list_list_int, distanceThreshold: int) -> int
pub fn find_the_city(n: i64, edges: &[Vec<i64>], distanceThreshold: i64) -> i64
Aegis.FindTheCity.find_the_city
pub fn find_the_city(n: i64, edges: &[Vec<i64>], distanceThreshold: i64) -> i64 { let n_usize = n as usize; let inf: i64 = 1_000_000_000; let mut dist: Vec<Vec<i64>> = Vec::new(); let mut i: usize = 0; while i < n_usize { let mut row: Vec<i64> = Vec::new(); let mut j: usize = 0; ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [find_the_city]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter....
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [find_the_city]: function definitions module public import Aeneas public import Aegis.FindTheCity.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.FindTheCity.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.FindTheCity.find_the_city 3#i64 (Slice.from [(alloc.vec.Vec.from [0#i64, 1#i64, 5#i64] (by scalar_tac) : alloc.vec.Vec Std.I64), (alloc.vec.Vec.from ...
[ { "input": "[3, [[0, 1, 5], [1, 2, 5], [0, 2, 5]], 10]", "output": "2" }, { "input": "[4, [[0, 1, 3], [1, 2, 1], [1, 3, 4], [2, 3, 1]], 4]", "output": "3" }, { "input": "[5, [[0, 1, 2], [0, 4, 8], [1, 2, 3], [1, 4, 2], [2, 3, 1], [3, 4, 1]], 2]", "output": "0" }, { "input": "...
61
false
61
verified
10
10
1
1,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.FindTheCity.Code.Funs /-! # Specifications of `Aegis.FindTheCity.find_the_city` LeetCode problem `find-the-city-with-the-smallest-number-of-neighbors-at-a-threshold-distance`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.FindTheCity ...
9
minimum-difficulty-of-a-job-schedule
1,335
Hard
[ "Array", "Dynamic Programming" ]
You want to schedule a list of jobs in d days. Jobs are dependent (i.e To work on the ith job, you have to finish all the jobs j where 0 <= j < i). You have to finish at least one task every day. The difficulty of a job schedule is the sum of difficulties of each day of the d days. The difficulty of a day is the maximu...
minDifficulty(jobDifficulty: list_int, d: int) -> int
pub fn min_difficulty(jobDifficulty: &[i64], d: i64) -> i64
Aegis.MinDifficulty.min_difficulty
pub fn min_difficulty(jobDifficulty: &[i64], d: i64) -> i64 { let n: usize = jobDifficulty.len(); if d <= 0 { return -1; } let mut days: usize = 0; let mut t: i64 = 0; while t < d { days += 1; t += 1; } if days > n { return -1; } let inf: i64 =...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [min_difficulty]: type definitions module public import Aeneas @[expose] public section 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 -- [min_difficulty]: function definitions module public import Aeneas public import Aegis.MinDifficulty.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.MinDifficulty.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.MinDifficulty.min_difficulty (Slice.from [1#i64] (by scalar_tac) : Slice Std.I64) 1#i64) (1#i64))}") #eval (s!"CASE 1 {(Result.reducesTo (Aegis.Min...
[ { "input": "[[1], 1]", "output": "1" }, { "input": "[[1, 2], 2]", "output": "3" }, { "input": "[[300, 500, 1000], 3]", "output": "1800" }, { "input": "[[100, 200, 300], 1]", "output": "300" }, { "input": "[[3, 2, 1], 1]", "output": "3" }, { "input": "[...
111
false
111
verified
10
10
1
4,403
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MinDifficulty.Code.Funs /-! # Specifications of `Aegis.MinDifficulty.min_difficulty` LeetCode problem `minimum-difficulty-of-a-job-schedule`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.MinDifficulty namespace AegisSpec.MinDifficulty d...
10
reduce-array-size-to-the-half
1,338
Medium
[ "Greedy", "Array", "Hash Table", "Sorting", "Heap (Priority Queue)" ]
You are given an integer array arr. You can choose a set of integers and remove all the occurrences of these integers in the array. Return the minimum size of the set so that at least half of the integers of the array are removed.   Example 1: Input: arr = [3,3,3,3,5,5,5,2,2,7] Output: 2 Explanation: Choosing {3,7} wi...
minSetSize(arr: list_int) -> int
pub fn min_set_size(arr: &[i64]) -> i64
Aegis.MinSetSize.min_set_size
pub fn min_set_size(arr: &[i64]) -> i64 { let n: usize = arr.len(); if n == 0 { return 0; } let mut maxv: i64 = 0; let mut i: usize = 0; while i < n { let x = arr[i]; if x > maxv { maxv = x; } i += 1; } let m: usize = (maxv + 1) as us...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [min_set_size]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter.s...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [min_set_size]: function definitions module public import Aeneas public import Aegis.MinSetSize.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option li...
import Aegis.MinSetSize.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.MinSetSize.min_set_size (Slice.from [7#i64, 7#i64, 7#i64, 7#i64, 7#i64, 7#i64] (by scalar_tac) : Slice Std.I64)) (1#i64))}") #eval (s!"CASE 1 {(Result...
[ { "input": "[[7, 7, 7, 7, 7, 7]]", "output": "1" }, { "input": "[[10, 10, 20, 20, 20, 30, 30, 30, 30, 30]]", "output": "1" }, { "input": "[[3, 3, 3, 3, 5, 5, 5, 2, 2, 7]]", "output": "2" }, { "input": "[[1, 2, 2, 3, 3, 3, 4, 4, 4, 4]]", "output": "2" }, { "input":...
85
false
85
verified
10
10
1
3,184
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MinSetSize.Code.Funs /-! # Specifications of `Aegis.MinSetSize.min_set_size` LeetCode problem `reduce-array-size-to-the-half`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.MinSetSize def vals (arr : Slice I64) : List ℤ := arr.val...
13
maximum-product-of-splitted-binary-tree
1,339
Medium
[ "Tree", "Depth-First Search", "Binary Tree" ]
Given the root of a binary tree, split the binary tree into two subtrees by removing one edge such that the product of the sums of the subtrees is maximized. Return the maximum product of the sums of the two subtrees. Since the answer may be too large, return it modulo 109 + 7. Note that you need to maximize the answer...
maxProduct(root: tree) -> int
pub fn max_product(root: &Tree) -> i64
Aegis.MaxProduct.max_product
pub fn max_product(root: &Tree) -> i64 { let total = sum_tree(root); let mut best: i64 = 0; traverse(root, total, &mut best, true); best % 1_000_000_007 } fn sum_tree(t: &Tree) -> i64 { match t { Tree::Null => 0, Tree::Node(v, l, r) => *v + sum_tree(l) + sum_tree(r), } } fn tra...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [max_product]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter.st...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [max_product]: function definitions module public import Aeneas public import Aegis.MaxProduct.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option lin...
import Aegis.MaxProduct.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.MaxProduct.max_product ((.Node 1#i64 (.Node 2#i64 (.Null) (.Null)) (.Node 3#i64 (.Null) (.Null))) : Aegis.MaxProduct.Tree)) (9#i64))}") #eval (s!"CASE...
[ { "input": "[[1, 2, 3]]", "output": "9" }, { "input": "[[1, 2, 3, 4, 5, 6]]", "output": "110" }, { "input": "[[100, 50, 150, 25, 75, 125, 175, 10, 30, 60, 80, 110, 130, 160, 180]]", "output": "486675" }, { "input": "[[5000, 2500, 7500, 1250, 3750, 6250, 8750, 625, 1875, 2500,...
33
false
33
verified
10
10
1
4,557
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MaxProduct.Code.Funs /-! # Specifications of `Aegis.MaxProduct.max_product` LeetCode problem `maximum-product-of-splitted-binary-tree`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.MaxProduct open Aegis.MaxProduct (Tree) def M...
11
jump-game-v
1,340
Hard
[ "Array", "Dynamic Programming", "Sorting" ]
Given an array of integers arr and an integer d. In one step you can jump from index i to index: i + x where: i + x < arr.length and 0 < x <= d. i - x where: i - x >= 0 and 0 < x <= d. In addition, you can only jump from index i to index j if arr[i] > arr[j] and arr[i] > arr[k] for all indices k between i and j (Mo...
maxJumps(arr: list_int, d: int) -> int
pub fn max_jumps(arr: &[i64], d: i64) -> i64
Aegis.MaxJumps.max_jumps
pub fn max_jumps(arr: &[i64], d: i64) -> i64 { let n: usize = arr.len(); if n == 0 { return 0; } let mut order: Vec<usize> = Vec::new(); let mut i: usize = 0; while i < n { order.push(i); i += 1; } // Insertion-sort indices by arr[index] in nondecreasing order. ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [max_jumps]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter.styl...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [max_jumps]: function definitions module public import Aeneas public import Aegis.MaxJumps.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.MaxJumps.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.MaxJumps.max_jumps (Slice.from [1#i64, 2#i64, 3#i64, 4#i64, 5#i64] (by scalar_tac) : Slice Std.I64) 4#i64) (5#i64))}") #eval (s!"CASE 1 {(Result.reduces...
[ { "input": "[[1, 2, 3, 4, 5], 4]", "output": "5" }, { "input": "[[1, 2, 3, 4, 5], 2]", "output": "5" }, { "input": "[[3, 3, 3, 3, 3], 3]", "output": "1" }, { "input": "[[5, 4, 3, 2, 1], 4]", "output": "5" }, { "input": "[[5, 4, 3, 2, 1], 1]", "output": "5" }...
122
false
122
verified
10
10
1
5,641
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MaxJumps.Code.Funs /-! # Specifications of `Aegis.MaxJumps.max_jumps` LeetCode problem `jump-game-v`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.MaxJumps namespace AegisSpec.MaxJumps def entry (arr : Slice I64) (i : Nat) : Int := (arr...
14
number-of-steps-to-reduce-a-number-to-zero
1,342
Easy
[ "Bit Manipulation", "Math" ]
Given an integer num, return the number of steps to reduce it to zero. In one step, if the current number is even, you have to divide it by 2, otherwise, you have to subtract 1 from it.   Example 1: Input: num = 14 Output: 6 Explanation:  Step 1) 14 is even; divide by 2 and obtain 7.  Step 2) 7 is odd; subtract 1 and ...
numberOfSteps(num: int) -> int
pub fn number_of_steps(num: i64) -> i64
Aegis.NumberOfSteps.number_of_steps
pub fn number_of_steps(num: i64) -> i64 { let mut n = num; let mut steps: i64 = 0; while n > 0 { if n % 2 == 0 { n = n / 2; } else { n = n - 1; } steps = steps + 1; } steps }
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [number_of_steps]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linte...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [number_of_steps]: function definitions module public import Aeneas public import Aegis.NumberOfSteps.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.NumberOfSteps.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.NumberOfSteps.number_of_steps 14#i64) (6#i64))}") #eval (s!"CASE 1 {(Result.reducesTo (Aegis.NumberOfSteps.number_of_steps 1000000#i64) (26#i64))}"...
[ { "input": "[14]", "output": "6" }, { "input": "[1000000]", "output": "26" }, { "input": "[8]", "output": "4" }, { "input": "[65535]", "output": "31" }, { "input": "[0]", "output": "0" }, { "input": "[2]", "output": "2" }, { "input": "[1]",...
59
false
59
verified
10
10
1
107
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.NumberOfSteps.Code.Funs /-! # Specifications of `Aegis.NumberOfSteps.number_of_steps` LeetCode problem `number-of-steps-to-reduce-a-number-to-zero`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.NumberOfSteps (number_of_steps) namespace Aeg...
16
number-of-sub-arrays-of-size-k-and-average-greater-than-or-equal-to-threshold
1,343
Medium
[ "Array", "Sliding Window" ]
Given an array of integers arr and two integers k and threshold, return the number of sub-arrays of size k and average greater than or equal to threshold.   Example 1: Input: arr = [2,2,2,2,5,5,5,8], k = 3, threshold = 4 Output: 3 Explanation: Sub-arrays [2,5,5],[5,5,5] and [5,5,8] have averages 4, 5 and 6 respectivel...
numOfSubarrays(arr: list_int, k: int, threshold: int) -> int
pub fn num_of_subarrays(arr: &[i64], k: i64, threshold: i64) -> i64
Aegis.NumOfSubarrays.num_of_subarrays
pub fn num_of_subarrays(arr: &[i64], k: i64, threshold: i64) -> i64 { let n: usize = arr.len(); if k <= 0 { return 0; } let k_usize: usize = k as usize; if k_usize > n { return 0; } let target: i64 = k * threshold; let mut sum: i64 = 0; let mut i: usize = 0; ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [num_of_subarrays]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option lint...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [num_of_subarrays]: function definitions module public import Aeneas public import Aegis.NumOfSubarrays.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.NumOfSubarrays.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.NumOfSubarrays.num_of_subarrays (Slice.from [10000#i64, 10000#i64, 10000#i64] (by scalar_tac) : Slice Std.I64) 3#i64 10000#i64) (1#i64))}") #eval ...
[ { "input": "[[10000, 10000, 10000], 3, 10000]", "output": "1" }, { "input": "[[1, 2, 3, 4, 5], 2, 3]", "output": "2" }, { "input": "[[10000, 10000, 10000, 10000, 10000], 1, 10000]", "output": "5" }, { "input": "[[10, 20, 30, 40, 50], 1, 10]", "output": "5" }, { "i...
101
false
101
verified
10
10
1
859
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.NumOfSubarrays.Code.Funs /-! # Specifications of `Aegis.NumOfSubarrays.num_of_subarrays` LeetCode problem `number-of-sub-arrays-of-size-k-and-average-greater-than-or-equal-to-threshold`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec....
16
jump-game-iv
1,345
Hard
[ "Breadth-First Search", "Array", "Hash Table" ]
Given an array of integers arr, you are initially positioned at the first index of the array. In one step you can jump from index i to index: i + 1 where: i + 1 < arr.length. i - 1 where: i - 1 >= 0. j where: arr[i] == arr[j] and i != j. Return the minimum number of steps to reach the last index of the array. Notice ...
minJumps(arr: list_int) -> int
pub fn min_jumps(arr: &[i64]) -> i64
Aegis.MinJumps.min_jumps
fn filled_i64(n: usize, x: i64) -> Vec<i64> { let mut v: Vec<i64> = Vec::new(); let mut i: usize = 0; while i < n { v.push(x); i += 1; } v } fn bytes_zero(n: usize) -> Vec<u8> { let mut v: Vec<u8> = Vec::new(); let mut i: usize = 0; while i < n { v.push(0); ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [min_jumps]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter.styl...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [min_jumps]: function definitions module public import Aeneas public import Aegis.MinJumps.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.MinJumps.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.MinJumps.min_jumps (Slice.from [7#i64] (by scalar_tac) : Slice Std.I64)) (0#i64))}") #eval (s!"CASE 1 {(Result.reducesTo (Aegis.MinJumps.min_jumps (Slic...
[ { "input": "[[7]]", "output": "0" }, { "input": "[[1, 2, 3, 4, 3, 2, 1]]", "output": "1" }, { "input": "[[7, 6, 9, 6, 9, 6, 9, 7]]", "output": "1" }, { "input": "[[10, 20, 30, 20, 10, 10, 20, 30, 10]]", "output": "1" }, { "input": "[[6, 1, 9, 6, 9, 1, 9, 6, 1, 9]]...
60
false
60
verified
10
10
2
20,590
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MinJumps.Code.Funs /-! # Specifications of `Aegis.MinJumps.min_jumps` LeetCode problem `jump-game-iv`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.MinJumps def value (arr : Slice Std.I64) (i : ℕ) : ℤ := ((arr.val[i]?).map (fun x =...
12
check-if-n-and-its-double-exist
1,346
Easy
[ "Array", "Hash Table", "Two Pointers", "Binary Search", "Sorting" ]
Given an array arr of integers, check if there exist two indices i and j such that : i != j 0 <= i, j < arr.length arr[i] == 2 * arr[j]   Example 1: Input: arr = [10,2,5,3] Output: true Explanation: For i = 0 and j = 2, arr[i] == 10 == 2 * 5 == 2 * arr[j] Example 2: Input: arr = [3,1,7,11] Output: false Explanatio...
checkIfExist(arr: list_int) -> bool
pub fn check_if_exist(arr: &[i64]) -> bool
Aegis.CheckIfExist.check_if_exist
pub fn check_if_exist(arr: &[i64]) -> bool { let n = arr.len(); let mut found: bool = false; let mut i: usize = 0; while i < n && !found { let mut j: usize = 0; while j < n && !found { if i != j && arr[i] == 2 * arr[j] { found = true; } ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [check_if_exist]: type definitions module public import Aeneas @[expose] public section 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 -- [check_if_exist]: function definitions module public import Aeneas public import Aegis.CheckIfExist.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_optio...
import Aegis.CheckIfExist.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.CheckIfExist.check_if_exist (Slice.from [0#i64, 0#i64] (by scalar_tac) : Slice Std.I64)) (true))}") #eval (s!"CASE 1 {(Result.reducesTo (Aegis.Check...
[ { "input": "[[0, 0]]", "output": "true" }, { "input": "[[-10, 10]]", "output": "false" }, { "input": "[[-10, -20, -5, -3]]", "output": "true" }, { "input": "[[10, 2, 5, 3]]", "output": "true" }, { "input": "[[3, 1, 7, 11]]", "output": "false" }, { "inp...
144
false
144
verified
10
10
2
584
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.CheckIfExist.Code.Funs /-! # Specifications of `Aegis.CheckIfExist.check_if_exist` LeetCode problem `check-if-n-and-its-double-exist`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.CheckIfExist namespace AegisSpec.CheckIfExist def contents (ar...
9
count-negative-numbers-in-a-sorted-matrix
1,351
Easy
[ "Array", "Binary Search", "Matrix" ]
Given a m x n matrix grid which is sorted in non-increasing order both row-wise and column-wise, return the number of negative numbers in grid.   Example 1: Input: grid = [[4,3,2,-1],[3,2,1,-1],[1,1,-1,-2],[-1,-1,-2,-3]] Output: 8 Explanation: There are 8 negatives number in the matrix. Example 2: Input: grid = [[3,...
countNegatives(grid: list_list_int) -> int
pub fn count_negatives(grid: &[Vec<i64>]) -> i64
Aegis.CountNegatives.count_negatives
pub fn count_negatives(grid: &[Vec<i64>]) -> i64 { let m = grid.len(); if m == 0 { return 0; } let n = grid[0].len(); if n == 0 { return 0; } let mut i: usize = m - 1; let mut j: usize = 0; let mut count: i64 = 0; let mut done: bool = false; while !done { ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [count_negatives]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linte...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [count_negatives]: function definitions module public import Aeneas public import Aegis.CountNegatives.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.CountNegatives.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.CountNegatives.count_negatives (Slice.from [(alloc.vec.Vec.from [1#i64] (by scalar_tac) : alloc.vec.Vec Std.I64)] (by scalar_tac) : Slice (alloc.v...
[ { "input": "[[[1]]]", "output": "0" }, { "input": "[[[-5]]]", "output": "1" }, { "input": "[[[-1]]]", "output": "1" }, { "input": "[[[-1, -1], [-1, -1]]]", "output": "4" }, { "input": "[[[3, 2], [1, 0]]]", "output": "0" }, { "input": "[[[1, -1], [-1, -...
96
false
96
verified
10
10
2
10,459
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.CountNegatives.Code.Funs /-! # Specifications of `Aegis.CountNegatives.count_negatives` LeetCode problem `count-negative-numbers-in-a-sorted-matrix`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.CountNegatives def rows (grid : Sl...
9
construct-target-array-with-multiple-sums
1,354
Hard
[ "Array", "Heap (Priority Queue)" ]
You are given an array target of n integers. From a starting array arr consisting of n 1's, you may perform the following procedure : let x be the sum of all elements currently in your array. choose index i, such that 0 <= i < n and set the value of arr at index i to x. You may repeat this procedure as many times as n...
isPossible(target: list_int) -> bool
pub fn is_possible(target: &[i64]) -> bool
Aegis.IsPossible.is_possible
pub fn is_possible(target: &[i64]) -> bool { let n = target.len(); let mut a: Vec<i64> = Vec::new(); let mut sum: i64 = 0; let mut i: usize = 0; while i < n { let v = target[i]; a.push(v); sum = sum + v; i += 1; } if n == 0 { return false; } ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [is_possible]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter.st...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [is_possible]: function definitions module public import Aeneas public import Aegis.IsPossible.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option lin...
import Aegis.IsPossible.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.IsPossible.is_possible (Slice.from [10#i64, 1#i64] (by scalar_tac) : Slice Std.I64)) (true))}") #eval (s!"CASE 1 {(Result.reducesTo (Aegis.IsPossible....
[ { "input": "[[10, 1]]", "output": "true" }, { "input": "[[1000000000, 1000000000]]", "output": "false" }, { "input": "[[1000000000, 1]]", "output": "true" }, { "input": "[[2, 900000000]]", "output": "false" }, { "input": "[[8, 5]]", "output": "true" }, { ...
99
false
99
verified
10
10
1
11,533
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.IsPossible.Code.Funs /-! # Specifications of `Aegis.IsPossible.is_possible` LeetCode problem `construct-target-array-with-multiple-sums`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.IsPossible (is_possible) namespace AegisSpec.IsPossible def...
15
sort-integers-by-the-number-of-1-bits
1,356
Easy
[ "Bit Manipulation", "Array", "Counting", "Sorting" ]
You are given an integer array arr. Sort the integers in the array in ascending order by the number of 1's in their binary representation and in case of two or more integers have the same number of 1's you have to sort them in ascending order. Return the array after sorting it.   Example 1: Input: arr = [0,1,2,3,4,5,6...
sortByBits(arr: list_int) -> list_int
pub fn sort_by_bits(arr: &[i64]) -> Vec<i64>
Aegis.SortByBits.sort_by_bits
pub fn sort_by_bits(arr: &[i64]) -> Vec<i64> { let mut v: Vec<i64> = Vec::new(); let mut i: usize = 0; while i < arr.len() { v.push(arr[i]); i += 1; } let n = v.len(); let mut i: usize = 1; while i < n { let key = v[i]; let mut j = i; while j > 0 && c...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [sort_by_bits]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter.s...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [sort_by_bits]: function definitions module public import Aeneas public import Aegis.SortByBits.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option li...
import Aegis.SortByBits.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.SortByBits.sort_by_bits (Slice.from [3#i64, 7#i64, 8#i64, 9#i64] (by scalar_tac) : Slice Std.I64)) ((alloc.vec.Vec.from [8#i64, 3#i64, 9#i64, 7#i64] (...
[ { "input": "[[3, 7, 8, 9]]", "output": "[8, 3, 9, 7]" }, { "input": "[[10, 100, 1000, 10000]]", "output": "[10, 100, 10000, 1000]" }, { "input": "[[1, 3, 5, 7, 9]]", "output": "[1, 3, 5, 9, 7]" }, { "input": "[[1, 0, 2, 3, 4]]", "output": "[0, 1, 2, 4, 3]" }, { "i...
96
false
96
verified
10
10
1
2,324
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.SortByBits.Code.Funs /-! # Specifications of `Aegis.SortByBits.sort_by_bits` LeetCode problem `sort-integers-by-the-number-of-1-bits`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.SortByBits open Aegis.SortByBits def onesNat (...
12
number-of-substrings-containing-all-three-characters
1,358
Medium
[ "Hash Table", "String", "Sliding Window" ]
Given a string s consisting only of characters a, b and c. Return the number of substrings containing at least one occurrence of all these characters a, b and c.   Example 1: Input: s = "abcabc" Output: 10 Explanation: The substrings containing at least one occurrence of the characters a, b and c are "abc", "abca", "a...
numberOfSubstrings(s: str) -> int
pub fn number_of_substrings(s: &[u8]) -> i64
Aegis.NumberOfSubstrings.number_of_substrings
pub fn number_of_substrings(s: &[u8]) -> i64 { let n = s.len(); let mut left: usize = 0; let mut count_a: usize = 0; let mut count_b: usize = 0; let mut count_c: usize = 0; let mut total: i64 = 0; let mut right: usize = 0; while right < n { let ch = s[right]; if ch == b'...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [number_of_substrings]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [number_of_substrings]: function definitions module public import Aeneas public import Aegis.NumberOfSubstrings.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand fal...
import Aegis.NumberOfSubstrings.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.NumberOfSubstrings.number_of_substrings (Slice.from [97#u8, 97#u8, 97#u8, 98#u8, 98#u8, 98#u8, 99#u8, 99#u8, 99#u8] (by scalar_tac) : Slice St...
[ { "input": "[\"aaabbbccc\"]", "output": "9" }, { "input": "[\"abcba\"]", "output": "5" }, { "input": "[\"cba\"]", "output": "1" }, { "input": "[\"cbaacb\"]", "output": "8" }, { "input": "[\"bbbacbac\"]", "output": "18" }, { "input": "[\"ccccabc\"]", ...
130
false
130
verified
10
10
1
2,348
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.NumberOfSubstrings.Code.Funs /-! # Specifications of `Aegis.NumberOfSubstrings.number_of_substrings` LeetCode problem `number-of-substrings-containing-all-three-characters`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.NumberOfSubst...
14
count-all-valid-pickup-and-delivery-options
1,359
Hard
[ "Math", "Dynamic Programming", "Combinatorics" ]
Given n orders, each order consists of a pickup and a delivery service. Count all valid pickup/delivery possible sequences such that delivery(i) is always after of pickup(i).  Since the answer may be too large, return it modulo 10^9 + 7.   Example 1: Input: n = 1 Output: 1 Explanation: Unique order (P1, D1), Delivery ...
countOrders(n: int) -> int
pub fn count_orders(n: i64) -> i64
Aegis.CountOrders.count_orders
pub fn count_orders(n: i64) -> i64 { let modulo: i64 = 1000000007; let mut ans: i64 = 1; let mut i: i64 = 1; while i <= n { ans = (ans * i) % modulo; ans = (ans * (2 * i - 1)) % modulo; i += 1; } ans }
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [count_orders]: type definitions module public import Aeneas @[expose] public section 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 -- [count_orders]: function definitions module public import Aeneas public import Aegis.CountOrders.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.CountOrders.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.CountOrders.count_orders 3#i64) (90#i64))}") #eval (s!"CASE 1 {(Result.reducesTo (Aegis.CountOrders.count_orders 250#i64) (418733499#i64))}") #eval (...
[ { "input": "[3]", "output": "90" }, { "input": "[250]", "output": "418733499" }, { "input": "[100]", "output": "14159051" }, { "input": "[4]", "output": "2520" }, { "input": "[2]", "output": "6" }, { "input": "[20]", "output": "580270580" }, { ...
32
false
32
verified
10
10
1
518
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.CountOrders.Code.Funs /-! # Specifications of `Aegis.CountOrders.count_orders` LeetCode problem `count-all-valid-pickup-and-delivery-options`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.CountOrders def modulus : Nat := 10000000...
7
number-of-days-between-two-dates
1,360
Easy
[ "Math", "String" ]
Write a program to count the number of days between two dates. The two dates are given as strings, their format is YYYY-MM-DD as shown in the examples.   Example 1: Input: date1 = "2019-06-29", date2 = "2019-06-30" Output: 1 Example 2: Input: date1 = "2020-01-15", date2 = "2019-12-31" Output: 15   Constraints: The gi...
daysBetweenDates(date1: str, date2: str) -> int
pub fn days_between_dates(date1: &[u8], date2: &[u8]) -> i64
Aegis.DaysBetweenDates.days_between_dates
fn is_leap_year(y: i64) -> bool { if y % 400 == 0 { return true; } if y % 100 == 0 { return false; } if y % 4 == 0 { return true; } false } fn days_in_month(y: i64, m: i64) -> i64 { if m == 2 { if is_leap_year(y) { return 29; } else { ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [days_between_dates]: type definitions module public import Aeneas @[expose] public section 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 -- [days_between_dates]: function definitions module public import Aeneas public import Aegis.DaysBetweenDates.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.DaysBetweenDates.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.DaysBetweenDates.days_between_dates (Slice.from [50#u8, 48#u8, 49#u8, 57#u8, 45#u8, 48#u8, 50#u8, 45#u8, 50#u8, 56#u8] (by scalar_tac) : Slice S...
[ { "input": "[\"2019-02-28\", \"2019-03-01\"]", "output": "1" }, { "input": "[\"2020-01-15\", \"2019-12-31\"]", "output": "15" }, { "input": "[\"2000-03-01\", \"2000-02-29\"]", "output": "1" }, { "input": "[\"2023-10-01\", \"2023-10-02\"]", "output": "1" }, { "inpu...
138
false
138
verified
10
10
1
2,252
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.DaysBetweenDates.Code.Funs /-! # Specifications of `Aegis.DaysBetweenDates.days_between_dates` LeetCode problem `number-of-days-between-two-dates`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.DaysBetweenDates namespace AegisSpec.DaysBetweenD...
10
validate-binary-tree-nodes
1,361
Medium
[ "Tree", "Depth-First Search", "Breadth-First Search", "Union Find", "Graph", "Binary Tree" ]
You have n binary tree nodes numbered from 0 to n - 1 where node i has two children leftChild[i] and rightChild[i], return true if and only if all the given nodes form exactly one valid binary tree. If node i has no left child then leftChild[i] will equal -1, similarly for the right child. Note that the nodes have no v...
validateBinaryTreeNodes(n: int, leftChild: list_int, rightChild: list_int) -> bool
pub fn validate_binary_tree_nodes(n: i64, leftChild: &[i64], rightChild: &[i64]) -> bool
Aegis.ValidateBinaryTreeNodes.validate_binary_tree_nodes
pub fn validate_binary_tree_nodes(n: i64, leftChild: &[i64], rightChild: &[i64]) -> bool { if n <= 0 { return false; } let nn: usize = n as usize; if leftChild.len() != nn || rightChild.len() != nn { return false; } // indegree[i] = number of parents pointing at node i. // p...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [validate_binary_tree_nodes]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_o...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [validate_binary_tree_nodes]: function definitions module public import Aeneas public import Aegis.ValidateBinaryTreeNodes.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hash...
import Aegis.ValidateBinaryTreeNodes.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.ValidateBinaryTreeNodes.validate_binary_tree_nodes 1#i64 (Slice.from [(-1)#i64] (by scalar_tac) : Slice Std.I64) (Slice.from [(-1)#i64] (...
[ { "input": "[1, [-1], [-1]]", "output": "true" }, { "input": "[2, [1, 0], [-1, -1]]", "output": "false" }, { "input": "[3, [1, -1, -1], [2, -1, -1]]", "output": "true" }, { "input": "[3, [1, 0, -1], [-1, -1, -1]]", "output": "false" }, { "input": "[3, [1, 2, -1], ...
137
false
137
verified
10
10
3
41,388
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.ValidateBinaryTreeNodes.Code.Funs /-! # Specifications of `Aegis.ValidateBinaryTreeNodes.validate_binary_tree_nodes` LeetCode problem `validate-binary-tree-nodes`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.ValidateBinaryTreeNodes ...
8
how-many-numbers-are-smaller-than-the-current-number
1,365
Easy
[ "Array", "Hash Table", "Counting Sort", "Sorting" ]
Given the array nums, for each nums[i] find out how many numbers in the array are smaller than it. That is, for each nums[i] you have to count the number of valid j's such that j != i and nums[j] < nums[i]. Return the answer in an array.   Example 1: Input: nums = [8,1,2,2,3] Output: [4,0,1,1,3] Explanation: For nums...
smallerNumbersThanCurrent(nums: list_int) -> list_int
pub fn smaller_numbers_than_current(nums: &[i64]) -> Vec<i64>
Aegis.SmallerNumbersThanCurrent.smaller_numbers_than_current
pub fn smaller_numbers_than_current(nums: &[i64]) -> Vec<i64> { let mut ans: Vec<i64> = Vec::new(); let n = nums.len(); let mut i: usize = 0; while i < n { let mut count: i64 = 0; let mut j: usize = 0; while j < n { if nums[j] < nums[i] { count += 1;...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [smaller_numbers_than_current]: type definitions module public import Aeneas @[expose] public 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 -- [smaller_numbers_than_current]: function definitions module public import Aeneas public import Aegis.SmallerNumbersThanCurrent.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter....
import Aegis.SmallerNumbersThanCurrent.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.SmallerNumbersThanCurrent.smaller_numbers_than_current (Slice.from [100#i64, 99#i64, 98#i64, 97#i64] (by scalar_tac) : Slice Std.I64)) ...
[ { "input": "[[100, 99, 98, 97]]", "output": "[3, 2, 1, 0]" }, { "input": "[[6, 5, 4, 8]]", "output": "[2, 1, 0, 3]" }, { "input": "[[0, 0, 0, 1]]", "output": "[0, 0, 0, 3]" }, { "input": "[[7, 7, 7, 7]]", "output": "[0, 0, 0, 0]" }, { "input": "[[8, 1, 2, 2, 3]]",...
110
false
110
verified
10
10
1
348
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.SmallerNumbersThanCurrent.Code.Funs /-! # Specifications of `Aegis.SmallerNumbersThanCurrent.smaller_numbers_than_current` LeetCode problem `how-many-numbers-are-smaller-than-the-current-number`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.S...
15
linked-list-in-binary-tree
1,367
Medium
[ "Tree", "Depth-First Search", "Linked List", "Binary Tree" ]
Given a binary tree root and a linked list with head as the first node.  Return True if all the elements in the linked list starting from the head correspond to some downward path connected in the binary tree otherwise return False. In this context downward path means a path that starts at some node and goes downwards....
isSubPath(head: linkedlist, root: tree) -> bool
pub fn is_sub_path(head: &List, root: &Tree) -> bool
Aegis.IsSubPath.is_sub_path
fn matches(list: &List, tree: &Tree) -> bool { match list { List::Nil => true, List::Cons(v, next) => match tree { Tree::Null => false, Tree::Node(tv, left, right) => { if *v == *tv { matches(&**next, &**left) || matches(&**next, &**right) ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [is_sub_path]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter.st...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [is_sub_path]: function definitions module public import Aeneas public import Aegis.IsSubPath.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option lint...
import Aegis.IsSubPath.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.IsSubPath.is_sub_path ((.Cons 1#i64 (.Cons 2#i64 (.Cons 3#i64 (.Cons 4#i64 (.Cons 5#i64 (.Cons 6#i64 (.Cons 7#i64 (.Nil)))))))) : Aegis.IsSubPath.List)...
[ { "input": "[[1, 2, 3, 4, 5, 6, 7], [1, 2, 3, 4, 5, 6, 7]]", "output": "false" }, { "input": "[[7, 8, 9], [5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 1, 2, 3, 4]]", "output": "false" }, { "input": "[[5, 5, 5], [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]]", "output": "true" }, { ...
32
false
32
verified
10
10
1
3,376
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.IsSubPath.Code.Funs /-! # Specifications of `Aegis.IsSubPath.is_sub_path` LeetCode problem `linked-list-in-binary-tree`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace Aegis.IsSubPath def List.val : List → _root_.List ℤ | .Nil => [] ...
7
minimum-cost-to-make-at-least-one-valid-path-in-a-grid
1,368
Hard
[ "Breadth-First Search", "Graph", "Array", "Matrix", "Shortest Path", "Heap (Priority Queue)" ]
Given an m x n grid. Each cell of the grid has a sign pointing to the next cell you should visit if you are currently in this cell. The sign of grid[i][j] can be: 1 which means go to the cell to the right. (i.e go from grid[i][j] to grid[i][j + 1]) 2 which means go to the cell to the left. (i.e go from grid[i][j] to g...
minCost(grid: list_list_int) -> int
pub fn min_cost(grid: &[Vec<i64>]) -> i64
Aegis.MinCost.min_cost
pub fn min_cost(grid: &[Vec<i64>]) -> i64 { let m = grid.len(); if m == 0 { return 0; } let n = grid[0].len(); if n == 0 { return 0; } let total = m * n; let inf: i64 = 1000000000; // dist[v] = current best cost to reach cell v let mut dist: Vec<i64> = Vec::new(...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [min_cost]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter.style...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [min_cost]: function definitions module public import Aeneas public import Aegis.MinCost.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.un...
import Aegis.MinCost.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.MinCost.min_cost (Slice.from [(alloc.vec.Vec.from [1#i64, 2#i64] (by scalar_tac) : alloc.vec.Vec Std.I64), (alloc.vec.Vec.from [4#i64, 3#i64] (by scalar_...
[ { "input": "[[[1, 2], [4, 3]]]", "output": "1" }, { "input": "[[[1, 1, 1], [1, 1, 1], [1, 1, 1]]]", "output": "2" }, { "input": "[[[4, 4, 4], [4, 4, 4], [4, 4, 4]]]", "output": "4" }, { "input": "[[[4, 2, 3], [1, 2, 1], [1, 2, 4]]]", "output": "3" }, { "input": "[...
87
false
87
verified
10
10
3
21,511
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MinCost.Code.Funs /-! # Specifications of `Aegis.MinCost.min_cost` LeetCode problem `minimum-cost-to-make-at-least-one-valid-path-in-a-grid`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.MinCost abbrev Grid := Slice (alloc.vec.Ve...
12
find-the-longest-substring-containing-vowels-in-even-counts
1,371
Medium
[ "Bit Manipulation", "Hash Table", "String", "Prefix Sum" ]
Given the string s, return the size of the longest substring containing each vowel an even number of times. That is, 'a', 'e', 'i', 'o', and 'u' must appear an even number of times.   Example 1: Input: s = "eleetminicoworoep" Output: 13 Explanation: The longest substring is "leetminicowor" which contains two each of t...
findTheLongestSubstring(s: str) -> int
pub fn find_the_longest_substring(s: &[u8]) -> i64
Aegis.FindTheLongestSubstring.find_the_longest_substring
pub fn find_the_longest_substring(s: &[u8]) -> i64 { let mut first: Vec<i64> = Vec::new(); let mut k: usize = 0; while k < 32 { first.push(-1); k += 1; } first[0] = 0; let mut mask: usize = 0; let mut best: i64 = 0; let mut i: usize = 0; let n = s.len(); while ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [find_the_longest_substring]: type definitions module public import Aeneas @[expose] public 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 -- [find_the_longest_substring]: function definitions module public import Aeneas public import Aegis.FindTheLongestSubstring.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hash...
import Aegis.FindTheLongestSubstring.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.FindTheLongestSubstring.find_the_longest_substring (Slice.from [98#u8, 99#u8, 98#u8, 99#u8, 98#u8, 99#u8] (by scalar_tac) : Slice Std.U8)...
[ { "input": "[\"bcbcbc\"]", "output": "6" }, { "input": "[\"cbacdcdcdbacdbad\"]", "output": "14" }, { "input": "[\"aeiouaeiouaeiouaeiou\"]", "output": "20" }, { "input": "[\"aaaaaeeeeeiioooouuuu\"]", "output": "14" }, { "input": "[\"abcdefghijklmnopqrstuvwxyz\"]", ...
77
false
77
verified
10
10
1
1,256
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.FindTheLongestSubstring.Code.Funs /-! # Specifications of `Aegis.FindTheLongestSubstring.find_the_longest_substring` LeetCode problem `find-the-longest-substring-containing-vowels-in-even-counts`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace ...
11
longest-zigzag-path-in-a-binary-tree
1,372
Medium
[ "Tree", "Depth-First Search", "Dynamic Programming", "Binary Tree" ]
You are given the root of a binary tree. A ZigZag path for a binary tree is defined as follow: Choose any node in the binary tree and a direction (right or left). If the current direction is right, move to the right child of the current node; otherwise, move to the left child. Change the direction from right to left o...
longestZigZag(root: tree) -> int
pub fn longest_zig_zag(root: &Tree) -> i64
Aegis.LongestZigZag.longest_zig_zag
pub fn longest_zig_zag(root: &Tree) -> i64 { let code = dfs(root); code % 100000 } fn dfs(t: &Tree) -> i64 { match t { Tree::Null => 0, Tree::Node(_, left, right) => { let left_code = dfs(&**left); let right_code = dfs(&**right); let left_down = match &*...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [longest_zig_zag]: type definitions module public import Aeneas @[expose] public section 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 -- [longest_zig_zag]: function definitions module public import Aeneas public import Aegis.LongestZigZag.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.LongestZigZag.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.LongestZigZag.longest_zig_zag ((.Node 1#i64 (.Null) (.Null)) : Aegis.LongestZigZag.Tree)) (0#i64))}") #eval (s!"CASE 1 {(Result.reducesTo (Aegis.Lo...
[ { "input": "[[1]]", "output": "0" }, { "input": "[[1, 2, 3, 4, 5, 6, 7]]", "output": "2" }, { "input": "[[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]]", "output": "3" }, { "input": "[[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]]", "output...
6
false
6
verified
6
6
1
7,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.LongestZigZag.Code.Funs /-! # Specifications of `Aegis.LongestZigZag.longest_zig_zag` LeetCode problem `longest-zigzag-path-in-a-binary-tree`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.LongestZigZag open Aegis.LongestZigZag induc...
13
number-of-times-binary-string-is-prefix-aligned
1,375
Medium
[ "Array" ]
You have a 1-indexed binary string of length n where all the bits are 0 initially. We will flip all the bits of this binary string (i.e., change them from 0 to 1) one by one. You are given a 1-indexed integer array flips where flips[i] indicates that the bit at index i will be flipped in the ith step. A binary string i...
numTimesAllBlue(flips: list_int) -> int
pub fn num_times_all_blue(flips: &[i64]) -> i64
Aegis.NumTimesAllBlue.num_times_all_blue
pub fn num_times_all_blue(flips: &[i64]) -> i64 { let n = flips.len(); let mut max_flip: i64 = 0; let mut count: i64 = 0; let mut i: usize = 0; while i < n { let f = flips[i]; if f > max_flip { max_flip = f; } let step = (i as i64) + 1; if max_fl...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [num_times_all_blue]: type definitions module public import Aeneas @[expose] public section 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_times_all_blue]: function definitions module public import Aeneas public import Aegis.NumTimesAllBlue.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.NumTimesAllBlue.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.NumTimesAllBlue.num_times_all_blue (Slice.from [4#i64, 1#i64, 2#i64, 3#i64] (by scalar_tac) : Slice Std.I64)) (1#i64))}") #eval (s!"CASE 1 {(Resu...
[ { "input": "[[4, 1, 2, 3]]", "output": "1" }, { "input": "[[5, 4, 3, 2, 1]]", "output": "1" }, { "input": "[[1, 2, 3, 4, 5]]", "output": "5" }, { "input": "[[2, 1, 3, 5, 4]]", "output": "3" }, { "input": "[[3, 2, 4, 1, 5]]", "output": "2" }, { "input":...
91
false
91
verified
10
10
1
498
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.NumTimesAllBlue.Code.Funs /-! # Specifications of `Aegis.NumTimesAllBlue.num_times_all_blue` LeetCode problem `number-of-times-binary-string-is-prefix-aligned`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.NumTimesAllBlue def iotaInt...
10
time-needed-to-inform-all-employees
1,376
Medium
[ "Tree", "Depth-First Search", "Breadth-First Search" ]
A company has n employees with a unique ID for each employee from 0 to n - 1. The head of the company is the one with headID. Each employee has one direct manager given in the manager array where manager[i] is the direct manager of the i-th employee, manager[headID] = -1. Also, it is guaranteed that the subordination r...
numOfMinutes(n: int, headID: int, manager: list_int, informTime: list_int) -> int
pub fn num_of_minutes(n: i64, headID: i64, manager: &[i64], informTime: &[i64]) -> i64
Aegis.NumOfMinutes.num_of_minutes
pub fn num_of_minutes(n: i64, headID: i64, manager: &[i64], informTime: &[i64]) -> i64 { let n_usize = n as usize; let mut children: Vec<Vec<i64>> = Vec::new(); let mut i: usize = 0; while i < n_usize { let row: Vec<i64> = Vec::new(); children.push(row); i += 1; } let m...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [num_of_minutes]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [num_of_minutes]: function definitions module public import Aeneas public import Aegis.NumOfMinutes.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_optio...
import Aegis.NumOfMinutes.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.NumOfMinutes.num_of_minutes 1#i64 0#i64 (Slice.from [(-1)#i64] (by scalar_tac) : Slice Std.I64) (Slice.from [0#i64] (by scalar_tac) : Slice Std.I64)...
[ { "input": "[1, 0, [-1], [0]]", "output": "0" }, { "input": "[4, 2, [3, 3, -1, 2], [0, 0, 162, 954]]", "output": "1116" }, { "input": "[4, 2, [3, 3, -1, 2], [0, 0, 162, 956]]", "output": "1118" }, { "input": "[4, 2, [3, 3, -1, 2], [0, 0, 162, 914]]", "output": "1076" },...
43
false
43
verified
10
10
2
4,351
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.NumOfMinutes.Code.Funs /-! # Specifications of `Aegis.NumOfMinutes.num_of_minutes` LeetCode problem `time-needed-to-inform-all-employees`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.NumOfMinutes def values (s : Aeneas.Std.Slice...
8
lucky-numbers-in-a-matrix
1,380
Easy
[ "Array", "Matrix" ]
Given an m x n matrix of distinct numbers, return all lucky numbers in the matrix in any order. A lucky number is an element of the matrix such that it is the minimum element in its row and maximum in its column.   Example 1: Input: matrix = [[3,7,8],[9,11,13],[15,16,17]] Output: [15] Explanation: 15 is the only lucky...
luckyNumbers(matrix: list_list_int) -> list_int
pub fn lucky_numbers(matrix: &[Vec<i64>]) -> Vec<i64>
Aegis.LuckyNumbers.lucky_numbers
pub fn lucky_numbers(matrix: &[Vec<i64>]) -> Vec<i64> { let m = matrix.len(); if m == 0 { return Vec::new(); } let n = matrix[0].len(); if n == 0 { return Vec::new(); } let mut row_min: Vec<i64> = Vec::new(); let mut i = 0; while i < m { let row = &matrix[i]...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [lucky_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 linter....
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [lucky_numbers]: function definitions module public import Aeneas public import Aegis.LuckyNumbers.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.LuckyNumbers.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(match (Aegis.LuckyNumbers.lucky_numbers (Slice.from [(alloc.vec.Vec.from [1#i64] (by scalar_tac) : alloc.vec.Vec Std.I64)] (by scalar_tac) : Slice (alloc.vec.Vec Std.I64)))...
[ { "input": "[[[1]]]", "output": "[1]" }, { "input": "[[[40, 10], [24, 30]]]", "output": "[]" }, { "input": "[[[36376, 85652], [55712, 5396]]]", "output": "[]" }, { "input": "[[[7, 8], [1, 2]]]", "output": "[7]" }, { "input": "[[[3, 6], [7, 1], [5, 9]]]", "outp...
87
true
87
verified
10
10
1
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.LuckyNumbers.Code.Funs /-! # Specifications of `Aegis.LuckyNumbers.lucky_numbers` LeetCode problem `lucky-numbers-in-a-matrix`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.LuckyNumbers namespace AegisSpec.LuckyNumbers def numRows (matrix : S...
12
balance-a-binary-search-tree
1,382
Medium
[ "Greedy", "Tree", "Depth-First Search", "Binary Search Tree", "Divide and Conquer", "Binary Tree" ]
Given the root of a binary search tree, return a balanced binary search tree with the same node values. If there is more than one answer, return any of them. A binary search tree is balanced if the depth of the two subtrees of every node never differs by more than 1.   Example 1: Input: root = [1,null,2,null,3,null,4...
balanceBST(root: tree) -> tree
pub fn balance_bst(root: &Tree) -> Tree
Aegis.BalanceBst.balance_bst
fn inorder(t: &Tree, out: Vec<i64>) -> Vec<i64> { match t { Tree::Null => out, Tree::Node(v, l, r) => { let mut out = inorder(&**l, out); out.push(*v); inorder(&**r, out) } } } fn build_balanced(vals: &[i64]) -> Tree { let n = vals.len(); if n...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [balance_bst]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter.st...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [balance_bst]: function definitions module public import Aeneas public import Aegis.BalanceBst.Code.Types public import Aegis.BalanceBst.Code.FunsExternal @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false s...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [balance_bst]: external functions. -- This is a template file: rename it to "FunsExternal.lean" and fill the holes. module public import Aeneas public import Aegis.BalanceBst.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_opt...
import Aegis.BalanceBst.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 deriving instance DecidableEq for Aegis.BalanceBst.Tree #eval (s!"CASE 0 {(match (Aegis.BalanceBst.balance_bst ((.Node 2#i64 (.Node 1#i64 (.Null) (.Null)) (.Node 3#i64 (.Null) (.Null))) : Aegi...
[ { "input": "[[2, 1, 3]]", "output": "[2, 1, 3]" }, { "input": "[[1, 2, 3, 4]]", "output": "[2, 4, 1, null, null, null, 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, 12, 13, 14, 15]]", "ou...
22
false
22
verified
10
10
1
22,574
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.BalanceBst.Code.Funs /-! # Specifications of `Aegis.BalanceBst.balance_bst` LeetCode problem `balance-a-binary-search-tree`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.BalanceBst abbrev Tree := _root_.Aegis.BalanceBst.Tree def val...
12
maximum-performance-of-a-team
1,383
Hard
[ "Greedy", "Array", "Sorting", "Heap (Priority Queue)" ]
You are given two integers n and k and two integer arrays speed and efficiency both of length n. There are n engineers numbered from 1 to n. speed[i] and efficiency[i] represent the speed and efficiency of the ith engineer respectively. Choose at most k different engineers out of the n engineers to form a team with the...
maxPerformance(n: int, speed: list_int, efficiency: list_int, k: int) -> int
pub fn max_performance(n: i64, speed: &[i64], efficiency: &[i64], k: i64) -> i64
Aegis.MaxPerformance.max_performance
fn sort_by_efficiency_desc(order: &mut Vec<i64>, efficiency: &[i64]) { let n = order.len(); if n == 0 { return; } let mut temp: Vec<i64> = Vec::new(); let mut p: usize = 0; while p < n { temp.push(0); p += 1; } let mut width: usize = 1; while width < n { ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [max_performance]: type definitions module public import Aeneas @[expose] public section 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 -- [max_performance]: function definitions module public import Aeneas public import Aegis.MaxPerformance.Code.Types public import Aegis.MaxPerformance.Code.FunsExternal @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNames...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [max_performance]: external functions. -- This is a template file: rename it to "FunsExternal.lean" and fill the holes. module public import Aeneas public import Aegis.MaxPerformance.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error...
import Aegis.MaxPerformance.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.MaxPerformance.max_performance 1#i64 (Slice.from [1#i64] (by scalar_tac) : Slice Std.I64) (Slice.from [1#i64] (by scalar_tac) : Slice Std.I64) 1#i...
[ { "input": "[1, [1], [1], 1]", "output": "1" }, { "input": "[3, [2, 8, 2], [2, 7, 1], 2]", "output": "56" }, { "input": "[3, [1, 2, 3], [3, 2, 1], 2]", "output": "6" }, { "input": "[5, [4, 1, 12, 7, 8], [2, 10, 8, 19, 4], 3]", "output": "160" }, { "input": "[5, [3...
41
false
41
verified
10
10
1
6,315
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MaxPerformance.Code.Funs /-! # Specifications of `Aegis.MaxPerformance.max_performance` LeetCode problem `maximum-performance-of-a-team`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.MaxPerformance def M : Int := 1000000007 def elem...
12
find-the-distance-value-between-two-arrays
1,385
Easy
[ "Array", "Two Pointers", "Binary Search", "Sorting" ]
Given two integer arrays arr1 and arr2, and the integer d, return the distance value between the two arrays. The distance value is defined as the number of elements arr1[i] such that there is not any element arr2[j] where |arr1[i]-arr2[j]| <= d.   Example 1: Input: arr1 = [4,5,8], arr2 = [10,9,1,8], d = 2 Output: 2 Ex...
findTheDistanceValue(arr1: list_int, arr2: list_int, d: int) -> int
pub fn find_the_distance_value(arr1: &[i64], arr2: &[i64], d: i64) -> i64
Aegis.FindTheDistanceValue.find_the_distance_value
pub fn find_the_distance_value(arr1: &[i64], arr2: &[i64], d: i64) -> i64 { let mut count: i64 = 0; let n1 = arr1.len(); let n2 = arr2.len(); let mut i: usize = 0; while i < n1 { let a = arr1[i]; let mut valid = true; let mut j: usize = 0; while j < n2 { ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [find_the_distance_value]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_opti...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [find_the_distance_value]: function definitions module public import Aeneas public import Aegis.FindTheDistanceValue.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashComman...
import Aegis.FindTheDistanceValue.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.FindTheDistanceValue.find_the_distance_value (Slice.from [1000#i64] (by scalar_tac) : Slice Std.I64) (Slice.from [(-1000)#i64] (by scalar_ta...
[ { "input": "[[1000], [-1000], 1999]", "output": "1" }, { "input": "[[1], [1], 0]", "output": "0" }, { "input": "[[-1000, 1000], [-500, 500], 499]", "output": "2" }, { "input": "[[1, 1, 1, 1], [1], 1]", "output": "0" }, { "input": "[[10, 20, 30], [5, 15, 25], 4]", ...
115
false
115
verified
10
10
1
499
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.FindTheDistanceValue.Code.Funs /-! # Specifications of `Aegis.FindTheDistanceValue.find_the_distance_value` LeetCode problem `find-the-distance-value-between-two-arrays`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.FindTheDistanceV...
7
cinema-seat-allocation
1,386
Medium
[ "Greedy", "Bit Manipulation", "Array", "Hash Table" ]
A cinema has n rows of seats, numbered from 1 to n and there are ten seats in each row, labelled from 1 to 10 as shown in the figure above. Given the array reservedSeats containing the numbers of seats already reserved, for example, reservedSeats[i] = [3,8] means the seat located in row 3 and labelled with 8 is alread...
maxNumberOfFamilies(n: int, reservedSeats: list_list_int) -> int
pub fn max_number_of_families(n: i64, reservedSeats: &[Vec<i64>]) -> i64
Aegis.MaxNumberOfFamilies.max_number_of_families
pub fn max_number_of_families(n: i64, reservedSeats: &[Vec<i64>]) -> i64 { let m = reservedSeats.len(); let mut keys: Vec<i64> = Vec::new(); let mut idx: usize = 0; while idx < m { let row = reservedSeats[idx][0]; let seat = reservedSeats[idx][1]; keys.push(row * 16 + seat); ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [max_number_of_families]: type definitions module public import Aeneas @[expose] public 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 -- [max_number_of_families]: function definitions module public import Aeneas public import Aegis.MaxNumberOfFamilies.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand ...
import Aegis.MaxNumberOfFamilies.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.MaxNumberOfFamilies.max_number_of_families 1#i64 (Slice.from [] (by scalar_tac) : Slice (alloc.vec.Vec Std.I64))) (2#i64))}") #eval (s!"CASE ...
[ { "input": "[1, []]", "output": "2" }, { "input": "[10, []]", "output": "20" }, { "input": "[1000000000, [[500000000, 5]]]", "output": "1999999999" }, { "input": "[1, [[1, 5]]]", "output": "1" }, { "input": "[1000000000, [[1, 2], [1000000000, 9]]]", "output": ...
76
false
76
verified
10
10
1
6,586
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MaxNumberOfFamilies.Code.Funs /-! # Specifications of `Aegis.MaxNumberOfFamilies.max_number_of_families` LeetCode problem `cinema-seat-allocation`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.MaxNumberOfFamilies def pairOf (v : allo...
14
sort-integers-by-the-power-value
1,387
Medium
[ "Memoization", "Dynamic Programming", "Sorting" ]
The power of an integer x is defined as the number of steps needed to transform x into 1 using the following steps: if x is even then x = x / 2 if x is odd then x = 3 * x + 1 For example, the power of x = 3 is 7 because 3 needs 7 steps to become 1 (3 --> 10 --> 5 --> 16 --> 8 --> 4 --> 2 --> 1). Given three integers ...
getKth(lo: int, hi: int, k: int) -> int
pub fn get_kth(lo: i64, hi: i64, k: i64) -> i64
Aegis.GetKth.get_kth
pub fn get_kth(lo: i64, hi: i64, k: i64) -> i64 { let mut vals: Vec<i64> = Vec::new(); let mut powers: Vec<i64> = Vec::new(); let mut x0 = lo; while x0 <= hi { let mut x = x0; let mut steps: i64 = 0; while x != 1 { if x % 2 == 0 { x = x / 2; ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [get_kth]: type definitions module public import Aeneas @[expose] public section 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 -- [get_kth]: function definitions module public import Aeneas public import Aegis.GetKth.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unus...
import Aegis.GetKth.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.GetKth.get_kth 1#i64 10#i64 1#i64) (1#i64))}") #eval (s!"CASE 1 {(Result.reducesTo (Aegis.GetKth.get_kth 5#i64 5#i64 1#i64) (5#i64))}") #eval (s!"CASE 2 {...
[ { "input": "[1, 10, 1]", "output": "1" }, { "input": "[5, 5, 1]", "output": "5" }, { "input": "[12, 15, 2]", "output": "13" }, { "input": "[1, 10, 5]", "output": "5" }, { "input": "[10, 20, 5]", "output": "13" }, { "input": "[7, 11, 4]", "output": ...
93
false
93
verified
10
10
1
2,345
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.GetKth.Code.Funs /-! # Specifications of `Aegis.GetKth.get_kth` LeetCode problem `sort-integers-by-the-power-value`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Classical namespace AegisSpec.GetKth def collatzStep (x : ℤ) : ℤ := if x % 2 = 0...
13
pizza-with-3n-slices
1,388
Hard
[ "Greedy", "Array", "Dynamic Programming", "Heap (Priority Queue)" ]
There is a pizza with 3n slices of varying size, you and your friends will take slices of pizza as follows: You will pick any pizza slice. Your friend Alice will pick the next slice in the anti-clockwise direction of your pick. Your friend Bob will pick the next slice in the clockwise direction of your pick. Repeat un...
maxSizeSlices(slices: list_int) -> int
pub fn max_size_slices(slices: &[i64]) -> i64
Aegis.MaxSizeSlices.max_size_slices
pub fn max_size_slices(slices: &[i64]) -> i64 { let m = slices.len(); let k = m / 3; if k == 0 { return 0; } let without_last = max_non_adjacent(slices, 0, m - 1, k); let without_first = max_non_adjacent(slices, 1, m, k); if without_last > without_first { without_last ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [max_size_slices]: type definitions module public import Aeneas @[expose] public section 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 -- [max_size_slices]: function definitions module public import Aeneas public import Aegis.MaxSizeSlices.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.MaxSizeSlices.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.MaxSizeSlices.max_size_slices (Slice.from [9#i64, 7#i64, 7#i64, 7#i64, 6#i64, 6#i64] (by scalar_tac) : Slice Std.I64)) (16#i64))}") #eval (s!"CASE ...
[ { "input": "[[9, 7, 7, 7, 6, 6]]", "output": "16" }, { "input": "[[1000, 1000, 1000, 1000, 1000, 1000]]", "output": "2000" }, { "input": "[[1, 2, 3, 4, 1, 2]]", "output": "6" }, { "input": "[[8, 9, 8, 6, 1, 1]]", "output": "16" }, { "input": "[[10, 1, 1, 1, 1, 10]...
111
false
111
verified
10
10
1
5,061
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MaxSizeSlices.Code.Funs /-! # Specifications of `Aegis.MaxSizeSlices.max_size_slices` LeetCode problem `pizza-with-3n-slices`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.MaxSizeSlices def i64OfInt (z : Int) : Std.I64 := ⟨BitVec.ofI...
12