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
create-target-array-in-the-given-order
1,389
Easy
[ "Array", "Simulation" ]
Given two arrays of integers nums and index. Your task is to create target array under the following rules: Initially target array is empty. From left to right read nums[i] and index[i], insert at index index[i] the value nums[i] in target array. Repeat the previous step until there are no elements to read in nums and...
createTargetArray(nums: list_int, index: list_int) -> list_int
pub fn create_target_array(nums: &[i64], index: &[i64]) -> Vec<i64>
Aegis.CreateTargetArray.create_target_array
pub fn create_target_array(nums: &[i64], index: &[i64]) -> Vec<i64> { let mut target: Vec<i64> = Vec::new(); let n = nums.len(); let mut i: usize = 0; while i < n { let mut pos = index[i] as usize; if pos > i { pos = i; } let value = nums[i]; target....
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [create_target_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 l...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [create_target_array]: function definitions module public import Aeneas public import Aegis.CreateTargetArray.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false...
import Aegis.CreateTargetArray.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.CreateTargetArray.create_target_array (Slice.from [1#i64] (by scalar_tac) : Slice Std.I64) (Slice.from [0#i64] (by scalar_tac) : Slice Std.I64)...
[ { "input": "[[1], [0]]", "output": "[1]" }, { "input": "[[1, 3, 2], [0, 0, 1]]", "output": "[3, 2, 1]" }, { "input": "[[1, 3, 2], [0, 1, 1]]", "output": "[1, 2, 3]" }, { "input": "[[3, 1, 2], [0, 1, 1]]", "output": "[3, 2, 1]" }, { "input": "[[3, 2, 1], [1, 1, 1]]...
115
false
115
verified
10
10
2
3,409
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.CreateTargetArray.Code.Funs /-! # Specifications of `Aegis.CreateTargetArray.create_target_array` LeetCode problem `create-target-array-in-the-given-order`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.CreateTargetArray open Aegi...
14
four-divisors
1,390
Medium
[ "Array", "Math" ]
Given an integer array nums, return the sum of divisors of the integers in that array that have exactly four divisors. If there is no such integer in the array, return 0.   Example 1: Input: nums = [21,4,7] Output: 32 Explanation: 21 has 4 divisors: 1, 3, 7, 21 4 has 3 divisors: 1, 2, 4 7 has 2 divisors: 1, 7 The ans...
sumFourDivisors(nums: list_int) -> int
pub fn sum_four_divisors(nums: &[i64]) -> i64
Aegis.SumFourDivisors.sum_four_divisors
pub fn sum_four_divisors(nums: &[i64]) -> i64 { let mut total: i64 = 0; let mut i: usize = 0; while i < nums.len() { let n: i64 = nums[i]; let mut count: i64 = 0; let mut sum: i64 = 0; let mut d: i64 = 1; while d * d <= n { if n % d == 0 { ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [sum_four_divisors]: type definitions module public import Aeneas @[expose] public section 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 -- [sum_four_divisors]: function definitions module public import Aeneas public import Aegis.SumFourDivisors.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.SumFourDivisors.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.SumFourDivisors.sum_four_divisors (Slice.from [21#i64, 21#i64] (by scalar_tac) : Slice Std.I64)) (64#i64))}") #eval (s!"CASE 1 {(Result.reducesTo...
[ { "input": "[[21, 21]]", "output": "64" }, { "input": "[[30, 100, 49]]", "output": "0" }, { "input": "[[21, 4, 7]]", "output": "32" }, { "input": "[[15, 28, 91]]", "output": "136" }, { "input": "[[30, 44, 25, 63]]", "output": "0" }, { "input": "[[100, ...
136
false
136
verified
10
10
1
811
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.SumFourDivisors.Code.Funs /-! # Specifications of `Aegis.SumFourDivisors.sum_four_divisors` LeetCode problem `four-divisors`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.SumFourDivisors open Aegis.SumFourDivisors (sum_four_divis...
11
check-if-there-is-a-valid-path-in-a-grid
1,391
Medium
[ "Depth-First Search", "Breadth-First Search", "Union Find", "Array", "Matrix" ]
You are given an m x n grid. Each cell of grid represents a street. The street of grid[i][j] can be: 1 which means a street connecting the left cell and the right cell. 2 which means a street connecting the upper cell and the lower cell. 3 which means a street connecting the left cell and the lower cell. 4 which means...
hasValidPath(grid: list_list_int) -> bool
pub fn has_valid_path(grid: &[Vec<i64>]) -> bool
Aegis.HasValidPath.has_valid_path
fn has_dir(t: i64, dir: i64) -> bool { if dir == 0 { // left t == 1 || t == 3 || t == 5 } else if dir == 1 { // right t == 1 || t == 4 || t == 6 } else if dir == 2 { // up t == 2 || t == 5 || t == 6 } else { // down t == 2 || t == 3 || t ==...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [has_valid_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 -- [has_valid_path]: function definitions module public import Aeneas public import Aegis.HasValidPath.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.HasValidPath.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.HasValidPath.has_valid_path (Slice.from [(alloc.vec.Vec.from [2#i64] (by scalar_tac) : alloc.vec.Vec Std.I64), (alloc.vec.Vec.from [2#i64] (by scala...
[ { "input": "[[[2], [2], [2]]]", "output": "true" }, { "input": "[[[1, 1, 2]]]", "output": "false" }, { "input": "[[[2, 4, 3], [6, 5, 2]]]", "output": "true" }, { "input": "[[[1, 2, 1], [1, 2, 1]]]", "output": "false" }, { "input": "[[[4, 3, 3], [6, 5, 2]]]", "...
77
false
77
verified
10
10
1
5,670
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.HasValidPath.Code.Funs /-! # Specifications of `Aegis.HasValidPath.has_valid_path` LeetCode problem `check-if-there-is-a-valid-path-in-a-grid`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.HasValidPath open Aegis.HasValidPath def ro...
10
find-lucky-integer-in-an-array
1,394
Easy
[ "Array", "Hash Table", "Counting" ]
Given an array of integers arr, a lucky integer is an integer that has a frequency in the array equal to its value. Return the largest lucky integer in the array. If there is no lucky integer return -1.   Example 1: Input: arr = [2,2,3,4] Output: 2 Explanation: The only lucky number in the array is 2 because frequency...
findLucky(arr: list_int) -> int
pub fn find_lucky(arr: &[i64]) -> i64
Aegis.FindLucky.find_lucky
pub fn find_lucky(arr: &[i64]) -> i64 { let mut counts: Vec<i64> = Vec::new(); let mut k: usize = 0; while k < 502 { counts.push(0); k += 1; } let mut i: usize = 0; while i < arr.len() { let v = arr[i]; if v >= 1 && v <= 500 { let idx = v as usize; ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [find_lucky]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter.sty...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [find_lucky]: function definitions module public import Aeneas public import Aegis.FindLucky.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.FindLucky.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.FindLucky.find_lucky (Slice.from [5#i64] (by scalar_tac) : Slice Std.I64)) ((-1)#i64))}") #eval (s!"CASE 1 {(Result.reducesTo (Aegis.FindLucky.find_luc...
[ { "input": "[[5]]", "output": "-1" }, { "input": "[[1]]", "output": "1" }, { "input": "[[1, 1]]", "output": "-1" }, { "input": "[[2, 2, 3, 4]]", "output": "2" }, { "input": "[[4, 4, 4, 4]]", "output": "4" }, { "input": "[[5, 5, 4, 4, 4]]", "output"...
61
false
61
verified
10
10
1
1,834
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.FindLucky.Code.Funs /-! # Specifications of `Aegis.FindLucky.find_lucky` LeetCode problem `find-lucky-integer-in-an-array`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.FindLucky def freq (arr : Slice Std.I64) (v : Int) : Nat := (a...
10
count-number-of-teams
1,395
Medium
[ "Binary Indexed Tree", "Segment Tree", "Array", "Dynamic Programming" ]
There are n soldiers standing in a line. Each soldier is assigned a unique rating value. You have to form a team of 3 soldiers amongst them under the following rules: Choose 3 soldiers with index (i, j, k) with rating (rating[i], rating[j], rating[k]). A team is valid if: (rating[i] < rating[j] < rating[k]) or (rating...
numTeams(rating: list_int) -> int
pub fn num_teams(rating: &[i64]) -> i64
Aegis.NumTeams.num_teams
pub fn num_teams(rating: &[i64]) -> i64 { let n = rating.len(); let mut total: i64 = 0; let mut j: usize = 1; while j + 1 < n { let mut left_less: i64 = 0; let mut left_greater: i64 = 0; let mut i: usize = 0; while i < j { if rating[i] < rating[j] { ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [num_teams]: type definitions module public import Aeneas @[expose] public section 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 -- [num_teams]: function definitions module public import Aeneas public import Aegis.NumTeams.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.NumTeams.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.NumTeams.num_teams (Slice.from [2#i64, 1#i64, 3#i64] (by scalar_tac) : Slice Std.I64)) (0#i64))}") #eval (s!"CASE 1 {(Result.reducesTo (Aegis.NumTeams.n...
[ { "input": "[[2, 1, 3]]", "output": "0" }, { "input": "[[10, 6, 5, 8]]", "output": "1" }, { "input": "[[1, 2, 3, 4]]", "output": "4" }, { "input": "[[3, 1, 2, 5, 4]]", "output": "2" }, { "input": "[[1, 5, 2, 4, 3]]", "output": "3" }, { "input": "[[5, 4...
114
false
114
verified
10
10
1
801
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.NumTeams.Code.Funs /-! # Specifications of `Aegis.NumTeams.num_teams` LeetCode problem `count-number-of-teams`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.NumTeams def len (a : Slice Std.I64) : ℕ := a.val.length def valAt (a...
12
find-all-good-strings
1,397
Hard
[ "String", "Dynamic Programming", "String Matching" ]
Given the strings s1 and s2 of size n and the string evil, return the number of good strings. A good string has size n, it is alphabetically greater than or equal to s1, it is alphabetically smaller than or equal to s2, and it does not contain the string evil as a substring. Since the answer can be a huge number, retur...
findGoodStrings(n: int, s1: str, s2: str, evil: str) -> int
pub fn find_good_strings(n: i64, s1: &[u8], s2: &[u8], evil: &[u8]) -> i64
Aegis.FindGoodStrings.find_good_strings
const MOD: i64 = 1000000007; fn count_leq(bound: &[u8], trans: &[Vec<i64>], m: usize, len: usize) -> i64 { let mut less: Vec<i64> = Vec::new(); let mut i: usize = 0; while i < m { less.push(0); i += 1; } let mut tight_valid: bool = true; let mut tight_state: usize = 0; let ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [find_good_strings]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option lin...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [find_good_strings]: function definitions module public import Aeneas public import Aegis.FindGoodStrings.Code.Types public import Aegis.FindGoodStrings.Code.FunsExternal @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupN...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [find_good_strings]: external functions. -- This is a template file: rename it to "FunsExternal.lean" and fill the holes. module public import Aeneas public import Aegis.FindGoodStrings.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Er...
import Aegis.FindGoodStrings.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.FindGoodStrings.find_good_strings 5#i64 (Slice.from [97#u8, 112#u8, 112#u8, 108#u8, 101#u8] (by scalar_tac) : Slice Std.U8) (Slice.from [122#u8, ...
[ { "input": "[5, \"apple\", \"zebra\", \"app\"]", "output": "11220078" }, { "input": "[5, \"apple\", \"appla\", \"appl\"]", "output": "0" }, { "input": "[3, \"aaa\", \"zzz\", \"abc\"]", "output": "17575" }, { "input": "[5, \"aaaaa\", \"zzzzz\", \"abc\"]", "output": "118793...
29
false
29
verified
10
10
1
14,165
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.FindGoodStrings.Code.Funs /-! # Specifications of `Aegis.FindGoodStrings.find_good_strings` LeetCode problem `find-all-good-strings`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.FindGoodStrings open Aegis.FindGoodStrings (find_g...
10
count-largest-group
1,399
Easy
[ "Hash Table", "Math" ]
You are given an integer n. Each number from 1 to n is grouped according to the sum of its digits. Return the number of groups that have the largest size.   Example 1: Input: n = 13 Output: 4 Explanation: There are 9 groups in total, they are grouped according sum of its digits of numbers from 1 to 13: [1,10], [2,11],...
countLargestGroup(n: int) -> int
pub fn count_largest_group(n: i64) -> i64
Aegis.CountLargestGroup.count_largest_group
pub fn count_largest_group(n: i64) -> i64 { let mut counts: Vec<i64> = Vec::new(); let mut k: usize = 0; while k < 50 { counts.push(0); k += 1; } let mut num: i64 = 1; while num <= n { let mut x: i64 = num; let mut digit_sum: i64 = 0; while x > 0 { ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [count_largest_group]: type definitions module public import Aeneas @[expose] public section 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 -- [count_largest_group]: function definitions module public import Aeneas public import Aegis.CountLargestGroup.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false...
import Aegis.CountLargestGroup.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.CountLargestGroup.count_largest_group 200#i64) (2#i64))}") #eval (s!"CASE 1 {(Result.reducesTo (Aegis.CountLargestGroup.count_largest_group 100...
[ { "input": "[200]", "output": "2" }, { "input": "[10000]", "output": "1" }, { "input": "[9]", "output": "9" }, { "input": "[104]", "output": "1" }, { "input": "[9999]", "output": "1" }, { "input": "[2]", "output": "2" }, { "input": "[100]",...
45
false
45
verified
10
10
1
1,008
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
0
construct-k-palindrome-strings
1,400
Medium
[ "Greedy", "Hash Table", "String", "Counting" ]
Given a string s and an integer k, return true if you can use all the characters in s to construct non-empty k palindrome strings or false otherwise.   Example 1: Input: s = "annabelle", k = 2 Output: true Explanation: You can construct two palindromes using all characters in s. Some possible constructions "anna" + "e...
canConstruct(s: str, k: int) -> bool
pub fn can_construct(s: &[u8], k: i64) -> bool
Aegis.CanConstruct.can_construct
pub fn can_construct(s: &[u8], k: i64) -> bool { let n = s.len() as i64; if k > n { return false; } let mut counts: Vec<i64> = Vec::new(); let mut i = 0; while i < 26 { counts.push(0); i += 1; } let mut pos = 0; while pos < s.len() { let idx = (s[pos...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [can_construct]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter....
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [can_construct]: function definitions module public import Aeneas public import Aegis.CanConstruct.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.CanConstruct.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.CanConstruct.can_construct (Slice.from [97#u8] (by scalar_tac) : Slice Std.U8) 2#i64) (false))}") #eval (s!"CASE 1 {(Result.reducesTo (Aegis.CanCons...
[ { "input": "[\"a\", 2]", "output": "false" }, { "input": "[\"aabbcc\", 3]", "output": "true" }, { "input": "[\"abcd\", 2]", "output": "false" }, { "input": "[\"yzyzyzyzyzyzyzy\", 17]", "output": "false" }, { "input": "[\"\", 0]", "output": "true" }, { ...
100
false
100
verified
10
10
1
985
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.CanConstruct.Code.Funs /-! # Specifications of `Aegis.CanConstruct.can_construct` LeetCode problem `construct-k-palindrome-strings`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.CanConstruct def bytes (s : Slice Std.U8) : List Na...
14
circle-and-rectangle-overlapping
1,401
Medium
[ "Geometry", "Math" ]
You are given a circle represented as (radius, xCenter, yCenter) and an axis-aligned rectangle represented as (x1, y1, x2, y2), where (x1, y1) are the coordinates of the bottom-left corner, and (x2, y2) are the coordinates of the top-right corner of the rectangle. Return true if the circle and rectangle are overlapped ...
checkOverlap(radius: int, xCenter: int, yCenter: int, x1: int, y1: int, x2: int, y2: int) -> bool
pub fn check_overlap(radius: i64, xCenter: i64, yCenter: i64, x1: i64, y1: i64, x2: i64, y2: i64) -> bool
Aegis.CheckOverlap.check_overlap
pub fn check_overlap(radius: i64, xCenter: i64, yCenter: i64, x1: i64, y1: i64, x2: i64, y2: i64) -> bool { let mut closest_x = xCenter; if closest_x < x1 { closest_x = x1; } if closest_x > x2 { closest_x = x2; } let mut closest_y = yCenter; if closest_y < y1 { close...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [check_overlap]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter....
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [check_overlap]: function definitions module public import Aeneas public import Aegis.CheckOverlap.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.CheckOverlap.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.CheckOverlap.check_overlap 3#i64 (-3)#i64 (-4)#i64 (-6)#i64 (-6)#i64 (-2)#i64 (-2)#i64) (true))}") #eval (s!"CASE 1 {(Result.reducesTo (Aegis.CheckO...
[ { "input": "[3, -3, -4, -6, -6, -2, -2]", "output": "true" }, { "input": "[2, -2, -2, -5, -5, -3, -3]", "output": "true" }, { "input": "[5, 0, 0, -5, -5, 5, 5]", "output": "true" }, { "input": "[1, 0, 0, 1, -1, 3, 1]", "output": "true" }, { "input": "[1, 0, 0, -1,...
114
false
114
verified
10
10
1
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.CheckOverlap.Code.Funs import Mathlib /-! # Specifications of `Aegis.CheckOverlap.check_overlap` LeetCode problem `circle-and-rectangle-overlapping`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.CheckOverlap def inClosedRect (x1 y1 x...
8
reducing-dishes
1,402
Hard
[ "Greedy", "Array", "Dynamic Programming", "Sorting" ]
A chef has collected data on the satisfaction level of his n dishes. Chef can cook any dish in 1 unit of time. Like-time coefficient of a dish is defined as the time taken to cook that dish including previous dishes multiplied by its satisfaction level i.e. time[i] * satisfaction[i]. Return the maximum sum of like-time...
maxSatisfaction(satisfaction: list_int) -> int
pub fn max_satisfaction(satisfaction: &[i64]) -> i64
Aegis.MaxSatisfaction.max_satisfaction
pub fn max_satisfaction(satisfaction: &[i64]) -> i64 { let n = satisfaction.len(); let mut a: Vec<i64> = Vec::new(); let mut i = 0; while i < n { a.push(satisfaction[i]); i += 1; } // Insertion sort in non-decreasing order. let mut i = 1; while i < n { let key =...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [max_satisfaction]: type definitions module public import Aeneas @[expose] public section 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 -- [max_satisfaction]: function definitions module public import Aeneas public import Aegis.MaxSatisfaction.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.MaxSatisfaction.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.MaxSatisfaction.max_satisfaction (Slice.from [0#i64] (by scalar_tac) : Slice Std.I64)) (0#i64))}") #eval (s!"CASE 1 {(Result.reducesTo (Aegis.Max...
[ { "input": "[[0]]", "output": "0" }, { "input": "[[-1]]", "output": "0" }, { "input": "[[1]]", "output": "1" }, { "input": "[[-1000, 1000]]", "output": "1000" }, { "input": "[[4, 3, 2]]", "output": "20" }, { "input": "[[-1, -4, -5]]", "output": "0"...
114
false
114
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.MaxSatisfaction.Code.Funs /-! # Specifications of `Aegis.MaxSatisfaction.max_satisfaction` LeetCode problem `reducing-dishes`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.MaxSatisfaction def vals (s : Slice Std.I64) : List ℤ := s.va...
14
minimum-subsequence-in-non-increasing-order
1,403
Easy
[ "Greedy", "Array", "Sorting" ]
Given the array nums, obtain a subsequence of the array whose sum of elements is strictly greater than the sum of the non included elements in such subsequence.  If there are multiple solutions, return the subsequence with minimum size and if there still exist multiple solutions, return the subsequence with the maximum...
minSubsequence(nums: list_int) -> list_int
pub fn min_subsequence(nums: &[i64]) -> Vec<i64>
Aegis.MinSubsequence.min_subsequence
pub fn min_subsequence(nums: &[i64]) -> Vec<i64> { let n = nums.len(); let mut total: i64 = 0; let mut copy: Vec<i64> = Vec::new(); let mut i = 0; while i < n { total += nums[i]; copy.push(nums[i]); i += 1; } // Sort copy in non-increasing order using a manual sele...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [min_subsequence]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linte...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [min_subsequence]: function definitions module public import Aeneas public import Aegis.MinSubsequence.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.MinSubsequence.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.MinSubsequence.min_subsequence (Slice.from [4#i64, 3#i64, 10#i64, 9#i64, 8#i64] (by scalar_tac) : Slice Std.I64)) ((alloc.vec.Vec.from [10#i64, 9#...
[ { "input": "[[4, 3, 10, 9, 8]]", "output": "[10, 9]" }, { "input": "[[1, 2, 3, 4, 5]]", "output": "[5, 4]" }, { "input": "[[4, 4, 7, 6, 7]]", "output": "[7, 7, 6]" }, { "input": "[[100, 90, 80, 70, 60]]", "output": "[100, 90, 80]" }, { "input": "[[100, 99, 98, 97,...
60
false
60
verified
10
10
1
1,001
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MinSubsequence.Code.Funs /-! # Specifications of `Aegis.MinSubsequence.min_subsequence` LeetCode problem `minimum-subsequence-in-non-increasing-order`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.MinSubsequence namespace AegisSpec.MinSubs...
15
number-of-steps-to-reduce-a-number-in-binary-representation-to-one
1,404
Medium
[ "Bit Manipulation", "String" ]
Given the binary representation of an integer as a string s, return the number of steps to reduce it to 1 under the following rules: If the current number is even, you have to divide it by 2. If the current number is odd, you have to add 1 to it. It is guaranteed that you can always reach one for all test cases. ...
numSteps(s: str) -> int
pub fn num_steps(s: &[u8]) -> i64
Aegis.NumSteps.num_steps
pub fn num_steps(s: &[u8]) -> i64 { let n = s.len(); let mut bits: Vec<u8> = Vec::new(); let mut idx = n; while idx > 0 { idx -= 1; if s[idx] == b'1' { bits.push(1); } else { bits.push(0); } } let mut start: usize = 0; let mut steps: ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [num_steps]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter.styl...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [num_steps]: function definitions module public import Aeneas public import Aegis.NumSteps.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.NumSteps.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.NumSteps.num_steps (Slice.from [49#u8, 49#u8, 49#u8, 48#u8, 49#u8, 49#u8, 49#u8, 48#u8, 49#u8, 49#u8, 49#u8] (by scalar_tac) : Slice Std.U8)) (14#i64))}...
[ { "input": "[\"11101110111\"]", "output": "14" }, { "input": "[\"1111\"]", "output": "5" }, { "input": "[\"101010101010101010101010101010101010101010101010101010101010101\"]", "output": "95" }, { "input": "[\"1100110\"]", "output": "10" }, { "input": "[\"111\"]", ...
101
false
101
verified
10
10
1
3,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.NumSteps.Code.Funs /-! # Specifications of `Aegis.NumSteps.num_steps` LeetCode problem `number-of-steps-to-reduce-a-number-in-binary-representation-to-one`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.NumSteps namespace AegisSpec.NumSteps op...
11
string-matching-in-an-array
1,408
Easy
[ "Array", "String", "String Matching" ]
Given an array of string words, return all strings in words that are a substring of another word. You can return the answer in any order.   Example 1: Input: words = ["mass","as","hero","superhero"] Output: ["as","hero"] Explanation: "as" is substring of "mass" and "hero" is substring of "superhero". ["hero","as"] is ...
stringMatching(words: list_str) -> list_str
pub fn string_matching(words: &[Vec<u8>]) -> Vec<Vec<u8>>
Aegis.StringMatching.string_matching
pub fn string_matching(words: &[Vec<u8>]) -> Vec<Vec<u8>> { let mut out: Vec<Vec<u8>> = Vec::new(); let n = words.len(); let mut i: usize = 0; while i < n { let needle_len = words[i].len(); let mut is_sub = false; let mut j: usize = 0; while j < n { if i != ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [string_matching]: type definitions module public import Aeneas @[expose] public section 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 -- [string_matching]: function definitions module public import Aeneas public import Aegis.StringMatching.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.StringMatching.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(match (Aegis.StringMatching.string_matching (Slice.from [(alloc.vec.Vec.from [98#u8, 108#u8, 117#u8, 101#u8] (by scalar_tac) : alloc.vec.Vec Std.U8), (alloc.vec.Vec.from ...
[ { "input": "[[\"blue\", \"green\", \"bu\"]]", "output": "[]" }, { "input": "[[\"leetcode\", \"et\", \"code\"]]", "output": "[\"et\", \"code\"]" }, { "input": "[[\"mass\", \"as\", \"hero\", \"superhero\"]]", "output": "[\"as\", \"hero\"]" }, { "input": "[[\"hello\", \"world\",...
97
true
97
verified
10
10
1
3,784
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.StringMatching.Code.Funs /-! # Specifications of `Aegis.StringMatching.string_matching` LeetCode problem `string-matching-in-an-array`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.StringMatching set_option autoImplicit false namespace ...
11
queries-on-a-permutation-with-key
1,409
Medium
[ "Binary Indexed Tree", "Array", "Simulation" ]
Given the array queries of positive integers between 1 and m, you have to process all queries[i] (from i=0 to i=queries.length-1) according to the following rules: In the beginning, you have the permutation P=[1,2,3,...,m]. For the current i, find the position of queries[i] in the permutation P (indexing from 0) and t...
processQueries(queries: list_int, m: int) -> list_int
pub fn process_queries(queries: &[i64], m: i64) -> Vec<i64>
Aegis.ProcessQueries.process_queries
pub fn process_queries(queries: &[i64], m: i64) -> Vec<i64> { let mut perm: Vec<i64> = Vec::new(); let mut i: i64 = 0; while i < m { perm.push(i + 1); i += 1; } let mut result: Vec<i64> = Vec::new(); let mut qi: usize = 0; while qi < queries.len() { let q = queries[...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [process_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 linte...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [process_queries]: function definitions module public import Aeneas public import Aegis.ProcessQueries.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.ProcessQueries.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.ProcessQueries.process_queries (Slice.from [1#i64, 2#i64, 3#i64] (by scalar_tac) : Slice Std.I64) 3#i64) ((alloc.vec.Vec.from [0#i64, 1#i64, 2#i64...
[ { "input": "[[1, 2, 3], 3]", "output": "[0, 1, 2]" }, { "input": "[[3, 1, 2, 1], 5]", "output": "[2, 1, 2, 1]" }, { "input": "[[4, 1, 2, 2], 4]", "output": "[3, 1, 2, 0]" }, { "input": "[[7, 5, 5, 8, 3], 8]", "output": "[6, 5, 0, 7, 5]" }, { "input": "[[1, 2, 3, 4...
97
false
97
verified
10
10
1
1,057
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.ProcessQueries.Code.Funs /-! # Specifications of `Aegis.ProcessQueries.process_queries` LeetCode problem `queries-on-a-permutation-with-key`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.ProcessQueries (process_queries) namespace AegisSpec.Pro...
9
html-entity-parser
1,410
Medium
[ "Hash Table", "String" ]
HTML entity parser is the parser that takes HTML code as input and replace all the entities of the special characters by the characters itself. The special characters and their entities for HTML are: Quotation Mark: the entity is &quot; and symbol character is ". Single Quote Mark: the entity is &apos; and symbol char...
entityParser(text: str) -> str
pub fn entity_parser(text: &[u8]) -> Vec<u8>
Aegis.EntityParser.entity_parser
fn slice_eq(text: &[u8], pos: usize, pat: &[u8], end: usize) -> bool { let plen = pat.len(); if pos > end { return false; } if plen > end - pos { return false; } let mut j: usize = 0; while j < plen { if text[pos + j] != pat[j] { return false; } ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [entity_parser]: type definitions module public import Aeneas @[expose] public section 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 -- [entity_parser]: function definitions module public import Aeneas public import Aegis.EntityParser.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.EntityParser.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.EntityParser.entity_parser (Slice.from [38#u8, 97#u8, 109#u8, 112#u8, 59#u8, 32#u8, 105#u8, 115#u8, 32#u8, 97#u8, 110#u8, 32#u8, 72#u8, 84#u8, 77#u8...
[ { "input": "[\"&amp; is an HTML entity but &ambassador; is not.\"]", "output": "\"& is an HTML entity but &ambassador; is not.\"" }, { "input": "[\"and I quote: &quot;...&quot;\"]", "output": "\"and I quote: \\\"...\\\"\"" }, { "input": "[\"Stay home! Practice on Leetcode :)\"]", "ou...
6
false
6
verified
6
6
4
15,267
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.EntityParser.Code.Funs /-! # Specifications of `Aegis.EntityParser.entity_parser` LeetCode problem `html-entity-parser`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.EntityParser def bytes (l : List Std.U8) : List ℕ := l.map fun b =>...
8
number-of-ways-to-paint-n-3-grid
1,411
Hard
[ "Dynamic Programming" ]
You have a grid of size n x 3 and you want to paint each cell of the grid with exactly one of the three colors: Red, Yellow, or Green while making sure that no two adjacent cells have the same color (i.e., no two cells that share vertical or horizontal sides have the same color). Given n the number of rows of the grid,...
numOfWays(n: int) -> int
pub fn num_of_ways(n: i64) -> i64
Aegis.NumOfWays.num_of_ways
pub fn num_of_ways(n: i64) -> i64 { const MOD: i64 = 1_000_000_007; let mut same: i64 = 6; let mut diff: i64 = 6; let mut row: i64 = 2; while row <= n { let next_same = (3 * same + 2 * diff) % MOD; let next_diff = (2 * same + 2 * diff) % MOD; same = next_same; diff ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [num_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.st...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [num_of_ways]: function definitions module public import Aeneas public import Aegis.NumOfWays.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.NumOfWays.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.NumOfWays.num_of_ways 3#i64) (246#i64))}") #eval (s!"CASE 1 {(Result.reducesTo (Aegis.NumOfWays.num_of_ways 1000#i64) (650420578#i64))}") #eval (s!"CAS...
[ { "input": "[3]", "output": "246" }, { "input": "[1000]", "output": "650420578" }, { "input": "[100]", "output": "905790447" }, { "input": "[2500]", "output": "80958521" }, { "input": "[4]", "output": "1122" }, { "input": "[4999]", "output": "13462...
37
false
37
verified
10
10
1
578
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.NumOfWays.Code.Funs /-! # Specifications of `Aegis.NumOfWays.num_of_ways` LeetCode problem `number-of-ways-to-paint-n-3-grid`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.NumOfWays def M : Nat := 1000000007 def modM (a : Nat)...
13
minimum-value-to-get-positive-step-by-step-sum
1,413
Easy
[ "Array", "Prefix Sum" ]
Given an array of integers nums, you start with an initial positive value startValue. In each iteration, you calculate the step by step sum of startValue plus elements in nums (from left to right). Return the minimum positive value of startValue such that the step by step sum is never less than 1.   Example 1: Input: ...
minStartValue(nums: list_int) -> int
pub fn min_start_value(nums: &[i64]) -> i64
Aegis.MinStartValue.min_start_value
pub fn min_start_value(nums: &[i64]) -> i64 { let mut sum: i64 = 0; let mut min_sum: i64 = 0; let mut i: usize = 0; while i < nums.len() { sum += nums[i]; if sum < min_sum { min_sum = sum; } i += 1; } let required: i64 = 1 - min_sum; if required ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [min_start_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 -- [min_start_value]: function definitions module public import Aeneas public import Aegis.MinStartValue.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.MinStartValue.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.MinStartValue.min_start_value (Slice.from [(-1)#i64] (by scalar_tac) : Slice Std.I64)) (2#i64))}") #eval (s!"CASE 1 {(Result.reducesTo (Aegis.MinSt...
[ { "input": "[[-1]]", "output": "2" }, { "input": "[[1]]", "output": "1" }, { "input": "[[100]]", "output": "1" }, { "input": "[[-100]]", "output": "101" }, { "input": "[[1, 2]]", "output": "1" }, { "input": "[[100, 100, 100]]", "output": "1" }, ...
95
false
95
verified
10
10
1
516
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MinStartValue.Code.Funs /-! # Specifications of `Aegis.MinStartValue.min_start_value` LeetCode problem `minimum-value-to-get-positive-step-by-step-sum`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.MinStartValue namespace AegisSpec.MinStar...
8
find-the-minimum-number-of-fibonacci-numbers-whose-sum-is-k
1,414
Medium
[ "Greedy", "Math" ]
Given an integer k, return the minimum number of Fibonacci numbers whose sum is equal to k. The same Fibonacci number can be used multiple times. The Fibonacci numbers are defined as: F1 = 1 F2 = 1 Fn = Fn-1 + Fn-2 for n > 2. It is guaranteed that for the given constraints we can always find such Fibonacci numbers th...
findMinFibonacciNumbers(k: int) -> int
pub fn find_min_fibonacci_numbers(k: i64) -> i64
Aegis.FindMinFibonacciNumbers.find_min_fibonacci_numbers
pub fn find_min_fibonacci_numbers(k: i64) -> i64 { if k <= 0 { return 0; } let mut fib: Vec<i64> = Vec::new(); fib.push(1); fib.push(2); let mut next: i64 = 3; while next <= k { fib.push(next); let n = fib.len(); next = fib[n - 1] + fib[n - 2]; } le...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [find_min_fibonacci_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_o...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [find_min_fibonacci_numbers]: function definitions module public import Aeneas public import Aegis.FindMinFibonacciNumbers.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hash...
import Aegis.FindMinFibonacciNumbers.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.FindMinFibonacciNumbers.find_min_fibonacci_numbers 433494437#i64) (1#i64))}") #eval (s!"CASE 1 {(Result.reducesTo (Aegis.FindMinFibonacci...
[ { "input": "[433494437]", "output": "1" }, { "input": "[377]", "output": "1" }, { "input": "[6765]", "output": "1" }, { "input": "[24157817]", "output": "1" }, { "input": "[102334155]", "output": "1" }, { "input": "[89]", "output": "1" }, { ...
70
false
70
verified
10
10
1
1,058
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.FindMinFibonacciNumbers.Code.Funs import Mathlib.Data.Nat.Fib.Basic /-! # Specifications of `Aegis.FindMinFibonacciNumbers.find_min_fibonacci_numbers` LeetCode problem `find-the-minimum-number-of-fibonacci-numbers-whose-sum-is-k`. Each `spec_<n>` theorem states one property of the function. -/ open Aene...
13
restore-the-array
1,416
Hard
[ "String", "Dynamic Programming" ]
A program was supposed to print an array of integers. The program forgot to print whitespaces and the array is printed as a string of digits s and all we know is that all integers in the array were in the range [1, k] and there are no leading zeros in the array. Given the string s and the integer k, return the number o...
numberOfArrays(s: str, k: int) -> int
pub fn number_of_arrays(s: &[u8], k: i64) -> i64
Aegis.NumberOfArrays.number_of_arrays
pub fn number_of_arrays(s: &[u8], k: i64) -> i64 { let modulus: i64 = 1000000007; let n = s.len(); let mut dp: Vec<i64> = Vec::new(); let mut p = 0usize; while p <= n { dp.push(0); p += 1; } dp[0] = 1; let mut i = 0usize; while i < n { if s[i] != b'0' && dp[...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [number_of_arrays]: type definitions module public import Aeneas @[expose] public section 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 -- [number_of_arrays]: function definitions module public import Aeneas public import Aegis.NumberOfArrays.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.NumberOfArrays.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.NumberOfArrays.number_of_arrays (Slice.from [50#u8, 51#u8, 55#u8] (by scalar_tac) : Slice Std.U8) 50#i64) (3#i64))}") #eval (s!"CASE 1 {(Result.re...
[ { "input": "[\"237\", 50]", "output": "3" }, { "input": "[\"111111111111111111111\", 11]", "output": "17711" }, { "input": "[\"123123123\", 123]", "output": "100" }, { "input": "[\"1317\", 2000]", "output": "8" }, { "input": "[\"99999\", 99999]", "output": "16...
104
false
104
verified
10
10
1
3,971
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.NumberOfArrays.Code.Funs /-! # Specifications of `Aegis.NumberOfArrays.number_of_arrays` LeetCode problem `restore-the-array`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.NumberOfArrays def MODULUS : Nat := 1000000007 def IsResidue...
8
minimum-number-of-frogs-croaking
1,419
Medium
[ "String", "Counting" ]
You are given the string croakOfFrogs, which represents a combination of the string "croak" from different frogs, that is, multiple frogs can croak at the same time, so multiple "croak" are mixed. Return the minimum number of different frogs to finish all the croaks in the given string. A valid "croak" means a frog is ...
minNumberOfFrogs(croakOfFrogs: str) -> int
pub fn min_number_of_frogs(croakOfFrogs: &[u8]) -> i64
Aegis.MinNumberOfFrogs.min_number_of_frogs
pub fn min_number_of_frogs(croakOfFrogs: &[u8]) -> i64 { let mut c: i64 = 0; let mut r: i64 = 0; let mut o: i64 = 0; let mut a: i64 = 0; let mut active: i64 = 0; let mut max_frogs: i64 = 0; let n = croakOfFrogs.len(); let mut i: usize = 0; while i < n { let b = croakOfFrog...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [min_number_of_frogs]: type definitions module public import Aeneas @[expose] public section 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 -- [min_number_of_frogs]: function definitions module public import Aeneas public import Aegis.MinNumberOfFrogs.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false ...
import Aegis.MinNumberOfFrogs.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.MinNumberOfFrogs.min_number_of_frogs (Slice.from [99#u8, 114#u8, 111#u8, 97#u8, 107#u8, 99#u8, 114#u8, 111#u8, 97#u8, 107#u8, 99#u8, 114#u8, 111...
[ { "input": "[\"croakcroakcroak\"]", "output": "1" }, { "input": "[\"croak\"]", "output": "1" }, { "input": "[\"cccrroooaaakkk\"]", "output": "-1" }, { "input": "[\"crcoakroak\"]", "output": "2" }, { "input": "[\"crrcooakak\"]", "output": "-1" }, { "inp...
197
false
197
verified
10
10
1
1,957
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MinNumberOfFrogs.Code.Funs /-! # Specifications of `Aegis.MinNumberOfFrogs.min_number_of_frogs` LeetCode problem `minimum-number-of-frogs-croaking`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.MinNumberOfFrogs namespace AegisSpec.MinNumbe...
12
build-array-where-you-can-find-the-maximum-exactly-k-comparisons
1,420
Hard
[ "Dynamic Programming", "Prefix Sum" ]
You are given three integers n, m and k. Consider the following algorithm to find the maximum element of an array of positive integers: You should build the array arr which has the following properties: arr has exactly n integers. 1 <= arr[i] <= m where (0 <= i < n). After applying the mentioned algorithm to arr, the...
numOfArrays(n: int, m: int, k: int) -> int
pub fn num_of_arrays(n: i64, m: i64, k: i64) -> i64
Aegis.NumOfArrays.num_of_arrays
const MOD: i64 = 1_000_000_007; 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 num_of_arrays(n: i64, m: i64, k: i64) -> i64 { if n <= 0 || m <= 0 || k <= 0 { return 0; ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [num_of_arrays]: type definitions module public import Aeneas @[expose] public section 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_arrays]: function definitions module public import Aeneas public import Aegis.NumOfArrays.Code.Types public import Aegis.NumOfArrays.Code.FunsExternal @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace fal...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [num_of_arrays]: external functions. -- This is a template file: rename it to "FunsExternal.lean" and fill the holes. module public import Aeneas public import Aegis.NumOfArrays.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_...
import Aegis.NumOfArrays.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval aegisCase...
[ { "input": "[1, 1, 1]", "output": "1" }, { "input": "[4, 5, 2]", "output": "305" }, { "input": "[3, 3, 0]", "output": "0" }, { "input": "[3, 5, 2]", "output": "60" }, { "input": "[5, 2, 3]", "output": "0" }, { "input": "[4, 4, 2]", "output": "125" ...
109
false
109
verified
10
10
2
24,682
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.NumOfArrays.Code.Funs /-! # Specifications of `Aegis.NumOfArrays.num_of_arrays` LeetCode problem `build-array-where-you-can-find-the-maximum-exactly-k-comparisons`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open scoped BigOperators namespace Aegis...
11
maximum-score-after-splitting-a-string
1,422
Easy
[ "String", "Prefix Sum" ]
Given a string s of zeros and ones, return the maximum score after splitting the string into two non-empty substrings (i.e. left substring and right substring). The score after splitting a string is the number of zeros in the left substring plus the number of ones in the right substring.   Example 1: Input: s = "01110...
maxScore(s: str) -> int
pub fn max_score(s: &[u8]) -> i64
Aegis.MaxScore.max_score
pub fn max_score(s: &[u8]) -> i64 { let n = s.len(); let mut total_ones: i64 = 0; let mut i: usize = 0; while i < n { if s[i] == b'1' { total_ones += 1; } i += 1; } let mut left_zeros: i64 = 0; let mut right_ones: i64 = total_ones; let mut best: i64 ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [max_score]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter.styl...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [max_score]: function definitions module public import Aeneas public import Aegis.MaxScore.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.MaxScore.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.MaxScore.max_score (Slice.from [49#u8, 49#u8, 49#u8, 49#u8] (by scalar_tac) : Slice Std.U8)) (3#i64))}") #eval (s!"CASE 1 {(Result.reducesTo (Aegis.MaxS...
[ { "input": "[\"1111\"]", "output": "3" }, { "input": "[\"00111\"]", "output": "5" }, { "input": "[\"100100\"]", "output": "3" }, { "input": "[\"110011\"]", "output": "4" }, { "input": "[\"001001\"]", "output": "5" }, { "input": "[\"11110000\"]", "o...
143
false
143
verified
10
10
1
642
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MaxScore.Code.Funs /-! # Specifications of `Aegis.MaxScore.max_score` LeetCode problem `maximum-score-after-splitting-a-string`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.MaxScore abbrev codeZero : ℕ := 48 abbrev codeOne : ...
11
maximum-points-you-can-obtain-from-cards
1,423
Medium
[ "Array", "Prefix Sum", "Sliding Window" ]
There are several cards arranged in a row, and each card has an associated number of points. The points are given in the integer array cardPoints. In one step, you can take one card from the beginning or from the end of the row. You have to take exactly k cards. Your score is the sum of the points of the cards you have...
maxScore(cardPoints: list_int, k: int) -> int
pub fn max_score(cardPoints: &[i64], k: i64) -> i64
Aegis.MaxScore.max_score
pub fn max_score(cardPoints: &[i64], k: i64) -> i64 { let n = cardPoints.len(); let k_usize = k as usize; let mut score: i64 = 0; let mut i: usize = 0; while i < k_usize { score += cardPoints[i]; i += 1; } let mut best = score; let mut take_right: usize = 1; while ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [max_score]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter.styl...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [max_score]: function definitions module public import Aeneas public import Aegis.MaxScore.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.MaxScore.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.MaxScore.max_score (Slice.from [1#i64, 1000#i64, 1#i64] (by scalar_tac) : Slice Std.I64) 1#i64) (1#i64))}") #eval (s!"CASE 1 {(Result.reducesTo (Aegis.M...
[ { "input": "[[1, 1000, 1], 1]", "output": "1" }, { "input": "[[2, 2, 2], 2]", "output": "4" }, { "input": "[[5, 2, 1, 2, 5], 3]", "output": "12" }, { "input": "[[10000, 10000, 10000, 10000, 10000], 5]", "output": "50000" }, { "input": "[[3, 2, 7, 4, 1], 2]", "...
78
false
78
verified
10
10
1
973
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MaxScore.Code.Funs /-! # Specifications of `Aegis.MaxScore.max_score` LeetCode problem `maximum-points-you-can-obtain-from-cards`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.MaxScore def cards (s : Slice Std.I64) : List ℤ := s.list...
14
diagonal-traverse-ii
1,424
Medium
[ "Array", "Sorting", "Heap (Priority Queue)" ]
Given a 2D integer array nums, return all elements of nums in diagonal order as shown in the below images.   Example 1: Input: nums = [[1,2,3],[4,5,6],[7,8,9]] Output: [1,4,2,7,5,3,8,6,9] Example 2: Input: nums = [[1,2,3,4,5],[6,7],[8],[9,10,11],[12,13,14,15,16]] Output: [1,6,2,8,7,3,9,4,12,10,5,13,11,14,15,16]  ...
findDiagonalOrder(nums: list_list_int) -> list_int
pub fn find_diagonal_order(nums: &[Vec<i64>]) -> Vec<i64>
Aegis.FindDiagonalOrder.find_diagonal_order
pub fn find_diagonal_order(nums: &[Vec<i64>]) -> Vec<i64> { let r = nums.len(); if r == 0 { return Vec::new(); } let mut max_sum: usize = 0; let mut i: usize = 0; while i < r { let len = nums[i].len(); if len > 0 { let s = i + len - 1; if s > max_...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [find_diagonal_order]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option l...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [find_diagonal_order]: function definitions module public import Aeneas public import Aegis.FindDiagonalOrder.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false...
import Aegis.FindDiagonalOrder.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.FindDiagonalOrder.find_diagonal_order (Slice.from [(alloc.vec.Vec.from [1#i64] (by scalar_tac) : alloc.vec.Vec Std.I64)] (by scalar_tac) : Slic...
[ { "input": "[[[1]]]", "output": "[1]" }, { "input": "[[[1, 2, 3], [4, 5], [6]]]", "output": "[1, 4, 2, 6, 5, 3]" }, { "input": "[[[1, 2], [3, 4], [5, 6]]]", "output": "[1, 3, 2, 5, 4, 6]" }, { "input": "[[[1, 2, 3], [4, 5, 6], [7, 8, 9]]]", "output": "[1, 4, 2, 7, 5, 3, 8...
70
false
70
verified
10
10
1
3,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.FindDiagonalOrder.Code.Funs /-! # Specifications of `Aegis.FindDiagonalOrder.find_diagonal_order` LeetCode problem `diagonal-traverse-ii`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.FindDiagonalOrder namespace AegisSpec.FindDiagonalOrde...
12
constrained-subsequence-sum
1,425
Hard
[ "Queue", "Array", "Dynamic Programming", "Sliding Window", "Monotonic Queue", "Heap (Priority Queue)" ]
Given an integer array nums and an integer k, return the maximum sum of a non-empty subsequence of that array such that for every two consecutive integers in the subsequence, nums[i] and nums[j], where i < j, the condition j - i <= k is satisfied. A subsequence of an array is obtained by deleting some number of element...
constrainedSubsetSum(nums: list_int, k: int) -> int
pub fn constrained_subset_sum(nums: &[i64], k: i64) -> i64
Aegis.ConstrainedSubsetSum.constrained_subset_sum
pub fn constrained_subset_sum(nums: &[i64], k: i64) -> i64 { let n = nums.len(); if n == 0 { return 0; } let mut dp: Vec<i64> = Vec::new(); let mut dq: Vec<i64> = Vec::new(); let mut z: usize = 0; while z < n { dq.push(0); z += 1; } let mut head: usize = 0;...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [constrained_subset_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_optio...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [constrained_subset_sum]: function definitions module public import Aeneas public import Aegis.ConstrainedSubsetSum.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand...
import Aegis.ConstrainedSubsetSum.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.ConstrainedSubsetSum.constrained_subset_sum (Slice.from [5#i64, (-1)#i64, 5#i64] (by scalar_tac) : Slice Std.I64) 2#i64) (10#i64))}") #eval ...
[ { "input": "[[5, -1, 5], 2]", "output": "10" }, { "input": "[[-1, -2, -3], 1]", "output": "-1" }, { "input": "[[5, 7, -3, 5], 1]", "output": "14" }, { "input": "[[10, 2, -10, 5, 20], 2]", "output": "37" }, { "input": "[[1, 2, 3, 4, 5], 3]", "output": "15" },...
115
false
115
verified
10
10
1
3,956
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.ConstrainedSubsetSum.Code.Funs /-! # Specifications of `Aegis.ConstrainedSubsetSum.constrained_subset_sum` LeetCode problem `constrained-subsequence-sum`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.ConstrainedSubsetSum def ints (a ...
14
counting-elements
1,426
Easy
[ "Array", "Hash Table" ]
Given an integer array arr, count how many elements x there are, such that x + 1 is also in arr. If there are duplicates in arr, count them separately.   Example 1: Input: arr = [1,2,3] Output: 2 Explanation: 1 and 2 are counted cause 2 and 3 are in arr. Example 2: Input: arr = [1,1,3,3,5,5,7,7] Output: 0 Explanatio...
countElements(arr: list_int) -> int
pub fn count_elements(arr: &[i64]) -> i64
Aegis.CountElements.count_elements
pub fn count_elements(arr: &[i64]) -> i64 { let n = arr.len(); let mut count: i64 = 0; let mut i: usize = 0; while i < n { let x = arr[i]; let mut found: bool = false; let mut j: usize = 0; while j < n { if arr[j] == x + 1 { found = true; ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [count_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 linter...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [count_elements]: function definitions module public import Aeneas public import Aegis.CountElements.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.CountElements.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.CountElements.count_elements (Slice.from [0#i64] (by scalar_tac) : Slice Std.I64)) (0#i64))}") #eval (s!"CASE 1 {(Result.reducesTo (Aegis.CountElem...
[ { "input": "[[0]]", "output": "0" }, { "input": "[[1]]", "output": "0" }, { "input": "[[1000]]", "output": "0" }, { "input": "[[1, 2]]", "output": "1" }, { "input": "[[0, 1000]]", "output": "0" }, { "input": "[[1, 2, 3]]", "output": "2" }, { ...
125
false
125
verified
10
10
1
680
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.CountElements.Code.Funs /-! # Specifications of `Aegis.CountElements.count_elements` LeetCode problem `counting-elements`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.CountElements open Aegis.CountElements def entriesInRange (arr :...
10
check-if-a-string-is-a-valid-sequence-from-root-to-leaves-path-in-a-binary-tree
1,430
Medium
[ "Tree", "Depth-First Search", "Breadth-First Search", "Binary Tree" ]
Given a binary tree where each path going from the root to any leaf form a valid sequence, check if a given string is a valid sequence in such binary tree.  We get the given string from the concatenation of an array of integers arr and the concatenation of all values of the nodes along a path results in a sequence in t...
isValidSequence(root: tree, arr: list_int) -> bool
pub fn is_valid_sequence(root: &Tree, arr: &[i64]) -> bool
Aegis.IsValidSequence.is_valid_sequence
pub fn is_valid_sequence(root: &Tree, arr: &[i64]) -> bool { if arr.len() == 0 { return false; } valid_from(root, arr, 0) } fn valid_from(node: &Tree, arr: &[i64], idx: usize) -> bool { if idx >= arr.len() { return false; } match node { Tree::Null => false, Tree...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [is_valid_sequence]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option lin...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [is_valid_sequence]: function definitions module public import Aeneas public import Aegis.IsValidSequence.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.IsValidSequence.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.IsValidSequence.is_valid_sequence ((.Node 1#i64 (.Node 2#i64 (.Null) (.Null)) (.Node 3#i64 (.Null) (.Null))) : Aegis.IsValidSequence.Tree) (Slice...
[ { "input": "[[1, 2, 3], [1, 2]]", "output": "true" }, { "input": "[[1, 0, 1, 0, 1, 0, 1], [1, 1]]", "output": "false" }, { "input": "[[1, 0, 1, 0, 1, 0, 1], [1, 0, 1]]", "output": "true" }, { "input": "[[9, 8, 7, 6, 5, 4, 3, 2, 1], [9, 8, 6, 2]]", "output": "true" }, ...
17
false
17
verified
10
10
1
1,920
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.IsValidSequence.Code.Funs /-! # Specifications of `Aegis.IsValidSequence.is_valid_sequence` LeetCode problem `check-if-a-string-is-a-valid-sequence-from-root-to-leaves-path-in-a-binary-tree`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace Aegis...
14
kids-with-the-greatest-number-of-candies
1,431
Easy
[ "Array" ]
There are n kids with candies. You are given an integer array candies, where each candies[i] represents the number of candies the ith kid has, and an integer extraCandies, denoting the number of extra candies that you have. Return a boolean array result of length n, where result[i] is true if, after giving the ith kid ...
kidsWithCandies(candies: list_int, extraCandies: int) -> list_bool
pub fn kids_with_candies(candies: &[i64], extraCandies: i64) -> Vec<bool>
Aegis.KidsWithCandies.kids_with_candies
pub fn kids_with_candies(candies: &[i64], extraCandies: i64) -> Vec<bool> { let n = candies.len(); if n == 0 { return Vec::new(); } let mut max_candies: i64 = candies[0]; let mut i: usize = 0; while i < n { if candies[i] > max_candies { max_candies = candies[i]; ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [kids_with_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 lin...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [kids_with_candies]: function definitions module public import Aeneas public import Aegis.KidsWithCandies.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.KidsWithCandies.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.KidsWithCandies.kids_with_candies (Slice.from [12#i64, 1#i64, 12#i64] (by scalar_tac) : Slice Std.I64) 10#i64) ((alloc.vec.Vec.from [true, false,...
[ { "input": "[[12, 1, 12], 10]", "output": "[true, false, true]" }, { "input": "[[5, 8, 7], 5]", "output": "[true, true, true]" }, { "input": "[[4, 2, 1, 1, 2], 1]", "output": "[true, false, false, false, false]" }, { "input": "[[50, 50, 50, 50, 50], 50]", "output": "[true...
81
false
81
verified
10
10
1
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.KidsWithCandies.Code.Funs /-! # Specifications of `Aegis.KidsWithCandies.kids_with_candies` LeetCode problem `kids-with-the-greatest-number-of-candies`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.KidsWithCandies def vals (candies :...
12
max-difference-you-can-get-from-changing-an-integer
1,432
Medium
[ "Greedy", "Math" ]
You are given an integer num. You will apply the following steps exactly two times: Pick a digit x (0 <= x <= 9). Pick another digit y (0 <= y <= 9). The digit y can be equal to x. Replace all the occurrences of x in the decimal representation of num by y. The new integer cannot have any leading zeros, also the new in...
maxDiff(num: int) -> int
pub fn max_diff(num: i64) -> i64
Aegis.MaxDiff.max_diff
pub fn max_diff(num: i64) -> i64 { let digits = to_digits(num); let n = digits.len(); // Find the maximum possible value. let mut x_max: i64 = -1; let mut i: usize = 0; while i < n { if x_max == -1 && digits[i] != 9 { x_max = digits[i]; } i += 1; } l...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [max_diff]: type definitions module public import Aeneas @[expose] public section 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_diff]: function definitions module public import Aeneas public import Aegis.MaxDiff.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.MaxDiff.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.MaxDiff.max_diff 1001100#i64) (8008800#i64))}") #eval (s!"CASE 1 {(Result.reducesTo (Aegis.MaxDiff.max_diff 9#i64) (8#i64))}") #eval (s!"CASE 2 {(Result....
[ { "input": "[1001100]", "output": "8008800" }, { "input": "[9]", "output": "8" }, { "input": "[98789]", "output": "81018" }, { "input": "[123456]", "output": "820000" }, { "input": "[987654321]", "output": "810000000" }, { "input": "[1000000]", "ou...
80
false
80
verified
10
10
1
5,245
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MaxDiff.Code.Funs /-! # Specifications of `Aegis.MaxDiff.max_diff` LeetCode problem `max-difference-you-can-get-from-changing-an-integer`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.MaxDiff def digitsOf (n : ℕ) : List ℕ := if n =...
11
number-of-ways-to-wear-different-hats-to-each-other
1,434
Hard
[ "Bit Manipulation", "Array", "Dynamic Programming", "Bitmask" ]
There are n people and 40 types of hats labeled from 1 to 40. Given a 2D integer array hats, where hats[i] is a list of all hats preferred by the ith person. Return the number of ways that n people can wear different hats from each other. Since the answer may be too large, return it modulo 109 + 7.   Example 1: Input:...
numberWays(hats: list_list_int) -> int
pub fn number_ways(hats: &[Vec<i64>]) -> i64
Aegis.NumberWays.number_ways
pub fn number_ways(hats: &[Vec<i64>]) -> i64 { let modulo: i64 = 1000000007; let n: usize = hats.len(); let total: usize = 1usize << n; let mut dp: Vec<i64> = Vec::new(); let mut i: usize = 0; while i < total { dp.push(0); i += 1; } dp[0] = 1; let mut max_hat: i64 =...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [number_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.st...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [number_ways]: function definitions module public import Aeneas public import Aegis.NumberWays.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.NumberWays.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.NumberWays.number_ways (Slice.from [(alloc.vec.Vec.from [3#i64] (by scalar_tac) : alloc.vec.Vec Std.I64), (alloc.vec.Vec.from [5#i64] (by scalar_tac) ...
[ { "input": "[[[3], [5], [1], [2]]]", "output": "1" }, { "input": "[[[1], [2], [3], [4], [5]]]", "output": "1" }, { "input": "[[[3, 5, 1], [3, 5]]]", "output": "4" }, { "input": "[[[3, 4], [4, 5], [5]]]", "output": "1" }, { "input": "[[[1, 2], [3, 4], [5, 6]]]", ...
83
false
83
verified
10
10
2
4,178
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.NumberWays.Code.Funs /-! # Specifications of `Aegis.NumberWays.number_ways` LeetCode problem `number-of-ways-to-wear-different-hats-to-each-other`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.NumberWays def rows (hats : Slice (alloc...
13
check-if-all-1s-are-at-least-length-k-places-away
1,437
Easy
[ "Array" ]
Given an binary array nums and an integer k, return true if all 1's are at least k places away from each other, otherwise return false.   Example 1: Input: nums = [1,0,0,0,1,0,0,1], k = 2 Output: true Explanation: Each of the 1s are at least 2 places away from each other. Example 2: Input: nums = [1,0,0,1,0,1], k ...
kLengthApart(nums: list_int, k: int) -> bool
pub fn k_length_apart(nums: &[i64], k: i64) -> bool
Aegis.KLengthApart.k_length_apart
pub fn k_length_apart(nums: &[i64], k: i64) -> bool { let n: usize = nums.len(); let mut i: usize = 0; let mut gap: i64 = k; // gap since last 1; start at k => "satisfied" before first 1 let mut ok: bool = true; while i < n { if nums[i] == 1 { if gap < k { ok = f...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [k_length_apart]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [k_length_apart]: function definitions module public import Aeneas public import Aegis.KLengthApart.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.KLengthApart.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.KLengthApart.k_length_apart (Slice.from [1#i64] (by scalar_tac) : Slice Std.I64) 1#i64) (true))}") #eval (s!"CASE 1 {(Result.reducesTo (Aegis.KLengt...
[ { "input": "[[1], 1]", "output": "true" }, { "input": "[[1], 0]", "output": "true" }, { "input": "[[1, 1, 0, 1], 0]", "output": "true" }, { "input": "[[1, 1, 1, 1, 1], 0]", "output": "true" }, { "input": "[[0, 0, 0, 0, 0], 1]", "output": "true" }, { "i...
104
false
104
verified
10
10
2
5,686
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.KLengthApart.Code.Funs /-! # Specifications of `Aegis.KLengthApart.k_length_apart` LeetCode problem `check-if-all-1s-are-at-least-length-k-places-away`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.KLengthApart namespace AegisSpec.KLengthA...
11
longest-continuous-subarray-with-absolute-diff-less-than-or-equal-to-limit
1,438
Medium
[ "Queue", "Array", "Ordered Set", "Sliding Window", "Monotonic Queue", "Heap (Priority Queue)" ]
Given an array of integers nums and an integer limit, return the size of the longest non-empty subarray such that the absolute difference between any two elements of this subarray is less than or equal to limit.   Example 1: Input: nums = [8,2,4,7], limit = 4 Output: 2 Explanation: All subarrays are: [8] with maximu...
longestSubarray(nums: list_int, limit: int) -> int
pub fn longest_subarray(nums: &[i64], limit: i64) -> i64
Aegis.LongestSubarray.longest_subarray
pub fn longest_subarray(nums: &[i64], limit: i64) -> i64 { let n = nums.len(); if n == 0 { return 0; } let mut maxq: Vec<i64> = Vec::new(); let mut minq: Vec<i64> = Vec::new(); let mut init: usize = 0; while init < n { maxq.push(0); minq.push(0); init += 1; ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [longest_subarray]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option lint...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [longest_subarray]: function definitions module public import Aeneas public import Aegis.LongestSubarray.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.LongestSubarray.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.LongestSubarray.longest_subarray (Slice.from [1#i64] (by scalar_tac) : Slice Std.I64) 1#i64) (1#i64))}") #eval (s!"CASE 1 {(Result.reducesTo (Aeg...
[ { "input": "[[1], 1]", "output": "1" }, { "input": "[[1], 10]", "output": "1" }, { "input": "[[1], 0]", "output": "1" }, { "input": "[[1, 2], 1]", "output": "2" }, { "input": "[[1000000000, 1000000000, 1000000000], 0]", "output": "3" }, { "input": "[[1...
184
false
184
verified
10
10
1
7,706
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.LongestSubarray.Code.Funs /-! # Specifications of `Aegis.LongestSubarray.longest_subarray` LeetCode problem `longest-continuous-subarray-with-absolute-diff-less-than-or-equal-to-limit`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.L...
14
build-an-array-with-stack-operations
1,441
Medium
[ "Stack", "Array", "Simulation" ]
You are given an integer array target and an integer n. You have an empty stack with the two following operations: "Push": pushes an integer to the top of the stack. "Pop": removes the integer on the top of the stack. You also have a stream of the integers in the range [1, n]. Use the two stack operations to make the...
buildArray(target: list_int, n: int) -> list_str
pub fn build_array(target: &[i64], n: i64) -> Vec<Vec<u8>>
Aegis.BuildArray.build_array
fn make_push() -> Vec<u8> { let mut op: Vec<u8> = Vec::new(); op.push(b'P'); op.push(b'u'); op.push(b's'); op.push(b'h'); op } fn make_pop() -> Vec<u8> { let mut op: Vec<u8> = Vec::new(); op.push(b'P'); op.push(b'o'); op.push(b'p'); op } pub fn build_array(target: &[i64], n...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [build_array]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter.st...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [build_array]: function definitions module public import Aeneas public import Aegis.BuildArray.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.BuildArray.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.BuildArray.build_array (Slice.from [1#i64] (by scalar_tac) : Slice Std.I64) 1#i64) ((alloc.vec.Vec.from [(alloc.vec.Vec.from [80#u8, 117#u8, 115#u8, 1...
[ { "input": "[[1], 1]", "output": "[\"Push\"]" }, { "input": "[[1, 2], 4]", "output": "[\"Push\", \"Push\"]" }, { "input": "[[1, 2, 3], 3]", "output": "[\"Push\", \"Push\", \"Push\"]" }, { "input": "[[1, 3], 3]", "output": "[\"Push\", \"Push\", \"Pop\", \"Push\"]" }, {...
113
false
113
verified
10
10
1
694
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.BuildArray.Code.Funs /-! # Specifications of `Aegis.BuildArray.build_array` LeetCode problem `build-an-array-with-stack-operations`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.BuildArray def pushBytes : List Std.U8 := [80#u8, 117#u...
14
count-triplets-that-can-form-two-arrays-of-equal-xor
1,442
Medium
[ "Bit Manipulation", "Array", "Hash Table", "Math", "Prefix Sum" ]
Given an array of integers arr. We want to select three indices i, j and k where (0 <= i < j <= k < arr.length). Let's define a and b as follows: a = arr[i] ^ arr[i + 1] ^ ... ^ arr[j - 1] b = arr[j] ^ arr[j + 1] ^ ... ^ arr[k] Note that ^ denotes the bitwise-xor operation. Return the number of triplets (i, j and k) ...
countTriplets(arr: list_int) -> int
pub fn count_triplets(arr: &[i64]) -> i64
Aegis.CountTriplets.count_triplets
pub fn count_triplets(arr: &[i64]) -> i64 { let n = arr.len(); let mut prefix: Vec<i64> = Vec::new(); prefix.push(0); let mut cur: i64 = 0; let mut i: usize = 0; while i < n { cur = cur ^ arr[i]; prefix.push(cur); i += 1; } let mut ans: i64 = 0; let mut x: ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [count_triplets]: type definitions module public import Aeneas @[expose] public section 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_triplets]: function definitions module public import Aeneas public import Aegis.CountTriplets.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.CountTriplets.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.CountTriplets.count_triplets (Slice.from [8#i64, 12#i64, 3#i64, 10#i64] (by scalar_tac) : Slice Std.I64)) (0#i64))}") #eval (s!"CASE 1 {(Result.red...
[ { "input": "[[8, 12, 3, 10]]", "output": "0" }, { "input": "[[1, 2, 3, 4, 5]]", "output": "5" }, { "input": "[[2, 3, 1, 6, 7]]", "output": "4" }, { "input": "[[5, 3, 0, 1, 4]]", "output": "0" }, { "input": "[[8, 1, 6, 2, 1]]", "output": "0" }, { "input...
93
false
93
verified
10
10
1
2,752
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.CountTriplets.Code.Funs /-! # Specifications of `Aegis.CountTriplets.count_triplets` LeetCode problem `count-triplets-that-can-form-two-arrays-of-equal-xor`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.CountTriplets def values (arr ...
6
consecutive-characters
1,446
Easy
[ "String" ]
The power of the string is the maximum length of a non-empty substring that contains only one unique character. Given a string s, return the power of s.   Example 1: Input: s = "leetcode" Output: 2 Explanation: The substring "ee" is of length 2 with the character 'e' only. Example 2: Input: s = "abbcccddddeeeeedcba"...
maxPower(s: str) -> int
pub fn max_power(s: &[u8]) -> i64
Aegis.MaxPower.max_power
pub fn max_power(s: &[u8]) -> i64 { let n = s.len(); if n == 0 { return 0; } let mut best: i64 = 1; let mut cur: i64 = 1; let mut i: usize = 1; while i < n { if s[i] == s[i - 1] { cur += 1; } else { cur = 1; } if cur > best {...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [max_power]: type definitions module public import Aeneas @[expose] public section 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_power]: function definitions module public import Aeneas public import Aegis.MaxPower.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.MaxPower.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.MaxPower.max_power (Slice.from [97#u8, 98#u8, 99#u8, 100#u8, 101#u8, 102#u8, 103#u8, 104#u8, 105#u8, 106#u8, 107#u8, 108#u8, 109#u8, 110#u8, 111#u8, 112...
[ { "input": "[\"abcdefghijklmnopqrstuvwxyz\"]", "output": "1" }, { "input": "[\"tourist\"]", "output": "1" }, { "input": "[\"a\"]", "output": "1" }, { "input": "[\"aabbbbccc\"]", "output": "4" }, { "input": "[\"cccccaaaa\"]", "output": "5" }, { "input":...
70
false
70
verified
10
10
1
370
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MaxPower.Code.Funs /-! # Specifications of `Aegis.MaxPower.max_power` LeetCode problem `consecutive-characters`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.MaxPower def toListN {α : Type} : (l : List α) → Aeneas.Data.ListN.ListN α ...
10
simplified-fractions
1,447
Medium
[ "Math", "String", "Number Theory" ]
Given an integer n, return a list of all simplified fractions between 0 and 1 (exclusive) such that the denominator is less-than-or-equal-to n. You can return the answer in any order.   Example 1: Input: n = 2 Output: ["1/2"] Explanation: "1/2" is the only unique fraction with a denominator less-than-or-equal-to 2. E...
simplifiedFractions(n: int) -> list_str
pub fn simplified_fractions(n: i64) -> Vec<Vec<u8>>
Aegis.SimplifiedFractions.simplified_fractions
pub fn simplified_fractions(n: i64) -> Vec<Vec<u8>> { let mut out: Vec<Vec<u8>> = Vec::new(); let mut num: i64 = 1; while num < n { // --- Precompute the (at most two) digit bytes of the numerator once. --- let num_two: bool = num >= 10; let nt: i64 = num / 10; let nu: i64 =...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [simplified_fractions]: type definitions module public import Aeneas @[expose] public section 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 -- [simplified_fractions]: function definitions module public import Aeneas public import Aegis.SimplifiedFractions.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand fa...
import Aegis.SimplifiedFractions.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval a...
[ { "input": "[1]", "output": "[]" }, { "input": "[2]", "output": "[\"1/2\"]" }, { "input": "[3]", "output": "[\"1/2\", \"1/3\", \"2/3\"]" }, { "input": "[4]", "output": "[\"1/2\", \"1/3\", \"1/4\", \"2/3\", \"3/4\"]" }, { "input": "[5]", "output": "[\"1/2\", \"...
11
true
11
verified_partial
10
7
2
27,649
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.SimplifiedFractions.Code.Funs /-! # Specifications of `Aegis.SimplifiedFractions.simplified_fractions` LeetCode problem `simplified-fractions`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.SimplifiedFractions namespace AegisSpec.SimplifiedFrac...
13
count-good-nodes-in-binary-tree
1,448
Medium
[ "Tree", "Depth-First Search", "Breadth-First Search", "Binary Tree" ]
Given a binary tree root, a node X in the tree is named good if in the path from root to X there are no nodes with a value greater than X.\r \r Return the number of good nodes in the binary tree.\r \r  \r Example 1:\r \r \r \r \r Input: root = [3,1,4,3,null,1,5]\r Output: 4\r Explanation: Nodes in blue are good.\r Root...
goodNodes(root: tree) -> int
pub fn good_nodes(root: &Tree) -> i64
Aegis.GoodNodes.good_nodes
fn count_good(node: &Tree, max_so_far: i64) -> i64 { match node { Tree::Null => 0, Tree::Node(value, left, right) => { let v = *value; let mut current_max = max_so_far; let mut count = 0; if v >= max_so_far { count = 1; ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [good_nodes]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter.sty...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [good_nodes]: function definitions module public import Aeneas public import Aegis.GoodNodes.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.GoodNodes.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.GoodNodes.good_nodes ((.Node 1#i64 (.Null) (.Null)) : Aegis.GoodNodes.Tree)) (1#i64))}") #eval (s!"CASE 1 {(Result.reducesTo (Aegis.GoodNodes.good_node...
[ { "input": "[[1]]", "output": "1" }, { "input": "[[-10000, -5000, -2500]]", "output": "3" }, { "input": "[[-10, -20, -5, -15, -30]]", "output": "2" }, { "input": "[[5, 10, 20, 15, 25]]", "output": "5" }, { "input": "[[5, 4, 6, 3, 8, 5, 7]]", "output": "4" },...
31
false
31
verified
10
10
1
1,215
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.GoodNodes.Code.Funs /-! # Specifications of `Aegis.GoodNodes.good_nodes` LeetCode problem `count-good-nodes-in-binary-tree`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.GoodNodes (good_nodes) open Aeneas.Std.Result namespace AegisSpec.GoodNo...
14
number-of-students-doing-homework-at-a-given-time
1,450
Easy
[ "Array" ]
Given two integer arrays startTime and endTime and given an integer queryTime. The ith student started doing their homework at the time startTime[i] and finished it at time endTime[i]. Return the number of students doing their homework at time queryTime. More formally, return the number of students where queryTime lays...
busyStudent(startTime: list_int, endTime: list_int, queryTime: int) -> int
pub fn busy_student(startTime: &[i64], endTime: &[i64], queryTime: i64) -> i64
Aegis.BusyStudent.busy_student
pub fn busy_student(startTime: &[i64], endTime: &[i64], queryTime: i64) -> i64 { let n = startTime.len(); let mut count: i64 = 0; let mut i: usize = 0; while i < n { if startTime[i] <= queryTime && queryTime <= endTime[i] { count += 1; } i += 1; } count }
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [busy_student]: type definitions module public import Aeneas @[expose] public section 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 -- [busy_student]: function definitions module public import Aeneas public import Aegis.BusyStudent.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.BusyStudent.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.BusyStudent.busy_student (Slice.from [4#i64] (by scalar_tac) : Slice Std.I64) (Slice.from [4#i64] (by scalar_tac) : Slice Std.I64) 4#i64) (1#i64))}")...
[ { "input": "[[4], [4], 4]", "output": "1" }, { "input": "[[1, 2, 3], [3, 2, 7], 4]", "output": "1" }, { "input": "[[100, 200, 300], [150, 250, 350], 225]", "output": "1" }, { "input": "[[10, 20, 30], [15, 25, 35], 22]", "output": "1" }, { "input": "[[100, 200, 300...
95
false
95
verified
10
10
1
133
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.BusyStudent.Code.Funs /-! # Specifications of `Aegis.BusyStudent.busy_student` LeetCode problem `number-of-students-doing-homework-at-a-given-time`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.BusyStudent abbrev containsQuery (s...
2
maximum-number-of-darts-inside-of-a-circular-dartboard
1,453
Hard
[ "Geometry", "Array", "Math" ]
Alice is throwing n darts on a very large wall. You are given an array darts where darts[i] = [xi, yi] is the position of the ith dart that Alice threw on the wall. Bob knows the positions of the n darts on the wall. He wants to place a dartboard of radius r on the wall so that the maximum number of darts that Alice th...
numPoints(darts: list_list_int, r: int) -> int
pub fn num_points(darts: &[Vec<i64>], r: i64) -> i64
Aegis.NumPoints.num_points
fn compare_sq_times(a: i64, d: i64, b: i64, k: i64) -> i64 { let base: i64 = 1_000_000_000; let a0 = a % base; let a1 = a / base; let p0 = a0 * a0; let c0 = p0 % base; let carry0 = p0 / base; let cross = 2 * a0 * a1 + carry0; let c1 = cross % base; let carry1 = cross / base; let...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [num_points]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter.sty...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [num_points]: function definitions module public import Aeneas public import Aegis.NumPoints.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.NumPoints.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.NumPoints.num_points (Slice.from [(alloc.vec.Vec.from [(-10000)#i64, 10000#i64] (by scalar_tac) : alloc.vec.Vec Std.I64), (alloc.vec.Vec.from [10000#i6...
[ { "input": "[[[-10000, 10000], [10000, -10000]], 5000]", "output": "1" }, { "input": "[[[100, 100], [-100, -100], [0, 0]], 150]", "output": "3" }, { "input": "[[[1, 1], [2, 2], [3, 3]], 1]", "output": "2" }, { "input": "[[[1000, -1000], [-1000, 1000], [0, 0]], 1500]", "ou...
123
false
123
verified
10
10
1
21,785
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.NumPoints.Code.Funs import Mathlib.Data.Real.Basic /-! # Specifications of `Aegis.NumPoints.num_points` LeetCode problem `maximum-number-of-darts-inside-of-a-circular-dartboard`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.NumPoints (num_point...
11
check-if-a-word-occurs-as-a-prefix-of-any-word-in-a-sentence
1,455
Easy
[ "Two Pointers", "String", "String Matching" ]
Given a sentence that consists of some words separated by a single space, and a searchWord, check if searchWord is a prefix of any word in sentence. Return the index of the word in sentence (1-indexed) where searchWord is a prefix of this word. If searchWord is a prefix of more than one word, return the index of the fi...
isPrefixOfWord(sentence: str, searchWord: str) -> int
pub fn is_prefix_of_word(sentence: &[u8], searchWord: &[u8]) -> i64
Aegis.IsPrefixOfWord.is_prefix_of_word
pub fn is_prefix_of_word(sentence: &[u8], searchWord: &[u8]) -> i64 { let n: usize = sentence.len(); let m: usize = searchWord.len(); let mut i: usize = 0; let mut word_index: i64 = 1; while i < n { let start: usize = i; while i < n && sentence[i] != b' ' { i += 1; ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [is_prefix_of_word]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option lin...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [is_prefix_of_word]: function definitions module public import Aeneas public import Aegis.IsPrefixOfWord.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.IsPrefixOfWord.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.IsPrefixOfWord.is_prefix_of_word (Slice.from [97#u8, 32#u8, 97#u8, 98#u8, 32#u8, 97#u8, 98#u8, 99#u8, 32#u8, 97#u8, 98#u8, 100#u8] (by scalar_tac)...
[ { "input": "[\"a ab abc abd\", \"a\"]", "output": "1" }, { "input": "[\"abcde fghij klmno\", \"mnop\"]", "output": "-1" }, { "input": "[\"find prefix quickly\", \"qui\"]", "output": "3" }, { "input": "[\"prefix test\", \"prefix\"]", "output": "1" }, { "input": "[\...
172
false
172
verified
10
10
1
941
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.IsPrefixOfWord.Code.Funs /-! # Specifications of `Aegis.IsPrefixOfWord.is_prefix_of_word` LeetCode problem `check-if-a-word-occurs-as-a-prefix-of-any-word-in-a-sentence`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.IsPrefixOfWord de...
13
max-dot-product-of-two-subsequences
1,458
Hard
[ "Array", "Dynamic Programming" ]
Given two arrays nums1 and nums2. Return the maximum dot product between non-empty subsequences of nums1 and nums2 with the same length. A subsequence of a array is a new array which is formed from the original array by deleting some (can be none) of the characters without disturbing the relative positions of the remai...
maxDotProduct(nums1: list_int, nums2: list_int) -> int
pub fn max_dot_product(nums1: &[i64], nums2: &[i64]) -> i64
Aegis.MaxDotProduct.max_dot_product
pub fn max_dot_product(nums1: &[i64], nums2: &[i64]) -> i64 { let n = nums1.len(); let m = nums2.len(); let cols = m + 1; let neg_inf: i64 = -1000000000000000000; let mut dp: Vec<i64> = Vec::new(); let mut i: usize = 0; while i <= n { let mut j: usize = 0; while j <= m { ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [max_dot_product]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linte...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [max_dot_product]: function definitions module public import Aeneas public import Aegis.MaxDotProduct.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.MaxDotProduct.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.MaxDotProduct.max_dot_product (Slice.from [1000#i64] (by scalar_tac) : Slice Std.I64) (Slice.from [(-1000)#i64] (by scalar_tac) : Slice Std.I64)) (...
[ { "input": "[[1000], [-1000]]", "output": "-1000000" }, { "input": "[[-1000], [1000]]", "output": "-1000000" }, { "input": "[[1], [1]]", "output": "1" }, { "input": "[[-1, -1], [1, 1]]", "output": "-1" }, { "input": "[[1000, -1000], [-1000, 1000]]", "output": ...
109
false
109
verified
10
10
1
3,794
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MaxDotProduct.Code.Funs /-! # Specifications of `Aegis.MaxDotProduct.max_dot_product` LeetCode problem `max-dot-product-of-two-subsequences`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.MaxDotProduct namespace AegisSpec.MaxDotProduct d...
14
make-two-arrays-equal-by-reversing-subarrays
1,460
Easy
[ "Array", "Hash Table", "Sorting" ]
You are given two integer arrays of equal length target and arr. In one step, you can select any non-empty subarray of arr and reverse it. You are allowed to make any number of steps. Return true if you can make arr equal to target or false otherwise.   Example 1: Input: target = [1,2,3,4], arr = [2,4,1,3] Output: tru...
canBeEqual(target: list_int, arr: list_int) -> bool
pub fn can_be_equal(target: &[i64], arr: &[i64]) -> bool
Aegis.CanBeEqual.can_be_equal
pub fn can_be_equal(target: &[i64], arr: &[i64]) -> bool { let n: usize = target.len(); if n != arr.len() { return false; } let mut used: Vec<bool> = Vec::new(); let mut i: usize = 0; while i < n { used.push(false); i += 1; } i = 0; while i < n { let...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [can_be_equal]: type definitions module public import Aeneas @[expose] public section 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 -- [can_be_equal]: function definitions module public import Aeneas public import Aegis.CanBeEqual.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.CanBeEqual.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.CanBeEqual.can_be_equal (Slice.from [7#i64] (by scalar_tac) : Slice Std.I64) (Slice.from [7#i64] (by scalar_tac) : Slice Std.I64)) (true))}") #eval (s...
[ { "input": "[[7], [7]]", "output": "true" }, { "input": "[[1000, 1000, 1000], [1000, 1000, 1000]]", "output": "true" }, { "input": "[[1, 2, 3], [3, 2, 1]]", "output": "true" }, { "input": "[[10, 20, 30], [30, 20, 10]]", "output": "true" }, { "input": "[[1000, 1, 1...
122
false
122
verified
10
10
1
2,052
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.CanBeEqual.Code.Funs /-! # Specifications of `Aegis.CanBeEqual.can_be_equal` LeetCode problem `make-two-arrays-equal-by-reversing-subarrays`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.CanBeEqual def inRange (xs : Slice I64) : Prop...
11
check-if-a-string-contains-all-binary-codes-of-size-k
1,461
Medium
[ "Bit Manipulation", "Hash Table", "String", "Hash Function", "Rolling Hash" ]
Given a binary string s and an integer k, return true if every binary code of length k is a substring of s. Otherwise, return false.   Example 1: Input: s = "00110110", k = 2 Output: true Explanation: The binary codes of length 2 are "00", "01", "10" and "11". They can be all found as substrings at indices 0, 1, 3 and...
hasAllCodes(s: str, k: int) -> bool
pub fn has_all_codes(s: &[u8], k: i64) -> bool
Aegis.HasAllCodes.has_all_codes
pub fn has_all_codes(s: &[u8], k: i64) -> bool { let n = s.len(); if k <= 0 { return true; } let kk = k as usize; if kk > n { return false; } let windows = n - kk + 1; let windows_i = windows as i64; // target = 2^k (k <= 20 in the given constraints, so this fits...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [has_all_codes]: type definitions module public import Aeneas @[expose] public section 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 -- [has_all_codes]: function definitions module public import Aeneas public import Aegis.HasAllCodes.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.HasAllCodes.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.HasAllCodes.has_all_codes (Slice.from [49#u8, 48#u8, 49#u8, 48#u8, 49#u8, 48#u8, 49#u8, 48#u8, 49#u8, 48#u8] (by scalar_tac) : Slice Std.U8) 5#i64) (...
[ { "input": "[\"1010101010\", 5]", "output": "false" }, { "input": "[\"1010101010\", 3]", "output": "false" }, { "input": "[\"0000000\", 3]", "output": "false" }, { "input": "[\"00110110\", 2]", "output": "true" }, { "input": "[\"00000000\", 4]", "output": "fal...
102
false
102
verified
10
10
2
9,750
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.HasAllCodes.Code.Funs /-! # Specifications of `Aegis.HasAllCodes.has_all_codes` LeetCode problem `check-if-a-string-contains-all-binary-codes-of-size-k`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.HasAllCodes open Aegis.HasAllCodes...
11
cherry-pickup-ii
1,463
Hard
[ "Array", "Dynamic Programming", "Matrix" ]
You are given a rows x cols matrix grid representing a field of cherries where grid[i][j] represents the number of cherries that you can collect from the (i, j) cell. You have two robots that can collect cherries for you: Robot #1 is located at the top-left corner (0, 0), and Robot #2 is located at the top-right corne...
cherryPickup(grid: list_list_int) -> int
pub fn cherry_pickup(grid: &[Vec<i64>]) -> i64
Aegis.CherryPickup.cherry_pickup
pub fn cherry_pickup(grid: &[Vec<i64>]) -> i64 { let rows = grid.len(); let cols = grid[0].len(); let neg: i64 = -1000000000; let size = cols * cols; let mut dp: Vec<i64> = Vec::new(); let mut z = 0usize; while z < size { dp.push(neg); z += 1; } let last = cols - 1;...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [cherry_pickup]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter....
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [cherry_pickup]: function definitions module public import Aeneas public import Aegis.CherryPickup.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option...
import Aegis.CherryPickup.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.CherryPickup.cherry_pickup (Slice.from [(alloc.vec.Vec.from [1#i64, 1#i64] (by scalar_tac) : alloc.vec.Vec Std.I64), (alloc.vec.Vec.from [1#i64, 1#i...
[ { "input": "[[[1, 1], [1, 1]]]", "output": "4" }, { "input": "[[[0, 0, 0], [0, 0, 0], [0, 0, 0]]]", "output": "0" }, { "input": "[[[1, 2, 3], [4, 5, 6], [7, 8, 9]]]", "output": "32" }, { "input": "[[[5, 5, 5], [5, 0, 5], [5, 5, 5]]]", "output": "30" }, { "input": ...
74
false
74
verified
10
10
1
4,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.CherryPickup.Code.Funs /-! # Specifications of `Aegis.CherryPickup.cherry_pickup` LeetCode problem `cherry-pickup-ii`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open scoped BigOperators open Aegis.CherryPickup namespace AegisSpec.CherryPickup def ce...
14
maximum-product-of-two-elements-in-an-array
1,464
Easy
[ "Array", "Sorting", "Heap (Priority Queue)" ]
Given the array of integers nums, you will choose two different indices i and j of that array. Return the maximum value of (nums[i]-1)*(nums[j]-1).   Example 1: Input: nums = [3,4,5,2] Output: 12 Explanation: If you choose the indices i=1 and j=2 (indexed from 0), you will get the maximum value, that is, (nums[1]-1)*...
maxProduct(nums: list_int) -> int
pub fn max_product(nums: &[i64]) -> i64
Aegis.MaxProduct.max_product
pub fn max_product(nums: &[i64]) -> i64 { let mut max1: i64 = 0; let mut max2: i64 = 0; let mut i: usize = 0; while i < nums.len() { let x = nums[i]; if x > max1 { max2 = max1; max1 = x; } else if x > max2 { max2 = x; } i += 1;...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [max_product]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter.st...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [max_product]: function definitions module public import Aeneas public import Aegis.MaxProduct.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option lin...
import Aegis.MaxProduct.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.MaxProduct.max_product (Slice.from [999#i64, 1000#i64] (by scalar_tac) : Slice Std.I64)) (997002#i64))}") #eval (s!"CASE 1 {(Result.reducesTo (Aegis.M...
[ { "input": "[[999, 1000]]", "output": "997002" }, { "input": "[[100, 100]]", "output": "9801" }, { "input": "[[3, 7]]", "output": "12" }, { "input": "[[10, 10, 10, 10]]", "output": "81" }, { "input": "[[5, 5, 5, 5]]", "output": "16" }, { "input": "[[1,...
96
false
96
verified
10
10
1
430
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": 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-two-elements-in-an-array`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.MaxProduct def vals (nums : Slice Std.I64) :...
9
maximum-area-of-a-piece-of-cake-after-horizontal-and-vertical-cuts
1,465
Medium
[ "Greedy", "Array", "Sorting" ]
You are given a rectangular cake of size h x w and two arrays of integers horizontalCuts and verticalCuts where: horizontalCuts[i] is the distance from the top of the rectangular cake to the ith horizontal cut and similarly, and verticalCuts[j] is the distance from the left of the rectangular cake to the jth vertical ...
maxArea(h: int, w: int, horizontalCuts: list_int, verticalCuts: list_int) -> int
pub fn max_area(h: i64, w: i64, horizontalCuts: &[i64], verticalCuts: &[i64]) -> i64
Aegis.MaxArea.max_area
const MOD: i64 = 1_000_000_007; fn sorted_cuts(cuts: &[i64]) -> Vec<i64> { let n = cuts.len(); let mut v: Vec<i64> = Vec::new(); let mut t: usize = 0; while t < n { v.push(cuts[t]); t += 1; } if n < 2 { return v; } let mut aux: Vec<i64> = Vec::new(); let mu...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [max_area]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter.style...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [max_area]: function definitions module public import Aeneas public import Aegis.MaxArea.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.MaxArea.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.MaxArea.max_area 5#i64 4#i64 (Slice.from [3#i64] (by scalar_tac) : Slice Std.I64) (Slice.from [3#i64] (by scalar_tac) : Slice Std.I64)) (9#i64))}") #eval...
[ { "input": "[5, 4, [3], [3]]", "output": "9" }, { "input": "[1000000000, 1000000000, [500000000], [500000000]]", "output": "250000014" }, { "input": "[50, 50, [25], [25]]", "output": "625" }, { "input": "[1000000, 1000000, [500000], [500000]]", "output": "999998257" }, ...
92
false
92
verified
10
10
1
3,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.MaxArea.Code.Funs /-! # Specifications of `Aegis.MaxArea.max_area` LeetCode problem `maximum-area-of-a-piece-of-cake-after-horizontal-and-vertical-cuts`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.MaxArea def modulus : ℤ := 100...
11
find-all-the-lonely-nodes
1,469
Easy
[ "Tree", "Depth-First Search", "Breadth-First Search", "Binary Tree" ]
In a binary tree, a lonely node is a node that is the only child of its parent node. The root of the tree is not lonely because it does not have a parent node. Given the root of a binary tree, return an array containing the values of all lonely nodes in the tree. Return the list in any order.   Example 1: Input: root...
getLonelyNodes(root: tree) -> list_int
pub fn get_lonely_nodes(root: &Tree) -> Vec<i64>
Aegis.GetLonelyNodes.get_lonely_nodes
pub fn get_lonely_nodes(root: &Tree) -> Vec<i64> { let mut result: Vec<i64> = Vec::new(); collect_lonely(root, false, &mut result); result } fn collect_lonely(node: &Tree, is_lonely: bool, result: &mut Vec<i64>) { match node { Tree::Null => {} Tree::Node(value, left, right) => { ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [get_lonely_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 lint...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [get_lonely_nodes]: function definitions module public import Aeneas public import Aegis.GetLonelyNodes.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.GetLonelyNodes.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(match (Aegis.GetLonelyNodes.get_lonely_nodes ((.Node 1#i64 (.Null) (.Null)) : Aegis.GetLonelyNodes.Tree)).match with | .ok r => r.val.isPerm ((alloc.vec.Vec.from [] (by s...
[ { "input": "[[1]]", "output": "[]" }, { "input": "[[1, 2]]", "output": "[2]" }, { "input": "[[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]]", "output": "[]" }, { "input": "[[2, 1, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]]", "output": "[]" }, { "input": "...
5
true
5
verified
5
5
1
1,773
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.GetLonelyNodes.Code.Funs /-! # Specifications of `Aegis.GetLonelyNodes.get_lonely_nodes` LeetCode problem `find-all-the-lonely-nodes`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.GetLonelyNodes namespace AegisSpec.GetLonelyNodes def no...
11
the-k-strongest-values-in-an-array
1,471
Medium
[ "Array", "Two Pointers", "Sorting" ]
Given an array of integers arr and an integer k. A value arr[i] is said to be stronger than a value arr[j] if |arr[i] - m| > |arr[j] - m| where m is the centre of the array. If |arr[i] - m| == |arr[j] - m|, then arr[i] is said to be stronger than arr[j] if arr[i] > arr[j]. Return a list of the strongest k values in the...
getStrongest(arr: list_int, k: int) -> list_int
pub fn get_strongest(arr: &[i64], k: i64) -> Vec<i64>
Aegis.GetStrongest.get_strongest
pub fn get_strongest(arr: &[i64], k: i64) -> Vec<i64> { let n = arr.len(); let mut sorted: Vec<i64> = Vec::new(); let mut i: usize = 0; while i < n { sorted.push(arr[i]); i += 1; } sorted.sort(); let median_index = (n - 1) / 2; let median = sorted[median_index]; l...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [get_strongest]: type definitions module public import Aeneas @[expose] public section 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 -- [get_strongest]: function definitions module public import Aeneas public import Aegis.GetStrongest.Code.Types public import Aegis.GetStrongest.Code.FunsExternal @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace f...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [get_strongest]: external functions. -- This is a template file: rename it to "FunsExternal.lean" and fill the holes. module public import Aeneas public import Aegis.GetStrongest.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set...
import Aegis.GetStrongest.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.GetStrongest.get_strongest (Slice.from [(-100000)#i64, 100000#i64] (by scalar_tac) : Slice Std.I64) 1#i64) ((alloc.vec.Vec.from [100000#i64] (by sca...
[ { "input": "[[-100000, 100000], 1]", "output": "[100000]" }, { "input": "[[-7, 22, 17, 3], 2]", "output": "[22, 17]" }, { "input": "[[0, 0, 0, 0, 0], 1]", "output": "[0]" }, { "input": "[[1, 2, 3, 4, 5], 2]", "output": "[5, 1]" }, { "input": "[[1, 1, 3, 5, 5], 2]"...
91
false
91
verified
10
10
1
5,972
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.GetStrongest.Code.Funs /-! # Specifications of `Aegis.GetStrongest.get_strongest` LeetCode problem `the-k-strongest-values-in-an-array`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.GetStrongest set_option autoImplicit false def i64...
10
paint-house-iii
1,473
Hard
[ "Array", "Dynamic Programming" ]
There is a row of m houses in a small city, each house must be painted with one of the n colors (labeled from 1 to n), some houses that have been painted last summer should not be painted again. A neighborhood is a maximal group of continuous houses that are painted with the same color. For example: houses = [1,2,2,3,...
minCost(houses: list_int, cost: list_list_int, m: int, n: int, target: int) -> int
pub fn min_cost(houses: &[i64], cost: &[Vec<i64>], m: i64, n: i64, target: i64) -> i64
Aegis.MinCost.min_cost
pub fn min_cost(houses: &[i64], cost: &[Vec<i64>], m: i64, n: i64, target: i64) -> i64 { // Top-level guards only (no returns inside loops). if m <= 0 || n <= 0 || target <= 0 { return -1; } let m_us = m as usize; let n_us = n as usize; let tgt = target as usize; if tgt > m_us || ho...
-- 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 [0#i64, 0#i64, 0#i64] (by scalar_tac) : Slice Std.I64) (Slice.from [(alloc.vec.Vec.from [1#i64, 2#i64, 3#i64] (by scalar_tac...
[ { "input": "[[0, 0, 0], [[1, 2, 3], [4, 5, 6], [7, 8, 9]], 3, 3, 2]", "output": "13" }, { "input": "[[1, 0, 0, 0, 0], [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6]], 5, 2, 2]", "output": "15" }, { "input": "[[1, 0, 1, 0, 0], [[1, 2], [3, 4], [1, 2], [3, 4], [1, 2]], 5, 2, 2]", "output": "8...
67
false
67
verified
10
10
3
28,472
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MinCost.Code.Funs /-! # Specifications of `Aegis.MinCost.min_cost` LeetCode problem `paint-house-iii`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.MinCost open Aegis.MinCost def houseVals (houses : Slice I64) : List Int := houses.v...
12
delete-n-nodes-after-m-nodes-of-a-linked-list
1,474
Easy
[ "Linked List" ]
You are given the head of a linked list and two integers m and n. Traverse the linked list and remove some nodes in the following way: Start with the head as the current node. Keep the first m nodes starting with the current node. Remove the next n nodes Keep repeating steps 2 and 3 until you reach the end of the list...
deleteNodes(head: linkedlist, m: int, n: int) -> linkedlist
pub fn delete_nodes(head: &List, m: i64, n: i64) -> List
Aegis.DeleteNodes.delete_nodes
fn delete_nodes_rec(l: &List, pos: i64, keep: i64, period: i64) -> List { match l { List::Nil => List::Nil, List::Cons(v, next) => { let p = pos % period; let rest = delete_nodes_rec(&**next, pos + 1, keep, period); if p < keep { List::Cons(*v, Box...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [delete_nodes]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter.s...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [delete_nodes]: function definitions module public import Aeneas public import Aegis.DeleteNodes.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.DeleteNodes.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 deriving instance DecidableEq for Aegis.DeleteNodes.List #eval (s!"CASE 0 {(match (Aegis.DeleteNodes.delete_nodes ((.Cons 1#i64 (.Nil)) : Aegis.DeleteNodes.List) 0#i64 1#i64).match with | .ok...
[ { "input": "[[1], 0, 1]", "output": "[1]" }, { "input": "[[1], 1, 0]", "output": "[1]" }, { "input": "[[1], 1, 1]", "output": "[1]" }, { "input": "[[42], 1, 1]", "output": "[42]" }, { "input": "[[1, 2], 1, 1]", "output": "[1]" }, { "input": "[[1, 2], 1...
105
false
105
verified
10
10
1
5,736
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.DeleteNodes.Code.Funs /-! # Specifications of `Aegis.DeleteNodes.delete_nodes` LeetCode problem `delete-n-nodes-after-m-nodes-of-a-linked-list`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.DeleteNodes abbrev LList : Type := Aegis.De...
13
final-prices-with-a-special-discount-in-a-shop
1,475
Easy
[ "Stack", "Array", "Monotonic Stack" ]
You are given an integer array prices where prices[i] is the price of the ith item in a shop. There is a special discount for items in the shop. If you buy the ith item, then you will receive a discount equivalent to prices[j] where j is the minimum index such that j > i and prices[j] <= prices[i]. Otherwise, you will ...
finalPrices(prices: list_int) -> list_int
pub fn final_prices(prices: &[i64]) -> Vec<i64>
Aegis.FinalPrices.final_prices
pub fn final_prices(prices: &[i64]) -> Vec<i64> { let n = prices.len(); let mut answer: Vec<i64> = Vec::new(); let mut i: usize = 0; while i < n { let mut discount: i64 = 0; let mut j: usize = i + 1; while j < n { if prices[j] <= prices[i] { discount...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [final_prices]: type definitions module public import Aeneas @[expose] public section 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 -- [final_prices]: function definitions module public import Aeneas public import Aegis.FinalPrices.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.FinalPrices.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.FinalPrices.final_prices (Slice.from [2#i64, 3#i64, 1#i64] (by scalar_tac) : Slice Std.I64)) ((alloc.vec.Vec.from [1#i64, 2#i64, 1#i64] (by scalar_ta...
[ { "input": "[[2, 3, 1]]", "output": "[1, 2, 1]" }, { "input": "[[10, 1, 1, 6]]", "output": "[9, 0, 1, 6]" }, { "input": "[[5, 5, 5, 5, 5]]", "output": "[0, 0, 0, 0, 5]" }, { "input": "[[8, 4, 6, 2, 3]]", "output": "[4, 2, 4, 2, 3]" }, { "input": "[[9, 8, 7, 6, 5]]...
117
false
117
verified
10
10
1
614
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.FinalPrices.Code.Funs /-! # Specifications of `Aegis.FinalPrices.final_prices` LeetCode problem `final-prices-with-a-special-discount-in-a-shop`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result set_option autoImplicit false namespace AegisSpec.FinalPri...
11
find-two-non-overlapping-sub-arrays-each-with-target-sum
1,477
Medium
[ "Array", "Hash Table", "Binary Search", "Dynamic Programming", "Sliding Window" ]
You are given an array of integers arr and an integer target. You have to find two non-overlapping sub-arrays of arr each with a sum equal target. There can be multiple answers so you have to find an answer where the sum of the lengths of the two sub-arrays is minimum. Return the minimum sum of the lengths of the two r...
minSumOfLengths(arr: list_int, target: int) -> int
pub fn min_sum_of_lengths(arr: &[i64], target: i64) -> i64
Aegis.MinSumOfLengths.min_sum_of_lengths
pub fn min_sum_of_lengths(arr: &[i64], target: i64) -> i64 { let n = arr.len(); let inf: i64 = 1_000_000_000; let mut ans: i64 = inf; let mut best_so_far: i64 = inf; let mut prefix_min: Vec<i64> = Vec::new(); let mut start: usize = 0; let mut cur: i64 = 0; let mut r: usize = 0; wh...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [min_sum_of_lengths]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option li...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [min_sum_of_lengths]: function definitions module public import Aeneas public import Aegis.MinSumOfLengths.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.MinSumOfLengths.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.MinSumOfLengths.min_sum_of_lengths (Slice.from [1000#i64, 1000#i64, 1000#i64] (by scalar_tac) : Slice Std.I64) 2000#i64) ((-1)#i64))}") #eval (s!...
[ { "input": "[[1000, 1000, 1000], 2000]", "output": "-1" }, { "input": "[[7, 3, 4, 7], 7]", "output": "2" }, { "input": "[[5, 5, 5, 5, 5], 10]", "output": "4" }, { "input": "[[1, 2, 3, 4, 5], 9]", "output": "-1" }, { "input": "[[3, 2, 2, 4, 3], 3]", "output": "...
85
false
85
verified
10
10
1
5,912
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MinSumOfLengths.Code.Funs /-! # Specifications of `Aegis.MinSumOfLengths.min_sum_of_lengths` LeetCode problem `find-two-non-overlapping-sub-arrays-each-with-target-sum`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.MinSumOfLengths ...
16
allocate-mailboxes
1,478
Hard
[ "Array", "Math", "Dynamic Programming", "Sorting" ]
Given the array houses where houses[i] is the location of the ith house along a street and an integer k, allocate k mailboxes in the street. Return the minimum total distance between each house and its nearest mailbox. The test cases are generated so that the answer fits in a 32-bit integer.   Example 1: Input: house...
minDistance(houses: list_int, k: int) -> int
pub fn min_distance(houses: &[i64], k: i64) -> i64
Aegis.MinDistance.min_distance
pub fn min_distance(houses: &[i64], k: i64) -> i64 { let n: usize = houses.len(); if n == 0 { return 0; } let n_i: i64 = n as i64; if k >= n_i { return 0; } let kk: usize = k as usize; let mut arr: Vec<i64> = Vec::new(); let mut i: usize = 0; while i < n { ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [min_distance]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter.s...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [min_distance]: function definitions module public import Aeneas public import Aegis.MinDistance.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option l...
import Aegis.MinDistance.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.MinDistance.min_distance (Slice.from [1#i64, 10000#i64] (by scalar_tac) : Slice Std.I64) 1#i64) (9999#i64))}") #eval (s!"CASE 1 {(Result.reducesTo (A...
[ { "input": "[[1, 10000], 1]", "output": "9999" }, { "input": "[[3, 6, 14, 10], 4]", "output": "0" }, { "input": "[[7, 4, 6, 1], 1]", "output": "8" }, { "input": "[[5, 10, 15, 20, 25], 2]", "output": "15" }, { "input": "[[1, 4, 8, 10, 20], 3]", "output": "5" ...
108
false
108
verified
10
10
1
4,874
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MinDistance.Code.Funs import Mathlib.Data.Real.Basic /-! # Specifications of `Aegis.MinDistance.min_distance` LeetCode problem `allocate-mailboxes`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result set_option maxHeartbeats 1000000 namespace AegisSpec.MinDis...
10
running-sum-of-1d-array
1,480
Easy
[ "Array", "Prefix Sum" ]
Given an array nums. We define a running sum of an array as runningSum[i] = sum(nums[0]…nums[i]). Return the running sum of nums.   Example 1: Input: nums = [1,2,3,4] Output: [1,3,6,10] Explanation: Running sum is obtained as follows: [1, 1+2, 1+2+3, 1+2+3+4]. Example 2: Input: nums = [1,1,1,1,1] Output: [1,2,3,4,5] ...
runningSum(nums: list_int) -> list_int
pub fn running_sum(nums: &[i64]) -> Vec<i64>
Aegis.RunningSum.running_sum
pub fn running_sum(nums: &[i64]) -> Vec<i64> { let n = nums.len(); let mut out: Vec<i64> = Vec::new(); let mut acc: i64 = 0; let mut i: usize = 0; while i < n { acc = acc + nums[i]; out.push(acc); i += 1; } out }
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [running_sum]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter.st...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [running_sum]: function definitions module public import Aeneas public import Aegis.RunningSum.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.RunningSum.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.RunningSum.running_sum (Slice.from [(-5)#i64] (by scalar_tac) : Slice Std.I64)) ((alloc.vec.Vec.from [(-5)#i64] (by scalar_tac) : alloc.vec.Vec Std.I6...
[ { "input": "[[-5]]", "output": "[-5]" }, { "input": "[[1]]", "output": "[1]" }, { "input": "[[-1000000]]", "output": "[-1000000]" }, { "input": "[[5]]", "output": "[5]" }, { "input": "[[1000000]]", "output": "[1000000]" }, { "input": "[[1000000, -10000...
94
false
94
verified
10
10
1
128
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.RunningSum.Code.Funs /-! # Specifications of `Aegis.RunningSum.running_sum` LeetCode problem `running-sum-of-1d-array`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.RunningSum def sliceVals (s : Slice Std.I64) : List ℤ := s.val.map (...
8
least-number-of-unique-integers-after-k-removals
1,481
Medium
[ "Greedy", "Array", "Hash Table", "Counting", "Sorting" ]
Given an array of integers arr and an integer k. Find the least number of unique integers after removing exactly k elements.\r \r \r \r \r  \r Example 1:\r \r \r Input: arr = [5,5,4], k = 1\r Output: 1\r Explanation: Remove the single 4, only 5 is left.\r \r Example 2:\r \r \r Input: arr = [4,3,1,1,3,3,2], k = 3\r Outp...
findLeastNumOfUniqueInts(arr: list_int, k: int) -> int
pub fn find_least_num_of_unique_ints(arr: &[i64], k: i64) -> i64
Aegis.FindLeastNumOfUniqueInts.find_least_num_of_unique_ints
pub fn find_least_num_of_unique_ints(arr: &[i64], k: i64) -> i64 { let n = arr.len(); let mut vals: Vec<i64> = Vec::new(); let mut i = 0usize; while i < n { vals.push(arr[i]); i += 1; } vals.sort(); let mut freqs: Vec<i64> = Vec::new(); let mut j = 0usize; while j...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [find_least_num_of_unique_ints]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false se...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [find_least_num_of_unique_ints]: function definitions module public import Aeneas public import Aegis.FindLeastNumOfUniqueInts.Code.Types public import Aegis.FindLeastNumOfUniqueInts.Code.FunsExternal @[expose] public section open Aeneas Aeneas.Std Result ControlFlo...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [find_least_num_of_unique_ints]: external functions. -- This is a template file: rename it to "FunsExternal.lean" and fill the holes. module public import Aeneas public import Aegis.FindLeastNumOfUniqueInts.Code.Types @[expose] public section open Aeneas Aeneas.Std ...
import Aegis.FindLeastNumOfUniqueInts.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.FindLeastNumOfUniqueInts.find_least_num_of_unique_ints (Slice.from [5#i64, 5#i64, 4#i64] (by scalar_tac) : Slice Std.I64) 1#i64) (1#i64)...
[ { "input": "[[5, 5, 4], 1]", "output": "1" }, { "input": "[[1, 1, 1, 1, 1], 3]", "output": "1" }, { "input": "[[1, 2, 3, 4, 5], 2]", "output": "3" }, { "input": "[[1, 2, 3, 4, 5], 0]", "output": "5" }, { "input": "[[1, 1, 1, 1, 1], 2]", "output": "1" }, { ...
69
false
69
verified
10
10
1
3,190
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.FindLeastNumOfUniqueInts.Code.Funs /-! # Specifications of `Aegis.FindLeastNumOfUniqueInts.find_least_num_of_unique_ints` LeetCode problem `least-number-of-unique-integers-after-k-removals`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpe...
17
minimum-number-of-days-to-make-m-bouquets
1,482
Medium
[ "Array", "Binary Search" ]
You are given an integer array bloomDay, an integer m and an integer k. You want to make m bouquets. To make a bouquet, you need to use k adjacent flowers from the garden. The garden consists of n flowers, the ith flower will bloom in the bloomDay[i] and then can be used in exactly one bouquet. Return the minimum numbe...
minDays(bloomDay: list_int, m: int, k: int) -> int
pub fn min_days(bloomDay: &[i64], m: i64, k: i64) -> i64
Aegis.MinDays.min_days
fn can_make(bloom_day: &[i64], m: i64, k: i64, day: i64) -> bool { let mut bouquets: i64 = 0; let mut flowers: i64 = 0; let mut i: usize = 0; while i < bloom_day.len() { if bloom_day[i] <= day { flowers = flowers + 1; if flowers == k { bouquets = bouquets...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [min_days]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter.style...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [min_days]: function definitions module public import Aeneas public import Aegis.MinDays.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.MinDays.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.MinDays.min_days (Slice.from [1#i64] (by scalar_tac) : Slice Std.I64) 1#i64 1#i64) (1#i64))}") #eval (s!"CASE 1 {(Result.reducesTo (Aegis.MinDays.min_day...
[ { "input": "[[1], 1, 1]", "output": "1" }, { "input": "[[1000000000], 1, 1]", "output": "1000000000" }, { "input": "[[1000000000, 1000000000, 1000000000], 1, 3]", "output": "1000000000" }, { "input": "[[1000000000, 1000000000, 1000000000], 1, 2]", "output": "1000000000" ...
93
false
93
verified
10
10
1
1,962
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MinDays.Code.Funs /-! # Specifications of `Aegis.MinDays.min_days` LeetCode problem `minimum-number-of-days-to-make-m-bouquets`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.MinDays def sliceLen (bloomDay : Slice Std.I64) : Nat := bl...
12
xor-operation-in-an-array
1,486
Easy
[ "Bit Manipulation", "Math" ]
You are given an integer n and an integer start. Define an array nums where nums[i] = start + 2 * i (0-indexed) and n == nums.length. Return the bitwise XOR of all elements of nums.   Example 1: Input: n = 5, start = 0 Output: 8 Explanation: Array nums is equal to [0, 2, 4, 6, 8] where (0 ^ 2 ^ 4 ^ 6 ^ 8) = 8. Where "...
xorOperation(n: int, start: int) -> int
pub fn xor_operation(n: i64, start: i64) -> i64
Aegis.XorOperation.xor_operation
pub fn xor_operation(n: i64, start: i64) -> i64 { let mut result: i64 = 0; let mut i: i64 = 0; while i < n { let value: i64 = start + 2 * i; result = result ^ value; i += 1; } result }
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [xor_operation]: type definitions module public import Aeneas @[expose] public section 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 -- [xor_operation]: function definitions module public import Aeneas public import Aegis.XorOperation.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.XorOperation.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.XorOperation.xor_operation 4#i64 3#i64) (8#i64))}") #eval (s!"CASE 1 {(Result.reducesTo (Aegis.XorOperation.xor_operation 8#i64 12#i64) (0#i64))}") ...
[ { "input": "[4, 3]", "output": "8" }, { "input": "[8, 12]", "output": "0" }, { "input": "[7, 2]", "output": "0" }, { "input": "[3, 2]", "output": "0" }, { "input": "[10, 1]", "output": "2" }, { "input": "[5, 0]", "output": "8" }, { "input":...
92
false
92
verified
10
10
1
271
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.XorOperation.Code.Funs /-! # Specifications of `Aegis.XorOperation.xor_operation` LeetCode problem `xor-operation-in-an-array`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.XorOperation open Aegis.XorOperation def xorInt (a b ...
7
making-file-names-unique
1,487
Medium
[ "Array", "Hash Table", "String" ]
Given an array of strings names of size n. You will create n folders in your file system such that, at the ith minute, you will create a folder with the name names[i]. Since two files cannot have the same name, if you enter a folder name that was previously used, the system will have a suffix addition to its name in th...
getFolderNames(names: list_str) -> list_str
pub fn get_folder_names(names: &[Vec<u8>]) -> Vec<Vec<u8>>
Aegis.GetFolderNames.get_folder_names
pub fn get_folder_names(names: &[Vec<u8>]) -> Vec<Vec<u8>> { let mut ans: Vec<Vec<u8>> = Vec::new(); let mut head: Vec<i64> = Vec::new(); let mut edge_ch: Vec<u8> = Vec::new(); let mut edge_to: Vec<i64> = Vec::new(); let mut edge_next: Vec<i64> = Vec::new(); let mut used: Vec<bool> = Vec::new()...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [get_folder_names]: type definitions module public import Aeneas @[expose] public section 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_folder_names]: function definitions module public import Aeneas public import Aegis.GetFolderNames.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.GetFolderNames.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.GetFolderNames.get_folder_names (Slice.from [(alloc.vec.Vec.from [112#u8, 101#u8, 115#u8] (by scalar_tac) : alloc.vec.Vec Std.U8), (alloc.vec.Vec....
[ { "input": "[[\"pes\", \"fifa\", \"gta\", \"pes(2019)\"]]", "output": "[\"pes\", \"fifa\", \"gta\", \"pes(2019)\"]" }, { "input": "[[\"gta\", \"gta(1)\", \"gta\", \"avalon\"]]", "output": "[\"gta\", \"gta(1)\", \"gta(2)\", \"avalon\"]" }, { "input": "[[\"doc\", \"doc(1)\", \"image\", \"d...
66
false
66
verified
10
10
1
24,126
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.GetFolderNames.Code.Funs /-! # Specifications of `Aegis.GetFolderNames.get_folder_names` LeetCode problem `making-file-names-unique`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.GetFolderNames def byteOfNat (n : ℕ) : U8 := ⟨BitVec.o...
12
avoid-flood-in-the-city
1,488
Medium
[ "Greedy", "Array", "Hash Table", "Binary Search", "Heap (Priority Queue)" ]
Your country has an infinite number of lakes. Initially, all the lakes are empty, but when it rains over the nth lake, the nth lake becomes full of water. If it rains over a lake that is full of water, there will be a flood. Your goal is to avoid floods in any lake. Given an integer array rains where: rains[i] > 0 mea...
avoidFlood(rains: list_int) -> list_int
pub fn avoid_flood(rains: &[i64]) -> Vec<i64>
Aegis.AvoidFlood.avoid_flood
fn lower_bound_i64(v: &[i64], x: i64) -> usize { let mut lo: usize = 0; let mut hi: usize = v.len(); while lo < hi { let mid: usize = lo + (hi - lo) / 2; if v[mid] < x { lo = mid + 1; } else { hi = mid; } } lo } fn sort_i64(v: &mut Vec<i64>) {...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [avoid_flood]: type definitions module public import Aeneas @[expose] public section 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 -- [avoid_flood]: function definitions module public import Aeneas public import Aegis.AvoidFlood.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.AvoidFlood.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.AvoidFlood.avoid_flood (Slice.from [0#i64] (by scalar_tac) : Slice Std.I64)) ((alloc.vec.Vec.from [1#i64] (by scalar_tac) : alloc.vec.Vec Std.I64)))}"...
[ { "input": "[[0]]", "output": "[1]" }, { "input": "[[1]]", "output": "[-1]" }, { "input": "[[0, 1, 1]]", "output": "[]" }, { "input": "[[10, 20, 20]]", "output": "[]" }, { "input": "[[1, 1, 0, 0]]", "output": "[]" }, { "input": "[[1, 2, 0, 1, 2]]", ...
242
false
242
verified
10
10
1
16,783
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.AvoidFlood.Code.Funs /-! # Specifications of `Aegis.AvoidFlood.avoid_flood` LeetCode problem `avoid-flood-in-the-city`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.AvoidFlood open Aegis.AvoidFlood def vals (l : List Std.I64) ...
11
find-critical-and-pseudo-critical-edges-in-minimum-spanning-tree
1,489
Hard
[ "Union Find", "Graph", "Minimum Spanning Tree", "Sorting", "Strongly Connected Component" ]
Given a weighted undirected connected graph with n vertices numbered from 0 to n - 1, and an array edges where edges[i] = [ai, bi, weighti] represents a bidirectional and weighted edge between nodes ai and bi. A minimum spanning tree (MST) is a subset of the graph's edges that connects all vertices without cycles and w...
findCriticalAndPseudoCriticalEdges(n: int, edges: list_list_int) -> list_list_int
pub fn find_critical_and_pseudo_critical_edges(n: i64, edges: &[Vec<i64>]) -> Vec<Vec<i64>>
Aegis.FindCriticalAndPseudoCriticalEdges.find_critical_and_pseudo_critical_edges
fn mst_weight(n: i64, edges: &[Vec<i64>], order: &[i64], skip: i64, force: i64) -> i64 { let inf: i64 = 1_000_000_000; let mut parent: Vec<i64> = Vec::new(); let mut size: Vec<i64> = Vec::new(); let mut i: i64 = 0; while i < n { parent.push(i); size.push(1); i += 1; } ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [find_critical_and_pseudo_critical_edges]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariable...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [find_critical_and_pseudo_critical_edges]: function definitions module public import Aeneas public import Aegis.FindCriticalAndPseudoCriticalEdges.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace fals...
import Aegis.FindCriticalAndPseudoCriticalEdges.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(match (Aegis.FindCriticalAndPseudoCriticalEdges.find_critical_and_pseudo_critical_edges 3#i64 (Slice.from [(alloc.vec.Vec.from [0#i64, 1#i64, 1#i64] (...
[ { "input": "[3, [[0, 1, 1], [1, 2, 1], [0, 2, 2]]]", "output": "[[0, 1], []]" }, { "input": "[3, [[0, 1, 1], [1, 2, 2], [0, 2, 3]]]", "output": "[[0, 1], []]" }, { "input": "[3, [[0, 1, 1], [1, 2, 2], [2, 0, 2]]]", "output": "[[0], [1, 2]]" }, { "input": "[4, [[0, 1, 1], [1, ...
55
true
55
verified
10
10
1
15,150
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.FindCriticalAndPseudoCriticalEdges.Code.Funs /-! # Specifications of `Aegis.FindCriticalAndPseudoCriticalEdges.find_critical_and_pseudo_critical_edges` LeetCode problem `find-critical-and-pseudo-critical-edges-in-minimum-spanning-tree`. Each `spec_<n>` theorem states one property of the function. -/ ope...
18
the-kth-factor-of-n
1,492
Medium
[ "Math", "Number Theory" ]
You are given two positive integers n and k. A factor of an integer n is defined as an integer i where n % i == 0. Consider a list of all factors of n sorted in ascending order, return the kth factor in this list or return -1 if n has less than k factors.   Example 1: Input: n = 12, k = 3 Output: 3 Explanation: Factor...
kthFactor(n: int, k: int) -> int
pub fn kth_factor(n: i64, k: i64) -> i64
Aegis.KthFactor.kth_factor
pub fn kth_factor(n: i64, k: i64) -> i64 { let mut count: i64 = 0; let mut i: i64 = 1; while i <= n { if n % i == 0 { count += 1; if count == k { return i; } } i += 1; } -1 }
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [kth_factor]: type definitions module public import Aeneas @[expose] public section 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 -- [kth_factor]: function definitions module public import Aeneas public import Aegis.KthFactor.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.KthFactor.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.KthFactor.kth_factor 1#i64 1#i64) (1#i64))}") #eval (s!"CASE 1 {(Result.reducesTo (Aegis.KthFactor.kth_factor 49#i64 3#i64) (49#i64))}") #eval (s!"CASE...
[ { "input": "[1, 1]", "output": "1" }, { "input": "[49, 3]", "output": "49" }, { "input": "[100, 5]", "output": "10" }, { "input": "[7, 2]", "output": "7" }, { "input": "[17, 2]", "output": "17" }, { "input": "[1000, 15]", "output": "500" }, { ...
81
false
81
verified
10
10
1
310
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.KthFactor.Code.Funs /-! # Specifications of `Aegis.KthFactor.kth_factor` LeetCode problem `the-kth-factor-of-n`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aeneas.Std.Result namespace AegisSpec.KthFactor def IsPosDivisor (n d : ℤ) : Prop :=...
15
longest-subarray-of-1s-after-deleting-one-element
1,493
Medium
[ "Array", "Dynamic Programming", "Sliding Window" ]
Given a binary array nums, you should delete one element from it. Return the size of the longest non-empty subarray containing only 1's in the resulting array. Return 0 if there is no such subarray.   Example 1: Input: nums = [1,1,0,1] Output: 3 Explanation: After deleting the number in position 2, [1,1,1] contains 3 ...
longestSubarray(nums: list_int) -> int
pub fn longest_subarray(nums: &[i64]) -> i64
Aegis.LongestSubarray.longest_subarray
pub fn longest_subarray(nums: &[i64]) -> i64 { let n = nums.len(); let mut left: usize = 0; let mut right: usize = 0; let mut zeros: i64 = 0; let mut best: i64 = 0; while right < n { if nums[right] == 0 { zeros += 1; } while zeros > 1 { if nums[l...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [longest_subarray]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option lint...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [longest_subarray]: function definitions module public import Aeneas public import Aegis.LongestSubarray.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.LongestSubarray.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.LongestSubarray.longest_subarray (Slice.from [0#i64, 0#i64, 0#i64] (by scalar_tac) : Slice Std.I64)) (0#i64))}") #eval (s!"CASE 1 {(Result.reduce...
[ { "input": "[[0, 0, 0]]", "output": "0" }, { "input": "[[1, 1, 1]]", "output": "2" }, { "input": "[[1, 1, 0, 1]]", "output": "3" }, { "input": "[[0, 1, 1, 1, 0, 1, 1, 0, 1]]", "output": "5" }, { "input": "[[0, 1, 0, 1, 0, 1, 0, 1, 0, 1]]", "output": "2" }, ...
92
false
92
verified
10
10
1
1,067
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.LongestSubarray.Code.Funs /-! # Specifications of `Aegis.LongestSubarray.longest_subarray` LeetCode problem `longest-subarray-of-1s-after-deleting-one-element`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.LongestSubarray def val...
13
parallel-courses-ii
1,494
Hard
[ "Bit Manipulation", "Graph", "Dynamic Programming", "Bitmask" ]
You are given an integer n, which indicates that there are n courses labeled from 1 to n. You are also given an array relations where relations[i] = [prevCoursei, nextCoursei], representing a prerequisite relationship between course prevCoursei and course nextCoursei: course prevCoursei has to be taken before course ne...
minNumberOfSemesters(n: int, relations: list_list_int, k: int) -> int
pub fn min_number_of_semesters(n: i64, relations: &[Vec<i64>], k: i64) -> i64
Aegis.MinNumberOfSemesters.min_number_of_semesters
fn bit_value(pos: i64) -> i64 { let mut result: i64 = 1; let mut i: i64 = 0; while i < pos { result = result * 2; i += 1; } result } pub fn min_number_of_semesters(n: i64, relations: &[Vec<i64>], k: i64) -> i64 { let mut prereq: Vec<i64> = Vec::new(); let mut i: i64 = 0; ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [min_number_of_semesters]: type definitions module public import Aeneas @[expose] public 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 -- [min_number_of_semesters]: function definitions module public import Aeneas public import Aegis.MinNumberOfSemesters.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashComman...
import Aegis.MinNumberOfSemesters.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.MinNumberOfSemesters.min_number_of_semesters 5#i64 (Slice.from [] (by scalar_tac) : Slice (alloc.vec.Vec Std.I64)) 3#i64) (2#i64))}") #eval ...
[ { "input": "[5, [], 3]", "output": "2" }, { "input": "[3, [], 3]", "output": "1" }, { "input": "[3, [], 2]", "output": "2" }, { "input": "[3, [[1, 3], [2, 3]], 2]", "output": "2" }, { "input": "[4, [[2, 1], [3, 1]], 1]", "output": "4" }, { "input": "[4...
92
false
92
verified
10
10
1
12,478
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MinNumberOfSemesters.Code.Funs /-! # Specifications of `Aegis.MinNumberOfSemesters.min_number_of_semesters` LeetCode problem `parallel-courses-ii`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.MinNumberOfSemesters def IsPair (v : a...
16
path-crossing
1,496
Easy
[ "Hash Table", "String" ]
Given a string path, where path[i] = 'N', 'S', 'E' or 'W', each representing moving one unit north, south, east, or west, respectively. You start at the origin (0, 0) on a 2D plane and walk on the path specified by path. Return true if the path crosses itself at any point, that is, if at any time you are on a location ...
isPathCrossing(path: str) -> bool
pub fn is_path_crossing(path: &[u8]) -> bool
Aegis.IsPathCrossing.is_path_crossing
pub fn is_path_crossing(path: &[u8]) -> bool { let mut xs: Vec<i64> = Vec::new(); let mut ys: Vec<i64> = Vec::new(); let mut x: i64 = 0; let mut y: i64 = 0; xs.push(x); ys.push(y); let n = path.len(); let mut i: usize = 0; let mut crossed: bool = false; while i < n && !crosse...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [is_path_crossing]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option lint...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [is_path_crossing]: function definitions module public import Aeneas public import Aegis.IsPathCrossing.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.IsPathCrossing.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.IsPathCrossing.is_path_crossing (Slice.from [78#u8, 69#u8, 69#u8, 83#u8, 87#u8, 78#u8, 87#u8, 87#u8, 83#u8, 78#u8, 78#u8, 87#u8, 78#u8, 83#u8, 83#...
[ { "input": "[\"NEESWNWWSNNWNSSSWEWEWEWE\"]", "output": "true" }, { "input": "[\"NNNSSSSSSEEEEEEEWWWWWWWWW\"]", "output": "true" }, { "input": "[\"NEWSNEWS\"]", "output": "true" }, { "input": "[\"EWEWEWEW\"]", "output": "true" }, { "input": "[\"NESWW\"]", "outp...
186
false
186
verified
10
10
2
2,074
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.IsPathCrossing.Code.Funs /-! # Specifications of `Aegis.IsPathCrossing.is_path_crossing` LeetCode problem `path-crossing`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.IsPathCrossing def byteN : Nat := 78 def byteS : Nat := 83...
7
number-of-subsequences-that-satisfy-the-given-sum-condition
1,498
Medium
[ "Array", "Two Pointers", "Binary Search", "Sorting" ]
You are given an array of integers nums and an integer target. Return the number of non-empty subsequences of nums such that the sum of the minimum and maximum element on it is less or equal to target. Since the answer may be too large, return it modulo 109 + 7.   Example 1: Input: nums = [3,5,6,7], target = 9 Output:...
numSubseq(nums: list_int, target: int) -> int
pub fn num_subseq(nums: &[i64], target: i64) -> i64
Aegis.NumSubseq.num_subseq
pub fn num_subseq(nums: &[i64], target: i64) -> i64 { let n = nums.len(); if n == 0 { return 0; } // Copy the input into an owned vector. let mut src: Vec<i64> = Vec::new(); let mut idx: usize = 0; while idx < n { src.push(nums[idx]); idx += 1; } // Iterativ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [num_subseq]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter.sty...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [num_subseq]: function definitions module public import Aeneas public import Aegis.NumSubseq.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.NumSubseq.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.NumSubseq.num_subseq (Slice.from [1#i64] (by scalar_tac) : Slice Std.I64) 1#i64) (0#i64))}") #eval (s!"CASE 1 {(Result.reducesTo (Aegis.NumSubseq.num_s...
[ { "input": "[[1], 1]", "output": "0" }, { "input": "[[1000000], 1000000]", "output": "0" }, { "input": "[[1, 2, 3], 5]", "output": "6" }, { "input": "[[10, 10, 10, 10], 20]", "output": "15" }, { "input": "[[1, 3, 5, 7], 8]", "output": "10" }, { "input"...
81
false
81
verified
10
10
1
7,812
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.NumSubseq.Code.Funs /-! # Specifications of `Aegis.NumSubseq.num_subseq` LeetCode problem `number-of-subsequences-that-satisfy-the-given-sum-condition`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.NumSubseq def vals (nums : Slice St...
11
max-value-of-equation
1,499
Hard
[ "Queue", "Array", "Sliding Window", "Monotonic Queue", "Heap (Priority Queue)" ]
You are given an array points containing the coordinates of points on a 2D plane, sorted by the x-values, where points[i] = [xi, yi] such that xi < xj for all 1 <= i < j <= points.length. You are also given an integer k. Return the maximum value of the equation yi + yj + |xi - xj| where |xi - xj| <= k and 1 <= i < j <=...
findMaxValueOfEquation(points: list_list_int, k: int) -> int
pub fn find_max_value_of_equation(points: &[Vec<i64>], k: i64) -> i64
Aegis.FindMaxValueOfEquation.find_max_value_of_equation
pub fn find_max_value_of_equation(points: &[Vec<i64>], k: i64) -> i64 { let n = points.len(); let mut dq: Vec<usize> = Vec::new(); let mut head: usize = 0; let mut ans: i64 = -1000000000000000000; let mut j: usize = 0; while j < n { while head < dq.len() { let i = dq[head]; ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [find_max_value_of_equation]: type definitions module public import Aeneas @[expose] public 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_max_value_of_equation]: function definitions module public import Aeneas public import Aegis.FindMaxValueOfEquation.Code.Types public import Aegis.FindMaxValueOfEquation.Code.FunsExternal @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [find_max_value_of_equation]: external functions. -- This is a template file: rename it to "FunsExternal.lean" and fill the holes. module public import Aeneas public import Aegis.FindMaxValueOfEquation.Code.Types @[expose] public section open Aeneas Aeneas.Std Resul...
import Aegis.FindMaxValueOfEquation.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.FindMaxValueOfEquation.find_max_value_of_equation (Slice.from [(alloc.vec.Vec.from [1#i64, 100000000#i64] (by scalar_tac) : alloc.vec.Vec ...
[ { "input": "[[[1, 100000000], [100000000, 1]], 200000000]", "output": "200000000" }, { "input": "[[[100000000, 100000000], [200000000, 200000000], [300000000, 300000000]], 100000000]", "output": "600000000" }, { "input": "[[[-1, 1], [-2, 2], [-3, 3]], 1]", "output": "4" }, { ...
107
false
107
verified
10
10
1
5,885
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.FindMaxValueOfEquation.Code.Funs /-! # Specifications of `Aegis.FindMaxValueOfEquation.find_max_value_of_equation` LeetCode problem `max-value-of-equation`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.FindMaxValueOfEquation namespace Aegi...
9
can-make-arithmetic-progression-from-sequence
1,502
Easy
[ "Array", "Sorting" ]
A sequence of numbers is called an arithmetic progression if the difference between any two consecutive elements is the same. Given an array of numbers arr, return true if the array can be rearranged to form an arithmetic progression. Otherwise, return false.   Example 1: Input: arr = [3,5,1] Output: true Explanation:...
canMakeArithmeticProgression(arr: list_int) -> bool
pub fn can_make_arithmetic_progression(arr: &[i64]) -> bool
Aegis.CanMakeArithmeticProgression.can_make_arithmetic_progression
pub fn can_make_arithmetic_progression(arr: &[i64]) -> bool { let n = arr.len(); if n < 2 { return true; } let mut v: Vec<i64> = Vec::new(); let mut i: usize = 0; while i < n { v.push(arr[i]); i += 1; } // Insertion sort the copied elements in nondecreasing ord...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [can_make_arithmetic_progression]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [can_make_arithmetic_progression]: function definitions module public import Aeneas public import Aegis.CanMakeArithmeticProgression.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option l...
import Aegis.CanMakeArithmeticProgression.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.CanMakeArithmeticProgression.can_make_arithmetic_progression (Slice.from [42#i64, 42#i64] (by scalar_tac) : Slice Std.I64)) (true))}...
[ { "input": "[[42, 42]]", "output": "true" }, { "input": "[[-1, 1, 0]]", "output": "true" }, { "input": "[[10, 5, 15]]", "output": "true" }, { "input": "[[100, -100, 0]]", "output": "true" }, { "input": "[[5, 3, 1]]", "output": "true" }, { "input": "[[1...
161
false
161
verified
10
10
1
804
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.CanMakeArithmeticProgression.Code.Funs /-! # Specifications of `Aegis.CanMakeArithmeticProgression.can_make_arithmetic_progression` LeetCode problem `can-make-arithmetic-progression-from-sequence`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace...
10
last-moment-before-all-ants-fall-out-of-a-plank
1,503
Medium
[ "Brainteaser", "Array", "Simulation" ]
We have a wooden plank of the length n units. Some ants are walking on the plank, each ant moves with a speed of 1 unit per second. Some of the ants move to the left, the other move to the right. When two ants moving in two different directions meet at some point, they change their directions and continue moving again....
getLastMoment(n: int, left: list_int, right: list_int) -> int
pub fn get_last_moment(n: i64, left: &[i64], right: &[i64]) -> i64
Aegis.GetLastMoment.get_last_moment
pub fn get_last_moment(n: i64, left: &[i64], right: &[i64]) -> i64 { let mut ans: i64 = 0; let mut i: usize = 0; while i < left.len() { if left[i] > ans { ans = left[i]; } i += 1; } let mut j: usize = 0; while j < right.len() { let t: i64 = n - right...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [get_last_moment]: type definitions module public import Aeneas @[expose] public section 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 -- [get_last_moment]: function definitions module public import Aeneas public import Aegis.GetLastMoment.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.GetLastMoment.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.GetLastMoment.get_last_moment 1#i64 (Slice.from [] (by scalar_tac) : Slice Std.I64) (Slice.from [0#i64] (by scalar_tac) : Slice Std.I64)) (1#i64))}...
[ { "input": "[1, [], [0]]", "output": "1" }, { "input": "[1, [1], []]", "output": "1" }, { "input": "[1, [0], []]", "output": "0" }, { "input": "[5, [5], [0]]", "output": "5" }, { "input": "[1, [0], [1]]", "output": "0" }, { "input": "[100, [], [0, 100]...
126
false
126
verified
10
10
1
635
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.GetLastMoment.Code.Funs /-! # Specifications of `Aegis.GetLastMoment.get_last_moment` LeetCode problem `last-moment-before-all-ants-fall-out-of-a-plank`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.GetLastMoment namespace AegisSpec.GetLastMom...
15
count-submatrices-with-all-ones
1,504
Medium
[ "Stack", "Array", "Dynamic Programming", "Matrix", "Monotonic Stack" ]
Given an m x n binary matrix mat, return the number of submatrices that have all ones.   Example 1: Input: mat = [[1,0,1],[1,1,0],[1,1,0]] Output: 13 Explanation: There are 6 rectangles of side 1x1. There are 2 rectangles of side 1x2. There are 3 rectangles of side 2x1. There is 1 rectangle of side 2x2. There is 1 ...
numSubmat(mat: list_list_int) -> int
pub fn num_submat(mat: &[Vec<i64>]) -> i64
Aegis.NumSubmat.num_submat
pub fn num_submat(mat: &[Vec<i64>]) -> i64 { let m = mat.len(); if m == 0 { return 0; } let n = mat[0].len(); let mut heights: Vec<i64> = Vec::new(); let mut j = 0; while j < n { heights.push(0); j += 1; } let mut total: i64 = 0; let mut i = 0; while...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [num_submat]: type definitions module public import Aeneas @[expose] public section 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 -- [num_submat]: function definitions module public import Aeneas public import Aegis.NumSubmat.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.NumSubmat.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.NumSubmat.num_submat (Slice.from [(alloc.vec.Vec.from [0#i64, 0#i64] (by scalar_tac) : alloc.vec.Vec Std.I64), (alloc.vec.Vec.from [0#i64, 0#i64] (by s...
[ { "input": "[[[0, 0], [0, 0]]]", "output": "0" }, { "input": "[[[1, 0], [0, 1]]]", "output": "2" }, { "input": "[[[1, 1], [1, 1]]]", "output": "9" }, { "input": "[[[0, 0, 0], [0, 0, 0]]]", "output": "0" }, { "input": "[[[1, 0, 1], [1, 1, 0], [1, 1, 0]]]", "out...
90
false
90
verified
10
10
1
1,934
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.NumSubmat.Code.Funs /-! # Specifications of `Aegis.NumSubmat.num_submat` LeetCode problem `count-submatrices-with-all-ones`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.NumSubmat def rows (mat : Slice (alloc.vec.Vec Std.I64)) : ...
15
minimum-difference-between-largest-and-smallest-value-in-three-moves
1,509
Medium
[ "Greedy", "Array", "Sorting" ]
You are given an integer array nums. In one move, you can choose one element of nums and change it to any value. Return the minimum difference between the largest and smallest value of nums after performing at most three moves.   Example 1: Input: nums = [5,3,2,4] Output: 0 Explanation: We can make at most 3 moves. In...
minDifference(nums: list_int) -> int
pub fn min_difference(nums: &[i64]) -> i64
Aegis.MinDifference.min_difference
pub fn min_difference(nums: &[i64]) -> i64 { let n = nums.len(); if n <= 4 { return 0; } let mut v: Vec<i64> = Vec::new(); let mut i = 0; while i < n { v.push(nums[i]); i += 1; } v.sort(); let d0 = v[n - 1] - v[3]; let d1 = v[n - 2] - v[2]; let d2 ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [min_difference]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [min_difference]: function definitions module public import Aeneas public import Aegis.MinDifference.Code.Types public import Aegis.MinDifference.Code.FunsExternal @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespac...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [min_difference]: external functions. -- This is a template file: rename it to "FunsExternal.lean" and fill the holes. module public import Aeneas public import Aegis.MinDifference.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error s...
import Aegis.MinDifference.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.MinDifference.min_difference (Slice.from [1#i64] (by scalar_tac) : Slice Std.I64)) (0#i64))}") #eval (s!"CASE 1 {(Result.reducesTo (Aegis.MinDiffer...
[ { "input": "[[1]]", "output": "0" }, { "input": "[[1, 2]]", "output": "0" }, { "input": "[[3, 100, 20]]", "output": "0" }, { "input": "[[1, 2, 3]]", "output": "0" }, { "input": "[[1, 1000000000, -1000000000, 0]]", "output": "0" }, { "input": "[[5, 3, 2...
109
false
109
verified
10
10
1
2,791
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MinDifference.Code.Funs /-! # Specifications of `Aegis.MinDifference.min_difference` LeetCode problem `minimum-difference-between-largest-and-smallest-value-in-three-moves`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.MinDifference...
11
stone-game-iv
1,510
Hard
[ "Math", "Dynamic Programming", "Game Theory" ]
Alice and Bob take turns playing a game, with Alice starting first. Initially, there are n stones in a pile. On each player's turn, that player makes a move consisting of removing any non-zero square number of stones in the pile. Also, if a player cannot make a move, he/she loses the game. Given a positive integer n, r...
winnerSquareGame(n: int) -> bool
pub fn winner_square_game(n: i64) -> bool
Aegis.WinnerSquareGame.winner_square_game
pub fn winner_square_game(n: i64) -> bool { if n <= 0 { return false; } let nn: usize = n as usize; let mut dp: Vec<i64> = Vec::new(); let mut idx: usize = 0; while idx <= nn { dp.push(0); idx += 1; } let mut i: usize = 1; while i <= nn { let mut wi...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [winner_square_game]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option li...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [winner_square_game]: function definitions module public import Aeneas public import Aegis.WinnerSquareGame.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.WinnerSquareGame.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.WinnerSquareGame.winner_square_game 101#i64) (true))}") #eval (s!"CASE 1 {(Result.reducesTo (Aegis.WinnerSquareGame.winner_square_game 3#i64) (t...
[ { "input": "[101]", "output": "true" }, { "input": "[3]", "output": "true" }, { "input": "[100]", "output": "true" }, { "input": "[30]", "output": "true" }, { "input": "[5]", "output": "false" }, { "input": "[4]", "output": "true" }, { "inp...
24
false
24
verified
10
10
1
1,473
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.WinnerSquareGame.Code.Funs /-! # Specifications of `Aegis.WinnerSquareGame.winner_square_game` LeetCode problem `stone-game-iv`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.WinnerSquareGame def W (m : ℤ) : Prop := if h : 0 < m the...
6
number-of-good-pairs
1,512
Easy
[ "Array", "Hash Table", "Math", "Counting" ]
Given an array of integers nums, return the number of good pairs. A pair (i, j) is called good if nums[i] == nums[j] and i < j.   Example 1: Input: nums = [1,2,3,1,1,3] Output: 4 Explanation: There are 4 good pairs (0,3), (0,4), (3,4), (2,5) 0-indexed. Example 2: Input: nums = [1,1,1,1] Output: 6 Explanation: Each p...
numIdenticalPairs(nums: list_int) -> int
pub fn num_identical_pairs(nums: &[i64]) -> i64
Aegis.NumIdenticalPairs.num_identical_pairs
pub fn num_identical_pairs(nums: &[i64]) -> i64 { let n = nums.len(); let mut count: i64 = 0; let mut i: usize = 0; while i < n { let mut j: usize = i + 1; while j < n { if nums[i] == nums[j] { count += 1; } j += 1; } i...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [num_identical_pairs]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option l...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [num_identical_pairs]: function definitions module public import Aeneas public import Aegis.NumIdenticalPairs.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false...
import Aegis.NumIdenticalPairs.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.NumIdenticalPairs.num_identical_pairs (Slice.from [1#i64] (by scalar_tac) : Slice Std.I64)) (0#i64))}") #eval (s!"CASE 1 {(Result.reducesTo (Ae...
[ { "input": "[[1]]", "output": "0" }, { "input": "[[100, 100]]", "output": "1" }, { "input": "[[10, 10, 10]]", "output": "3" }, { "input": "[[1, 2, 3]]", "output": "0" }, { "input": "[[1, 1, 1, 1]]", "output": "6" }, { "input": "[[5, 5, 5, 5, 5]]", ...
102
false
102
verified
10
10
1
318
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.NumIdenticalPairs.Code.Funs /-! # Specifications of `Aegis.NumIdenticalPairs.num_identical_pairs` LeetCode problem `number-of-good-pairs`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.NumIdenticalPairs namespace AegisSpec.NumIdenticalPairs...
14
number-of-substrings-with-only-1s
1,513
Medium
[ "Math", "String" ]
Given a binary string s, return the number of substrings with all characters 1's. Since the answer may be too large, return it modulo 109 + 7.   Example 1: Input: s = "0110111" Output: 9 Explanation: There are 9 substring in total with only 1's characters. "1" -> 5 times. "11" -> 3 times. "111" -> 1 time. Example 2: ...
numSub(s: str) -> int
pub fn num_sub(s: &[u8]) -> i64
Aegis.NumSub.num_sub
pub fn num_sub(s: &[u8]) -> i64 { let n = s.len(); let mut total: i64 = 0; let mut run: i64 = 0; let mut i: usize = 0; while i < n { if s[i] == b'1' { run += 1; } else { if run > 0 { total = (total + run * (run + 1) / 2) % 1000000007; ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [num_sub]: type definitions module public import Aeneas @[expose] public section 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_sub]: function definitions module public import Aeneas public import Aegis.NumSub.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.NumSub.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.NumSub.num_sub (Slice.from [49#u8, 49#u8, 48#u8, 48#u8, 49#u8, 49#u8, 48#u8, 48#u8, 49#u8, 49#u8] (by scalar_tac) : Slice Std.U8)) (9#i64))}") #eval (s!"C...
[ { "input": "[\"1100110011\"]", "output": "9" }, { "input": "[\"101\"]", "output": "2" }, { "input": "[\"1001001001\"]", "output": "4" }, { "input": "[\"1111101111\"]", "output": "25" }, { "input": "[\"110110110110110\"]", "output": "15" }, { "input": "...
28
false
28
verified
10
10
1
457
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.NumSub.Code.Funs /-! # Specifications of `Aegis.NumSub.num_sub` LeetCode problem `number-of-substrings-with-only-1s`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.NumSub def IsUniqueMod (m c x : ℤ) : Prop := 0 ≤ x ∧ x < m ∧ m ∣ (c ...
14
water-bottles
1,518
Easy
[ "Math", "Simulation" ]
There are numBottles water bottles that are initially full of water. You can exchange numExchange empty water bottles from the market with one full water bottle. The operation of drinking a full water bottle turns it into an empty bottle. Given the two integers numBottles and numExchange, return the maximum number of w...
numWaterBottles(numBottles: int, numExchange: int) -> int
pub fn num_water_bottles(numBottles: i64, numExchange: i64) -> i64
Aegis.NumWaterBottles.num_water_bottles
pub fn num_water_bottles(numBottles: i64, numExchange: i64) -> i64 { let mut total = numBottles; let mut empty = numBottles; while empty >= numExchange { let new_full = empty / numExchange; total = total + new_full; empty = (empty % numExchange) + new_full; } total }
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [num_water_bottles]: type definitions module public import Aeneas @[expose] public section 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 -- [num_water_bottles]: function definitions module public import Aeneas public import Aegis.NumWaterBottles.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.NumWaterBottles.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.NumWaterBottles.num_water_bottles 10#i64 2#i64) (19#i64))}") #eval (s!"CASE 1 {(Result.reducesTo (Aegis.NumWaterBottles.num_water_bottles 20#i64 ...
[ { "input": "[10, 2]", "output": "19" }, { "input": "[20, 6]", "output": "23" }, { "input": "[100, 10]", "output": "111" }, { "input": "[5, 5]", "output": "6" }, { "input": "[15, 4]", "output": "19" }, { "input": "[100, 2]", "output": "199" }, {...
73
false
73
verified
10
10
1
428
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.NumWaterBottles.Code.Funs /-! # Specifications of `Aegis.NumWaterBottles.num_water_bottles` LeetCode problem `water-bottles`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.NumWaterBottles structure BottleState where full : Nat...
10
number-of-nodes-in-the-sub-tree-with-the-same-label
1,519
Medium
[ "Tree", "Depth-First Search", "Breadth-First Search", "Hash Table", "Counting" ]
You are given a tree (i.e. a connected, undirected graph that has no cycles) consisting of n nodes numbered from 0 to n - 1 and exactly n - 1 edges. The root of the tree is the node 0, and each node of the tree has a label which is a lower-case character given in the string labels (i.e. The node with the number i has t...
countSubTrees(n: int, edges: list_list_int, labels: str) -> list_int
pub fn count_sub_trees(n: i64, edges: &[Vec<i64>], labels: &[u8]) -> Vec<i64>
Aegis.CountSubTrees.count_sub_trees
pub fn count_sub_trees(n: i64, edges: &[Vec<i64>], labels: &[u8]) -> Vec<i64> { let nn = n as usize; let mut head: Vec<i64> = Vec::new(); let mut i: usize = 0; while i < nn { head.push(-1); i += 1; } let mut to: Vec<i64> = Vec::new(); let mut nxt: Vec<i64> = Vec::new(); ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [count_sub_trees]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linte...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [count_sub_trees]: function definitions module public import Aeneas public import Aegis.CountSubTrees.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.CountSubTrees.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.CountSubTrees.count_sub_trees 1#i64 (Slice.from [] (by scalar_tac) : Slice (alloc.vec.Vec Std.I64)) (Slice.from [97#u8] (by scalar_tac) : Slice Std...
[ { "input": "[1, [], \"a\"]", "output": "[1]" }, { "input": "[3, [[0, 1], [0, 2]], \"aaa\"]", "output": "[3, 1, 1]" }, { "input": "[4, [[0, 1], [1, 2], [0, 3]], \"bbbb\"]", "output": "[4, 2, 1, 1]" }, { "input": "[5, [[0, 1], [0, 2], [1, 3], [0, 4]], \"aabab\"]", "output":...
44
false
44
verified
10
10
1
7,842
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.CountSubTrees.Code.Funs /-! # Specifications of `Aegis.CountSubTrees.count_sub_trees` LeetCode problem `number-of-nodes-in-the-sub-tree-with-the-same-label`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open scoped Classical open Aegis.CountSubTrees ...
16
maximum-number-of-non-overlapping-substrings
1,520
Hard
[ "Greedy", "String" ]
Given a string s of lowercase letters, you need to find the maximum number of non-empty substrings of s that meet the following conditions: The substrings do not overlap, that is for any two substrings s[i..j] and s[x..y], either j < x or i > y is true. A substring that contains a certain character c must also contain...
maxNumOfSubstrings(s: str) -> list_str
pub fn max_num_of_substrings(s: &[u8]) -> Vec<Vec<u8>>
Aegis.MaxNumOfSubstrings.max_num_of_substrings
pub fn max_num_of_substrings(s: &[u8]) -> Vec<Vec<u8>> { let n = s.len(); let mut first: Vec<usize> = Vec::new(); let mut last: Vec<usize> = Vec::new(); let mut i = 0; while i < 26 { first.push(n); last.push(0); i += 1; } let mut pos = 0; while pos < n { ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [max_num_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 -- [max_num_of_substrings]: function definitions module public import Aeneas public import Aegis.MaxNumOfSubstrings.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand fa...
import Aegis.MaxNumOfSubstrings.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(match (Aegis.MaxNumOfSubstrings.max_num_of_substrings (Slice.from [97#u8, 97#u8, 98#u8, 98#u8, 99#u8, 99#u8, 97#u8, 97#u8, 97#u8, 97#u8, 98#u8, 98#u8, 98#u8, 98#u8, 9...
[ { "input": "[\"aabbccaaaabbbbcccc\"]", "output": "[\"aabbccaaaabbbbcccc\"]" }, { "input": "[\"abcdcba\"]", "output": "[\"d\"]" }, { "input": "[\"aaaabaaaabaaaabaaaabaaaa\"]", "output": "[\"aaaabaaaabaaaabaaaabaaaa\"]" }, { "input": "[\"abababab\"]", "output": "[\"abababab...
59
true
59
verified
10
10
1
28,754
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MaxNumOfSubstrings.Code.Funs /-! # Specifications of `Aegis.MaxNumOfSubstrings.max_num_of_substrings` LeetCode problem `maximum-number-of-non-overlapping-substrings`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.MaxNumOfSubstrings de...
16
find-a-value-of-a-mysterious-function-closest-to-target
1,521
Hard
[ "Bit Manipulation", "Segment Tree", "Array", "Binary Search" ]
Winston was given the above mysterious function func. He has an integer array arr and an integer target and he wants to find the values l and r that make the value |func(arr, l, r) - target| minimum possible. Return the minimum possible value of |func(arr, l, r) - target|. Notice that func should be called with the va...
closestToTarget(arr: list_int, target: int) -> int
pub fn closest_to_target(arr: &[i64], target: i64) -> i64
Aegis.ClosestToTarget.closest_to_target
pub fn closest_to_target(arr: &[i64], target: i64) -> i64 { let n = arr.len(); let mut ans: i64 = 1000000000; let mut vals: Vec<i64> = Vec::new(); let mut i: usize = 0; while i < n { let a = arr[i]; let mut new_vals: Vec<i64> = Vec::new(); new_vals.push(a); let mut ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [closest_to_target]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option lin...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [closest_to_target]: function definitions module public import Aeneas public import Aegis.ClosestToTarget.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.ClosestToTarget.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.ClosestToTarget.closest_to_target (Slice.from [1000000#i64] (by scalar_tac) : Slice Std.I64) 1000000#i64) (0#i64))}") #eval (s!"CASE 1 {(Result.r...
[ { "input": "[[1000000], 1000000]", "output": "0" }, { "input": "[[1000000, 1000000, 1000000], 1]", "output": "999999" }, { "input": "[[2, 4, 6, 8, 10], 7]", "output": "1" }, { "input": "[[5, 5, 5, 5, 5], 5]", "output": "0" }, { "input": "[[1, 1, 1, 1, 1], 2]", ...
119
false
119
verified
10
10
1
2,309
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.ClosestToTarget.Code.Funs /-! # Specifications of `Aegis.ClosestToTarget.closest_to_target` LeetCode problem `find-a-value-of-a-mysterious-function-closest-to-target`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.ClosestToTarget open...
12
count-odd-numbers-in-an-interval-range
1,523
Easy
[ "Math" ]
Given two non-negative integers low and high. Return the count of odd numbers between low and high (inclusive).\r \r  \r Example 1:\r \r \r Input: low = 3, high = 7\r Output: 3\r Explanation: The odd numbers between 3 and 7 are [3,5,7].\r \r Example 2:\r \r \r Input: low = 8, high = 10\r Output: 1\r Explanation: The od...
countOdds(low: int, high: int) -> int
pub fn count_odds(low: i64, high: i64) -> i64
Aegis.CountOdds.count_odds
pub fn count_odds(low: i64, high: i64) -> i64 { (high + 1) / 2 - low / 2 }
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [count_odds]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter.sty...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [count_odds]: function definitions module public import Aeneas public import Aegis.CountOdds.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.CountOdds.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.CountOdds.count_odds 3#i64 7#i64) (3#i64))}") #eval (s!"CASE 1 {(Result.reducesTo (Aegis.CountOdds.count_odds 0#i64 1000000000#i64) (500000000#i64))}")...
[ { "input": "[3, 7]", "output": "3" }, { "input": "[0, 1000000000]", "output": "500000000" }, { "input": "[0, 1]", "output": "1" }, { "input": "[500000000, 500000000]", "output": "0" }, { "input": "[1, 1000000000]", "output": "500000000" }, { "input": "...
93
false
93
verified
10
10
1
455
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.CountOdds.Code.Funs /-! # Specifications of `Aegis.CountOdds.count_odds` LeetCode problem `count-odd-numbers-in-an-interval-range`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.CountOdds def countOddInRange (lo hi : ℤ) : ℕ := ...
12
number-of-sub-arrays-with-odd-sum
1,524
Medium
[ "Array", "Math", "Dynamic Programming", "Prefix Sum" ]
Given an array of integers arr, return the number of subarrays with an odd sum. Since the answer can be very large, return it modulo 109 + 7.   Example 1: Input: arr = [1,3,5] Output: 4 Explanation: All subarrays are [[1],[1,3],[1,3,5],[3],[3,5],[5]] All sub-arrays sum are [1,4,9,3,8,5]. Odd sums are [1,9,3,5] so the ...
numOfSubarrays(arr: list_int) -> int
pub fn num_of_subarrays(arr: &[i64]) -> i64
Aegis.NumOfSubarrays.num_of_subarrays
pub fn num_of_subarrays(arr: &[i64]) -> i64 { const MOD: i64 = 1_000_000_007; let n = arr.len(); let mut even_prefix: i64 = 1; let mut odd_prefix: i64 = 0; let mut parity: i64 = 0; let mut ans: i64 = 0; let mut i: usize = 0; while i < n { let x = arr[i]; if x % 2 != 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 [1#i64] (by scalar_tac) : Slice Std.I64)) (1#i64))}") #eval (s!"CASE 1 {(Result.reducesTo (Aegis.NumOf...
[ { "input": "[[1]]", "output": "1" }, { "input": "[[2]]", "output": "0" }, { "input": "[[1, 2]]", "output": "2" }, { "input": "[[1, 2, 3]]", "output": "4" }, { "input": "[[99, 100, 101]]", "output": "4" }, { "input": "[[100, 100, 100]]", "output": "...
87
false
87
verified
10
10
1
1,305
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": 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-with-odd-sum`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.NumOfSubarrays def MOD : Nat := 1000000007 d...
13
minimum-number-of-increments-on-subarrays-to-form-a-target-array
1,526
Hard
[ "Stack", "Greedy", "Array", "Dynamic Programming", "Monotonic Stack" ]
You are given an integer array target. You have an integer array initial of the same size as target with all elements initially zeros. In one operation you can choose any subarray from initial and increment each value by one. Return the minimum number of operations to form a target array from initial. The test cases ar...
minNumberOperations(target: list_int) -> int
pub fn min_number_operations(target: &[i64]) -> i64
Aegis.MinNumberOperations.min_number_operations
pub fn min_number_operations(target: &[i64]) -> i64 { let n: usize = target.len(); if n == 0 { return 0; } let mut ops: i64 = target[0]; let mut i: usize = 1; while i < n { if target[i] > target[i - 1] { ops += target[i] - target[i - 1]; } i += 1; ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [min_number_operations]: type definitions module public import Aeneas @[expose] public section 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 -- [min_number_operations]: function definitions module public import Aeneas public import Aegis.MinNumberOperations.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand f...
import Aegis.MinNumberOperations.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.MinNumberOperations.min_number_operations (Slice.from [100000#i64] (by scalar_tac) : Slice Std.I64)) (100000#i64))}") #eval (s!"CASE 1 {(Resu...
[ { "input": "[[100000]]", "output": "100000" }, { "input": "[[1, 100000, 1]]", "output": "100000" }, { "input": "[[3, 1, 1, 2]]", "output": "4" }, { "input": "[[1, 2, 3, 4, 5]]", "output": "5" }, { "input": "[[5, 4, 3, 2, 1]]", "output": "5" }, { "input...
105
false
105
verified
10
10
1
333
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MinNumberOperations.Code.Funs /-! # Specifications of `Aegis.MinNumberOperations.min_number_operations` LeetCode problem `minimum-number-of-increments-on-subarrays-to-form-a-target-array`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.MinNumbe...
10
minimum-suffix-flips
1,529
Medium
[ "Greedy", "String" ]
You are given a 0-indexed binary string target of length n. You have another binary string s of length n that is initially set to all zeros. You want to make s equal to target. In one operation, you can pick an index i where 0 <= i < n and flip all bits in the inclusive range [i, n - 1]. Flip means changing '0' to '1' ...
minFlips(target: str) -> int
pub fn min_flips(target: &[u8]) -> i64
Aegis.MinFlips.min_flips
pub fn min_flips(target: &[u8]) -> i64 { let mut flips: i64 = 0; let mut current: u8 = 0; let n = target.len(); let mut i: usize = 0; while i < n { let bit: u8 = if target[i] == b'1' { 1 } else { 0 }; if bit != current { flips += 1; if current == 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 (Slice.from [48#u8, 48#u8, 48#u8, 48#u8, 48#u8] (by scalar_tac) : Slice Std.U8)) (0#i64))}") #eval (s!"CASE 1 {(Result.reducesTo (Aeg...
[ { "input": "[\"00000\"]", "output": "0" }, { "input": "[\"00110\"]", "output": "2" }, { "input": "[\"1100110011\"]", "output": "5" }, { "input": "[\"000111000111\"]", "output": "3" }, { "input": "[\"001100\"]", "output": "2" }, { "input": "[\"10001\"]"...
117
false
117
verified
10
10
1
489
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": 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-suffix-flips`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.MinFlips (min_flips) namespace AegisSpec.MinFlips def bitOfByte (b : U8) : ℕ := ...
13
number-of-good-leaf-nodes-pairs
1,530
Medium
[ "Tree", "Depth-First Search", "Binary Tree" ]
You are given the root of a binary tree and an integer distance. A pair of two different leaf nodes of a binary tree is said to be good if the length of the shortest path between them is less than or equal to distance. Return the number of good leaf node pairs in the tree.   Example 1: Input: root = [1,2,3,null,4], d...
countPairs(root: tree, distance: int) -> int
pub fn count_pairs(root: &Tree, distance: i64) -> i64
Aegis.CountPairs.count_pairs
fn dfs(t: &Tree, distance: i64) -> Vec<i64> { match t { Tree::Null => { let mut res: Vec<i64> = Vec::new(); res.push(0); res } Tree::Node(_, left, right) => { let left_null = match &**left { Tree::Null => true, T...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [count_pairs]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter.st...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [count_pairs]: function definitions module public import Aeneas public import Aegis.CountPairs.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.CountPairs.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.CountPairs.count_pairs ((.Node 1#i64 (.Null) (.Null)) : Aegis.CountPairs.Tree) 1#i64) (0#i64))}") #eval (s!"CASE 1 {(Result.reducesTo (Aegis.CountPair...
[ { "input": "[[1], 1]", "output": "0" }, { "input": "[[1, 2, 3, 4, 5, 6, 7], 5]", "output": "6" }, { "input": "[[1, 2, 3, 4, 5, 6, 7], 3]", "output": "2" }, { "input": "[[1, 2, 3, 4, 5, 6, 7], 1]", "output": "0" }, { "input": "[[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 1...
15
false
15
verified
10
10
1
6,878
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.CountPairs.Code.Funs /-! # Specifications of `Aegis.CountPairs.count_pairs` LeetCode problem `number-of-good-leaf-nodes-pairs`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.CountPairs open Aegis.CountPairs def nodeCount : Tree...
4
string-compression-ii
1,531
Hard
[ "String", "Dynamic Programming" ]
Run-length encoding is a string compression method that works by replacing consecutive identical characters (repeated 2 or more times) with the concatenation of the character and the number marking the count of the characters (length of the run). For example, to compress the string "aabccc" we replace "aa" by "a2" and ...
getLengthOfOptimalCompression(s: str, k: int) -> int
pub fn get_length_of_optimal_compression(s: &[u8], k: i64) -> i64
Aegis.GetLengthOfOptimalCompression.get_length_of_optimal_compression
fn encoded_run_cost(cnt: usize) -> i64 { if cnt == 0usize { return 0i64; } if cnt == 1usize { return 1i64; } if cnt < 10usize { return 2i64; } if cnt < 100usize { return 3i64; } 4i64 } pub fn get_length_of_optimal_compression(s: &[u8], k: i64) -> i64 ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [get_length_of_optimal_compression]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables fals...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [get_length_of_optimal_compression]: function definitions module public import Aeneas public import Aegis.GetLengthOfOptimalCompression.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_optio...
import Aegis.GetLengthOfOptimalCompression.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.GetLengthOfOptimalCompression.get_length_of_optimal_compression (Slice.from [97#u8, 98#u8, 99#u8, 97#u8, 98#u8, 99#u8, 97#u8, 98#u8...
[ { "input": "[\"abcabcabc\", 5]", "output": "3" }, { "input": "[\"aaabcccd\", 2]", "output": "4" }, { "input": "[\"aabcc\", 1]", "output": "4" }, { "input": "[\"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\", 20]", "output": "32" }, { "input": "[\"aabccabcc...
84
false
84
verified
10
10
1
12,757
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.GetLengthOfOptimalCompression.Code.Funs /-! # Specifications of `Aegis.GetLengthOfOptimalCompression.get_length_of_optimal_compression` LeetCode problem `string-compression-ii`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.GetLengthOfOptimalC...
14
count-good-triplets
1,534
Easy
[ "Array", "Enumeration" ]
Given an array of integers arr, and three integers a, b and c. You need to find the number of good triplets.\r \r A triplet (arr[i], arr[j], arr[k]) is good if the following conditions are true:\r \r \r 0 <= i < j < k < arr.length\r |arr[i] - arr[j]| <= a\r |arr[j] - arr[k]| <= b\r |arr[i] - arr[k]| <= c\r \r \r Wh...
countGoodTriplets(arr: list_int, a: int, b: int, c: int) -> int
pub fn count_good_triplets(arr: &[i64], a: i64, b: i64, c: i64) -> i64
Aegis.CountGoodTriplets.count_good_triplets
pub fn count_good_triplets(arr: &[i64], a: i64, b: i64, c: i64) -> i64 { let n: usize = arr.len(); let mut count: i64 = 0; let mut i: usize = 0; while i < n { let mut j: usize = i + 1; while j < n { let d_ij = arr[i] - arr[j]; let abs_ij = if d_ij < 0 { -d_ij } ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [count_good_triplets]: type definitions module public import Aeneas @[expose] public section 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 -- [count_good_triplets]: function definitions module public import Aeneas public import Aegis.CountGoodTriplets.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false...
import Aegis.CountGoodTriplets.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.CountGoodTriplets.count_good_triplets (Slice.from [0#i64, 0#i64, 0#i64, 0#i64] (by scalar_tac) : Slice Std.I64) 1#i64 1#i64 1#i64) (4#i64))}") ...
[ { "input": "[[0, 0, 0, 0], 1, 1, 1]", "output": "4" }, { "input": "[[1, 3, 5, 7, 9], 2, 3, 4]", "output": "3" }, { "input": "[[1, 1, 2, 2, 3], 0, 0, 1]", "output": "0" }, { "input": "[[10, 20, 30, 40, 50], 5, 10, 15]", "output": "0" }, { "input": "[[10, 20, 30, 40...
101
false
101
verified
10
10
1
855
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.CountGoodTriplets.Code.Funs /-! # Specifications of `Aegis.CountGoodTriplets.count_good_triplets` LeetCode problem `count-good-triplets`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.CountGoodTriplets def elemAt (arr : Aeneas.Std...
12
find-the-winner-of-an-array-game
1,535
Medium
[ "Array", "Simulation" ]
Given an integer array arr of distinct integers and an integer k. A game will be played between the first two elements of the array (i.e. arr[0] and arr[1]). In each round of the game, we compare arr[0] with arr[1], the larger integer wins and remains at position 0, and the smaller integer moves to the end of the array...
getWinner(arr: list_int, k: int) -> int
pub fn get_winner(arr: &[i64], k: i64) -> i64
Aegis.GetWinner.get_winner
pub fn get_winner(arr: &[i64], k: i64) -> i64 { let n = arr.len(); let mut current: i64 = arr[0]; let mut wins: i64 = 0; let mut i: usize = 1; while i < n { if arr[i] < current { wins = wins + 1; } else { current = arr[i]; wins = 1; } ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [get_winner]: type definitions module public import Aeneas @[expose] public section 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 -- [get_winner]: function definitions module public import Aeneas public import Aegis.GetWinner.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.GetWinner.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.GetWinner.get_winner (Slice.from [3#i64, 2#i64, 1#i64] (by scalar_tac) : Slice Std.I64) 10#i64) (3#i64))}") #eval (s!"CASE 1 {(Result.reducesTo (Aegis....
[ { "input": "[[3, 2, 1], 10]", "output": "3" }, { "input": "[[7, 10, 5, 3, 8], 3]", "output": "10" }, { "input": "[[5, 4, 3, 2, 1], 1]", "output": "5" }, { "input": "[[5, 1, 4, 2, 3], 4]", "output": "5" }, { "input": "[[1, 2, 3, 4, 5], 1]", "output": "2" }, ...
105
false
105
verified
10
10
1
1,476
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.GetWinner.Code.Funs /-! # Specifications of `Aegis.GetWinner.get_winner` LeetCode problem `find-the-winner-of-an-array-game`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.GetWinner namespace AegisSpec.GetWinner def lget (l : List I64) (i : Na...
14
minimum-swaps-to-arrange-a-binary-grid
1,536
Medium
[ "Greedy", "Array", "Matrix" ]
Given an n x n binary grid, in one step you can choose two adjacent rows of the grid and swap them. A grid is said to be valid if all the cells above the main diagonal are zeros. Return the minimum number of steps needed to make the grid valid, or -1 if the grid cannot be valid. The main diagonal of a grid is the diago...
minSwaps(grid: list_list_int) -> int
pub fn min_swaps(grid: &[Vec<i64>]) -> i64
Aegis.MinSwaps.min_swaps
pub fn min_swaps(grid: &[Vec<i64>]) -> i64 { let n: usize = grid.len(); let mut trailing: Vec<i64> = Vec::new(); let mut i: usize = 0; while i < n { let mut cnt: i64 = 0; let mut k: usize = n; let mut still_zero: bool = true; while k > 0 { k -= 1; ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [min_swaps]: type definitions module public import Aeneas @[expose] public section 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_swaps]: function definitions module public import Aeneas public import Aegis.MinSwaps.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.MinSwaps.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.MinSwaps.min_swaps (Slice.from [(alloc.vec.Vec.from [0#i64, 0#i64, 1#i64] (by scalar_tac) : alloc.vec.Vec Std.I64), (alloc.vec.Vec.from [1#i64, 1#i64, 0...
[ { "input": "[[[0, 0, 1], [1, 1, 0], [1, 0, 0]]]", "output": "3" }, { "input": "[[[1, 1, 1], [1, 1, 1], [1, 1, 1]]]", "output": "-1" }, { "input": "[[[0, 0, 0], [0, 0, 1], [0, 1, 0]]]", "output": "1" }, { "input": "[[[1, 0, 0], [1, 1, 0], [1, 1, 1]]]", "output": "0" }, ...
71
false
71
verified
10
10
1
4,659
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MinSwaps.Code.Funs /-! # Specifications of `Aegis.MinSwaps.min_swaps` LeetCode problem `minimum-swaps-to-arrange-a-binary-grid`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.MinSwaps namespace AegisSpec.MinSwaps def rows (grid : Slice (...
13
get-the-maximum-score
1,537
Hard
[ "Greedy", "Array", "Two Pointers", "Dynamic Programming" ]
You are given two sorted arrays of distinct integers nums1 and nums2. A valid path is defined as follows: Choose array nums1 or nums2 to traverse (from index-0). Traverse the current array from left to right. If you are reading any value that is present in nums1 and nums2 you are allowed to change your path to the oth...
maxSum(nums1: list_int, nums2: list_int) -> int
pub fn max_sum(nums1: &[i64], nums2: &[i64]) -> i64
Aegis.MaxSum.max_sum
pub fn max_sum(nums1: &[i64], nums2: &[i64]) -> i64 { let n1 = nums1.len(); let n2 = nums2.len(); let mut i: usize = 0; let mut j: usize = 0; let mut sum1: i64 = 0; let mut sum2: i64 = 0; let mut total: i64 = 0; while i < n1 && j < n2 { if nums1[i] < nums2[j] { sum...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [max_sum]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter.style....
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [max_sum]: function definitions module public import Aeneas public import Aegis.MaxSum.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.MaxSum.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.MaxSum.max_sum (Slice.from [10000000#i64] (by scalar_tac) : Slice Std.I64) (Slice.from [10000000#i64] (by scalar_tac) : Slice Std.I64)) (10000000#i64))}")...
[ { "input": "[[10000000], [10000000]]", "output": "10000000" }, { "input": "[[1], [1]]", "output": "1" }, { "input": "[[1, 10000000], [2, 9999999]]", "output": "10000001" }, { "input": "[[1, 10000000], [5000000, 10000000]]", "output": "15000000" }, { "input": "[[1,...
110
false
110
verified
10
10
1
1,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.MaxSum.Code.Funs /-! # Specifications of `Aegis.MaxSum.max_sum` LeetCode problem `get-the-maximum-score`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.MaxSum def vals (s : Slice Std.I64) : List Int := s.val.map (fun x => x.val) ...
7
kth-missing-positive-number
1,539
Easy
[ "Array", "Binary Search" ]
Given an array arr of positive integers sorted in a strictly increasing order, and an integer k. Return the kth positive integer that is missing from this array.   Example 1: Input: arr = [2,3,4,7,11], k = 5 Output: 9 Explanation: The missing positive integers are [1,5,6,8,9,10,12,13,...]. The 5th missing positive int...
findKthPositive(arr: list_int, k: int) -> int
pub fn find_kth_positive(arr: &[i64], k: i64) -> i64
Aegis.FindKthPositive.find_kth_positive
pub fn find_kth_positive(arr: &[i64], k: i64) -> i64 { let n = arr.len(); if n == 0 { return k; } let mut missing: i64 = 0; let mut i: usize = 0; while i < n { let prev: i64 = if i == 0 { 0 } else { arr[i - 1] }; let gap: i64 = arr[i] - prev - 1; if missing + g...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [find_kth_positive]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option lin...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [find_kth_positive]: function definitions module public import Aeneas public import Aegis.FindKthPositive.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.FindKthPositive.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.FindKthPositive.find_kth_positive (Slice.from [10#i64, 20#i64, 30#i64] (by scalar_tac) : Slice Std.I64) 15#i64) (16#i64))}") #eval (s!"CASE 1 {(R...
[ { "input": "[[10, 20, 30], 15]", "output": "16" }, { "input": "[[10, 20, 30], 5]", "output": "5" }, { "input": "[[300, 600, 900], 1000]", "output": "1003" }, { "input": "[[1, 3, 5, 7], 3]", "output": "6" }, { "input": "[[1, 2, 3, 4], 2]", "output": "6" }, ...
109
false
109
verified
10
10
1
1,163
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.FindKthPositive.Code.Funs /-! # Specifications of `Aegis.FindKthPositive.find_kth_positive` LeetCode problem `kth-missing-positive-number`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.FindKthPositive def occurs (arr : Slice Std....
10
can-convert-string-in-k-moves
1,540
Medium
[ "Hash Table", "String" ]
Given two strings s and t, your goal is to convert s into t in k moves or less. During the ith (1 <= i <= k) move you can: Choose any index j (1-indexed) from s, such that 1 <= j <= s.length and j has not been chosen in any previous move, and shift the character at that index i times. Do nothing. Shifting a character...
canConvertString(s: str, t: str, k: int) -> bool
pub fn can_convert_string(s: &[u8], t: &[u8], k: i64) -> bool
Aegis.CanConvertString.can_convert_string
pub fn can_convert_string(s: &[u8], t: &[u8], k: i64) -> bool { if s.len() != t.len() { return false; } let mut counts: Vec<i64> = Vec::new(); let mut i = 0; while i < 26 { counts.push(0); i += 1; } let n = s.len(); let mut i = 0; while i < n { let a...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [can_convert_string]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option li...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [can_convert_string]: function definitions module public import Aeneas public import Aegis.CanConvertString.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.CanConvertString.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.CanConvertString.can_convert_string (Slice.from [97#u8, 98#u8, 99#u8] (by scalar_tac) : Slice Std.U8) (Slice.from [97#u8, 98#u8, 99#u8] (by scal...
[ { "input": "[\"abc\", \"abc\", 0]", "output": "true" }, { "input": "[\"aaa\", \"zzz\", 702]", "output": "true" }, { "input": "[\"abc\", \"bcd\", 10]", "output": "false" }, { "input": "[\"abc\", \"xyz\", 702]", "output": "true" }, { "input": "[\"abcd\", \"pqrs\", 1...
119
false
119
verified
10
10
1
1,360
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.CanConvertString.Code.Funs /-! # Specifications of `Aegis.CanConvertString.can_convert_string` LeetCode problem `can-convert-string-in-k-moves`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.CanConvertString namespace AegisSpec.CanConvertString...
14
minimum-insertions-to-balance-a-parentheses-string
1,541
Medium
[ "Stack", "Greedy", "String" ]
Given a parentheses string s containing only the characters '(' and ')'. A parentheses string is balanced if: Any left parenthesis '(' must have a corresponding two consecutive right parenthesis '))'. Left parenthesis '(' must go before the corresponding two consecutive right parenthesis '))'. In other words, we trea...
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(); let mut ans: i64 = 0; let mut need: i64 = 0; let mut i: usize = 0; while i < n { if s[i] == b'(' { need += 2; if need % 2 == 1 { ans += 1; need -= 1; } } els...
-- 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 [40#u8, 40#u8, 41#u8, 41#u8, 41#u8] (by scalar_tac) : Slice Std.U8)) (1#i64))}") #eval (s!"CASE 1 {(Result...
[ { "input": "[\"(()))\"]", "output": "1" }, { "input": "[\"))())(\"]", "output": "3" }, { "input": "[\"())\"]", "output": "0" }, { "input": "[\"(()(())))))))))))()()\"]", "output": "6" }, { "input": "[\"(()))(()))(()))(()))(())))()\"]", "output": "5" }, { ...
115
false
115
verified
10
10
1
4,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.MinInsertions.Code.Funs /-! # Specifications of `Aegis.MinInsertions.min_insertions` LeetCode problem `minimum-insertions-to-balance-a-parentheses-string`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.MinInsertions def LPAREN : Std.U...
15
find-longest-awesome-substring
1,542
Hard
[ "Bit Manipulation", "Hash Table", "String" ]
You are given a string s. An awesome substring is a non-empty substring of s such that we can make any number of swaps in order to make it a palindrome. Return the length of the maximum length awesome substring of s.   Example 1: Input: s = "3242415" Output: 5 Explanation: "24241" is the longest awesome substring, we ...
longestAwesome(s: str) -> int
pub fn longest_awesome(s: &[u8]) -> i64
Aegis.LongestAwesome.longest_awesome
pub fn longest_awesome(s: &[u8]) -> i64 { let n = s.len(); let mut first: Vec<i64> = Vec::new(); let mut j: usize = 0; while j < 1024 { first.push(-1); j += 1; } first[0] = 0; let mut mask: usize = 0; let mut best: i64 = 0; let mut i: usize = 0; while i < n { ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [longest_awesome]: type definitions module public import Aeneas @[expose] public section 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_awesome]: function definitions module public import Aeneas public import Aegis.LongestAwesome.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.LongestAwesome.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.LongestAwesome.longest_awesome (Slice.from [49#u8, 49#u8, 49#u8, 49#u8] (by scalar_tac) : Slice Std.U8)) (4#i64))}") #eval (s!"CASE 1 {(Result.red...
[ { "input": "[\"1111\"]", "output": "4" }, { "input": "[\"1000000001\"]", "output": "10" }, { "input": "[\"9876543210\"]", "output": "1" }, { "input": "[\"213123\"]", "output": "6" }, { "input": "[\"9437493749\"]", "output": "9" }, { "input": "[\"1221\"...
133
false
133
verified
10
10
1
3,411
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.LongestAwesome.Code.Funs /-! # Specifications of `Aegis.LongestAwesome.longest_awesome` LeetCode problem `find-longest-awesome-substring`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.LongestAwesome open Aegis.LongestAwesome d...
14
maximum-number-of-non-overlapping-subarrays-with-sum-equals-target
1,546
Medium
[ "Greedy", "Array", "Hash Table", "Prefix Sum" ]
Given an array nums and an integer target, return the maximum number of non-empty non-overlapping subarrays such that the sum of values in each subarray is equal to target.   Example 1: Input: nums = [1,1,1,1,1], target = 2 Output: 2 Explanation: There are 2 non-overlapping subarrays [1,1,1,1,1] with sum equals to tar...
maxNonOverlapping(nums: list_int, target: int) -> int
pub fn max_non_overlapping(nums: &[i64], target: i64) -> i64
Aegis.MaxNonOverlapping.max_non_overlapping
fn hash_index(key: i64, cap: usize) -> usize { let mut y: i64 = key + 2000000000; y = y ^ (y >> 16); y = y ^ (y >> 8); y = y ^ (y >> 4); let m: i64 = cap as i64; let mut v: i64 = y % m; if v < 0 { v = v + m; } v as usize } fn table_contains(keys: &[i64], stamps: &[i64], key...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [max_non_overlapping]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option l...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [max_non_overlapping]: function definitions module public import Aeneas public import Aegis.MaxNonOverlapping.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false...
import Aegis.MaxNonOverlapping.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.MaxNonOverlapping.max_non_overlapping (Slice.from [5#i64, 5#i64, 5#i64, 5#i64, 5#i64] (by scalar_tac) : Slice Std.I64) 10#i64) (2#i64))}") #eva...
[ { "input": "[[5, 5, 5, 5, 5], 10]", "output": "2" }, { "input": "[[1, 2, 3, 4, 5], 9]", "output": "1" }, { "input": "[[0, 0, 0, 0, 0], 0]", "output": "5" }, { "input": "[[1, 1, 1, 1, 1], 2]", "output": "2" }, { "input": "[[5, 5, 5, 5, 5], 15]", "output": "1" ...
96
false
96
verified
10
10
1
16,481
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MaxNonOverlapping.Code.Funs /-! # Specifications of `Aegis.MaxNonOverlapping.max_non_overlapping` LeetCode problem `maximum-number-of-non-overlapping-subarrays-with-sum-equals-target`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.MaxN...
13
the-most-similar-path-in-a-graph
1,548
Hard
[ "Graph", "Dynamic Programming" ]
We have n cities and m bi-directional roads where roads[i] = [ai, bi] connects city ai with city bi. Each city has a name consisting of exactly three upper-case English letters given in the string array names. Starting at any city x, you can reach any city y where y != x (i.e., the cities and the roads are forming an u...
mostSimilar(n: int, roads: list_list_int, names: list_str, targetPath: list_str) -> list_int
pub fn most_similar(n: i64, roads: &[Vec<i64>], names: &[Vec<u8>], targetPath: &[Vec<u8>]) -> Vec<i64>
Aegis.MostSimilar.most_similar
pub fn most_similar(n: i64, roads: &[Vec<i64>], names: &[Vec<u8>], targetPath: &[Vec<u8>]) -> Vec<i64> { let n_usize = n as usize; let mut adj: Vec<Vec<i64>> = Vec::new(); let mut i: usize = 0; while i < n_usize { let empty: Vec<i64> = Vec::new(); adj.push(empty); i += 1; } ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [most_similar]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter.s...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [most_similar]: function definitions module public import Aeneas public import Aegis.MostSimilar.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.MostSimilar.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.MostSimilar.most_similar 5#i64 (Slice.from [(alloc.vec.Vec.from [0#i64, 2#i64] (by scalar_tac) : alloc.vec.Vec Std.I64), (alloc.vec.Vec.from [0#i64, ...
[ { "input": "[5, [[0, 2], [0, 3], [1, 2], [1, 3], [1, 4], [2, 4]], [\"ATL\", \"PEK\", \"LAX\", \"DXB\", \"HND\"], [\"ATL\", \"DXB\", \"HND\", \"LAX\"]]", "output": "[0, 3, 0, 2]" }, { "input": "[6, [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5]], [\"ATL\", \"PEK\", \"LAX\", \"ATL\", \"DXB\", \"HND\"], [\"AT...
13
false
13
verified
10
10
1
14,439
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MostSimilar.Code.Funs /-! # Specifications of `Aegis.MostSimilar.most_similar` LeetCode problem `the-most-similar-path-in-a-graph`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.MostSimilar abbrev ByteSeq := List Nat abbrev Cit...
14
three-consecutive-odds
1,550
Easy
[ "Array" ]
Given an integer array arr, return true if there are three consecutive odd numbers in the array. Otherwise, return false.   Example 1: Input: arr = [2,6,4,1] Output: false Explanation: There are no three consecutive odds. Example 2: Input: arr = [1,2,34,3,4,5,7,23,12] Output: true Explanation: [5,7,23] are three con...
threeConsecutiveOdds(arr: list_int) -> bool
pub fn three_consecutive_odds(arr: &[i64]) -> bool
Aegis.ThreeConsecutiveOdds.three_consecutive_odds
pub fn three_consecutive_odds(arr: &[i64]) -> bool { let n = arr.len(); if n < 3 { return false; } let mut i: usize = 0; while i + 2 < n { let a = arr[i]; let b = arr[i + 1]; let c = arr[i + 2]; let odd_a = a % 2 != 0; let odd_b = b % 2 != 0; l...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [three_consecutive_odds]: type definitions module public import Aeneas @[expose] public 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 -- [three_consecutive_odds]: function definitions module public import Aeneas public import Aegis.ThreeConsecutiveOdds.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand...
import Aegis.ThreeConsecutiveOdds.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.ThreeConsecutiveOdds.three_consecutive_odds (Slice.from [999#i64, 997#i64, 995#i64] (by scalar_tac) : Slice Std.I64)) (true))}") #eval (s!"C...
[ { "input": "[[999, 997, 995]]", "output": "true" }, { "input": "[[1001, 1003, 1005]]", "output": "true" }, { "input": "[[1, 3, 5]]", "output": "true" }, { "input": "[[1000, 999, 998, 997]]", "output": "false" }, { "input": "[[2, 6, 4, 1]]", "output": "false" ...
131
false
131
verified
10
10
1
211
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.ThreeConsecutiveOdds.Code.Funs /-! # Specifications of `Aegis.ThreeConsecutiveOdds.three_consecutive_odds` LeetCode problem `three-consecutive-odds`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.ThreeConsecutiveOdds namespace AegisSpec.ThreeC...
10
minimum-operations-to-make-array-equal
1,551
Medium
[ "Math" ]
You have an array arr of length n where arr[i] = (2 * i) + 1 for all valid values of i (i.e., 0 <= i < n). In one operation, you can select two indices x and y where 0 <= x, y < n and subtract 1 from arr[x] and add 1 to arr[y] (i.e., perform arr[x] -=1 and arr[y] += 1). The goal is to make all the elements of the array...
minOperations(n: int) -> int
pub fn min_operations(n: i64) -> i64
Aegis.MinOperations.min_operations
pub fn min_operations(n: i64) -> i64 { let half = n / 2; half * (n - half) }
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [min_operations]: type definitions module public import Aeneas @[expose] public section 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_operations]: function definitions module public import Aeneas public import Aegis.MinOperations.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.MinOperations.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.MinOperations.min_operations 3#i64) (2#i64))}") #eval (s!"CASE 1 {(Result.reducesTo (Aegis.MinOperations.min_operations 100#i64) (2500#i64))}") #ev...
[ { "input": "[3]", "output": "2" }, { "input": "[100]", "output": "2500" }, { "input": "[10000]", "output": "25000000" }, { "input": "[6]", "output": "9" }, { "input": "[1]", "output": "0" }, { "input": "[1000]", "output": "250000" }, { "inp...
53
false
53
verified
10
10
1
537
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MinOperations.Code.Funs /-! # Specifications of `Aegis.MinOperations.min_operations` LeetCode problem `minimum-operations-to-make-array-equal`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.MinOperations def initArr (n : ℕ) : Fin n → ...
13
magnetic-force-between-two-balls
1,552
Medium
[ "Array", "Binary Search", "Sorting" ]
In the universe Earth C-137, Rick discovered a special form of magnetic force between two balls if they are put in his new invented basket. Rick has n empty baskets, the ith basket is at position[i], Morty has m balls and needs to distribute the balls into the baskets such that the minimum magnetic force between any tw...
maxDistance(position: list_int, m: int) -> int
pub fn max_distance(position: &[i64], m: i64) -> i64
Aegis.MaxDistance.max_distance
pub fn max_distance(position: &[i64], m: i64) -> i64 { let n = position.len(); if n == 0 { return 0; } let mut pos: Vec<i64> = Vec::new(); let mut i: usize = 0; while i < n { pos.push(position[i]); i += 1; } pos.sort(); let mut lo: i64 = 0; let mut hi: i...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [max_distance]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter.s...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [max_distance]: function definitions module public import Aeneas public import Aegis.MaxDistance.Code.Types public import Aegis.MaxDistance.Code.FunsExternal @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace fals...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [max_distance]: external functions. -- This is a template file: rename it to "FunsExternal.lean" and fill the holes. module public import Aeneas public import Aegis.MaxDistance.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_o...
import Aegis.MaxDistance.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.MaxDistance.max_distance (Slice.from [1#i64, 1000000000#i64] (by scalar_tac) : Slice Std.I64) 2#i64) (999999999#i64))}") #eval (s!"CASE 1 {(Result.re...
[ { "input": "[[1, 1000000000], 2]", "output": "999999999" }, { "input": "[[1, 1000000000], 2]", "output": "999999999" }, { "input": "[[1, 3, 5, 7, 9], 4]", "output": "2" }, { "input": "[[10, 20, 30, 40, 50], 4]", "output": "10" }, { "input": "[[10, 15, 20, 25, 30],...
87
false
87
verified
10
10
1
2,139
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MaxDistance.Code.Funs /-! # Specifications of `Aegis.MaxDistance.max_distance` LeetCode problem `magnetic-force-between-two-balls`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.MaxDistance open Aegis.MaxDistance def vals (posi...
12
minimum-number-of-days-to-eat-n-oranges
1,553
Hard
[ "Memoization", "Dynamic Programming" ]
There are n oranges in the kitchen and you decided to eat some of these oranges every day as follows: Eat one orange. If the number of remaining oranges n is divisible by 2 then you can eat n / 2 oranges. If the number of remaining oranges n is divisible by 3 then you can eat 2 * (n / 3) oranges. You can only choose ...
minDays(n: int) -> int
pub fn min_days(n: i64) -> i64
Aegis.MinDays.min_days
pub fn min_days(n: i64) -> i64 { if n <= 0 { return 0; } let mut memo: Vec<i64> = Vec::new(); let mut st_n: Vec<i64> = Vec::new(); let mut st_stage: Vec<i64> = Vec::new(); let mut st_a: Vec<i64> = Vec::new(); st_n.push(n); st_stage.push(0); st_a.push(0); let mut sp: u...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [min_days]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter.style...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [min_days]: function definitions module public import Aeneas public import Aegis.MinDays.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.MinDays.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval aegisCase "ev...
[ { "input": "[3]", "output": "2" }, { "input": "[2000000000]", "output": "32" }, { "input": "[100]", "output": "8" }, { "input": "[1000]", "output": "10" }, { "input": "[5]", "output": "4" }, { "input": "[4]", "output": "3" }, { "input": "[2...
234
false
234
verified
10
10
2
24,281
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MinDays.Code.Funs /-! # Specifications of `Aegis.MinDays.min_days` LeetCode problem `minimum-number-of-days-to-eat-n-oranges`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.MinDays def Step (m k : ℕ) : Prop := 0 < m ∧ (k = m -...
11
minimum-number-of-vertices-to-reach-all-nodes
1,557
Medium
[ "Graph" ]
Given a directed acyclic graph, with n vertices numbered from 0 to n-1, and an array edges where edges[i] = [fromi, toi] represents a directed edge from node fromi to node toi. Find the smallest set of vertices from which all nodes in the graph are reachable. It's guaranteed that a unique solution exists. Notice that y...
findSmallestSetOfVertices(n: int, edges: list_list_int) -> list_int
pub fn find_smallest_set_of_vertices(n: i64, edges: &[Vec<i64>]) -> Vec<i64>
Aegis.FindSmallestSetOfVertices.find_smallest_set_of_vertices
pub fn find_smallest_set_of_vertices(n: i64, edges: &[Vec<i64>]) -> Vec<i64> { let nn = n as usize; let mut has_parent: Vec<bool> = Vec::new(); let mut i: usize = 0; while i < nn { has_parent.push(false); i += 1; } let mut e: usize = 0; while e < edges.len() { let t...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [find_smallest_set_of_vertices]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false se...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [find_smallest_set_of_vertices]: function definitions module public import Aeneas public import Aegis.FindSmallestSetOfVertices.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter...
import Aegis.FindSmallestSetOfVertices.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(match (Aegis.FindSmallestSetOfVertices.find_smallest_set_of_vertices 3#i64 (Slice.from [(alloc.vec.Vec.from [0#i64, 1#i64] (by scalar_tac) : alloc.vec.Vec Std....
[ { "input": "[3, [[0, 1], [0, 2]]]", "output": "[0]" }, { "input": "[4, [[2, 0], [2, 1], [1, 3]]]", "output": "[2]" }, { "input": "[7, [[1, 2], [3, 4], [5, 6]]]", "output": "[0, 1, 3, 5]" }, { "input": "[6, [[0, 1], [0, 2], [2, 5], [3, 4], [4, 2]]]", "output": "[0, 3]" }...
77
true
77
verified
10
10
1
457
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.FindSmallestSetOfVertices.Code.Funs /-! # Specifications of `Aegis.FindSmallestSetOfVertices.find_smallest_set_of_vertices` LeetCode problem `minimum-number-of-vertices-to-reach-all-nodes`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.FindSma...
4
minimum-numbers-of-function-calls-to-make-target-array
1,558
Medium
[ "Greedy", "Bit Manipulation", "Array" ]
You are given an integer array nums. You have an integer array arr of the same length with all values set to 0 initially. You also have the following modify function: You want to use the modify function to convert arr to nums using the minimum number of calls. Return the minimum number of function calls to make nums f...
minOperations(nums: list_int) -> int
pub fn min_operations(nums: &[i64]) -> i64
Aegis.MinOperations.min_operations
pub fn min_operations(nums: &[i64]) -> i64 { let mut total_increments: i64 = 0; let mut max_doublings: i64 = 0; let n = nums.len(); let mut i: usize = 0; while i < n { let mut x = nums[i]; let mut bit_count: i64 = 0; let mut bit_length: i64 = 0; while x > 0 { ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [min_operations]: type definitions module public import Aeneas @[expose] public section 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_operations]: function definitions module public import Aeneas public import Aegis.MinOperations.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.MinOperations.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.MinOperations.min_operations (Slice.from [1000000000#i64] (by scalar_tac) : Slice Std.I64)) (42#i64))}") #eval (s!"CASE 1 {(Result.reducesTo (Aegis...
[ { "input": "[[1000000000]]", "output": "42" }, { "input": "[[1, 1000000000]]", "output": "43" }, { "input": "[[1, 5]]", "output": "5" }, { "input": "[[1000000000, 1000000000]]", "output": "55" }, { "input": "[[2, 2]]", "output": "3" }, { "input": "[[1,...
98
false
98
verified
10
10
1
670
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MinOperations.Code.Funs /-! # Specifications of `Aegis.MinOperations.min_operations` LeetCode problem `minimum-numbers-of-function-calls-to-make-target-array`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.MinOperations namespace AegisSpec.Min...
12
most-visited-sector-in-a-circular-track
1,560
Easy
[ "Array", "Simulation" ]
Given an integer n and an integer array rounds. We have a circular track which consists of n sectors labeled from 1 to n. A marathon will be held on this track, the marathon consists of m rounds. The ith round starts at sector rounds[i - 1] and ends at sector rounds[i]. For example, round 1 starts at sector rounds[0] a...
mostVisited(n: int, rounds: list_int) -> list_int
pub fn most_visited(n: i64, rounds: &[i64]) -> Vec<i64>
Aegis.MostVisited.most_visited
pub fn most_visited(n: i64, rounds: &[i64]) -> Vec<i64> { let mut out: Vec<i64> = Vec::new(); if rounds.len() == 0 { return out; } let start = rounds[0]; let end = rounds[rounds.len() - 1]; if start <= end { let mut sector = start; while sector <= end { out...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [most_visited]: type definitions module public import Aeneas @[expose] public section 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 -- [most_visited]: function definitions module public import Aeneas public import Aegis.MostVisited.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.MostVisited.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.MostVisited.most_visited 10#i64 (Slice.from [3#i64, 8#i64, 3#i64] (by scalar_tac) : Slice Std.I64)) ((alloc.vec.Vec.from [3#i64] (by scalar_tac) : al...
[ { "input": "[10, [3, 8, 3]]", "output": "[3]" }, { "input": "[5, [1, 5, 1]]", "output": "[1]" }, { "input": "[3, [1, 2, 3, 1]]", "output": "[1]" }, { "input": "[4, [1, 3, 1, 2]]", "output": "[1, 2]" }, { "input": "[10, [3, 8, 3, 10, 3]]", "output": "[3]" }, ...
98
false
98
verified
10
10
1
1,809
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MostVisited.Code.Funs import Mathlib /-! # Specifications of `Aegis.MostVisited.most_visited` LeetCode problem `most-visited-sector-in-a-circular-track`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.MostVisited namespace AegisSpec.MostVisited ...
12