task_id
stringlengths
3
79
question_id
int64
2
3.24k
difficulty
stringclasses
3 values
tags
listlengths
1
8
description
stringlengths
224
3.74k
leetcode_signature
stringlengths
18
130
rust_signature
stringlengths
25
141
lean_function
stringlengths
13
102
rust_solution
stringlengths
52
8.38k
lean_types
stringlengths
716
1.17k
lean_funs
stringlengths
921
54.6k
lean_funs_external
stringclasses
151 values
lean_eval
stringlengths
420
114k
test_cases
listlengths
3
450
num_test_cases
int64
3
450
order_insensitive
bool
2 classes
rust_cases_passed
int64
3
450
lean_check
stringclasses
2 values
lean_check_cases
int64
3
10
lean_check_cases_true
int64
3
10
num_llm_calls
int64
1
7
total_completion_tokens
int64
41
176k
trajectory
listlengths
7
27
lean_specs
stringlengths
0
31k
num_specs
int64
0
20
count-collisions-on-a-road
2,211
Medium
[ "Stack", "String", "Simulation" ]
There are n cars on an infinitely long road. The cars are numbered from 0 to n - 1 from left to right and each car is present at a unique point. You are given a 0-indexed string directions of length n. directions[i] can be either 'L', 'R', or 'S' denoting whether the ith car is moving towards the left, towards the righ...
countCollisions(directions: str) -> int
pub fn count_collisions(directions: &[u8]) -> i64
Aegis.CountCollisions.count_collisions
pub fn count_collisions(directions: &[u8]) -> i64 { let n = directions.len(); let mut start: usize = 0; while start < n && directions[start] == b'L' { start += 1; } let mut end: usize = n; while end > start && directions[end - 1] == b'R' { end -= 1; } let mut ans: i64 ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [count_collisions]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option lint...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [count_collisions]: function definitions module public import Aeneas public import Aegis.CountCollisions.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.CountCollisions.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval aegis...
[ { "input": "[\"SSRLSL\"]", "output": "3" }, { "input": "[\"LRLRLR\"]", "output": "4" }, { "input": "[\"RRRR\"]", "output": "0" }, { "input": "[\"LRRSLRLR\"]", "output": "5" }, { "input": "[\"LSRL\"]", "output": "2" }, { "input": "[\"SSSS\"]", "outp...
177
false
177
verified
10
10
1
1,046
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.CountCollisions.Code.Funs /-! # Specifications of `Aegis.CountCollisions.count_collisions` LeetCode problem `count-collisions-on-a-road`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.CountCollisions def byteL : Aeneas.Std.U8 := ⟨...
11
minimum-health-to-beat-game
2,214
Medium
[ "Greedy", "Array" ]
You are playing a game that has n levels numbered from 0 to n - 1. You are given a 0-indexed integer array damage where damage[i] is the amount of health you will lose to complete the ith level. You are also given an integer armor. You may use your armor ability at most once during the game on any level which will prot...
minimumHealth(damage: list_int, armor: int) -> int
pub fn minimum_health(damage: &[i64], armor: i64) -> i64
Aegis.MinimumHealth.minimum_health
pub fn minimum_health(damage: &[i64], armor: i64) -> i64 { let mut total: i64 = 0; let mut max_damage: i64 = 0; let n = damage.len(); let mut i: usize = 0; while i < n { let d = damage[i]; total += d; if d > max_damage { max_damage = d; } i += 1; ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [minimum_health]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [minimum_health]: function definitions module public import Aeneas public import Aegis.MinimumHealth.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.MinimumHealth.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval aegisCa...
[ { "input": "[[100000], 100000]", "output": "1" }, { "input": "[[3, 3, 3], 0]", "output": "10" }, { "input": "[[0, 0, 0], 5]", "output": "1" }, { "input": "[[5, 10, 15], 10]", "output": "21" }, { "input": "[[2, 7, 4, 3], 4]", "output": "13" }, { "input"...
95
false
95
verified
10
10
1
490
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MinimumHealth.Code.Funs /-! # Specifications of `Aegis.MinimumHealth.minimum_health` LeetCode problem `minimum-health-to-beat-game`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result ControlFlow Error open Aegis.MinimumHealth (minimum_health) namespace AegisS...
15
minimum-deletions-to-make-array-beautiful
2,216
Medium
[ "Stack", "Greedy", "Array" ]
You are given a 0-indexed integer array nums. The array nums is beautiful if: nums.length is even. nums[i] != nums[i + 1] for all i % 2 == 0. Note that an empty array is considered beautiful. You can delete any number of elements from nums. When you delete an element, all the elements to the right of the deleted elem...
minDeletion(nums: list_int) -> int
pub fn min_deletion(nums: &[i64]) -> i64
Aegis.MinDeletion.min_deletion
pub fn min_deletion(nums: &[i64]) -> i64 { let n = nums.len(); let mut i: usize = 0; let mut kept: i64 = 0; let mut last: i64 = 0; let mut deleted: i64 = 0; while i < n { if kept % 2 == 0 { last = nums[i]; kept += 1; } else if nums[i] != last { ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [min_deletion]: type definitions module public import Aeneas @[expose] public section 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_deletion]: function definitions module public import Aeneas public import Aegis.MinDeletion.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.MinDeletion.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": "[[]]", "output": "0" }, { "input": "[[1]]", "output": "1" }, { "input": "[[1, 1, 2, 3, 5]]", "output": "1" }, { "input": "[[100000, 100000, 100000, 100000, 100000, 100000]]", "output": "6" }, { "input": "[[1, 1, 2, 2, 3, 3]]", "output": "2" }, ...
125
false
125
verified
10
10
1
3,146
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MinDeletion.Code.Funs /-! # Specifications of `Aegis.MinDeletion.min_deletion` LeetCode problem `minimum-deletions-to-make-array-beautiful`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.MinDeletion (min_deletion) namespace AegisSpec.MinDeletio...
14
find-palindrome-with-fixed-length
2,217
Medium
[ "Array", "Math" ]
Given an integer array queries and a positive integer intLength, return an array answer where answer[i] is either the queries[i]th smallest positive palindrome of length intLength or -1 if no such palindrome exists. A palindrome is a number that reads the same backwards and forwards. Palindromes cannot have leading zer...
kthPalindrome(queries: list_int, intLength: int) -> list_int
pub fn kth_palindrome(queries: &[i64], intLength: i64) -> Vec<i64>
Aegis.KthPalindrome.kth_palindrome
fn pow10(exp: i64) -> i64 { let mut result = 1; let mut e = exp; while e > 0 { result *= 10; e -= 1; } result } fn reverse_digits(x0: i64) -> i64 { let mut x = x0; let mut result = 0; while x > 0 { result = result * 10 + x % 10; x /= 10; } result ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [kth_palindrome]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [kth_palindrome]: function definitions module public import Aeneas public import Aegis.KthPalindrome.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.KthPalindrome.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval aegisCa...
[ { "input": "[[50000], 15]", "output": "[100499999994001]" }, { "input": "[[5000000], 1]", "output": "[-1]" }, { "input": "[[1000000000], 15]", "output": "[-1]" }, { "input": "[[100000], 15]", "output": "[100999999999001]" }, { "input": "[[123456789], 15]", "ou...
110
false
110
verified
10
10
1
2,296
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.KthPalindrome.Code.Funs /-! # Specifications of `Aegis.KthPalindrome.kth_palindrome` LeetCode problem `find-palindrome-with-fixed-length`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.KthPalindrome def digitsRev (n : ℕ) : List ℕ ...
11
maximum-sum-score-of-array
2,219
Medium
[ "Array", "Prefix Sum" ]
You are given a 0-indexed integer array nums of length n. The sum score of nums at an index i where 0 <= i < n is the maximum of: The sum of the first i + 1 elements of nums. The sum of the last n - i elements of nums. Return the maximum sum score of nums at any index.   Example 1: Input: nums = [4,3,-2,5] Output: 1...
maximumSumScore(nums: list_int) -> int
pub fn maximum_sum_score(nums: &[i64]) -> i64
Aegis.MaximumSumScore.maximum_sum_score
pub fn maximum_sum_score(nums: &[i64]) -> i64 { let n: usize = nums.len(); let mut total: i64 = 0; let mut i: usize = 0; while i < n { total += nums[i]; i += 1; } let mut ans: i64 = nums[0]; let mut prefix_before: i64 = 0; i = 0; while i < n { let prefix_in...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [maximum_sum_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 lin...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [maximum_sum_score]: function definitions module public import Aeneas public import Aegis.MaximumSumScore.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.MaximumSumScore.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval aegis...
[ { "input": "[[-1]]", "output": "-1" }, { "input": "[[5]]", "output": "5" }, { "input": "[[-5]]", "output": "-5" }, { "input": "[[-3, -5]]", "output": "-3" }, { "input": "[[4, 3, -2, 5]]", "output": "10" }, { "input": "[[-10, -20, -30, -40, -50]]", ...
93
false
93
verified
10
10
1
1,068
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MaximumSumScore.Code.Funs /-! # Specifications of `Aegis.MaximumSumScore.maximum_sum_score` LeetCode problem `maximum-sum-score-of-array`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.MaximumSumScore (maximum_sum_score) namespace AegisSpec.Max...
12
minimum-bit-flips-to-convert-number
2,220
Easy
[ "Bit Manipulation" ]
A bit flip of a number x is choosing a bit in the binary representation of x and flipping it from either 0 to 1 or 1 to 0. For example, for x = 7, the binary representation is 111 and we may choose any bit (including any leading zeros not shown) and flip it. We can flip the first bit from the right to get 110, flip th...
minBitFlips(start: int, goal: int) -> int
pub fn min_bit_flips(start: i64, goal: i64) -> i64
Aegis.MinBitFlips.min_bit_flips
pub fn min_bit_flips(start: i64, goal: i64) -> i64 { let mut a = start; let mut b = goal; let mut count: i64 = 0; while a > 0 || b > 0 { let ra = a % 2; let rb = b % 2; if ra != rb { count += 1; } a = a / 2; b = b / 2; } count }
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [min_bit_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....
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [min_bit_flips]: function definitions module public import Aeneas public import Aegis.MinBitFlips.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.MinBitFlips.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": "[123456789, 987654321]", "output": "15" }, { "input": "[5, 2]", "output": "3" }, { "input": "[1000000000, 500000000]", "output": "14" }, { "input": "[8, 15]", "output": "3" }, { "input": "[15, 8]", "output": "3" }, { "input": "[5, 8]", ...
85
false
85
verified
10
10
1
628
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MinBitFlips.Code.Funs /-! # Specifications of `Aegis.MinBitFlips.min_bit_flips` LeetCode problem `minimum-bit-flips-to-convert-number`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.MinBitFlips namespace AegisSpec.MinBitFlips def bitAt (x : ℤ)...
13
find-triangular-sum-of-an-array
2,221
Medium
[ "Array", "Math", "Combinatorics", "Simulation" ]
You are given a 0-indexed integer array nums, where nums[i] is a digit between 0 and 9 (inclusive). The triangular sum of nums is the value of the only element present in nums after the following process terminates: Let nums comprise of n elements. If n == 1, end the process. Otherwise, create a new 0-indexed integer ...
triangularSum(nums: list_int) -> int
pub fn triangular_sum(nums: &[i64]) -> i64
Aegis.TriangularSum.triangular_sum
pub fn triangular_sum(nums: &[i64]) -> i64 { let n = nums.len(); if n == 0 { return 0; } let mut cur: Vec<i64> = Vec::new(); let mut i = 0; while i < n { cur.push(nums[i]); i += 1; } let mut len = n; while len > 1 { let mut j = 0; while j + 1...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [triangular_sum]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [triangular_sum]: function definitions module public import Aeneas public import Aegis.TriangularSum.Code.Types public import Aegis.TriangularSum.Code.FunsExternal @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespac...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [triangular_sum]: external functions. -- This is a template file: rename it to "FunsExternal.lean" and fill the holes. module public import Aeneas public import Aegis.TriangularSum.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error s...
import Aegis.TriangularSum.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval aegisCa...
[ { "input": "[[0]]", "output": "0" }, { "input": "[[5]]", "output": "5" }, { "input": "[[1, 2]]", "output": "3" }, { "input": "[[4, 3, 2, 1]]", "output": "0" }, { "input": "[[0, 0, 0, 0]]", "output": "0" }, { "input": "[[9, 9, 9, 9]]", "output": "2"...
96
false
96
verified
10
10
1
493
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.TriangularSum.Code.Funs /-! # Specifications of `Aegis.TriangularSum.triangular_sum` LeetCode problem `find-triangular-sum-of-an-array`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.TriangularSum namespace AegisSpec.TriangularSum def va...
12
number-of-ways-to-select-buildings
2,222
Medium
[ "String", "Dynamic Programming", "Prefix Sum" ]
You are given a 0-indexed binary string s which represents the types of buildings along a street where: s[i] = '0' denotes that the ith building is an office and s[i] = '1' denotes that the ith building is a restaurant. As a city official, you would like to select 3 buildings for random inspection. However, to ensure...
numberOfWays(s: str) -> int
pub fn number_of_ways(s: &[u8]) -> i64
Aegis.NumberOfWays.number_of_ways
pub fn number_of_ways(s: &[u8]) -> i64 { let mut count0: i64 = 0; let mut count1: i64 = 0; let mut seq01: i64 = 0; let mut seq10: i64 = 0; let mut ans: i64 = 0; let n = s.len(); let mut i: usize = 0; while i < n { if s[i] == 48u8 { // Append this '0' to every previo...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [number_of_ways]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [number_of_ways]: function definitions module public import Aeneas public import Aegis.NumberOfWays.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_optio...
import Aegis.NumberOfWays.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval aegisCas...
[ { "input": "[\"100100100\"]", "output": "24" }, { "input": "[\"101010101\"]", "output": "30" }, { "input": "[\"000111000\"]", "output": "27" }, { "input": "[\"111\"]", "output": "0" }, { "input": "[\"0000000001\"]", "output": "0" }, { "input": "[\"0101...
162
false
162
verified
10
10
1
1,401
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.NumberOfWays.Code.Funs /-! # Specifications of `Aegis.NumberOfWays.number_of_ways` LeetCode problem `number-of-ways-to-select-buildings`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace Aeneas.Std def Slice.bytes (s : Slice Std.U8) : List ℕ := s....
12
sum-of-scores-of-built-strings
2,223
Hard
[ "String", "Binary Search", "String Matching", "Suffix Array", "Hash Function", "Rolling Hash" ]
You are building a string s of length n one character at a time, prepending each new character to the front of the string. The strings are labeled from 1 to n, where the string with length i is labeled si. For example, for s = "abaca", s1 == "a", s2 == "ca", s3 == "aca", etc. The score of si is the length of the long...
sumScores(s: str) -> int
pub fn sum_scores(s: &[u8]) -> i64
Aegis.SumScores.sum_scores
pub fn sum_scores(s: &[u8]) -> i64 { let n = s.len(); if n == 0 { return 0; } let mut z: Vec<usize> = Vec::new(); let mut i: usize = 0; while i < n { z.push(0); i += 1; } z[0] = n; let mut l: usize = 0; let mut r: usize = 0; let mut k: usize = 1; ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [sum_scores]: type definitions module public import Aeneas @[expose] public section 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 -- [sum_scores]: function definitions module public import Aeneas public import Aegis.SumScores.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.SumScores.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": "[\"xyzxyzxyz\"]", "output": "18" }, { "input": "[\"abcabcabc\"]", "output": "18" }, { "input": "[\"aabbcc\"]", "output": "7" }, { "input": "[\"abacabadabacaba\"]", "output": "32" }, { "input": "[\"zzzzz\"]", "output": "15" }, { "input": "[\...
123
false
123
verified
10
10
1
6,908
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.SumScores.Code.Funs /-! # Specifications of `Aegis.SumScores.sum_scores` LeetCode problem `sum-of-scores-of-built-strings`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open scoped BigOperators namespace AegisSpec.SumScores def byteAt (s : Slice Std.U8)...
10
find-players-with-zero-or-one-losses
2,225
Medium
[ "Array", "Hash Table", "Counting", "Sorting" ]
You are given an integer array matches where matches[i] = [winneri, loseri] indicates that the player winneri defeated player loseri in a match. Return a list answer of size 2 where: answer[0] is a list of all players that have not lost any matches. answer[1] is a list of all players that have lost exactly one match. ...
findWinners(matches: list_list_int) -> list_list_int
pub fn find_winners(matches: &[Vec<i64>]) -> Vec<Vec<i64>>
Aegis.FindWinners.find_winners
pub fn find_winners(matches: &[Vec<i64>]) -> Vec<Vec<i64>> { let mut answer: Vec<Vec<i64>> = Vec::new(); if matches.len() == 0 { let empty0: Vec<i64> = Vec::new(); let empty1: Vec<i64> = Vec::new(); answer.push(empty0); answer.push(empty1); return answer; } let ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [find_winners]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter.s...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [find_winners]: function definitions module public import Aeneas public import Aegis.FindWinners.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.FindWinners.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, 2]]]", "output": "[[1], [2]]" }, { "input": "[[[100, 200], [200, 300], [100, 300]]]", "output": "[[100], [200]]" }, { "input": "[[[5, 3], [5, 4], [4, 5], [3, 4]]]", "output": "[[], [3, 5]]" }, { "input": "[[[100, 200], [200, 300], [100, 300], [400, 500]]]", ...
69
false
69
verified
10
10
1
1,573
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.FindWinners.Code.Funs /-! # Specifications of `Aegis.FindWinners.find_winners` LeetCode problem `find-players-with-zero-or-one-losses`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.FindWinners def matchMatrix («matches» : Slice (allo...
14
maximum-candies-allocated-to-k-children
2,226
Medium
[ "Array", "Binary Search" ]
You are given a 0-indexed integer array candies. Each element in the array denotes a pile of candies of size candies[i]. You can divide each pile into any number of sub piles, but you cannot merge two piles together. You are also given an integer k. You should allocate piles of candies to k children such that each chil...
maximumCandies(candies: list_int, k: int) -> int
pub fn maximum_candies(candies: &[i64], k: i64) -> i64
Aegis.MaximumCandies.maximum_candies
pub fn maximum_candies(candies: &[i64], k: i64) -> i64 { let n = candies.len(); if n == 0 || k <= 0 { return 0; } let mut max_candy: i64 = 0; let mut i: usize = 0; while i < n { if candies[i] > max_candy { max_candy = candies[i]; } i += 1; } ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [maximum_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 linte...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [maximum_candies]: function definitions module public import Aeneas public import Aegis.MaximumCandies.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.MaximumCandies.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval aegisC...
[ { "input": "[[10000000], 1]", "output": "10000000" }, { "input": "[[1000000], 1]", "output": "1000000" }, { "input": "[[10000000], 10000001]", "output": "0" }, { "input": "[[2, 5], 11]", "output": "0" }, { "input": "[[10000000, 10000000, 10000000], 10000000]", ...
82
false
82
verified
10
10
1
1,591
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MaximumCandies.Code.Funs /-! # Specifications of `Aegis.MaximumCandies.maximum_candies` LeetCode problem `maximum-candies-allocated-to-k-children`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.MaximumCandies def intsOf (candies :...
12
check-if-an-array-is-consecutive
2,229
Easy
[ "Array", "Hash Table", "Sorting" ]
Given an integer array nums, return true if nums is consecutive, otherwise return false. An array is consecutive if it contains every number in the range [x, x + n - 1] (inclusive), where x is the minimum number in the array and n is the length of the array.   Example 1: Input: nums = [1,3,4,2] Output: true Explanatio...
isConsecutive(nums: list_int) -> bool
pub fn is_consecutive(nums: &[i64]) -> bool
Aegis.IsConsecutive.is_consecutive
pub fn is_consecutive(nums: &[i64]) -> bool { let n = nums.len(); if n == 0 { return true; } let mut min: i64 = nums[0]; let mut max: i64 = nums[0]; let mut i: usize = 1; while i < n { let v = nums[i]; if v < min { min = v; } if v > max {...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [is_consecutive]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [is_consecutive]: function definitions module public import Aeneas public import Aegis.IsConsecutive.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.IsConsecutive.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval aegisCa...
[ { "input": "[[1]]", "output": "true" }, { "input": "[[0]]", "output": "true" }, { "input": "[[100000]]", "output": "true" }, { "input": "[[5]]", "output": "true" }, { "input": "[[7]]", "output": "true" }, { "input": "[[0, 2]]", "output": "false" ...
131
false
131
verified
10
10
1
1,731
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.IsConsecutive.Code.Funs /-! # Specifications of `Aegis.IsConsecutive.is_consecutive` LeetCode problem `check-if-an-array-is-consecutive`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.IsConsecutive (is_consecutive) namespace AegisSpec.IsCo...
10
largest-number-after-digit-swaps-by-parity
2,231
Easy
[ "Sorting", "Heap (Priority Queue)" ]
You are given a positive integer num. You may swap any two digits of num that have the same parity (i.e. both odd digits or both even digits). Return the largest possible value of num after any number of swaps.   Example 1: Input: num = 1234 Output: 3412 Explanation: Swap the digit 3 with the digit 1, this results in ...
largestInteger(num: int) -> int
pub fn largest_integer(num: i64) -> i64
Aegis.LargestInteger.largest_integer
pub fn largest_integer(num: i64) -> i64 { let mut digits: Vec<i64> = Vec::new(); let mut n = num; if n == 0 { digits.push(0); } else { while n > 0 { let d = n % 10; digits.push(d); n = n / 10; } } let mut counts: Vec<i64> = Vec::new()...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [largest_integer]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linte...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [largest_integer]: function definitions module public import Aeneas public import Aegis.LargestInteger.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.LargestInteger.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval aegisC...
[ { "input": "[24680]", "output": "86420" }, { "input": "[987654321]", "output": "987654321" }, { "input": "[13524687]", "output": "75386421" }, { "input": "[1000000]", "output": "1000000" }, { "input": "[2222]", "output": "2222" }, { "input": "[222222]"...
67
false
67
verified
10
10
1
2,355
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.LargestInteger.Code.Funs /-! # Specifications of `Aegis.LargestInteger.largest_integer` LeetCode problem `largest-number-after-digit-swaps-by-parity`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.LargestInteger namespace AegisSpec.LargestInteg...
12
maximum-product-after-k-increments
2,233
Medium
[ "Greedy", "Array", "Heap (Priority Queue)" ]
You are given an array of non-negative integers nums and an integer k. In one operation, you may choose any element from nums and increment it by 1. Return the maximum product of nums after at most k operations. Since the answer may be very large, return it modulo 109 + 7. Note that you should maximize the product befo...
maximumProduct(nums: list_int, k: int) -> int
pub fn maximum_product(nums: &[i64], k: i64) -> i64
Aegis.MaximumProduct.maximum_product
const MOD: i64 = 1000000007; fn pow_mod(mut base: i64, mut exp: i64) -> i64 { base = base % MOD; let mut result: i64 = 1; while exp > 0 { if exp % 2 == 1 { result = (result * base) % MOD; } base = (base * base) % MOD; exp = exp / 2; } result } pub fn max...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [maximum_product]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linte...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [maximum_product]: function definitions module public import Aeneas public import Aegis.MaximumProduct.Code.Types public import Aegis.MaximumProduct.Code.FunsExternal @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNames...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [maximum_product]: external functions. -- This is a template file: rename it to "FunsExternal.lean" and fill the holes. module public import Aeneas public import Aegis.MaximumProduct.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error...
import Aegis.MaximumProduct.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval aegisC...
[ { "input": "[[1000000], 1000000]", "output": "2000000" }, { "input": "[[1], 100000]", "output": "100001" }, { "input": "[[0, 4], 5]", "output": "20" }, { "input": "[[1000000, 1000000], 1000000]", "output": "999984257" }, { "input": "[[1, 1000000], 999999]", "o...
101
false
101
verified
10
10
1
5,304
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MaximumProduct.Code.Funs /-! # Specifications of `Aegis.MaximumProduct.maximum_product` LeetCode problem `maximum-product-after-k-increments`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.MaximumProduct open Aegis.MaximumProduct (max...
13
maximum-total-beauty-of-the-gardens
2,234
Hard
[ "Greedy", "Array", "Two Pointers", "Binary Search", "Enumeration", "Prefix Sum", "Sorting" ]
Alice is a caretaker of n gardens and she wants to plant flowers to maximize the total beauty of all her gardens. You are given a 0-indexed integer array flowers of size n, where flowers[i] is the number of flowers already planted in the ith garden. Flowers that are already planted cannot be removed. You are then given...
maximumBeauty(flowers: list_int, newFlowers: int, target: int, full: int, partial: int) -> int
pub fn maximum_beauty(flowers: &[i64], newFlowers: i64, target: i64, full: i64, partial: i64) -> i64
Aegis.MaximumBeauty.maximum_beauty
fn sort_values(a: &mut Vec<i64>) { let n = a.len(); if n < 2 { return; } let mut tmp: Vec<i64> = Vec::new(); let mut z: usize = 0; while z < n { tmp.push(0); z += 1; } let mut width: usize = 1; while width < n { let mut left: usize = 0; while...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [maximum_beauty]: type definitions module public import Aeneas @[expose] public section 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 -- [maximum_beauty]: function definitions module public import Aeneas public import Aegis.MaximumBeauty.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.MaximumBeauty.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval aegisCa...
[ { "input": "[[10, 20, 30], 100, 25, 50, 10]", "output": "340" }, { "input": "[[100000, 100000, 100000], 300000, 100000, 100000, 100000]", "output": "300000" }, { "input": "[[10, 10, 10], 0, 10, 100, 50]", "output": "300" }, { "input": "[[1, 1, 1, 1], 15, 3, 5, 3]", "outpu...
113
false
113
verified
10
10
2
44,106
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MaximumBeauty.Code.Funs /-! # Specifications of `Aegis.MaximumBeauty.maximum_beauty` LeetCode problem `maximum-total-beauty-of-the-gardens`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.MaximumBeauty def contents (flowers : Slice Std...
14
add-two-integers
2,235
Easy
[ "Math" ]
Given two integers num1 and num2, return the sum of the two integers.   Example 1: Input: num1 = 12, num2 = 5 Output: 17 Explanation: num1 is 12, num2 is 5, and their sum is 12 + 5 = 17, so 17 is returned. Example 2: Input: num1 = -10, num2 = 4 Output: -6 Explanation: num1 + num2 = -6, so -6 is returned.   Constrai...
sum(num1: int, num2: int) -> int
pub fn sum(num1: i64, num2: i64) -> i64
Aegis.Sum.sum
pub fn sum(num1: i64, num2: i64) -> i64 { num1 + num2 }
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [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.whit...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [sum]: function definitions module public import Aeneas public import Aegis.Sum.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVaria...
import Aegis.Sum.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval aegisCase "eval/S...
[ { "input": "[100, -100]", "output": "0" }, { "input": "[-10, 4]", "output": "-6" }, { "input": "[25, 25]", "output": "50" }, { "input": "[-50, 50]", "output": "0" }, { "input": "[99, 1]", "output": "100" }, { "input": "[-50, 25]", "output": "-25" ...
59
false
59
verified
10
10
1
41
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.Sum.Code.Funs /-! # Specifications of `Aegis.Sum.sum` LeetCode problem `add-two-integers`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.Sum theorem i64Bounds (x : ℤ) (hlo : -100 ≤ x) (hhi : x ≤ 100) : -2 ^ (Aeneas.Std.IScalarTy.I...
5
root-equals-sum-of-children
2,236
Easy
[ "Tree", "Binary Tree" ]
You are given the root of a binary tree that consists of exactly 3 nodes: the root, its left child, and its right child. Return true if the value of the root is equal to the sum of the values of its two children, or false otherwise.   Example 1: Input: root = [10,4,6] Output: true Explanation: The values of the root,...
checkTree(root: tree) -> bool
pub fn check_tree(root: &Tree) -> bool
Aegis.CheckTree.check_tree
fn value_or_zero(t: &Tree) -> i64 { match t { Tree::Null => 0, Tree::Node(v, _, _) => *v, } } pub fn check_tree(root: &Tree) -> bool { match root { Tree::Null => false, Tree::Node(v, left, right) => { *v == value_or_zero(&**left) + value_or_zero(&**right) ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [check_tree]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter.sty...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [check_tree]: function definitions module public import Aeneas public import Aegis.CheckTree.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.CheckTree.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, 2]]", "output": "true" }, { "input": "[[-5, -3, -2]]", "output": "true" }, { "input": "[[5, 3, 1]]", "output": "false" }, { "input": "[[99, 50, 49]]", "output": "true" }, { "input": "[[-100, 50, 50]]", "output": "false" }, { "input...
72
false
72
verified
10
10
1
1,346
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.CheckTree.Code.Funs /-! # Specifications of `Aegis.CheckTree.check_tree` LeetCode problem `root-equals-sum-of-children`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.CheckTree namespace AegisSpec.CheckTree def InI64Range (n : ℤ) : Prop := A...
3
find-closest-number-to-zero
2,239
Easy
[ "Array" ]
Given an integer array nums of size n, return the number with the value closest to 0 in nums. If there are multiple answers, return the number with the largest value.   Example 1: Input: nums = [-4,-2,1,4,8] Output: 1 Explanation: The distance from -4 to 0 is |-4| = 4. The distance from -2 to 0 is |-2| = 2. The distan...
findClosestNumber(nums: list_int) -> int
pub fn find_closest_number(nums: &[i64]) -> i64
Aegis.FindClosestNumber.find_closest_number
pub fn find_closest_number(nums: &[i64]) -> i64 { let mut best = nums[0]; let mut best_dist = if best < 0 { -best } else { best }; let mut i: usize = 1; while i < nums.len() { let x = nums[i]; let d = if x < 0 { -x } else { x }; if d < best_dist || (d == best_dist && x > best) ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [find_closest_number]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option l...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [find_closest_number]: function definitions module public import Aeneas public import Aegis.FindClosestNumber.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false...
import Aegis.FindClosestNumber.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval aeg...
[ { "input": "[[-1]]", "output": "-1" }, { "input": "[[1]]", "output": "1" }, { "input": "[[0]]", "output": "0" }, { "input": "[[-100000]]", "output": "-100000" }, { "input": "[[100000]]", "output": "100000" }, { "input": "[[-100000, 100000]]", "outp...
128
false
128
verified
10
10
1
291
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.FindClosestNumber.Code.Funs /-! # Specifications of `Aegis.FindClosestNumber.find_closest_number` LeetCode problem `find-closest-number-to-zero`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.FindClosestNumber def countValue (nums...
7
number-of-ways-to-buy-pens-and-pencils
2,240
Medium
[ "Math", "Enumeration" ]
You are given an integer total indicating the amount of money you have. You are also given two integers cost1 and cost2 indicating the price of a pen and pencil respectively. You can spend part or all of your money to buy multiple quantities (or none) of each kind of writing utensil. Return the number of distinct ways ...
waysToBuyPensPencils(total: int, cost1: int, cost2: int) -> int
pub fn ways_to_buy_pens_pencils(total: i64, cost1: i64, cost2: i64) -> i64
Aegis.WaysToBuyPensPencils.ways_to_buy_pens_pencils
pub fn ways_to_buy_pens_pencils(total: i64, cost1: i64, cost2: i64) -> i64 { let mut ways: i64 = 0; let mut paid_for_pens: i64 = 0; while paid_for_pens <= total { let remaining: i64 = total - paid_for_pens; ways += remaining / cost2 + 1; paid_for_pens += cost1; } ways }
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [ways_to_buy_pens_pencils]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_opt...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [ways_to_buy_pens_pencils]: function definitions module public import Aeneas public import Aegis.WaysToBuyPensPencils.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashComma...
import Aegis.WaysToBuyPensPencils.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval ...
[ { "input": "[20, 10, 5]", "output": "9" }, { "input": "[1000, 1, 1]", "output": "501501" }, { "input": "[5, 10, 10]", "output": "1" }, { "input": "[5, 10, 10]", "output": "1" }, { "input": "[100, 1, 1]", "output": "5151" }, { "input": "[50, 7, 11]", ...
102
false
102
verified
10
10
1
1,530
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.WaysToBuyPensPencils.Code.Funs /-! # Specifications of `Aegis.WaysToBuyPensPencils.ways_to_buy_pens_pencils` LeetCode problem `number-of-ways-to-buy-pens-and-pencils`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.WaysToBuyPensPencils ...
13
maximum-score-of-a-node-sequence
2,242
Hard
[ "Graph", "Array", "Enumeration", "Sorting" ]
There is an undirected graph with n nodes, numbered from 0 to n - 1. You are given a 0-indexed integer array scores of length n where scores[i] denotes the score of node i. You are also given a 2D integer array edges where edges[i] = [ai, bi] denotes that there exists an undirected edge connecting nodes ai and bi. A no...
maximumScore(scores: list_int, edges: list_list_int) -> int
pub fn maximum_score(scores: &[i64], edges: &[Vec<i64>]) -> i64
Aegis.MaximumScore.maximum_score
pub fn maximum_score(scores: &[i64], edges: &[Vec<i64>]) -> i64 { let n = scores.len(); if n < 4 { return -1; } let mut best1: Vec<i64> = Vec::new(); let mut best2: Vec<i64> = Vec::new(); let mut best3: Vec<i64> = Vec::new(); let mut i: usize = 0; while i < n { best1.pu...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [maximum_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....
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [maximum_score]: function definitions module public import Aeneas public import Aegis.MaximumScore.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.MaximumScore.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval aegisCas...
[ { "input": "[[1, 2, 3, 4], [[0, 1], [1, 2], [2, 3]]]", "output": "10" }, { "input": "[[10, 10, 10, 10], [[0, 1], [1, 2], [2, 3], [3, 0]]]", "output": "40" }, { "input": "[[10, 20, 30, 40, 50], [[0, 1], [1, 2], [2, 3], [3, 4]]]", "output": "140" }, { "input": "[[50, 40, 30, 20...
80
false
80
verified
10
10
1
8,989
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MaximumScore.Code.Funs /-! # Specifications of `Aegis.MaximumScore.maximum_score` LeetCode problem `maximum-score-of-a-node-sequence`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.MaximumScore (maximum_score) namespace AegisSpec.MaximumScore ...
15
minimum-rounds-to-complete-all-tasks
2,244
Medium
[ "Greedy", "Array", "Hash Table", "Counting" ]
You are given a 0-indexed integer array tasks, where tasks[i] represents the difficulty level of a task. In each round, you can complete either 2 or 3 tasks of the same difficulty level. Return the minimum rounds required to complete all the tasks, or -1 if it is not possible to complete all the tasks.   Example 1: In...
minimumRounds(tasks: list_int) -> int
pub fn minimum_rounds(tasks: &[i64]) -> i64
Aegis.MinimumRounds.minimum_rounds
pub fn minimum_rounds(tasks: &[i64]) -> i64 { let n = tasks.len(); let mut v: Vec<i64> = Vec::new(); let mut i: usize = 0; while i < n { v.push(tasks[i]); i += 1; } // Bottom-up merge sort the copied task difficulties. if n > 1 { let mut temp: Vec<i64> = Vec::new();...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [minimum_rounds]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [minimum_rounds]: function definitions module public import Aeneas public import Aegis.MinimumRounds.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.MinimumRounds.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval aegisCa...
[ { "input": "[[1]]", "output": "-1" }, { "input": "[[2, 3, 3]]", "output": "-1" }, { "input": "[[1, 2, 3, 4, 5]]", "output": "-1" }, { "input": "[[1, 1, 1, 1, 1, 1]]", "output": "2" }, { "input": "[[5, 5, 5, 5, 5, 5]]", "output": "2" }, { "input": "[[5,...
58
false
58
verified
10
10
1
7,968
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MinimumRounds.Code.Funs /-! # Specifications of `Aegis.MinimumRounds.minimum_rounds` LeetCode problem `minimum-rounds-to-complete-all-tasks`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.MinimumRounds (minimum_rounds) namespace AegisSpec.Mini...
8
maximum-trailing-zeros-in-a-cornered-path
2,245
Medium
[ "Array", "Matrix", "Prefix Sum" ]
You are given a 2D integer array grid of size m x n, where each cell contains a positive integer. A cornered path is defined as a set of adjacent cells with at most one turn. More specifically, the path should exclusively move either horizontally or vertically up to the turn (if there is one), without returning to a pr...
maxTrailingZeros(grid: list_list_int) -> int
pub fn max_trailing_zeros(grid: &[Vec<i64>]) -> i64
Aegis.MaxTrailingZeros.max_trailing_zeros
fn count_factor(mut x: i64, p: i64) -> i64 { let mut c = 0; while x > 1 && x % p == 0 { c += 1; x = x / p; } c } pub fn max_trailing_zeros(grid: &[Vec<i64>]) -> i64 { let m = grid.len(); if m == 0 { return 0; } let n = grid[0].len(); if n == 0 { retur...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [max_trailing_zeros]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option li...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [max_trailing_zeros]: function definitions module public import Aeneas public import Aegis.MaxTrailingZeros.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.MaxTrailingZeros.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval aegi...
[ { "input": "[[[2, 5], [10, 5]]]", "output": "2" }, { "input": "[[[5, 10, 15], [20, 25, 30], [35, 40, 45]]]", "output": "5" }, { "input": "[[[10, 5, 2], [6, 3, 8], [4, 7, 1]]]", "output": "2" }, { "input": "[[[1, 2, 3], [4, 5, 6], [7, 8, 9]]]", "output": "1" }, { "...
84
false
84
verified
10
10
1
10,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.MaxTrailingZeros.Code.Funs /-! # Specifications of `Aegis.MaxTrailingZeros.max_trailing_zeros` LeetCode problem `maximum-trailing-zeros-in-a-cornered-path`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result ControlFlow Error namespace AegisSpec.MaxTrailingZer...
8
longest-path-with-different-adjacent-characters
2,246
Hard
[ "Tree", "Depth-First Search", "Graph", "Topological Sort", "Array", "String" ]
You are given a tree (i.e. a connected, undirected graph that has no cycles) rooted at node 0 consisting of n nodes numbered from 0 to n - 1. The tree is represented by a 0-indexed array parent of size n, where parent[i] is the parent of node i. Since node 0 is the root, parent[0] == -1. You are also given a string s o...
longestPath(parent: list_int, s: str) -> int
pub fn longest_path(parent: &[i64], s: &[u8]) -> i64
Aegis.LongestPath.longest_path
pub fn longest_path(parent: &[i64], s: &[u8]) -> i64 { let n = parent.len(); if n == 0 { return 0; } let mut head: Vec<i64> = Vec::new(); let mut next: Vec<i64> = Vec::new(); let mut i: usize = 0; while i < n { head.push(-1); next.push(-1); i = i + 1; } ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [longest_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.s...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [longest_path]: function definitions module public import Aeneas public import Aegis.LongestPath.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.LongestPath.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval aegisCase...
[ { "input": "[[-1, 0, 0, 0], \"aabc\"]", "output": "3" }, { "input": "[[-1, 0, 0, 2, 2, 2], \"abbccc\"]", "output": "4" }, { "input": "[[-1, 0, 0, 1, 1, 2], \"abacbe\"]", "output": "3" }, { "input": "[[-1, 0, 1, 2, 3, 4, 5], \"abcdefg\"]", "output": "7" }, { "input...
49
false
49
verified
10
10
1
8,943
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.LongestPath.Code.Funs /-! # Specifications of `Aegis.LongestPath.longest_path` LeetCode problem `longest-path-with-different-adjacent-characters`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.LongestPath namespace AegisSpec.LongestPath def p...
13
maximum-cost-of-trip-with-k-highways
2,247
Hard
[ "Bit Manipulation", "Graph", "Dynamic Programming", "Bitmask" ]
A series of highways connect n cities numbered from 0 to n - 1. You are given a 2D integer array highways where highways[i] = [city1i, city2i, tolli] indicates that there is a highway that connects city1i and city2i, allowing a car to go from city1i to city2i and vice versa for a cost of tolli. You are also given an in...
maximumCost(n: int, highways: list_list_int, k: int) -> int
pub fn maximum_cost(n: i64, highways: &[Vec<i64>], k: i64) -> i64
Aegis.MaximumCost.maximum_cost
fn popcount(mut x: usize) -> usize { let mut count: usize = 0; while x > 0 { count += x & 1; x = x >> 1; } count } pub fn maximum_cost(n: i64, highways: &[Vec<i64>], k: i64) -> i64 { if k < 0 { return -1; } if k >= n { return -1; } let n_us = n as us...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [maximum_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.s...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [maximum_cost]: function definitions module public import Aeneas public import Aegis.MaximumCost.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.MaximumCost.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": "[3, [[0, 1, 2], [1, 2, 3]], 2]", "output": "5" }, { "input": "[4, [[0, 1, 3], [2, 3, 2]], 2]", "output": "-1" }, { "input": "[3, [[0, 1, 5], [1, 2, 4], [0, 2, 3]], 2]", "output": "9" }, { "input": "[4, [[0, 1, 1], [1, 2, 1], [2, 3, 1], [3, 0, 1]], 3]", "output...
75
false
75
verified
10
10
1
4,829
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MaximumCost.Code.Funs /-! # Specifications of `Aegis.MaximumCost.maximum_cost` LeetCode problem `maximum-cost-of-trip-with-k-highways`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.MaximumCost namespace AegisSpec.MaximumCost def entryIn...
15
intersection-of-multiple-arrays
2,248
Easy
[ "Array", "Hash Table", "Counting", "Sorting" ]
Given a 2D integer array nums where nums[i] is a non-empty array of distinct positive integers, return the list of integers that are present in each array of nums sorted in ascending order.   Example 1: Input: nums = [[3,1,2,4,5],[1,2,3,4],[3,4,5,6]] Output: [3,4] Explanation: The only integers present in each of num...
intersection(nums: list_list_int) -> list_int
pub fn intersection(nums: &[Vec<i64>]) -> Vec<i64>
Aegis.Intersection.intersection
pub fn intersection(nums: &[Vec<i64>]) -> Vec<i64> { let m: usize = nums.len(); let mut out: Vec<i64> = Vec::new(); if m == 0 { return out; } let mut count: Vec<i64> = Vec::new(); let mut k: usize = 0; while k < 1001 { count.push(0); k += 1; } let mut i: us...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [intersection]: type definitions module public import Aeneas @[expose] public section 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 -- [intersection]: function definitions module public import Aeneas public import Aegis.Intersection.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.Intersection.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval aegisCas...
[ { "input": "[[[1], [1]]]", "output": "[1]" }, { "input": "[[[5], [5]]]", "output": "[5]" }, { "input": "[[[1], [1], [1], [1]]]", "output": "[1]" }, { "input": "[[[1], [2], [3], [4], [5]]]", "output": "[]" }, { "input": "[[[1, 2], [2, 3], [3, 4]]]", "output": "...
93
false
93
verified
10
10
1
3,435
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.Intersection.Code.Funs /-! # Specifications of `Aegis.Intersection.intersection` LeetCode problem `intersection-of-multiple-arrays`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.Intersection def vals (v : alloc.vec.Vec Std.I64) : Lis...
11
count-lattice-points-inside-a-circle
2,249
Medium
[ "Geometry", "Array", "Hash Table", "Math", "Enumeration" ]
Given a 2D integer array circles where circles[i] = [xi, yi, ri] represents the center (xi, yi) and radius ri of the ith circle drawn on a grid, return the number of lattice points that are present inside at least one circle. Note: A lattice point is a point with integer coordinates. Points that lie on the circumferen...
countLatticePoints(circles: list_list_int) -> int
pub fn count_lattice_points(circles: &[Vec<i64>]) -> i64
Aegis.CountLatticePoints.count_lattice_points
fn isqrt_bounded(n: i64, hi0: i64) -> i64 { // floor(sqrt(n)) for n >= 0, searching in [0, hi0] let mut lo: i64 = 0; let mut hi: i64 = hi0; while lo < hi { let mid: i64 = (lo + hi + 1) / 2; if mid * mid <= n { lo = mid; } else { hi = mid - 1; } ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [count_lattice_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 ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [count_lattice_points]: function definitions module public import Aeneas public import Aegis.CountLatticePoints.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand fal...
import Aegis.CountLatticePoints.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval ae...
[ { "input": "[[[2, 2, 1]]]", "output": "5" }, { "input": "[[[100, 100, 1]]]", "output": "5" }, { "input": "[[[100, 100, 50]]]", "output": "7845" }, { "input": "[[[50, 50, 50]]]", "output": "7845" }, { "input": "[[[100, 100, 100]]]", "output": "31417" }, { ...
114
false
114
verified
10
10
6
68,380
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.CountLatticePoints.Code.Funs /-! # Specifications of `Aegis.CountLatticePoints.count_lattice_points` LeetCode problem `count-lattice-points-inside-a-circle`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result set_option autoImplicit false namespace AegisSpec....
8
count-number-of-rectangles-containing-each-point
2,250
Medium
[ "Binary Indexed Tree", "Array", "Hash Table", "Binary Search", "Sorting" ]
You are given a 2D integer array rectangles where rectangles[i] = [li, hi] indicates that ith rectangle has a length of li and a height of hi. You are also given a 2D integer array points where points[j] = [xj, yj] is a point with coordinates (xj, yj). The ith rectangle has its bottom-left corner point at the coordinat...
countRectangles(rectangles: list_list_int, points: list_list_int) -> list_int
pub fn count_rectangles(rectangles: &[Vec<i64>], points: &[Vec<i64>]) -> Vec<i64>
Aegis.CountRectangles.count_rectangles
fn sort_i64(v: &mut Vec<i64>) { let n = v.len(); if n <= 1 { return; } let mut width: usize = 1; while width < n { let mut tmp: Vec<i64> = Vec::new(); let mut start: usize = 0; while start < n { let mid_add = start + width; let mid: usize = i...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [count_rectangles]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option lint...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [count_rectangles]: function definitions module public import Aeneas public import Aegis.CountRectangles.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.CountRectangles.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval aegis...
[ { "input": "[[[1, 2], [2, 3], [2, 5]], [[2, 1], [1, 4]]]", "output": "[2, 1]" }, { "input": "[[[1, 1], [2, 2], [3, 3]], [[1, 3], [1, 1]]]", "output": "[1, 3]" }, { "input": "[[[10, 1], [9, 10], [10, 10], [1, 1]], [[5, 5], [6, 6], [7, 7]]]", "output": "[2, 2, 2]" }, { "input":...
64
false
64
verified
10
10
1
12,688
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.CountRectangles.Code.Funs /-! # Specifications of `Aegis.CountRectangles.count_rectangles` LeetCode problem `count-number-of-rectangles-containing-each-point`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.CountRectangles def coor...
12
number-of-flowers-in-full-bloom
2,251
Hard
[ "Array", "Hash Table", "Binary Search", "Ordered Set", "Prefix Sum", "Sorting" ]
You are given a 0-indexed 2D integer array flowers, where flowers[i] = [starti, endi] means the ith flower will be in full bloom from starti to endi (inclusive). You are also given a 0-indexed integer array people of size n, where people[i] is the time that the ith person will arrive to see the flowers. Return an integ...
fullBloomFlowers(flowers: list_list_int, people: list_int) -> list_int
pub fn full_bloom_flowers(flowers: &[Vec<i64>], people: &[i64]) -> Vec<i64>
Aegis.FullBloomFlowers.full_bloom_flowers
pub fn full_bloom_flowers(flowers: &[Vec<i64>], people: &[i64]) -> Vec<i64> { let mut starts: Vec<i64> = Vec::new(); let mut ends: Vec<i64> = Vec::new(); let mut i = 0usize; while i < flowers.len() { let row = &flowers[i]; starts.push(row[0]); ends.push(row[1]); i += 1; ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [full_bloom_flowers]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option li...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [full_bloom_flowers]: function definitions module public import Aeneas public import Aegis.FullBloomFlowers.Code.Types public import Aegis.FullBloomFlowers.Code.FunsExternal @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.d...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [full_bloom_flowers]: external functions. -- This is a template file: rename it to "FunsExternal.lean" and fill the holes. module public import Aeneas public import Aegis.FullBloomFlowers.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow ...
import Aegis.FullBloomFlowers.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval aegi...
[ { "input": "[[[1, 1000000000]], [1, 1000000000]]", "output": "[1, 1]" }, { "input": "[[[1, 100]], [50, 100, 150]]", "output": "[1, 1, 0]" }, { "input": "[[[1, 1000000000]], [1, 500000000, 1000000000]]", "output": "[1, 1, 1]" }, { "input": "[[[1, 10], [3, 3]], [3, 3, 2]]", ...
105
false
105
verified
10
10
1
2,399
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.FullBloomFlowers.Code.Funs /-! # Specifications of `Aegis.FullBloomFlowers.full_bloom_flowers` LeetCode problem `number-of-flowers-in-full-bloom`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.FullBloomFlowers namespace AegisSpec.FullBloomFlowe...
13
count-prefixes-of-a-given-string
2,255
Easy
[ "Array", "String" ]
You are given a string array words and a string s, where words[i] and s comprise only of lowercase English letters. Return the number of strings in words that are a prefix of s. A prefix of a string is a substring that occurs at the beginning of the string. A substring is a contiguous sequence of characters within a st...
countPrefixes(words: list_str, s: str) -> int
pub fn count_prefixes(words: &[Vec<u8>], s: &[u8]) -> i64
Aegis.CountPrefixes.count_prefixes
pub fn count_prefixes(words: &[Vec<u8>], s: &[u8]) -> i64 { let mut count: i64 = 0; let mut i: usize = 0; while i < words.len() { let w = &words[i]; let m = w.len(); if m <= s.len() { let mut j: usize = 0; let mut ok: bool = true; while j < m &&...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [count_prefixes]: type definitions module public import Aeneas @[expose] public section 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_prefixes]: function definitions module public import Aeneas public import Aegis.CountPrefixes.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.CountPrefixes.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval aegisCa...
[ { "input": "[[\"short\"], \"shorter\"]", "output": "1" }, { "input": "[[\"hello\"], \"h\"]", "output": "0" }, { "input": "[[\"hello\"], \"hello\"]", "output": "1" }, { "input": "[[\"prefix\"], \"prefix\"]", "output": "1" }, { "input": "[[\"world\"], \"world\"]", ...
146
false
146
verified
10
10
1
451
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.CountPrefixes.Code.Funs /-! # Specifications of `Aegis.CountPrefixes.count_prefixes` LeetCode problem `count-prefixes-of-a-given-string`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.CountPrefixes def vecBytes (v : alloc.vec.Vec Std....
14
minimum-average-difference
2,256
Medium
[ "Array", "Prefix Sum" ]
You are given a 0-indexed integer array nums of length n. The average difference of the index i is the absolute difference between the average of the first i + 1 elements of nums and the average of the last n - i - 1 elements. Both averages should be rounded down to the nearest integer. Return the index with the minimu...
minimumAverageDifference(nums: list_int) -> int
pub fn minimum_average_difference(nums: &[i64]) -> i64
Aegis.MinimumAverageDifference.minimum_average_difference
pub fn minimum_average_difference(nums: &[i64]) -> i64 { let n = nums.len(); if n == 0 { return 0; } let mut total: i64 = 0; let mut i: usize = 0; while i < n { total += nums[i]; i += 1; } let mut prefix: i64 = 0; let mut best_diff: i64 = -1; let mut bes...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [minimum_average_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_o...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [minimum_average_difference]: function definitions module public import Aeneas public import Aegis.MinimumAverageDifference.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.has...
import Aegis.MinimumAverageDifference.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #e...
[ { "input": "[[1]]", "output": "0" }, { "input": "[[0]]", "output": "0" }, { "input": "[[1, 2, 3]]", "output": "0" }, { "input": "[[1, 0, 1, 0, 1]]", "output": "1" }, { "input": "[[0, 1, 0, 1, 0]]", "output": "0" }, { "input": "[[10, 20, 30, 40, 50]]", ...
94
false
94
verified
10
10
1
1,461
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MinimumAverageDifference.Code.Funs /-! # Specifications of `Aegis.MinimumAverageDifference.minimum_average_difference` LeetCode problem `minimum-average-difference`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.MinimumAverageDifference nam...
6
count-unguarded-cells-in-the-grid
2,257
Medium
[ "Array", "Matrix", "Simulation" ]
You are given two integers m and n representing a 0-indexed m x n grid. You are also given two 2D integer arrays guards and walls where guards[i] = [rowi, coli] and walls[j] = [rowj, colj] represent the positions of the ith guard and jth wall respectively. A guard can see every cell in the four cardinal directions (nor...
countUnguarded(m: int, n: int, guards: list_list_int, walls: list_list_int) -> int
pub fn count_unguarded(m: i64, n: i64, guards: &[Vec<i64>], walls: &[Vec<i64>]) -> i64
Aegis.CountUnguarded.count_unguarded
pub fn count_unguarded(m: i64, n: i64, guards: &[Vec<i64>], walls: &[Vec<i64>]) -> i64 { let rows = m as usize; let cols = n as usize; let total = rows * cols; let mut grid: Vec<i64> = Vec::new(); let mut i: usize = 0; while i < total { grid.push(0); i += 1; } // 2 = wa...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [count_unguarded]: type definitions module public import Aeneas @[expose] public section 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_unguarded]: function definitions module public import Aeneas public import Aegis.CountUnguarded.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.CountUnguarded.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval aegisC...
[ { "input": "[5, 5, [[2, 2]], [[0, 0], [4, 4]]]", "output": "14" }, { "input": "[10, 10, [[3, 3], [6, 6]], [[1, 1], [8, 8]]]", "output": "62" }, { "input": "[6, 6, [[1, 1], [4, 4]], [[2, 2], [3, 3]]]", "output": "14" }, { "input": "[3, 3, [[1, 1]], [[0, 1], [1, 0], [2, 1], [1,...
83
false
83
verified
10
10
1
2,782
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.CountUnguarded.Code.Funs /-! # Specifications of `Aegis.CountUnguarded.count_unguarded` LeetCode problem `count-unguarded-cells-in-the-grid`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.CountUnguarded namespace AegisSpec.CountUnguarded abb...
8
escape-the-spreading-fire
2,258
Hard
[ "Breadth-First Search", "Array", "Binary Search", "Matrix" ]
You are given a 0-indexed 2D integer array grid of size m x n which represents a field. Each cell has one of three values: 0 represents grass, 1 represents fire, 2 represents a wall that you and fire cannot pass through. You are situated in the top-left cell, (0, 0), and you want to travel to the safehouse at the bot...
maximumMinutes(grid: list_list_int) -> int
pub fn maximum_minutes(grid: &[Vec<i64>]) -> i64
Aegis.MaximumMinutes.maximum_minutes
pub fn maximum_minutes(grid: &[Vec<i64>]) -> i64 { let m = grid.len(); if m == 0 { return -1; } let n = grid[0].len(); if n == 0 { return -1; } let inf: i64 = 1000000000000000; let mut fire: Vec<Vec<i64>> = Vec::new(); let mut i = 0; while i < m { let mu...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [maximum_minutes]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linte...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [maximum_minutes]: function definitions module public import Aeneas public import Aegis.MaximumMinutes.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.MaximumMinutes.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval aegisC...
[ { "input": "[[[0, 1], [0, 0]]]", "output": "-1" }, { "input": "[[[0, 0, 0], [2, 2, 0], [1, 2, 0]]]", "output": "1000000000" }, { "input": "[[[0, 0, 0, 0], [0, 1, 2, 0], [0, 2, 0, 0]]]", "output": "-1" }, { "input": "[[[0, 0, 0, 1], [0, 2, 2, 0], [0, 2, 2, 0], [0, 0, 0, 0]]]",...
85
false
85
verified
10
10
2
21,982
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MaximumMinutes.Code.Funs /-! # Specifications of `Aegis.MaximumMinutes.maximum_minutes` LeetCode problem `escape-the-spreading-fire`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.MaximumMinutes open Aegis.MaximumMinutes (maximum_...
11
minimum-consecutive-cards-to-pick-up
2,260
Medium
[ "Array", "Hash Table", "Sliding Window" ]
You are given an integer array cards where cards[i] represents the value of the ith card. A pair of cards are matching if the cards have the same value. Return the minimum number of consecutive cards you have to pick up to have a pair of matching cards among the picked cards. If it is impossible to have matching cards,...
minimumCardPickup(cards: list_int) -> int
pub fn minimum_card_pickup(cards: &[i64]) -> i64
Aegis.MinimumCardPickup.minimum_card_pickup
pub fn minimum_card_pickup(cards: &[i64]) -> i64 { let n = cards.len(); if n < 2 { return -1; } let mut max_val: i64 = 0; let mut i: usize = 0; while i < n { if cards[i] > max_val { max_val = cards[i]; } i += 1; } let size = max_val as usize ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [minimum_card_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 l...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [minimum_card_pickup]: function definitions module public import Aeneas public import Aegis.MinimumCardPickup.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false...
import Aegis.MinimumCardPickup.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval aeg...
[ { "input": "[[5]]", "output": "-1" }, { "input": "[[0, 0]]", "output": "2" }, { "input": "[[1, 1]]", "output": "2" }, { "input": "[[1000000, 999999, 1000000]]", "output": "3" }, { "input": "[[1000000, 0, 1000000]]", "output": "3" }, { "input": "[[1, 0,...
109
false
109
verified_partial
10
3
1
1,202
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MinimumCardPickup.Code.Funs /-! # Specifications of `Aegis.MinimumCardPickup.minimum_card_pickup` LeetCode problem `minimum-consecutive-cards-to-pick-up`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.MinimumCardPickup namespace AegisSpec.Minim...
13
k-divisible-elements-subarrays
2,261
Medium
[ "Trie", "Array", "Hash Table", "Enumeration", "Hash Function", "Rolling Hash" ]
Given an integer array nums and two integers k and p, return the number of distinct subarrays, which have at most k elements that are divisible by p. Two arrays nums1 and nums2 are said to be distinct if: They are of different lengths, or There exists at least one index i where nums1[i] != nums2[i]. A subarray is def...
countDistinct(nums: list_int, k: int, p: int) -> int
pub fn count_distinct(nums: &[i64], k: i64, p: i64) -> i64
Aegis.CountDistinct.count_distinct
pub fn count_distinct(nums: &[i64], k: i64, p: i64) -> i64 { let n = nums.len(); let mut node_vals: Vec<Vec<i64>> = Vec::new(); let mut node_children: Vec<Vec<usize>> = Vec::new(); node_vals.push(Vec::new()); node_children.push(Vec::new()); let mut ans: i64 = 0; let mut i: usize = 0; ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [count_distinct]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [count_distinct]: function definitions module public import Aeneas public import Aegis.CountDistinct.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.CountDistinct.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval aegisCa...
[ { "input": "[[1, 2, 1, 2], 1, 2]", "output": "5" }, { "input": "[[5, 5, 5, 5], 2, 5]", "output": "2" }, { "input": "[[5, 10, 15, 20], 2, 5]", "output": "7" }, { "input": "[[7, 11, 13, 17], 1, 2]", "output": "10" }, { "input": "[[5, 5, 5, 5], 1, 5]", "output": ...
135
false
135
verified
10
10
1
5,665
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.CountDistinct.Code.Funs /-! # Specifications of `Aegis.CountDistinct.count_distinct` LeetCode problem `k-divisible-elements-subarrays`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.CountDistinct open Aegis.CountDistinct def len (num...
15
total-appeal-of-a-string
2,262
Hard
[ "Hash Table", "String", "Dynamic Programming" ]
The appeal of a string is the number of distinct characters found in the string. For example, the appeal of "abbca" is 3 because it has 3 distinct characters: 'a', 'b', and 'c'. Given a string s, return the total appeal of all of its substrings. A substring is a contiguous sequence of characters within a string.   Ex...
appealSum(s: str) -> int
pub fn appeal_sum(s: &[u8]) -> i64
Aegis.AppealSum.appeal_sum
pub fn appeal_sum(s: &[u8]) -> i64 { let n = s.len(); let mut last: Vec<i64> = Vec::new(); let mut k: usize = 0; while k < 26 { last.push(-1); k += 1; } let mut total: i64 = 0; let mut i: usize = 0; while i < n { let idx: usize = s[i] as usize - 97; let...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [appeal_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.sty...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [appeal_sum]: function definitions module public import Aeneas public import Aegis.AppealSum.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.AppealSum.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": "[\"abcdefghijklmnopqrstuvwxyz\"]", "output": "3276" }, { "input": "[\"zzzaaa\"]", "output": "30" }, { "input": "[\"a\"]", "output": "1" }, { "input": "[\"abacabadabacaba\"]", "output": "357" }, { "input": "[\"abcabcabc\"]", "output": "109" }, {...
69
false
69
verified
10
10
1
1,004
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.AppealSum.Code.Funs /-! # Specifications of `Aegis.AppealSum.appeal_sum` LeetCode problem `total-appeal-of-a-string`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.AppealSum namespace AegisSpec.AppealSum set_option autoImplicit false ...
13
count-nodes-equal-to-average-of-subtree
2,265
Medium
[ "Tree", "Depth-First Search", "Binary Tree" ]
Given the root of a binary tree, return the number of nodes where the value of the node is equal to the average of the values in its subtree. Note: The average of n elements is the sum of the n elements divided by n and rounded down to the nearest integer. A subtree of root is a tree consisting of root and all of its ...
averageOfSubtree(root: tree) -> int
pub fn average_of_subtree(root: &Tree) -> i64
Aegis.AverageOfSubtree.average_of_subtree
fn subtree_sum(t: &Tree) -> i64 { match t { Tree::Null => 0, Tree::Node(v, l, r) => *v + subtree_sum(l) + subtree_sum(r), } } fn subtree_count(t: &Tree) -> i64 { match t { Tree::Null => 0, Tree::Node(_, l, r) => 1 + subtree_count(l) + subtree_count(r), } } fn count_aver...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [average_of_subtree]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option li...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [average_of_subtree]: function definitions module public import Aeneas public import Aegis.AverageOfSubtree.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.AverageOfSubtree.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval aegi...
[ { "input": "[[1]]", "output": "1" }, { "input": "[[10, 5, 15, 3, 7, 18]]", "output": "4" }, { "input": "[[0, 0, 0, 0, 0, 0, 0]]", "output": "7" }, { "input": "[[2, 3, 3, 8, 10, 14, 13]]", "output": "4" }, { "input": "[[100, 99, 101, 98, 102, 97, 103]]", "outpu...
34
false
34
verified
10
10
1
1,919
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.AverageOfSubtree.Code.Funs /-! # Specifications of `Aegis.AverageOfSubtree.average_of_subtree` LeetCode problem `count-nodes-equal-to-average-of-subtree`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.AverageOfSubtree open Aegis.Avera...
11
count-number-of-texts
2,266
Medium
[ "Hash Table", "Math", "String", "Dynamic Programming" ]
Alice is texting Bob using her phone. The mapping of digits to letters is shown in the figure below. In order to add a letter, Alice has to press the key of the corresponding digit i times, where i is the position of the letter in the key. For example, to add the letter 's', Alice has to press '7' four times. Similar...
countTexts(pressedKeys: str) -> int
pub fn count_texts(pressedKeys: &[u8]) -> i64
Aegis.CountTexts.count_texts
pub fn count_texts(pressed_keys: &[u8]) -> i64 { let n = pressed_keys.len(); let mut dp: Vec<i64> = Vec::new(); let mut i: usize = 0; while i <= n { dp.push(0); i += 1; } dp[0] = 1; i = 0; while i < n { let digit = pressed_keys[i]; let max_presses: usize...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [count_texts]: type definitions module public import Aeneas @[expose] public section 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_texts]: function definitions module public import Aeneas public import Aegis.CountTexts.Code.Types public import Aegis.CountTexts.Code.FunsExternal @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false s...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [count_texts]: external functions. -- This is a template file: rename it to "FunsExternal.lean" and fill the holes. module public import Aeneas public import Aegis.CountTexts.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_opt...
import Aegis.CountTexts.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": "[\"99999999\"]", "output": "108" }, { "input": "[\"3333\"]", "output": "7" }, { "input": "[\"33\"]", "output": "2" }, { "input": "[\"4444\"]", "output": "7" }, { "input": "[\"555555\"]", "output": "24" }, { "input": "[\"9999999\"]", "ou...
38
false
38
verified
10
10
1
5,182
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.CountTexts.Code.Funs /-! # Specifications of `Aegis.CountTexts.count_texts` LeetCode problem `count-number-of-texts`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result Aegis.CountTexts namespace AegisSpec.CountTexts def M : ℤ := 1000000007 def threePressDig...
6
minimum-number-of-keypresses
2,268
Medium
[ "Greedy", "Hash Table", "String", "Counting", "Sorting" ]
You have a keypad with 9 buttons, numbered from 1 to 9, each mapped to lowercase English letters. You can choose which characters each button is matched to as long as: All 26 lowercase English letters are mapped to. Each character is mapped to by exactly 1 button. Each button maps to at most 3 characters. To type the...
minimumKeypresses(s: str) -> int
pub fn minimum_keypresses(s: &[u8]) -> i64
Aegis.MinimumKeypresses.minimum_keypresses
pub fn minimum_keypresses(s: &[u8]) -> i64 { let mut freq: Vec<i64> = Vec::new(); let mut i: usize = 0; while i < 26 { freq.push(0); i += 1; } let mut index: usize = 0; while index < s.len() { let letter: usize = (s[index] - b'a') as usize; freq[letter] = freq[le...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [minimum_keypresses]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option li...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [minimum_keypresses]: function definitions module public import Aeneas public import Aegis.MinimumKeypresses.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false ...
import Aegis.MinimumKeypresses.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval aeg...
[ { "input": "[\"mmmmmmmmmmmmmmmm\"]", "output": "16" }, { "input": "[\"mississippi\"]", "output": "11" }, { "input": "[\"abcdefghijklmnopqrstuvwxyz\"]", "output": "51" }, { "input": "[\"banana\"]", "output": "6" }, { "input": "[\"aabbccddeeffgghhiijjkkllmmnnooppqqr...
76
false
76
verified
10
10
1
1,307
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MinimumKeypresses.Code.Funs /-! # Specifications of `Aegis.MinimumKeypresses.minimum_keypresses` LeetCode problem `minimum-number-of-keypresses`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.MinimumKeypresses def freq (s : Slice ...
12
find-the-k-beauty-of-a-number
2,269
Easy
[ "Math", "String", "Sliding Window" ]
The k-beauty of an integer num is defined as the number of substrings of num when it is read as a string that meet the following conditions: It has a length of k. It is a divisor of num. Given integers num and k, return the k-beauty of num. Note: Leading zeros are allowed. 0 is not a divisor of any value. A substri...
divisorSubstrings(num: int, k: int) -> int
pub fn divisor_substrings(num: i64, k: i64) -> i64
Aegis.DivisorSubstrings.divisor_substrings
pub fn divisor_substrings(num: i64, k: i64) -> i64 { if num <= 0 || k <= 0 { return 0; } let mut digits: Vec<i64> = Vec::new(); let mut n: i64 = num; while n > 0 { digits.push(n % 10); n = n / 10; } let dlen: usize = digits.len(); let mut left: usize = 0; l...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [divisor_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 li...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [divisor_substrings]: function definitions module public import Aeneas public import Aegis.DivisorSubstrings.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false ...
import Aegis.DivisorSubstrings.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval aeg...
[ { "input": "[100000, 2]", "output": "1" }, { "input": "[240, 2]", "output": "2" }, { "input": "[1111, 2]", "output": "3" }, { "input": "[430043, 2]", "output": "2" }, { "input": "[99999, 5]", "output": "1" }, { "input": "[123456, 3]", "output": "0"...
83
false
83
verified
10
10
1
3,283
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.DivisorSubstrings.Code.Funs /-! # Specifications of `Aegis.DivisorSubstrings.divisor_substrings` LeetCode problem `find-the-k-beauty-of-a-number`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.DivisorSubstrings def digitsOf (n : N...
13
number-of-ways-to-split-array
2,270
Medium
[ "Array", "Prefix Sum" ]
You are given a 0-indexed integer array nums of length n. nums contains a valid split at index i if the following are true: The sum of the first i + 1 elements is greater than or equal to the sum of the last n - i - 1 elements. There is at least one element to the right of i. That is, 0 <= i < n - 1. Return the numbe...
waysToSplitArray(nums: list_int) -> int
pub fn ways_to_split_array(nums: &[i64]) -> i64
Aegis.WaysToSplitArray.ways_to_split_array
pub fn ways_to_split_array(nums: &[i64]) -> i64 { let n = nums.len(); let mut total: i64 = 0; let mut j: usize = 0; while j < n { total += nums[j]; j += 1; } let mut prefix: i64 = 0; let mut count: i64 = 0; let mut i: usize = 0; while i + 1 < n { prefix += ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [ways_to_split_array]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option l...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [ways_to_split_array]: function definitions module public import Aeneas public import Aegis.WaysToSplitArray.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false ...
import Aegis.WaysToSplitArray.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval aegi...
[ { "input": "[[10, 4, -8, 7]]", "output": "2" }, { "input": "[[2, 3, 1, 0]]", "output": "2" }, { "input": "[[-100000, -100000, -100000, -100000, -100000]]", "output": "2" }, { "input": "[[1, -1, 1, -1, 1]]", "output": "2" }, { "input": "[[100, -50, 50, -25, 25]]", ...
105
false
105
verified
10
10
1
488
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.WaysToSplitArray.Code.Funs /-! # Specifications of `Aegis.WaysToSplitArray.ways_to_split_array` LeetCode problem `number-of-ways-to-split-array`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.WaysToSplitArray namespace AegisSpec.WaysToSplit...
12
maximum-white-tiles-covered-by-a-carpet
2,271
Medium
[ "Greedy", "Array", "Binary Search", "Prefix Sum", "Sorting", "Sliding Window" ]
You are given a 2D integer array tiles where tiles[i] = [li, ri] represents that every tile j in the range li <= j <= ri is colored white. You are also given an integer carpetLen, the length of a single carpet that can be placed anywhere. Return the maximum number of white tiles that can be covered by the carpet.   Exa...
maximumWhiteTiles(tiles: list_list_int, carpetLen: int) -> int
pub fn maximum_white_tiles(tiles: &[Vec<i64>], carpetLen: i64) -> i64
Aegis.MaximumWhiteTiles.maximum_white_tiles
pub fn maximum_white_tiles(tiles: &[Vec<i64>], carpetLen: i64) -> i64 { let n = tiles.len(); let mut starts: Vec<i64> = Vec::new(); let mut ends: Vec<i64> = Vec::new(); let mut idx = 0; while idx < n { starts.push(tiles[idx][0]); ends.push(tiles[idx][1]); idx += 1; } ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [maximum_white_tiles]: type definitions module public import Aeneas @[expose] public section 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 -- [maximum_white_tiles]: function definitions module public import Aeneas public import Aegis.MaximumWhiteTiles.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false...
import Aegis.MaximumWhiteTiles.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval aeg...
[ { "input": "[[[1, 1000000000]], 1000000000]", "output": "1000000000" }, { "input": "[[[1, 100]], 50]", "output": "50" }, { "input": "[[[1, 1000000000]], 500000000]", "output": "500000000" }, { "input": "[[[1, 1000000000]], 999999999]", "output": "999999999" }, { "...
111
false
111
verified
10
10
1
6,395
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MaximumWhiteTiles.Code.Funs /-! # Specifications of `Aegis.MaximumWhiteTiles.maximum_white_tiles` LeetCode problem `maximum-white-tiles-covered-by-a-carpet`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.MaximumWhiteTiles namespace AegisSpe...
12
substring-with-largest-variance
2,272
Hard
[ "Array", "Dynamic Programming" ]
The variance of a string is defined as the largest difference between the number of occurrences of any 2 characters present in the string. Note the two characters may or may not be the same. Given a string s consisting of lowercase English letters only, return the largest variance possible among all substrings of s. A ...
largestVariance(s: str) -> int
pub fn largest_variance(s: &[u8]) -> i64
Aegis.LargestVariance.largest_variance
pub fn largest_variance(s: &[u8]) -> i64 { let n = s.len(); let mut ans: i64 = 0; let neg_inf: i64 = -1000000000; let mut major_i: i64 = 0; while major_i < 26 { let mut minor_i: i64 = 0; while minor_i < 26 { if major_i != minor_i { let major: i64 = 97 + m...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [largest_variance]: type definitions module public import Aeneas @[expose] public section 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 -- [largest_variance]: function definitions module public import Aeneas public import Aegis.LargestVariance.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.LargestVariance.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval aegis...
[ { "input": "[\"zzzzzzy\"]", "output": "5" }, { "input": "[\"zyzzyzyzy\"]", "output": "2" }, { "input": "[\"abcdefghijklmnopqrstuvwxyz\"]", "output": "0" }, { "input": "[\"abbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\"]", "output": "1" }, { "input": "[\"abba...
25
false
25
verified
10
10
1
5,032
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.LargestVariance.Code.Funs /-! # Specifications of `Aegis.LargestVariance.largest_variance` LeetCode problem `substring-with-largest-variance`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.LargestVariance open Aegis.LargestVariance (l...
16
maximum-consecutive-floors-without-special-floors
2,274
Medium
[ "Array", "Sorting" ]
Alice manages a company and has rented some floors of a building as office space. Alice has decided some of these floors should be special floors, used for relaxation only. You are given two integers bottom and top, which denote that Alice has rented all the floors from bottom to top (inclusive). You are also given the...
maxConsecutive(bottom: int, top: int, special: list_int) -> int
pub fn max_consecutive(bottom: i64, top: i64, special: &[i64]) -> i64
Aegis.MaxConsecutive.max_consecutive
pub fn max_consecutive(bottom: i64, top: i64, special: &[i64]) -> i64 { let mut s: Vec<i64> = Vec::new(); let mut i: usize = 0; while i < special.len() { s.push(special[i]); i += 1; } s.sort(); let n = s.len(); if n == 0 { return top - bottom + 1; } let mut...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [max_consecutive]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linte...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [max_consecutive]: function definitions module public import Aeneas public import Aegis.MaxConsecutive.Code.Types public import Aegis.MaxConsecutive.Code.FunsExternal @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNames...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [max_consecutive]: external functions. -- This is a template file: rename it to "FunsExternal.lean" and fill the holes. module public import Aeneas public import Aegis.MaxConsecutive.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error...
import Aegis.MaxConsecutive.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval aegisC...
[ { "input": "[1, 1, [1]]", "output": "0" }, { "input": "[5, 15, [10]]", "output": "5" }, { "input": "[1, 10, [5]]", "output": "5" }, { "input": "[10, 10, [10]]", "output": "0" }, { "input": "[1, 1000000000, [500000000]]", "output": "500000000" }, { "inp...
93
false
93
verified
10
10
1
2,900
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MaxConsecutive.Code.Funs /-! # Specifications of `Aegis.MaxConsecutive.max_consecutive` LeetCode problem `maximum-consecutive-floors-without-special-floors`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.MaxConsecutive namespace AegisSpec.M...
12
largest-combination-with-bitwise-and-greater-than-zero
2,275
Medium
[ "Bit Manipulation", "Array", "Hash Table", "Counting" ]
The bitwise AND of an array nums is the bitwise AND of all integers in nums. For example, for nums = [1, 5, 3], the bitwise AND is equal to 1 & 5 & 3 = 1. Also, for nums = [7], the bitwise AND is 7. You are given an array of positive integers candidates. Compute the bitwise AND for all possible combinations of elemen...
largestCombination(candidates: list_int) -> int
pub fn largest_combination(candidates: &[i64]) -> i64
Aegis.LargestCombination.largest_combination
pub fn largest_combination(candidates: &[i64]) -> i64 { let n = candidates.len(); let mut best: i64 = 0; let mut divisor: i64 = 1; let mut bit: usize = 0; while bit < 63 { let mut count: i64 = 0; let mut i: usize = 0; while i < n { let shifted = candidates[i] / ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [largest_combination]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option l...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [largest_combination]: function definitions module public import Aeneas public import Aegis.LargestCombination.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand fals...
import Aegis.LargestCombination.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval ae...
[ { "input": "[[8, 8]]", "output": "2" }, { "input": "[[1048575, 1048574, 1048573, 1048572, 1048571]]", "output": "5" }, { "input": "[[31, 31, 31, 31, 31]]", "output": "5" }, { "input": "[[2147483647, 2147483646, 2147483645, 2147483644, 2147483643]]", "output": "5" }, {...
92
false
92
verified
10
10
1
2,850
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.LargestCombination.Code.Funs /-! # Specifications of `Aegis.LargestCombination.largest_combination` LeetCode problem `largest-combination-with-bitwise-and-greater-than-zero`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.LargestCombination (la...
12
closest-node-to-path-in-tree
2,277
Hard
[ "Tree", "Depth-First Search", "Breadth-First Search", "Array" ]
You are given a positive integer n representing the number of nodes in a tree, numbered from 0 to n - 1 (inclusive). You are also given a 2D integer array edges of length n - 1, where edges[i] = [node1i, node2i] denotes that there is a bidirectional edge connecting node1i and node2i in the tree. You are given a 0-index...
closestNode(n: int, edges: list_list_int, query: list_list_int) -> list_int
pub fn closest_node(n: i64, edges: &[Vec<i64>], query: &[Vec<i64>]) -> Vec<i64>
Aegis.ClosestNode.closest_node
pub fn closest_node(n: i64, edges: &[Vec<i64>], query: &[Vec<i64>]) -> Vec<i64> { let nn = n as usize; let mut adj: Vec<Vec<i64>> = Vec::new(); let mut i = 0; while i < nn { let row: Vec<i64> = Vec::new(); adj.push(row); i += 1; } let edge_count = edges.len(); i = 0...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [closest_node]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter.s...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [closest_node]: function definitions module public import Aeneas public import Aegis.ClosestNode.Code.Types public import Aegis.ClosestNode.Code.FunsExternal @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace fals...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [closest_node]: external functions. -- This is a template file: rename it to "FunsExternal.lean" and fill the holes. module public import Aeneas public import Aegis.ClosestNode.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_o...
import Aegis.ClosestNode.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": "[3, [[0, 1], [1, 2]], [[0, 1, 2]]]", "output": "[1]" }, { "input": "[3, [[0, 1], [1, 2]], [[0, 0, 0]]]", "output": "[0]" }, { "input": "[5, [[0, 1], [1, 2], [2, 3], [3, 4]], [[4, 0, 2]]]", "output": "[2]" }, { "input": "[4, [[0, 1], [1, 2], [1, 3]], [[2, 3, 0], [0...
78
false
78
verified
10
10
1
3,705
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.ClosestNode.Code.Funs /-! # Specifications of `Aegis.ClosestNode.closest_node` LeetCode problem `closest-node-to-path-in-tree`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.ClosestNode def vecInts (v : alloc.vec.Vec Std.I64) : Li...
12
percentage-of-letter-in-string
2,278
Easy
[ "String" ]
Given a string s and a character letter, return the percentage of characters in s that equal letter rounded down to the nearest whole percent.   Example 1: Input: s = "foobar", letter = "o" Output: 33 Explanation: The percentage of characters in s that equal the letter 'o' is 2 / 6 * 100% = 33% when rounded down, so w...
percentageLetter(s: str, letter: str) -> int
pub fn percentage_letter(s: &[u8], letter: &[u8]) -> i64
Aegis.PercentageLetter.percentage_letter
pub fn percentage_letter(s: &[u8], letter: &[u8]) -> i64 { let target: u8 = letter[0]; let mut count: i64 = 0; let mut i: usize = 0; while i < s.len() { if s[i] == target { count += 1; } i += 1; } count * 100 / (s.len() as i64) }
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [percentage_letter]: type definitions module public import Aeneas @[expose] public section 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 -- [percentage_letter]: function definitions module public import Aeneas public import Aegis.PercentageLetter.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.PercentageLetter.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval aegi...
[ { "input": "[\"jjjj\", \"k\"]", "output": "0" }, { "input": "[\"foobar\", \"o\"]", "output": "33" }, { "input": "[\"mississippi\", \"i\"]", "output": "36" }, { "input": "[\"python\", \"y\"]", "output": "16" }, { "input": "[\"abcabcabc\", \"a\"]", "output": "33...
107
false
107
verified
10
10
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.PercentageLetter.Code.Funs /-! # Specifications of `Aegis.PercentageLetter.percentage_letter` LeetCode problem `percentage-of-letter-in-string`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.PercentageLetter def isLowerAscii (b : U8) ...
12
maximum-bags-with-full-capacity-of-rocks
2,279
Medium
[ "Greedy", "Array", "Sorting" ]
You have n bags numbered from 0 to n - 1. You are given two 0-indexed integer arrays capacity and rocks. The ith bag can hold a maximum of capacity[i] rocks and currently contains rocks[i] rocks. You are also given an integer additionalRocks, the number of additional rocks you can place in any of the bags. Return the m...
maximumBags(capacity: list_int, rocks: list_int, additionalRocks: int) -> int
pub fn maximum_bags(capacity: &[i64], rocks: &[i64], additionalRocks: i64) -> i64
Aegis.MaximumBags.maximum_bags
pub fn maximum_bags(capacity: &[i64], rocks: &[i64], additionalRocks: i64) -> i64 { let n = capacity.len(); let mut deficits: Vec<i64> = Vec::new(); let mut i: usize = 0; while i < n { deficits.push(capacity[i] - rocks[i]); i += 1; } deficits.sort(); let mut ans: i64 = 0; ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [maximum_bags]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter.s...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [maximum_bags]: function definitions module public import Aeneas public import Aegis.MaximumBags.Code.Types public import Aegis.MaximumBags.Code.FunsExternal @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace fals...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [maximum_bags]: external functions. -- This is a template file: rename it to "FunsExternal.lean" and fill the holes. module public import Aeneas public import Aegis.MaximumBags.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_o...
import Aegis.MaximumBags.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": "[[999999999, 1], [0, 0], 1000000000]", "output": "2" }, { "input": "[[1000000000, 1000000000], [0, 1], 1999999999]", "output": "2" }, { "input": "[[1, 2, 3], [0, 0, 0], 5]", "output": "2" }, { "input": "[[3, 2, 1], [0, 0, 0], 5]", "output": "2" }, { "i...
103
false
103
verified
10
10
1
2,407
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MaximumBags.Code.Funs /-! # Specifications of `Aegis.MaximumBags.maximum_bags` LeetCode problem `maximum-bags-with-full-capacity-of-rocks`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.MaximumBags namespace AegisSpec.MaximumBags def i64At (s ...
13
sum-of-total-strength-of-wizards
2,281
Hard
[ "Stack", "Array", "Prefix Sum", "Monotonic Stack" ]
As the ruler of a kingdom, you have an army of wizards at your command. You are given a 0-indexed integer array strength, where strength[i] denotes the strength of the ith wizard. For a contiguous group of wizards (i.e. the wizards' strengths form a subarray of strength), the total strength is defined as the product of...
totalStrength(strength: list_int) -> int
pub fn total_strength(strength: &[i64]) -> i64
Aegis.TotalStrength.total_strength
const MOD: i64 = 1000000007; pub fn total_strength(strength: &[i64]) -> i64 { let n = strength.len(); if n == 0 { return 0; } // q[k] = sum_{t = 0}^{k - 1} prefix[t], modulo MOD let mut q: Vec<i64> = Vec::new(); q.push(0); let mut pcur: i64 = 0; // prefix sum of strength, modulo M...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [total_strength]: type definitions module public import Aeneas @[expose] public section 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 -- [total_strength]: function definitions module public import Aeneas public import Aegis.TotalStrength.Code.Types public import Aegis.TotalStrength.Code.FunsExternal @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespac...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [total_strength]: external functions. -- This is a template file: rename it to "FunsExternal.lean" and fill the holes. module public import Aeneas public import Aegis.TotalStrength.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error s...
import Aegis.TotalStrength.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval aegisCa...
[ { "input": "[[1]]", "output": "1" }, { "input": "[[5]]", "output": "25" }, { "input": "[[1000000000, 1000000000]]", "output": "196" }, { "input": "[[1000000000, 1000000000, 1000000000]]", "output": "490" }, { "input": "[[5, 4, 6]]", "output": "213" }, { ...
104
false
104
verified
10
10
1
9,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.TotalStrength.Code.Funs /-! # Specifications of `Aegis.TotalStrength.total_strength` LeetCode problem `sum-of-total-strength-of-wizards`. Each `spec_<n>` theorem states one property of the function. -/ namespace AegisSpec.TotalStrength def M : ℤ := 1000000007 def vals (s : Aeneas.Std.Slice Aeneas.Std....
10
check-if-number-has-equal-digit-count-and-digit-value
2,283
Easy
[ "Hash Table", "String", "Counting" ]
You are given a 0-indexed string num of length n consisting of digits. Return true if for every index i in the range 0 <= i < n, the digit i occurs num[i] times in num, otherwise return false.   Example 1: Input: num = "1210" Output: true Explanation: num[0] = '1'. The digit 0 occurs once in num. num[1] = '2'. The dig...
digitCount(num: str) -> bool
pub fn digit_count(num: &[u8]) -> bool
Aegis.DigitCount.digit_count
pub fn digit_count(num: &[u8]) -> bool { let n = num.len(); let mut i: usize = 0; while i < n { let target = b'0' + (i as u8); let mut count: i64 = 0; let mut j: usize = 0; while j < n { if num[j] == target { count += 1; } j...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [digit_count]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter.st...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [digit_count]: function definitions module public import Aeneas public import Aegis.DigitCount.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.DigitCount.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": "[\"1111\"]", "output": "false" }, { "input": "[\"00000\"]", "output": "false" }, { "input": "[\"10\"]", "output": "false" }, { "input": "[\"1111111111\"]", "output": "false" }, { "input": "[\"000\"]", "output": "false" }, { "input": "[\"620...
150
false
150
verified
10
10
1
2,344
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.DigitCount.Code.Funs /-! # Specifications of `Aegis.DigitCount.digit_count` LeetCode problem `check-if-number-has-equal-digit-count-and-digit-value`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.DigitCount open Aegis.DigitCount (digi...
9
maximum-total-importance-of-roads
2,285
Medium
[ "Greedy", "Graph", "Sorting", "Heap (Priority Queue)" ]
You are given an integer n denoting the number of cities in a country. The cities are numbered from 0 to n - 1. You are also given a 2D integer array roads where roads[i] = [ai, bi] denotes that there exists a bidirectional road connecting cities ai and bi. You need to assign each city with an integer value from 1 to n...
maximumImportance(n: int, roads: list_list_int) -> int
pub fn maximum_importance(n: i64, roads: &[Vec<i64>]) -> i64
Aegis.MaximumImportance.maximum_importance
pub fn maximum_importance(n: i64, roads: &[Vec<i64>]) -> i64 { let n_usize = n as usize; let mut degrees: Vec<i64> = Vec::new(); let mut i: usize = 0; while i < n_usize { degrees.push(0); i += 1; } let m: usize = roads.len(); let mut r: usize = 0; while r < m { ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [maximum_importance]: type definitions module public import Aeneas @[expose] public section 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 -- [maximum_importance]: function definitions module public import Aeneas public import Aegis.MaximumImportance.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false ...
import Aegis.MaximumImportance.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval aeg...
[ { "input": "[3, [[0, 1], [1, 2]]]", "output": "9" }, { "input": "[4, [[0, 1], [1, 2], [2, 3]]]", "output": "17" }, { "input": "[5, [[0, 3], [2, 4], [1, 3]]]", "output": "20" }, { "input": "[4, [[0, 1], [0, 3], [1, 2], [2, 3]]]", "output": "20" }, { "input": "[6, [...
65
false
65
verified
10
10
1
2,249
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MaximumImportance.Code.Funs /-! # Specifications of `Aegis.MaximumImportance.maximum_importance` LeetCode problem `maximum-total-importance-of-roads`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.MaximumImportance open Aegis.MaximumI...
8
rearrange-characters-to-make-target-string
2,287
Easy
[ "Hash Table", "String", "Counting" ]
You are given two 0-indexed strings s and target. You can take some letters from s and rearrange them to form new strings. Return the maximum number of copies of target that can be formed by taking letters from s and rearranging them.   Example 1: Input: s = "ilovecodingonleetcode", target = "code" Output: 2 Explanati...
rearrangeCharacters(s: str, target: str) -> int
pub fn rearrange_characters(s: &[u8], target: &[u8]) -> i64
Aegis.RearrangeCharacters.rearrange_characters
pub fn rearrange_characters(s: &[u8], target: &[u8]) -> i64 { let mut s_count: Vec<i64> = Vec::new(); let mut target_count: Vec<i64> = Vec::new(); let mut i = 0usize; while i < 26 { s_count.push(0); target_count.push(0); i += 1; } i = 0; while i < s.len() { ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [rearrange_characters]: type definitions module public import Aeneas @[expose] public section 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 -- [rearrange_characters]: function definitions module public import Aeneas public import Aegis.RearrangeCharacters.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand fa...
import Aegis.RearrangeCharacters.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": "[\"aabbc\", \"abc\"]", "output": "1" }, { "input": "[\"aabbbccc\", \"abc\"]", "output": "2" }, { "input": "[\"zzzz\", \"zz\"]", "output": "2" }, { "input": "[\"abcabcabc\", \"abc\"]", "output": "3" }, { "input": "[\"abcd\", \"abce\"]", "output": "0...
129
false
129
verified
10
10
1
1,202
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.RearrangeCharacters.Code.Funs /-! # Specifications of `Aegis.RearrangeCharacters.rearrange_characters` LeetCode problem `rearrange-characters-to-make-target-string`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.RearrangeCharacters de...
15
steps-to-make-array-non-decreasing
2,289
Medium
[ "Stack", "Array", "Linked List", "Monotonic Stack" ]
You are given a 0-indexed integer array nums. In one step, remove all elements nums[i] where nums[i - 1] > nums[i] for all 0 < i < nums.length. Return the number of steps performed until nums becomes a non-decreasing array.   Example 1: Input: nums = [5,3,4,4,7,3,6,11,8,5,11] Output: 3 Explanation: The following are t...
totalSteps(nums: list_int) -> int
pub fn total_steps(nums: &[i64]) -> i64
Aegis.TotalSteps.total_steps
pub fn total_steps(nums: &[i64]) -> i64 { let n = nums.len(); let mut vals: Vec<i64> = Vec::new(); let mut steps: Vec<i64> = Vec::new(); let mut ans: i64 = 0; let mut i: usize = n; while i > 0 { i -= 1; let v = nums[i]; let mut cnt: i64 = 0; while vals.len() > 0...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [total_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.st...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [total_steps]: function definitions module public import Aeneas public import Aegis.TotalSteps.Code.Types public import Aegis.TotalSteps.Code.FunsExternal @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false s...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [total_steps]: external functions. -- This is a template file: rename it to "FunsExternal.lean" and fill the holes. module public import Aeneas public import Aegis.TotalSteps.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_opt...
import Aegis.TotalSteps.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval aegisCase ...
[ { "input": "[[1]]", "output": "0" }, { "input": "[[2, 1]]", "output": "1" }, { "input": "[[1, 2]]", "output": "0" }, { "input": "[[1, 3, 2]]", "output": "1" }, { "input": "[[4, 5, 7, 7, 13]]", "output": "0" }, { "input": "[[1000000000, 999999999, 99999...
129
false
129
verified
10
10
1
6,328
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.TotalSteps.Code.Funs /-! # Specifications of `Aegis.TotalSteps.total_steps` LeetCode problem `steps-to-make-array-non-decreasing`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.TotalSteps namespace AegisSpec.TotalSteps def nextAux : Std.I64 → ...
10
minimum-obstacle-removal-to-reach-corner
2,290
Hard
[ "Breadth-First Search", "Graph", "Array", "Matrix", "Shortest Path", "Heap (Priority Queue)" ]
You are given a 0-indexed 2D integer array grid of size m x n. Each cell has one of two values: 0 represents an empty cell, 1 represents an obstacle that may be removed. You can move up, down, left, or right from and to an empty cell. Return the minimum number of obstacles to remove so you can move from the upper lef...
minimumObstacles(grid: list_list_int) -> int
pub fn minimum_obstacles(grid: &[Vec<i64>]) -> i64
Aegis.MinimumObstacles.minimum_obstacles
fn relax( nr: usize, nc: usize, n: usize, d: i64, grid: &[Vec<i64>], dist: &mut Vec<i64>, cur: &mut Vec<i64>, next: &mut Vec<i64>, ) { let nidx = nr * n + nc; let cost = grid[nr][nc]; let nd = d + cost; if nd < dist[nidx] { dist[nidx] = nd; if cost == 0 { ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [minimum_obstacles]: type definitions module public import Aeneas @[expose] public section 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 -- [minimum_obstacles]: function definitions module public import Aeneas public import Aegis.MinimumObstacles.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.MinimumObstacles.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval aegi...
[ { "input": "[[[0, 1], [1, 0]]]", "output": "1" }, { "input": "[[[0, 0, 0], [0, 1, 0], [0, 0, 0]]]", "output": "0" }, { "input": "[[[0, 1, 1], [1, 1, 0], [1, 1, 0]]]", "output": "2" }, { "input": "[[[0, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 0]]]", "output": "4" }, { "i...
59
false
59
verified
10
10
2
12,710
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MinimumObstacles.Code.Funs /-! # Specifications of `Aegis.MinimumObstacles.minimum_obstacles` LeetCode problem `minimum-obstacle-removal-to-reach-corner`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.MinimumObstacles abbrev Grid := S...
13
maximum-profit-from-trading-stocks
2,291
Medium
[ "Array", "Dynamic Programming" ]
You are given two 0-indexed integer arrays of the same length present and future where present[i] is the current price of the ith stock and future[i] is the price of the ith stock a year in the future. You may buy each stock at most once. You are also given an integer budget representing the amount of money you current...
maximumProfit(present: list_int, future: list_int, budget: int) -> int
pub fn maximum_profit(present: &[i64], future: &[i64], budget: i64) -> i64
Aegis.MaximumProfit.maximum_profit
pub fn maximum_profit(present: &[i64], future: &[i64], budget: i64) -> i64 { let n = present.len(); let b = budget as usize; let mut dp: Vec<i64> = Vec::new(); let mut i: usize = 0; while i <= b { dp.push(0); i += 1; } let mut idx: usize = 0; while idx < n { let...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [maximum_profit]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [maximum_profit]: function definitions module public import Aeneas public import Aegis.MaximumProfit.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.MaximumProfit.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval aegisCa...
[ { "input": "[[10, 20, 30], [25, 35, 45], 50]", "output": "30" }, { "input": "[[100, 100, 100], [100, 100, 100], 200]", "output": "0" }, { "input": "[[100, 100, 100], [90, 90, 90], 300]", "output": "0" }, { "input": "[[2, 2, 5], [3, 4, 10], 6]", "output": "5" }, { ...
117
false
117
verified
10
10
1
3,084
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MaximumProfit.Code.Funs /-! # Specifications of `Aegis.MaximumProfit.maximum_profit` LeetCode problem `maximum-profit-from-trading-stocks`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.MaximumProfit def entry (s : Slice I64) (i :...
14
min-max-game
2,293
Easy
[ "Array", "Simulation" ]
You are given a 0-indexed integer array nums whose length is a power of 2. Apply the following algorithm on nums: Let n be the length of nums. If n == 1, end the process. Otherwise, create a new 0-indexed integer array newNums of length n / 2. For every even index i where 0 <= i < n / 2, assign the value of newNums[i]...
minMaxGame(nums: list_int) -> int
pub fn min_max_game(nums: &[i64]) -> i64
Aegis.MinMaxGame.min_max_game
pub fn min_max_game(nums: &[i64]) -> i64 { let mut cur: Vec<i64> = Vec::new(); let mut k: usize = 0; while k < nums.len() { cur.push(nums[k]); k += 1; } while cur.len() > 1 { let n: usize = cur.len(); let mut next: Vec<i64> = Vec::new(); let mut i: usize = 0;...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [min_max_game]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter.s...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [min_max_game]: function definitions module public import Aeneas public import Aegis.MinMaxGame.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.MinMaxGame.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": "[[3]]", "output": "3" }, { "input": "[[1024]]", "output": "1024" }, { "input": "[[1, 3, 5, 2, 4, 8, 2, 2]]", "output": "1" }, { "input": "[[1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000]]", "output": "1000000000...
93
false
93
verified
10
10
1
567
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MinMaxGame.Code.Funs /-! # Specifications of `Aegis.MinMaxGame.min_max_game` LeetCode problem `min-max-game`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.MinMaxGame namespace AegisSpec.MinMaxGame def valueAt (l : List Std.I64) (i : ℕ) (hi : ...
9
partition-array-such-that-maximum-difference-is-k
2,294
Medium
[ "Greedy", "Array", "Sorting" ]
You are given an integer array nums and an integer k. You may partition nums into one or more subsequences such that each element in nums appears in exactly one of the subsequences. Return the minimum number of subsequences needed such that the difference between the maximum and minimum values in each subsequence is at...
partitionArray(nums: list_int, k: int) -> int
pub fn partition_array(nums: &[i64], k: i64) -> i64
Aegis.PartitionArray.partition_array
pub fn partition_array(nums: &[i64], k: i64) -> i64 { let n: usize = nums.len(); if n == 0 { return 0; } // Copy the input into an owned vector so it can be sorted in place. let mut a: Vec<i64> = Vec::new(); let mut i: usize = 0; while i < n { a.push(nums[i]); i += 1...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [partition_array]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linte...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [partition_array]: function definitions module public import Aeneas public import Aegis.PartitionArray.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.PartitionArray.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval aegisC...
[ { "input": "[[1, 100000], 99999]", "output": "1" }, { "input": "[[1, 2, 3], 1]", "output": "2" }, { "input": "[[2, 2, 4, 5], 0]", "output": "3" }, { "input": "[[10, 20, 30, 40, 50], 10]", "output": "3" }, { "input": "[[5, 5, 5, 5, 5], 0]", "output": "1" }, ...
112
false
112
verified
10
10
2
3,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.PartitionArray.Code.Funs /-! # Specifications of `Aegis.PartitionArray.partition_array` LeetCode problem `partition-array-such-that-maximum-difference-is-k`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.PartitionArray (partition_array) namespa...
16
replace-elements-in-an-array
2,295
Medium
[ "Array", "Hash Table", "Simulation" ]
You are given a 0-indexed array nums that consists of n distinct positive integers. Apply m operations to this array, where in the ith operation you replace the number operations[i][0] with operations[i][1]. It is guaranteed that in the ith operation: operations[i][0] exists in nums. operations[i][1] does not exist in...
arrayChange(nums: list_int, operations: list_list_int) -> list_int
pub fn array_change(nums: &[i64], operations: &[Vec<i64>]) -> Vec<i64>
Aegis.ArrayChange.array_change
fn hash_index(x: i64, mask: usize) -> usize { (x as usize) & mask } pub fn array_change(nums: &[i64], operations: &[Vec<i64>]) -> Vec<i64> { let mut cap: usize = 1; let target: usize = operations.len() * 2 + 2; while cap < target { cap = cap * 2; } let mask: usize = cap - 1; let mu...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [array_change]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter.s...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [array_change]: function definitions module public import Aeneas public import Aegis.ArrayChange.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.ArrayChange.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, 100000], [[1, 50000], [100000, 99999]]]", "output": "[50000, 99999]" }, { "input": "[[1, 1000000], [[1, 2], [1000000, 1]]]", "output": "[2, 1]" }, { "input": "[[1, 2], [[1, 3], [2, 1], [3, 2]]]", "output": "[2, 1]" }, { "input": "[[100, 200, 300], [[100, 150]...
76
false
76
verified
10
10
2
20,405
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.ArrayChange.Code.Funs /-! # Specifications of `Aegis.ArrayChange.array_change` LeetCode problem `replace-elements-in-an-array`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.ArrayChange abbrev SliceI64 := Aeneas.Std.Slice Aeneas.S...
12
jump-game-viii
2,297
Medium
[ "Stack", "Graph", "Array", "Dynamic Programming", "Shortest Path", "Monotonic Stack" ]
You are given a 0-indexed integer array nums of length n. You are initially standing at index 0. You can jump from index i to index j where i < j if: nums[i] <= nums[j] and nums[k] < nums[i] for all indexes k in the range i < k < j, or nums[i] > nums[j] and nums[k] >= nums[i] for all indexes k in the range i < k < j. ...
minCost(nums: list_int, costs: list_int) -> int
pub fn min_cost(nums: &[i64], costs: &[i64]) -> i64
Aegis.MinCost.min_cost
pub fn min_cost(nums: &[i64], costs: &[i64]) -> i64 { let n = nums.len(); if n == 0 { return 0; } let mut next_ge: Vec<usize> = Vec::new(); let mut next_less: Vec<usize> = Vec::new(); let mut i = 0; while i < n { next_ge.push(n); next_less.push(n); i += 1; ...
-- 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 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": "[[0, 1, 2], [1, 1, 1]]", "output": "2" }, { "input": "[[1, 3, 5, 7], [2, 4, 6, 8]]", "output": "18" }, { "input": "[[5, 4, 3, 2, 1], [1, 1, 1, 1, 1]]", "output": "4" }, { "input": "[[10, 5, 15, 20, 25], [1, 2, 3, 4, 5]]", "output": "12" }, { "input": "...
115
false
115
verified
10
10
1
21,852
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": 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 `jump-game-viii`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.MinCost def sval (s : Slice Std.I64) (i : Nat) : Int := (s.val[i]!).val def ValidJump...
12
strong-password-checker-ii
2,299
Easy
[ "String" ]
A password is said to be strong if it satisfies all the following criteria: It has at least 8 characters. It contains at least one lowercase letter. It contains at least one uppercase letter. It contains at least one digit. It contains at least one special character. The special characters are the characters in the fo...
strongPasswordCheckerII(password: str) -> bool
pub fn strong_password_checker_ii(password: &[u8]) -> bool
Aegis.StrongPasswordCheckerIi.strong_password_checker_ii
pub fn strong_password_checker_ii(password: &[u8]) -> bool { let n = password.len(); if n < 8 { return false; } let mut has_lower = false; let mut has_upper = false; let mut has_digit = false; let mut has_special = false; let mut i: usize = 0; while i < n { let c = ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [strong_password_checker_ii]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_o...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [strong_password_checker_ii]: function definitions module public import Aeneas public import Aegis.StrongPasswordCheckerIi.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hash...
import Aegis.StrongPasswordCheckerIi.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}" #ev...
[ { "input": "[\"OneSpecialChar@\"]", "output": "false" }, { "input": "[\"EndsWithSpecialChar!\"]", "output": "false" }, { "input": "[\"ValidPass1@\"]", "output": "false" }, { "input": "[\"lowercaseonly\"]", "output": "false" }, { "input": "[\"Short!1A\"]", "out...
67
false
67
verified
10
10
1
1,225
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.StrongPasswordCheckerIi.Code.Funs /-! # Specifications of `Aegis.StrongPasswordCheckerIi.strong_password_checker_ii` LeetCode problem `strong-password-checker-ii`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.StrongPasswordCheckerIi namesp...
7
successful-pairs-of-spells-and-potions
2,300
Medium
[ "Array", "Two Pointers", "Binary Search", "Sorting" ]
You are given two positive integer arrays spells and potions, of length n and m respectively, where spells[i] represents the strength of the ith spell and potions[j] represents the strength of the jth potion. You are also given an integer success. A spell and potion pair is considered successful if the product of their...
successfulPairs(spells: list_int, potions: list_int, success: int) -> list_int
pub fn successful_pairs(spells: &[i64], potions: &[i64], success: i64) -> Vec<i64>
Aegis.SuccessfulPairs.successful_pairs
pub fn successful_pairs(spells: &[i64], potions: &[i64], success: i64) -> Vec<i64> { let m = potions.len(); let mut sorted: Vec<i64> = Vec::new(); let mut i: usize = 0; while i < m { sorted.push(potions[i]); i += 1; } sorted = merge_sort(sorted); let mut result: Vec<i64> =...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [successful_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 lint...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [successful_pairs]: function definitions module public import Aeneas public import Aegis.SuccessfulPairs.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.SuccessfulPairs.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval aegis...
[ { "input": "[[100000], [100000], 10000000000]", "output": "[1]" }, { "input": "[[3, 1, 2], [8, 5, 8], 16]", "output": "[2, 0, 2]" }, { "input": "[[1, 1, 1], [1, 1, 1], 2]", "output": "[0, 0, 0]" }, { "input": "[[100000, 100000, 100000], [100000, 100000, 100000], 10000000000]"...
96
false
96
verified
10
10
1
6,933
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.SuccessfulPairs.Code.Funs /-! # Specifications of `Aegis.SuccessfulPairs.successful_pairs` LeetCode problem `successful-pairs-of-spells-and-potions`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.SuccessfulPairs def sliceInts (s : Sli...
9
count-subarrays-with-score-less-than-k
2,302
Hard
[ "Array", "Binary Search", "Prefix Sum", "Sliding Window" ]
The score of an array is defined as the product of its sum and its length. For example, the score of [1, 2, 3, 4, 5] is (1 + 2 + 3 + 4 + 5) * 5 = 75. Given a positive integer array nums and an integer k, return the number of non-empty subarrays of nums whose score is strictly less than k. A subarray is a contiguous s...
countSubarrays(nums: list_int, k: int) -> int
pub fn count_subarrays(nums: &[i64], k: i64) -> i64
Aegis.CountSubarrays.count_subarrays
pub fn count_subarrays(nums: &[i64], k: i64) -> i64 { let n = nums.len(); let mut ans: i64 = 0; let mut left: usize = 0; let mut right: usize = 0; let mut sum: i64 = 0; let mut len: i64 = 0; while right < n { sum = sum + nums[right]; len = len + 1; while len > 0 && ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [count_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 linte...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [count_subarrays]: function definitions module public import Aeneas public import Aegis.CountSubarrays.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.CountSubarrays.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval aegisC...
[ { "input": "[[1], 2]", "output": "1" }, { "input": "[[10, 10, 10], 100]", "output": "6" }, { "input": "[[1, 1, 1], 5]", "output": "5" }, { "input": "[[10, 20, 30], 100]", "output": "4" }, { "input": "[[5, 5, 5, 5], 20]", "output": "4" }, { "input": "[[...
79
false
79
verified
10
10
1
2,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.CountSubarrays.Code.Funs /-! # Specifications of `Aegis.CountSubarrays.count_subarrays` LeetCode problem `count-subarrays-with-score-less-than-k`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.CountSubarrays def sliceVals (nums : Slic...
15
minimum-path-cost-in-a-grid
2,304
Medium
[ "Array", "Dynamic Programming", "Matrix" ]
You are given a 0-indexed m x n integer matrix grid consisting of distinct integers from 0 to m * n - 1. You can move in this matrix from a cell to any other cell in the next row. That is, if you are in cell (x, y) such that x < m - 1, you can move to any of the cells (x + 1, 0), (x + 1, 1), ..., (x + 1, n - 1). Note t...
minPathCost(grid: list_list_int, moveCost: list_list_int) -> int
pub fn min_path_cost(grid: &[Vec<i64>], moveCost: &[Vec<i64>]) -> i64
Aegis.MinPathCost.min_path_cost
pub fn min_path_cost(grid: &[Vec<i64>], moveCost: &[Vec<i64>]) -> i64 { let m = grid.len(); if m == 0 { return 0; } let n = grid[0].len(); if n == 0 { return 0; } let mut prev: Vec<i64> = Vec::new(); let mut j = 0; while j < n { prev.push(grid[0][j]); ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [min_path_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....
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [min_path_cost]: function definitions module public import Aeneas public import Aegis.MinPathCost.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.MinPathCost.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval aegisCase...
[ { "input": "[[[0, 1], [2, 3]], [[9, 8], [1, 5], [10, 12], [18, 6]]]", "output": "4" }, { "input": "[[[5, 3], [4, 0], [2, 1]], [[9, 8], [1, 5], [10, 12], [18, 6], [2, 4], [14, 3]]]", "output": "17" }, { "input": "[[[1, 2, 3], [4, 5, 6]], [[1, 2, 3], [4, 5, 6], [7, 8, 9], [10, 11, 12], [13...
28
false
28
verified
10
10
1
1,070
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MinPathCost.Code.Funs /-! # Specifications of `Aegis.MinPathCost.min_path_cost` LeetCode problem `minimum-path-cost-in-a-grid`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.MinPathCost abbrev Mat : Type := List (List Int) def ...
8
fair-distribution-of-cookies
2,305
Medium
[ "Bit Manipulation", "Array", "Dynamic Programming", "Backtracking", "Bitmask" ]
You are given an integer array cookies, where cookies[i] denotes the number of cookies in the ith bag. You are also given an integer k that denotes the number of children to distribute all the bags of cookies to. All the cookies in the same bag must go to the same child and cannot be split up. The unfairness of a distr...
distributeCookies(cookies: list_int, k: int) -> int
pub fn distribute_cookies(cookies: &[i64], k: i64) -> i64
Aegis.DistributeCookies.distribute_cookies
pub fn distribute_cookies(cookies: &[i64], k: i64) -> i64 { let n: usize = cookies.len(); let kk: usize = k as usize; let mut size: usize = 1; let mut z: usize = 0; while z < n { size *= 2; z += 1; } let mut sums: Vec<i64> = Vec::new(); let mut mask: usize = 0; whil...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [distribute_cookies]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option li...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [distribute_cookies]: function definitions module public import Aeneas public import Aegis.DistributeCookies.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false ...
import Aegis.DistributeCookies.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval aeg...
[ { "input": "[[8, 15, 10, 20, 8], 2]", "output": "31" }, { "input": "[[1, 1, 1, 1, 1, 1, 1, 100000], 7]", "output": "100000" }, { "input": "[[100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000], 8]", "output": "100000" }, { "input": "[[1, 100000, 1, 1, 1, 1, 1, 1],...
104
false
104
verified
10
10
1
4,862
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.DistributeCookies.Code.Funs /-! # Specifications of `Aegis.DistributeCookies.distribute_cookies` LeetCode problem `fair-distribution-of-cookies`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.DistributeCookies def vals (cookies : ...
16
sum-of-numbers-with-units-digit-k
2,310
Medium
[ "Greedy", "Math", "Dynamic Programming", "Enumeration" ]
Given two integers num and k, consider a set of positive integers with the following properties: The units digit of each integer is k. The sum of the integers is num. Return the minimum possible size of such a set, or -1 if no such set exists. Note: The set can contain multiple instances of the same integer, and the...
minimumNumbers(num: int, k: int) -> int
pub fn minimum_numbers(num: i64, k: i64) -> i64
Aegis.MinimumNumbers.minimum_numbers
pub fn minimum_numbers(num: i64, k: i64) -> i64 { if num == 0 { return 0; } if k == 0 { if num < 10 || num % 10 != 0 { return -1; } return 1; } let mut n: i64 = 1; while n <= 10 { if num >= n * k && (num - n * k) % 10 == 0 { retur...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [minimum_numbers]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linte...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [minimum_numbers]: function definitions module public import Aeneas public import Aegis.MinimumNumbers.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.MinimumNumbers.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval aegisC...
[ { "input": "[25, 5]", "output": "1" }, { "input": "[2023, 3]", "output": "1" }, { "input": "[37, 2]", "output": "-1" }, { "input": "[100, 0]", "output": "1" }, { "input": "[58, 9]", "output": "2" }, { "input": "[99, 9]", "output": "1" }, { ...
114
false
114
verified
10
10
1
1,590
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MinimumNumbers.Code.Funs /-! # Specifications of `Aegis.MinimumNumbers.minimum_numbers` LeetCode problem `sum-of-numbers-with-units-digit-k`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.MinimumNumbers def IsCandidateMultiset (num ...
12
count-asterisks
2,315
Easy
[ "String" ]
You are given a string s, where every two consecutive vertical bars '|' are grouped into a pair. In other words, the 1st and 2nd '|' make a pair, the 3rd and 4th '|' make a pair, and so forth. Return the number of '*' in s, excluding the '*' between each pair of '|'. Note that each '|' will belong to exactly one pair. ...
countAsterisks(s: str) -> int
pub fn count_asterisks(s: &[u8]) -> i64
Aegis.CountAsterisks.count_asterisks
pub fn count_asterisks(s: &[u8]) -> i64 { let mut count: i64 = 0; let mut inside: bool = false; let mut i: usize = 0; while i < s.len() { let c = s[i]; if c == b'|' { inside = !inside; } else if c == b'*' { if !inside { count += 1; ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [count_asterisks]: type definitions module public import Aeneas @[expose] public section 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_asterisks]: function definitions module public import Aeneas public import Aegis.CountAsterisks.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.CountAsterisks.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval aegisC...
[ { "input": "[\"iamprogrammer\"]", "output": "0" }, { "input": "[\"|*|*|*|*|\"]", "output": "2" }, { "input": "[\"||||||||||\"]", "output": "0" }, { "input": "[\"yo|uar|e**|b|e***au|tifu|l\"]", "output": "5" }, { "input": "[\"l|*e*et|c**o|*de|\"]", "output": "2...
106
false
106
verified
10
10
1
302
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.CountAsterisks.Code.Funs /-! # Specifications of `Aegis.CountAsterisks.count_asterisks` LeetCode problem `count-asterisks`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.CountAsterisks def byteAt (s : Slice Std.U8) (i : ℕ) : Optio...
10
count-unreachable-pairs-of-nodes-in-an-undirected-graph
2,316
Medium
[ "Depth-First Search", "Breadth-First Search", "Union Find", "Graph" ]
You are given an integer n. There is an undirected graph with n nodes, numbered from 0 to n - 1. You are given a 2D integer array edges where edges[i] = [ai, bi] denotes that there exists an undirected edge connecting nodes ai and bi. Return the number of pairs of different nodes that are unreachable from each other.  ...
countPairs(n: int, edges: list_list_int) -> int
pub fn count_pairs(n: i64, edges: &[Vec<i64>]) -> i64
Aegis.CountPairs.count_pairs
pub fn count_pairs(n: i64, edges: &[Vec<i64>]) -> i64 { let nu: usize = n as usize; // parent[i] < 0 means i is a root and -parent[i] is the component size. // parent[i] >= 0 means the parent of i. let mut parent: Vec<i64> = Vec::new(); let mut i: usize = 0; while i < nu { parent.push(-...
-- 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 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": "[6, []]", "output": "15" }, { "input": "[4, []]", "output": "6" }, { "input": "[1, []]", "output": "0" }, { "input": "[10, []]", "output": "45" }, { "input": "[100, []]", "output": "4950" }, { "input": "[5, [[0, 1], [2, 3]]]", "output":...
55
false
55
verified
10
10
1
2,721
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.CountPairs.Code.Funs /-! # Specifications of `Aegis.CountPairs.count_pairs` LeetCode problem `count-unreachable-pairs-of-nodes-in-an-undirected-graph`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.CountPairs noncomputable section at...
12
maximum-xor-after-operations
2,317
Medium
[ "Bit Manipulation", "Array", "Math" ]
You are given a 0-indexed integer array nums. In one operation, select any non-negative integer x and an index i, then update nums[i] to be equal to nums[i] AND (nums[i] XOR x). Note that AND is the bitwise AND operation and XOR is the bitwise XOR operation. Return the maximum possible bitwise XOR of all elements of nu...
maximumXOR(nums: list_int) -> int
pub fn maximum_xor(nums: &[i64]) -> i64
Aegis.MaximumXor.maximum_xor
pub fn maximum_xor(nums: &[i64]) -> i64 { let mut result: i64 = 0; let mut i: usize = 0; while i < nums.len() { result = result | nums[i]; i = i + 1; } result }
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [maximum_xor]: type definitions module public import Aeneas @[expose] public section 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 -- [maximum_xor]: function definitions module public import Aeneas public import Aegis.MaximumXor.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.MaximumXor.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": "[[1073741824]]", "output": "1073741824" }, { "input": "[[1, 0, 3, 2]]", "output": "3" }, { "input": "[[1, 1, 1, 1]]", "output": "1" }, { "input": "[[3, 2, 4, 6]]", "output": "7" }, { "input": "[[0, 0, 0, 0]]", "output": "0" }, { "input": "[...
116
false
116
verified
10
10
1
403
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MaximumXor.Code.Funs import Mathlib.Data.Int.Bitwise /-! # Specifications of `Aegis.MaximumXor.maximum_xor` LeetCode problem `maximum-xor-after-operations`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result ControlFlow Error namespace AegisSpec.MaximumXor de...
10
number-of-distinct-roll-sequences
2,318
Hard
[ "Memoization", "Dynamic Programming" ]
You are given an integer n. You roll a fair 6-sided dice n times. Determine the total number of distinct sequences of rolls possible such that the following conditions are satisfied: The greatest common divisor of any adjacent values in the sequence is equal to 1. There is at least a gap of 2 rolls between equal value...
distinctSequences(n: int) -> int
pub fn distinct_sequences(n: i64) -> i64
Aegis.DistinctSequences.distinct_sequences
const MOD: i64 = 1000000007; fn gcd(mut a: i64, mut b: i64) -> i64 { while b != 0 { let t = a % b; a = b; b = t; } a } pub fn distinct_sequences(n: i64) -> i64 { if n <= 0 { return 0; } if n == 1 { return 6; } // dp[a * 6 + b] = number of valid ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [distinct_sequences]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option li...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [distinct_sequences]: function definitions module public import Aeneas public import Aegis.DistinctSequences.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false ...
import Aegis.DistinctSequences.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval aeg...
[ { "input": "[3]", "output": "66" }, { "input": "[100]", "output": "534856607" }, { "input": "[4]", "output": "184" }, { "input": "[10000]", "output": "874574246" }, { "input": "[2]", "output": "22" }, { "input": "[1]", "output": "6" }, { "i...
21
false
21
verified
10
10
2
5,415
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.DistinctSequences.Code.Funs /-! # Specifications of `Aegis.DistinctSequences.distinct_sequences` LeetCode problem `number-of-distinct-roll-sequences`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.DistinctSequences open Classical def...
10
check-if-matrix-is-x-matrix
2,319
Easy
[ "Array", "Matrix" ]
A square matrix is said to be an X-Matrix if both of the following conditions hold: All the elements in the diagonals of the matrix are non-zero. All other elements are 0. Given a 2D integer array grid of size n x n representing a square matrix, return true if grid is an X-Matrix. Otherwise, return false.   Example 1...
checkXMatrix(grid: list_list_int) -> bool
pub fn check_x_matrix(grid: &[Vec<i64>]) -> bool
Aegis.CheckXMatrix.check_x_matrix
pub fn check_x_matrix(grid: &[Vec<i64>]) -> bool { let n = grid.len(); let mut ok: bool = true; let mut i: usize = 0; while i < n { let mut j: usize = 0; while j < n { let mut is_diagonal: bool = false; if i == j { is_diagonal = true; ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [check_x_matrix]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [check_x_matrix]: function definitions module public import Aeneas public import Aegis.CheckXMatrix.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.CheckXMatrix.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval aegisCas...
[ { "input": "[[[5, 7, 0], [0, 3, 1], [0, 5, 0]]]", "output": "false" }, { "input": "[[[1, 2, 3], [4, 5, 6], [7, 8, 9]]]", "output": "false" }, { "input": "[[[0, 1, 0], [1, 2, 1], [0, 1, 0]]]", "output": "false" }, { "input": "[[[1, 0, 0], [0, 1, 0], [0, 0, 1]]]", "output":...
70
false
70
verified
10
10
3
2,632
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.CheckXMatrix.Code.Funs /-! # Specifications of `Aegis.CheckXMatrix.check_x_matrix` LeetCode problem `check-if-matrix-is-x-matrix`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.CheckXMatrix def rowVals (grid : Slice (alloc.vec.Vec Std...
6
count-number-of-ways-to-place-houses
2,320
Medium
[ "Dynamic Programming" ]
There is a street with n * 2 plots, where there are n plots on each side of the street. The plots on each side are numbered from 1 to n. On each plot, a house can be placed. Return the number of ways houses can be placed such that no two houses are adjacent to each other on the same side of the street. Since the answer...
countHousePlacements(n: int) -> int
pub fn count_house_placements(n: i64) -> i64
Aegis.CountHousePlacements.count_house_placements
pub fn count_house_placements(n: i64) -> i64 { let modulo: i64 = 1_000_000_007; // ways(0) = 1, ways(1) = 2 // ways(k) = ways(k-1) + ways(k-2) let mut prev: i64 = 1; let mut cur: i64 = 2; let mut i: i64 = 1; while i < n { let next = (prev + cur) % modulo; prev = cur; ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [count_house_placements]: type definitions module public import Aeneas @[expose] public 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 -- [count_house_placements]: function definitions module public import Aeneas public import Aegis.CountHousePlacements.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand...
import Aegis.CountHousePlacements.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval ...
[ { "input": "[3]", "output": "25" }, { "input": "[100]", "output": "20522904" }, { "input": "[10000]", "output": "402613600" }, { "input": "[2]", "output": "9" }, { "input": "[1]", "output": "4" }, { "input": "[1000]", "output": "500478595" }, {...
33
false
33
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.CountHousePlacements.Code.Funs /-! # Specifications of `Aegis.CountHousePlacements.count_house_placements` LeetCode problem `count-number-of-ways-to-place-houses`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.CountHousePlacements def...
6
minimum-score-after-removals-on-a-tree
2,322
Hard
[ "Bit Manipulation", "Tree", "Depth-First Search", "Array" ]
There is an undirected connected tree with n nodes labeled from 0 to n - 1 and n - 1 edges. You are given a 0-indexed integer array nums of length n where nums[i] represents the value of the ith node. You are also given a 2D integer array edges of length n - 1 where edges[i] = [ai, bi] indicates that there is an edge b...
minimumScore(nums: list_int, edges: list_list_int) -> int
pub fn minimum_score(nums: &[i64], edges: &[Vec<i64>]) -> i64
Aegis.MinimumScore.minimum_score
pub fn minimum_score(nums: &[i64], edges: &[Vec<i64>]) -> i64 { let n = nums.len(); // Build adjacency list. let mut adj: Vec<Vec<i64>> = Vec::new(); let mut i = 0; while i < n { adj.push(Vec::new()); i += 1; } let mut e = 0; while e < edges.len() { let edge = &...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [minimum_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....
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [minimum_score]: function definitions module public import Aeneas public import Aegis.MinimumScore.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.MinimumScore.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval aegisCas...
[ { "input": "[[1, 5, 5, 4, 11], [[0, 1], [1, 2], [1, 3], [3, 4]]]", "output": "9" }, { "input": "[[10, 20, 30, 40, 50], [[0, 1], [0, 2], [0, 3], [3, 4]]]", "output": "4" }, { "input": "[[10, 20, 30, 40, 50], [[0, 1], [1, 2], [2, 3], [3, 4]]]", "output": "4" }, { "input": "[[1,...
55
false
55
verified
10
10
1
10,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.MinimumScore.Code.Funs /-! # Specifications of `Aegis.MinimumScore.minimum_score` LeetCode problem `minimum-score-after-removals-on-a-tree`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.MinimumScore open Aegis.MinimumScore (minimum...
9
find-minimum-time-to-finish-all-jobs-ii
2,323
Medium
[ "Greedy", "Array", "Sorting" ]
You are given two 0-indexed integer arrays jobs and workers of equal length, where jobs[i] is the amount of time needed to complete the ith job, and workers[j] is the amount of time the jth worker can work each day. Each job should be assigned to exactly one worker, such that each worker completes exactly one job. Retu...
minimumTime(jobs: list_int, workers: list_int) -> int
pub fn minimum_time(jobs: &[i64], workers: &[i64]) -> i64
Aegis.MinimumTime.minimum_time
fn min_usize(a: usize, b: usize) -> usize { if a < b { a } else { b } } fn sorted_copy(xs: &[i64]) -> Vec<i64> { let n = xs.len(); let mut a: Vec<i64> = Vec::new(); let mut i: usize = 0; while i < n { a.push(xs[i]); i += 1; } if n <= 1 { retu...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [minimum_time]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter.s...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [minimum_time]: function definitions module public import Aeneas public import Aegis.MinimumTime.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.MinimumTime.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": "[[100, 200, 300], [10, 20, 30]]", "output": "10" }, { "input": "[[5, 2, 4], [1, 7, 5]]", "output": "2" }, { "input": "[[100000, 100000, 100000], [1, 1, 1]]", "output": "100000" }, { "input": "[[10, 20, 30], [5, 10, 15]]", "output": "2" }, { "input": "[...
89
false
89
verified
10
10
1
3,741
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MinimumTime.Code.Funs /-! # Specifications of `Aegis.MinimumTime.minimum_time` LeetCode problem `find-minimum-time-to-finish-all-jobs-ii`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.MinimumTime def valAt (xs : Slice Std.I64) (n : N...
9
spiral-matrix-iv
2,326
Medium
[ "Array", "Linked List", "Matrix", "Simulation" ]
You are given two integers m and n, which represent the dimensions of a matrix. You are also given the head of a linked list of integers. Generate an m x n matrix that contains the integers in the linked list presented in spiral order (clockwise), starting from the top-left of the matrix. If there are remaining empty s...
spiralMatrix(m: int, n: int, head: linkedlist) -> list_list_int
pub fn spiral_matrix(m: i64, n: i64, head: &List) -> Vec<Vec<i64>>
Aegis.SpiralMatrix.spiral_matrix
fn collect_rev(l: &List) -> Vec<i64> { match l { List::Nil => Vec::new(), List::Cons(v, next) => { let mut r: Vec<i64> = collect_rev(&**next); r.push(*v); r } } } pub fn spiral_matrix(m: i64, n: i64, head: &List) -> Vec<Vec<i64>> { let rows: usize...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [spiral_matrix]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter....
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [spiral_matrix]: function definitions module public import Aeneas public import Aegis.SpiralMatrix.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.SpiralMatrix.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval aegisCas...
[ { "input": "[1, 1, [999]]", "output": "[[999]]" }, { "input": "[2, 2, [1]]", "output": "[[1, -1], [-1, -1]]" }, { "input": "[2, 2, [1, 2]]", "output": "[[1, 2], [-1, -1]]" }, { "input": "[2, 2, [1, 2, 3]]", "output": "[[1, 2], [-1, 3]]" }, { "input": "[1, 4, [0, 1...
100
false
100
verified
10
10
2
32,236
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.SpiralMatrix.Code.Funs /-! # Specifications of `Aegis.SpiralMatrix.spiral_matrix` LeetCode problem `spiral-matrix-iv`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.SpiralMatrix def nth? {α : Type} : List α → Nat → Option α | [], _ ...
2
number-of-people-aware-of-a-secret
2,327
Medium
[ "Queue", "Dynamic Programming", "Simulation" ]
On day 1, one person discovers a secret. You are given an integer delay, which means that each person will share the secret with a new person every day, starting from delay days after discovering the secret. You are also given an integer forget, which means that each person will forget the secret forget days after disc...
peopleAwareOfSecret(n: int, delay: int, forget: int) -> int
pub fn people_aware_of_secret(n: i64, delay: i64, forget: i64) -> i64
Aegis.PeopleAwareOfSecret.people_aware_of_secret
pub fn people_aware_of_secret(n: i64, delay: i64, forget: i64) -> i64 { const MOD: i64 = 1000000007; let n_usize = n as usize; let mut new_people: Vec<i64> = Vec::new(); let mut i: usize = 0; while i <= n_usize + 1 { new_people.push(0); i += 1; } if n_usize >= 1 { ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [people_aware_of_secret]: type definitions module public import Aeneas @[expose] public 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 -- [people_aware_of_secret]: function definitions module public import Aeneas public import Aegis.PeopleAwareOfSecret.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand ...
import Aegis.PeopleAwareOfSecret.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": "[8, 3, 6]", "output": "6" }, { "input": "[500, 100, 400]", "output": "5820125" }, { "input": "[4, 1, 3]", "output": "6" }, { "input": "[1000, 5, 10]", "output": "743819361" }, { "input": "[1000, 1, 999]", "output": "344211603" }, { "input":...
96
false
96
verified
10
10
1
3,992
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.PeopleAwareOfSecret.Code.Funs /-! # Specifications of `Aegis.PeopleAwareOfSecret.people_aware_of_secret` LeetCode problem `number-of-people-aware-of-a-secret`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.PeopleAwareOfSecret def spec...
12
number-of-increasing-paths-in-a-grid
2,328
Hard
[ "Depth-First Search", "Breadth-First Search", "Graph", "Topological Sort", "Memoization", "Array", "Dynamic Programming", "Matrix" ]
You are given an m x n integer matrix grid, where you can move from a cell to any adjacent cell in all 4 directions. Return the number of strictly increasing paths in the grid such that you can start from any cell and end at any cell. Since the answer may be very large, return it modulo 109 + 7. Two paths are considere...
countPaths(grid: list_list_int) -> int
pub fn count_paths(grid: &[Vec<i64>]) -> i64
Aegis.CountPaths.count_paths
pub fn count_paths(grid: &[Vec<i64>]) -> i64 { let m = grid.len(); if m == 0 { return 0; } let n = grid[0].len(); if n == 0 { return 0; } let total = m * n; let modulo: i64 = 1000000007; let mut dp: Vec<i64> = Vec::new(); let mut i = 0; while i < total { ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [count_paths]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter.st...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [count_paths]: function definitions module public import Aeneas public import Aegis.CountPaths.Code.Types public import Aegis.CountPaths.Code.FunsExternal @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false s...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [count_paths]: external functions. -- This is a template file: rename it to "FunsExternal.lean" and fill the holes. module public import Aeneas public import Aegis.CountPaths.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_opt...
import Aegis.CountPaths.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval aegisCase ...
[ { "input": "[[[1]]]", "output": "1" }, { "input": "[[[10]]]", "output": "1" }, { "input": "[[[1], [2]]]", "output": "3" }, { "input": "[[[1, 1], [3, 4]]]", "output": "8" }, { "input": "[[[4, 3, 2, 1], [5, 6, 7, 8]]]", "output": "50" }, { "input": "[[[1...
88
false
88
verified
10
10
1
8,636
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.CountPaths.Code.Funs /-! # Specifications of `Aegis.CountPaths.count_paths` LeetCode problem `number-of-increasing-paths-in-a-grid`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.CountPaths namespace AegisSpec.CountPaths def gridVals (gr...
12
valid-palindrome-iv
2,330
Medium
[ "Two Pointers", "String" ]
You are given a 0-indexed string s consisting of only lowercase English letters. In one operation, you can change any character of s to any other character. Return true if you can make s a palindrome after performing exactly one or two operations, or return false otherwise.   Example 1: Input: s = "abcdba" Output: tru...
makePalindrome(s: str) -> bool
pub fn make_palindrome(s: &[u8]) -> bool
Aegis.MakePalindrome.make_palindrome
pub fn make_palindrome(s: &[u8]) -> bool { let n = s.len(); let mut mismatches: i64 = 0; let mut i: usize = 0; while i < n / 2 { if s[i] != s[n - 1 - i] { mismatches += 1; } i += 1; } mismatches <= 2 }
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [make_palindrome]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linte...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [make_palindrome]: function definitions module public import Aeneas public import Aegis.MakePalindrome.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.MakePalindrome.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval aegisC...
[ { "input": "[\"abcba\"]", "output": "true" }, { "input": "[\"abcdef\"]", "output": "false" }, { "input": "[\"abcdedcba\"]", "output": "true" }, { "input": "[\"abcdba\"]", "output": "true" }, { "input": "[\"a\"]", "output": "true" }, { "input": "[\"abcd...
141
false
141
verified
10
10
1
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.MakePalindrome.Code.Funs /-! # Specifications of `Aegis.MakePalindrome.make_palindrome` LeetCode problem `valid-palindrome-iv`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.MakePalindrome namespace AegisSpec.MakePalindrome def len (s : Slice ...
11
the-latest-time-to-catch-a-bus
2,332
Medium
[ "Array", "Two Pointers", "Binary Search", "Sorting" ]
You are given a 0-indexed integer array buses of length n, where buses[i] represents the departure time of the ith bus. You are also given a 0-indexed integer array passengers of length m, where passengers[j] represents the arrival time of the jth passenger. All bus departure times are unique. All passenger arrival tim...
latestTimeCatchTheBus(buses: list_int, passengers: list_int, capacity: int) -> int
pub fn latest_time_catch_the_bus(buses: &[i64], passengers: &[i64], capacity: i64) -> i64
Aegis.LatestTimeCatchTheBus.latest_time_catch_the_bus
pub fn latest_time_catch_the_bus(buses: &[i64], passengers: &[i64], capacity: i64) -> i64 { let mut bs: Vec<i64> = Vec::new(); let mut i: usize = 0; while i < buses.len() { bs.push(buses[i]); i += 1; } sort_i64(&mut bs); let mut ps: Vec<i64> = Vec::new(); i = 0; while i ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [latest_time_catch_the_bus]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_op...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [latest_time_catch_the_bus]: function definitions module public import Aeneas public import Aegis.LatestTimeCatchTheBus.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCom...
import Aegis.LatestTimeCatchTheBus.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval...
[ { "input": "[[100], [99], 1]", "output": "98" }, { "input": "[[100], [10], 1]", "output": "9" }, { "input": "[[10, 20], [2, 17, 18, 19], 2]", "output": "16" }, { "input": "[[100, 200], [99, 101, 102, 103], 2]", "output": "100" }, { "input": "[[3, 5, 7], [2, 4, 6, ...
93
false
93
verified
10
10
1
8,195
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.LatestTimeCatchTheBus.Code.Funs /-! # Specifications of `Aegis.LatestTimeCatchTheBus.latest_time_catch_the_bus` LeetCode problem `the-latest-time-to-catch-a-bus`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std namespace AegisSpec.LatestTimeCatchTheBus def elems ...
16
minimum-sum-of-squared-difference
2,333
Medium
[ "Greedy", "Array", "Binary Search", "Sorting", "Heap (Priority Queue)" ]
You are given two positive 0-indexed integer arrays nums1 and nums2, both of length n. The sum of squared difference of arrays nums1 and nums2 is defined as the sum of (nums1[i] - nums2[i])2 for each 0 <= i < n. You are also given two positive integers k1 and k2. You can modify any of the elements of nums1 by +1 or -1 ...
minSumSquareDiff(nums1: list_int, nums2: list_int, k1: int, k2: int) -> int
pub fn min_sum_square_diff(nums1: &[i64], nums2: &[i64], k1: i64, k2: i64) -> i64
Aegis.MinSumSquareDiff.min_sum_square_diff
pub fn min_sum_square_diff(nums1: &[i64], nums2: &[i64], k1: i64, k2: i64) -> i64 { let n = nums1.len(); if n == 0 { return 0; } let mut diffs: Vec<i64> = Vec::new(); let mut max_diff: i64 = 0; let mut total_diff: i64 = 0; let mut i: usize = 0; while i < n { let mut d =...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [min_sum_square_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 l...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [min_sum_square_diff]: function definitions module public import Aeneas public import Aegis.MinSumSquareDiff.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false ...
import Aegis.MinSumSquareDiff.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval aegi...
[ { "input": "[[100000, 100000], [0, 0], 100000, 100000]", "output": "0" }, { "input": "[[1, 2, 3], [3, 2, 1], 3, 3]", "output": "0" }, { "input": "[[1, 2, 3], [3, 2, 1], 10, 10]", "output": "0" }, { "input": "[[1, 2, 3], [3, 2, 1], 2, 2]", "output": "0" }, { "input...
116
false
116
verified
10
10
2
22,969
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MinSumSquareDiff.Code.Funs /-! # Specifications of `Aegis.MinSumSquareDiff.min_sum_square_diff` LeetCode problem `minimum-sum-of-squared-difference`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.MinSumSquareDiff open Aegis.MinSum...
17
minimum-amount-of-time-to-fill-cups
2,335
Easy
[ "Greedy", "Array", "Sorting", "Heap (Priority Queue)" ]
You have a water dispenser that can dispense cold, warm, and hot water. Every second, you can either fill up 2 cups with different types of water, or 1 cup of any type of water. You are given a 0-indexed integer array amount of length 3 where amount[0], amount[1], and amount[2] denote the number of cold, warm, and hot ...
fillCups(amount: list_int) -> int
pub fn fill_cups(amount: &[i64]) -> i64
Aegis.FillCups.fill_cups
pub fn fill_cups(amount: &[i64]) -> i64 { let a = amount[0]; let b = amount[1]; let c = amount[2]; let total = a + b + c; let mut max_amount = a; if b > max_amount { max_amount = b; } if c > max_amount { max_amount = c; } let half_ceiling = (total + 1) / 2; ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [fill_cups]: type definitions module public import Aeneas @[expose] public section 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 -- [fill_cups]: function definitions module public import Aeneas public import Aegis.FillCups.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.FillCups.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 "e...
[ { "input": "[[33, 33, 34]]", "output": "50" }, { "input": "[[0, 0, 0]]", "output": "0" }, { "input": "[[99, 1, 1]]", "output": "99" }, { "input": "[[7, 7, 7]]", "output": "11" }, { "input": "[[10, 10, 10]]", "output": "15" }, { "input": "[[1, 2, 3]]", ...
178
false
178
verified
10
10
1
451
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.FillCups.Code.Funs /-! # Specifications of `Aegis.FillCups.fill_cups` LeetCode problem `minimum-amount-of-time-to-fill-cups`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.FillCups def entry (l : List Aeneas.Std.I64) (i : Nat) : ℤ...
11
count-the-number-of-ideal-arrays
2,338
Hard
[ "Math", "Dynamic Programming", "Combinatorics", "Number Theory" ]
You are given two integers n and maxValue, which are used to describe an ideal array. A 0-indexed integer array arr of length n is considered ideal if the following conditions hold: Every arr[i] is a value from 1 to maxValue, for 0 <= i < n. Every arr[i] is divisible by arr[i - 1], for 0 < i < n. Return the number of...
idealArrays(n: int, maxValue: int) -> int
pub fn ideal_arrays(n: i64, maxValue: i64) -> i64
Aegis.IdealArrays.ideal_arrays
const MOD: i64 = 1_000_000_007; pub fn ideal_arrays(n: i64, maxValue: i64) -> i64 { let m: usize = maxValue as usize; let n_usize: usize = n as usize; let max_k: usize = 20; let kk: usize = if n_usize < max_k { n_usize } else { max_k }; let mut prev: Vec<i64> = Vec::new(); let mut i: usize = 0...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [ideal_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.s...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [ideal_arrays]: function definitions module public import Aeneas public import Aegis.IdealArrays.Code.Types public import Aegis.IdealArrays.Code.FunsExternal @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace fals...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [ideal_arrays]: external functions. -- This is a template file: rename it to "FunsExternal.lean" and fill the holes. module public import Aeneas public import Aegis.IdealArrays.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_o...
import Aegis.IdealArrays.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": "[7, 7]", "output": "106" }, { "input": "[2, 5]", "output": "10" }, { "input": "[3, 7]", "output": "28" }, { "input": "[3, 6]", "output": "25" }, { "input": "[6, 12]", "output": "327" }, { "input": "[10, 5]", "output": "86" }, { ...
80
false
80
verified
10
10
1
5,858
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.IdealArrays.Code.Funs /-! # Specifications of `Aegis.IdealArrays.ideal_arrays` LeetCode problem `count-the-number-of-ideal-arrays`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.IdealArrays def MOD : ℤ := 1000000007 def IsIdealArray ...
8
minimum-adjacent-swaps-to-make-a-valid-array
2,340
Medium
[ "Greedy", "Array" ]
You are given a 0-indexed integer array nums. Swaps of adjacent elements are able to be performed on nums. A valid array meets the following conditions: The largest element (any of the largest elements if there are multiple) is at the rightmost position in the array. The smallest element (any of the smallest elements ...
minimumSwaps(nums: list_int) -> int
pub fn minimum_swaps(nums: &[i64]) -> i64
Aegis.MinimumSwaps.minimum_swaps
pub fn minimum_swaps(nums: &[i64]) -> i64 { let n = nums.len(); if n <= 1 { return 0; } let mut min_val: i64 = nums[0]; let mut max_val: i64 = nums[0]; let mut min_idx: usize = 0; let mut max_idx: usize = 0; let mut i: usize = 1; while i < n { if nums[i] < min_val {...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [minimum_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....
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [minimum_swaps]: function definitions module public import Aeneas public import Aegis.MinimumSwaps.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.MinimumSwaps.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval aegisCas...
[ { "input": "[[9]]", "output": "0" }, { "input": "[[100000, 1, 100000]]", "output": "1" }, { "input": "[[1, 2, 3, 5, 4]]", "output": "1" }, { "input": "[[5, 1, 2, 3, 4]]", "output": "4" }, { "input": "[[1, 3, 2, 3, 1]]", "output": "1" }, { "input": "[[5...
105
false
105
verified
10
10
2
5,036
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MinimumSwaps.Code.Funs /-! # Specifications of `Aegis.MinimumSwaps.minimum_swaps` LeetCode problem `minimum-adjacent-swaps-to-make-a-valid-array`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.MinimumSwaps open Aegis.MinimumSwaps ...
13
maximum-number-of-pairs-in-array
2,341
Easy
[ "Array", "Hash Table", "Counting" ]
You are given a 0-indexed integer array nums. In one operation, you may do the following: Choose two integers in nums that are equal. Remove both integers from nums, forming a pair. The operation is done on nums as many times as possible. Return a 0-indexed integer array answer of size 2 where answer[0] is the number...
numberOfPairs(nums: list_int) -> list_int
pub fn number_of_pairs(nums: &[i64]) -> Vec<i64>
Aegis.NumberOfPairs.number_of_pairs
pub fn number_of_pairs(nums: &[i64]) -> Vec<i64> { let n = nums.len(); let mut seen: Vec<bool> = Vec::new(); let mut i = 0; while i < n { seen.push(false); i += 1; } let mut pairs: i64 = 0; let mut leftovers: i64 = 0; let mut i = 0; while i < n { if !seen[i...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [number_of_pairs]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linte...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [number_of_pairs]: function definitions module public import Aeneas public import Aegis.NumberOfPairs.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.NumberOfPairs.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval aegisCa...
[ { "input": "[[42]]", "output": "[0, 1]" }, { "input": "[[1]]", "output": "[0, 1]" }, { "input": "[[0]]", "output": "[0, 1]" }, { "input": "[[1, 1]]", "output": "[1, 0]" }, { "input": "[[100, 100, 100]]", "output": "[1, 1]" }, { "input": "[[1, 2, 3, 4, ...
126
false
126
verified
10
10
1
1,424
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.NumberOfPairs.Code.Funs /-! # Specifications of `Aegis.NumberOfPairs.number_of_pairs` LeetCode problem `maximum-number-of-pairs-in-array`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.NumberOfPairs def elem (nums : Slice Std.I64)...
12
max-sum-of-a-pair-with-equal-sum-of-digits
2,342
Medium
[ "Array", "Hash Table", "Sorting", "Heap (Priority Queue)" ]
You are given a 0-indexed array nums consisting of positive integers. You can choose two indices i and j, such that i != j, and the sum of digits of the number nums[i] is equal to that of nums[j]. Return the maximum value of nums[i] + nums[j] that you can obtain over all possible indices i and j that satisfy the condit...
maximumSum(nums: list_int) -> int
pub fn maximum_sum(nums: &[i64]) -> i64
Aegis.MaximumSum.maximum_sum
pub fn maximum_sum(nums: &[i64]) -> i64 { let mut best1: Vec<i64> = Vec::new(); let mut best2: Vec<i64> = Vec::new(); let mut k: usize = 0; while k < 100 { best1.push(-1); best2.push(-1); k += 1; } let mut i: usize = 0; while i < nums.len() { let x = nums[i]...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [maximum_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 -- [maximum_sum]: function definitions module public import Aeneas public import Aegis.MaximumSum.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.MaximumSum.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": "[[1000000000]]", "output": "-1" }, { "input": "[[999999999, 999999999]]", "output": "1999999998" }, { "input": "[[999999999, 111111111, 222222222]]", "output": "-1" }, { "input": "[[123, 321, 213]]", "output": "534" }, { "input": "[[99, 18, 81, 27]]", ...
121
false
121
verified
10
10
1
2,096
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MaximumSum.Code.Funs /-! # Specifications of `Aegis.MaximumSum.maximum_sum` LeetCode problem `max-sum-of-a-pair-with-equal-sum-of-digits`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.MaximumSum def vals (nums : Slice I64) : List ℤ :...
12
minimum-deletions-to-make-array-divisible
2,344
Hard
[ "Array", "Math", "Number Theory", "Sorting", "Heap (Priority Queue)" ]
You are given two positive integer arrays nums and numsDivide. You can delete any number of elements from nums. Return the minimum number of deletions such that the smallest element in nums divides all the elements of numsDivide. If this is not possible, return -1. Note that an integer x divides y if y % x == 0.   Exam...
minOperations(nums: list_int, numsDivide: list_int) -> int
pub fn min_operations(nums: &[i64], numsDivide: &[i64]) -> i64
Aegis.MinOperations.min_operations
fn gcd(mut a: i64, mut b: i64) -> i64 { while b != 0 { let r = a % b; a = b; b = r; } a } pub fn min_operations(nums: &[i64], numsDivide: &[i64]) -> i64 { let n = nums.len(); let m = numsDivide.len(); let mut g = numsDivide[0]; let mut i: usize = 1; while i < m ...
-- 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 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval aegisCa...
[ { "input": "[[1], [1]]", "output": "0" }, { "input": "[[1000000000, 2000000000, 3000000000], [5000000000, 10000000000]]", "output": "0" }, { "input": "[[10, 20, 30], [5, 10, 15]]", "output": "-1" }, { "input": "[[5, 7, 10], [14, 35, 70]]", "output": "1" }, { "inpu...
158
false
158
verified
10
10
1
1,462
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": 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-deletions-to-make-array-divisible`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.MinOperations def values (s : Slice Std.I...
12
finding-the-number-of-visible-mountains
2,345
Medium
[ "Stack", "Array", "Sorting", "Monotonic Stack" ]
You are given a 0-indexed 2D integer array peaks where peaks[i] = [xi, yi] states that mountain i has a peak at coordinates (xi, yi). A mountain can be described as a right-angled isosceles triangle, with its base along the x-axis and a right angle at its peak. More formally, the gradients of ascending and descending t...
visibleMountains(peaks: list_list_int) -> int
pub fn visible_mountains(peaks: &[Vec<i64>]) -> i64
Aegis.VisibleMountains.visible_mountains
pub fn visible_mountains(peaks: &[Vec<i64>]) -> i64 { let n = peaks.len(); if n == 0 { return 0; } let base: i64 = 300000; let offset: i64 = 200000; let max_r_const: i64 = 200000; let mut keys: Vec<i64> = Vec::new(); let mut i: usize = 0; while i < n { let x = peaks...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [visible_mountains]: type definitions module public import Aeneas @[expose] public section 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 -- [visible_mountains]: function definitions module public import Aeneas public import Aegis.VisibleMountains.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.VisibleMountains.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval aegi...
[ { "input": "[[[1, 3], [1, 3]]]", "output": "0" }, { "input": "[[[5, 5], [5, 5], [5, 5]]]", "output": "0" }, { "input": "[[[100, 100], [200, 50], [300, 100]]]", "output": "3" }, { "input": "[[[10, 10], [15, 5], [20, 15]]]", "output": "2" }, { "input": "[[[10, 10], ...
129
false
129
verified
10
10
1
11,916
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.VisibleMountains.Code.Funs /-! # Specifications of `Aegis.VisibleMountains.visible_mountains` LeetCode problem `finding-the-number-of-visible-mountains`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.VisibleMountains open Aegis.Vi...
11
number-of-zero-filled-subarrays
2,348
Medium
[ "Array", "Math" ]
Given an integer array nums, return the number of subarrays filled with 0. A subarray is a contiguous non-empty sequence of elements within an array.   Example 1: Input: nums = [1,3,0,0,2,0,0,4] Output: 6 Explanation: There are 4 occurrences of [0] as a subarray. There are 2 occurrences of [0,0] as a subarray. There ...
zeroFilledSubarray(nums: list_int) -> int
pub fn zero_filled_subarray(nums: &[i64]) -> i64
Aegis.ZeroFilledSubarray.zero_filled_subarray
pub fn zero_filled_subarray(nums: &[i64]) -> i64 { let mut total: i64 = 0; let mut run: i64 = 0; let n: usize = nums.len(); let mut i: usize = 0; while i < n { if nums[i] == 0 { run += 1; total += run; } else { run = 0; } i += 1; ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [zero_filled_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 ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [zero_filled_subarray]: function definitions module public import Aeneas public import Aegis.ZeroFilledSubarray.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand fal...
import Aegis.ZeroFilledSubarray.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval ae...
[ { "input": "[[1]]", "output": "0" }, { "input": "[[0]]", "output": "1" }, { "input": "[[2, 10, 2019]]", "output": "0" }, { "input": "[[0, 0, 0, 0]]", "output": "10" }, { "input": "[[1, 0, 1, 0, 1]]", "output": "2" }, { "input": "[[5, 6, 7, 8, 9]]", ...
99
false
99
verified
10
10
1
252
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.ZeroFilledSubarray.Code.Funs /-! # Specifications of `Aegis.ZeroFilledSubarray.zero_filled_subarray` LeetCode problem `number-of-zero-filled-subarrays`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.ZeroFilledSubarray namespace AegisSpec.Ze...
14
shortest-impossible-sequence-of-rolls
2,350
Hard
[ "Greedy", "Array", "Hash Table" ]
You are given an integer array rolls of length n and an integer k. You roll a k sided dice numbered from 1 to k, n times, where the result of the ith roll is rolls[i]. Return the length of the shortest sequence of rolls so that there's no such subsequence in rolls. A sequence of rolls of length len is the result of rol...
shortestSequence(rolls: list_int, k: int) -> int
pub fn shortest_sequence(rolls: &[i64], k: i64) -> i64
Aegis.ShortestSequence.shortest_sequence
pub fn shortest_sequence(rolls: &[i64], k: i64) -> i64 { let n: usize = rolls.len(); // One-sided die: every sequence is a run of 1s (all of them present), // so the shortest impossible sequence is just longer than the whole array. if k <= 1 { return n as i64 + 1; } // Fewer rolls than...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [shortest_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 -- [shortest_sequence]: function definitions module public import Aeneas public import Aegis.ShortestSequence.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.ShortestSequence.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval aegi...
[ { "input": "[[1], 1]", "output": "2" }, { "input": "[[1], 100000]", "output": "1" }, { "input": "[[1, 1, 2, 2], 2]", "output": "2" }, { "input": "[[1, 1, 1, 1, 1], 1]", "output": "6" }, { "input": "[[5, 5, 5, 5, 5], 5]", "output": "1" }, { "input": "[[...
97
false
97
verified
10
10
3
37,745
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.ShortestSequence.Code.Funs /-! # Specifications of `Aegis.ShortestSequence.shortest_sequence` LeetCode problem `shortest-impossible-sequence-of-rolls`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.ShortestSequence def OccursIn (v...
15
equal-row-and-column-pairs
2,352
Medium
[ "Array", "Hash Table", "Matrix", "Simulation" ]
Given a 0-indexed n x n integer matrix grid, return the number of pairs (ri, cj) such that row ri and column cj are equal. A row and column pair is considered equal if they contain the same elements in the same order (i.e., an equal array).   Example 1: Input: grid = [[3,2,1],[1,7,6],[2,7,7]] Output: 1 Explanation: T...
equalPairs(grid: list_list_int) -> int
pub fn equal_pairs(grid: &[Vec<i64>]) -> i64
Aegis.EqualPairs.equal_pairs
pub fn equal_pairs(grid: &[Vec<i64>]) -> i64 { let n = grid.len(); let mut count: i64 = 0; let mut i: usize = 0; while i < n { let mut j: usize = 0; while j < n { let mut equal: bool = true; let mut k: usize = 0; while k < n { if grid...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [equal_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 -- [equal_pairs]: function definitions module public import Aeneas public import Aegis.EqualPairs.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.EqualPairs.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": "[[[5]]]", "output": "1" }, { "input": "[[[1, 1, 1], [1, 1, 1], [1, 1, 1]]]", "output": "9" }, { "input": "[[[5, 5, 5], [5, 5, 5], [5, 5, 5]]]", "output": "9" }, { "input": "[[[3, 2, 1], [1, 7, 6], [2, 7, 7]]]", "output": "1" }, { "input": "[[[1, 2, 3],...
64
false
64
verified
10
10
1
658
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.EqualPairs.Code.Funs /-! # Specifications of `Aegis.EqualPairs.equal_pairs` LeetCode problem `equal-row-and-column-pairs`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open scoped BigOperators set_option maxHeartbeats 1000000 namespace AegisSpec.EqualPa...
12
number-of-excellent-pairs
2,354
Hard
[ "Bit Manipulation", "Array", "Hash Table", "Binary Search" ]
You are given a 0-indexed positive integer array nums and a positive integer k. A pair of numbers (num1, num2) is called excellent if the following conditions are satisfied: Both the numbers num1 and num2 exist in the array nums. The sum of the number of set bits in num1 OR num2 and num1 AND num2 is greater than or eq...
countExcellentPairs(nums: list_int, k: int) -> int
pub fn count_excellent_pairs(nums: &[i64], k: i64) -> i64
Aegis.CountExcellentPairs.count_excellent_pairs
fn popcount(mut x: i64) -> usize { let mut count: usize = 0; while x > 0 { if (x & 1) == 1 { count += 1; } x = x >> 1; } count } pub fn count_excellent_pairs(nums: &[i64], k: i64) -> i64 { let n = nums.len(); let mut vals: Vec<i64> = Vec::new(); let mut ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [count_excellent_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...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [count_excellent_pairs]: function definitions module public import Aeneas public import Aegis.CountExcellentPairs.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand f...
import Aegis.CountExcellentPairs.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": "[[5, 1, 1], 10]", "output": "0" }, { "input": "[[7, 8, 9], 5]", "output": "3" }, { "input": "[[1, 1, 1, 1], 1]", "output": "1" }, { "input": "[[2, 4, 8, 16], 3]", "output": "0" }, { "input": "[[31, 14, 7, 3], 6]", "output": "11" }, { "input...
111
false
111
verified
10
10
1
6,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.CountExcellentPairs.Code.Funs /-! # Specifications of `Aegis.CountExcellentPairs.count_excellent_pairs` LeetCode problem `number-of-excellent-pairs`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.CountExcellentPairs (count_excellent_pairs) set_...
16
maximum-number-of-books-you-can-take
2,355
Hard
[ "Stack", "Array", "Dynamic Programming", "Monotonic Stack" ]
You are given a 0-indexed integer array books of length n where books[i] denotes the number of books on the ith shelf of a bookshelf. You are going to take books from a contiguous section of the bookshelf spanning from l to r where 0 <= l <= r < n. For each index i in the range l <= i < r, you must take strictly fewer ...
maximumBooks(books: list_int) -> int
pub fn maximum_books(books: &[i64]) -> i64
Aegis.MaximumBooks.maximum_books
pub fn maximum_books(books: &[i64]) -> i64 { let n: usize = books.len(); let mut dp: Vec<i64> = Vec::new(); let mut stack: Vec<usize> = Vec::new(); let mut ans: i64 = 0; let mut i: usize = 0; while i < n { let bi: i64 = books[i]; let i_val: i64 = i as i64; let ci: i64 = ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [maximum_books]: type definitions module public import Aeneas @[expose] public section 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 -- [maximum_books]: function definitions module public import Aeneas public import Aegis.MaximumBooks.Code.Types public import Aegis.MaximumBooks.Code.FunsExternal @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace f...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [maximum_books]: external functions. -- This is a template file: rename it to "FunsExternal.lean" and fill the holes. module public import Aeneas public import Aegis.MaximumBooks.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set...
import Aegis.MaximumBooks.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval aegisCas...
[ { "input": "[[100000]]", "output": "100000" }, { "input": "[[1]]", "output": "1" }, { "input": "[[0]]", "output": "0" }, { "input": "[[5, 4, 3, 2, 1]]", "output": "7" }, { "input": "[[7, 0, 3, 4, 5]]", "output": "12" }, { "input": "[[100000, 99999, 999...
140
false
140
verified
10
10
1
13,529
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MaximumBooks.Code.Funs /-! # Specifications of `Aegis.MaximumBooks.maximum_books` LeetCode problem `maximum-number-of-books-you-can-take`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.MaximumBooks open scoped BigOperators open Aegis...
11
make-array-zero-by-subtracting-equal-amounts
2,357
Easy
[ "Greedy", "Array", "Hash Table", "Sorting", "Simulation", "Heap (Priority Queue)" ]
You are given a non-negative integer array nums. In one operation, you must: Choose a positive integer x such that x is less than or equal to the smallest non-zero element in nums. Subtract x from every positive element in nums. Return the minimum number of operations to make every element in nums equal to 0.   Examp...
minimumOperations(nums: list_int) -> int
pub fn minimum_operations(nums: &[i64]) -> i64
Aegis.MinimumOperations.minimum_operations
pub fn minimum_operations(nums: &[i64]) -> i64 { let mut count: i64 = 0; let n = nums.len(); let mut i: usize = 0; while i < n { let v = nums[i]; if v > 0 { let mut seen: bool = false; let mut j: usize = 0; while j < i { if nums[j] == ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [minimum_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 li...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [minimum_operations]: function definitions module public import Aeneas public import Aegis.MinimumOperations.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false ...
import Aegis.MinimumOperations.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval aeg...
[ { "input": "[[1]]", "output": "1" }, { "input": "[[0]]", "output": "0" }, { "input": "[[100, 0, 50, 50]]", "output": "2" }, { "input": "[[0, 0, 0, 0]]", "output": "0" }, { "input": "[[2, 2, 2, 2]]", "output": "1" }, { "input": "[[1, 0, 1, 0, 1]]", ...
116
false
116
verified
10
10
1
432
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MinimumOperations.Code.Funs /-! # Specifications of `Aegis.MinimumOperations.minimum_operations` LeetCode problem `make-array-zero-by-subtracting-equal-amounts`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.MinimumOperations open Aeg...
6
maximum-number-of-groups-entering-a-competition
2,358
Medium
[ "Greedy", "Array", "Math", "Binary Search" ]
You are given a positive integer array grades which represents the grades of students in a university. You would like to enter all these students into a competition in ordered non-empty groups, such that the ordering meets the following conditions: The sum of the grades of students in the ith group is less than the su...
maximumGroups(grades: list_int) -> int
pub fn maximum_groups(grades: &[i64]) -> i64
Aegis.MaximumGroups.maximum_groups
pub fn maximum_groups(grades: &[i64]) -> i64 { let n = grades.len() as i64; let mut k: i64 = 0; while (k + 1) * (k + 2) / 2 <= n { k = k + 1; } k }
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [maximum_groups]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [maximum_groups]: function definitions module public import Aeneas public import Aegis.MaximumGroups.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.MaximumGroups.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval aegisCa...
[ { "input": "[[1]]", "output": "1" }, { "input": "[[1, 2]]", "output": "1" }, { "input": "[[8, 8]]", "output": "1" }, { "input": "[[100, 200, 300, 400, 500]]", "output": "2" }, { "input": "[[10, 6, 12, 7, 3, 5]]", "output": "3" }, { "input": "[[100, 90,...
84
false
84
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.MaximumGroups.Code.Funs /-! # Specifications of `Aegis.MaximumGroups.maximum_groups` LeetCode problem `maximum-number-of-groups-entering-a-competition`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.MaximumGroups def gradeAt (grades...
10
find-closest-node-to-given-two-nodes
2,359
Medium
[ "Depth-First Search", "Graph" ]
You are given a directed graph of n nodes numbered from 0 to n - 1, where each node has at most one outgoing edge. The graph is represented with a given 0-indexed array edges of size n, indicating that there is a directed edge from node i to node edges[i]. If there is no outgoing edge from i, then edges[i] == -1. You a...
closestMeetingNode(edges: list_int, node1: int, node2: int) -> int
pub fn closest_meeting_node(edges: &[i64], node1: i64, node2: i64) -> i64
Aegis.ClosestMeetingNode.closest_meeting_node
pub fn closest_meeting_node(edges: &[i64], node1: i64, node2: i64) -> i64 { let n = edges.len(); let mut dist1: Vec<i64> = Vec::new(); let mut dist2: Vec<i64> = Vec::new(); let mut i = 0usize; while i < n { dist1.push(-1); dist2.push(-1); i += 1; } let mut cur = no...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [closest_meeting_node]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [closest_meeting_node]: function definitions module public import Aeneas public import Aegis.ClosestMeetingNode.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand fal...
import Aegis.ClosestMeetingNode.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval ae...
[ { "input": "[[1, 2, -1], 0, 2]", "output": "2" }, { "input": "[[1, 2, 0, -1], 0, 2]", "output": "0" }, { "input": "[[1, 2, 0, -1], 1, 2]", "output": "2" }, { "input": "[[2, 2, 3, -1], 0, 1]", "output": "2" }, { "input": "[[2, -1, 3, 1], 0, 2]", "output": "2" ...
101
false
101
verified
10
10
1
1,792
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.ClosestMeetingNode.Code.Funs /-! # Specifications of `Aegis.ClosestMeetingNode.closest_meeting_node` LeetCode problem `find-closest-node-to-given-two-nodes`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.ClosestMeetingNode def edgeAt ...
13
longest-cycle-in-a-graph
2,360
Hard
[ "Depth-First Search", "Breadth-First Search", "Graph", "Topological Sort" ]
You are given a directed graph of n nodes numbered from 0 to n - 1, where each node has at most one outgoing edge. The graph is represented with a given 0-indexed array edges of size n, indicating that there is a directed edge from node i to node edges[i]. If there is no outgoing edge from node i, then edges[i] == -1. ...
longestCycle(edges: list_int) -> int
pub fn longest_cycle(edges: &[i64]) -> i64
Aegis.LongestCycle.longest_cycle
pub fn longest_cycle(edges: &[i64]) -> i64 { let n = edges.len(); let mut state: Vec<i64> = Vec::new(); let mut dist: Vec<i64> = Vec::new(); let mut k: usize = 0; while k < n { state.push(0); dist.push(0); k += 1; } let mut ans: i64 = -1; let mut i: usize = 0; ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [longest_cycle]: type definitions module public import Aeneas @[expose] public section 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 -- [longest_cycle]: function definitions module public import Aeneas public import Aegis.LongestCycle.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.LongestCycle.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval aegisCas...
[ { "input": "[[2, 1, 2]]", "output": "1" }, { "input": "[[1, 0, -1, -1]]", "output": "2" }, { "input": "[[1, 2, 0, -1]]", "output": "3" }, { "input": "[[2, -1, 3, 1]]", "output": "-1" }, { "input": "[[1, 3, 2, 3]]", "output": "1" }, { "input": "[[-1, 2,...
109
false
109
verified
10
10
1
4,615
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.LongestCycle.Code.Funs /-! # Specifications of `Aegis.LongestCycle.longest_cycle` LeetCode problem `longest-cycle-in-a-graph`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.LongestCycle def succ (edges : Slice Std.I64) (i : Nat) :...
11
minimum-costs-using-the-train-line
2,361
Hard
[ "Array", "Dynamic Programming" ]
A train line going through a city has two routes, the regular route and the express route. Both routes go through the same n + 1 stops labeled from 0 to n. Initially, you start on the regular route at stop 0. You are given two 1-indexed integer arrays regular and express, both of length n. regular[i] describes the cost...
minimumCosts(regular: list_int, express: list_int, expressCost: int) -> list_int
pub fn minimum_costs(regular: &[i64], express: &[i64], expressCost: i64) -> Vec<i64>
Aegis.MinimumCosts.minimum_costs
pub fn minimum_costs(regular: &[i64], express: &[i64], express_cost: i64) -> Vec<i64> { let n: usize = regular.len(); let mut costs: Vec<i64> = Vec::new(); let mut reg: i64 = 0; let mut exp: i64 = express_cost; let mut i: usize = 0; while i < n { let r_cost: i64 = regular[i]; l...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [minimum_costs]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter....
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [minimum_costs]: function definitions module public import Aeneas public import Aegis.MinimumCosts.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.MinimumCosts.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval aegisCas...
[ { "input": "[[5], [10], 7]", "output": "[5]" }, { "input": "[[10, 20, 30], [5, 15, 25], 2]", "output": "[7, 22, 47]" }, { "input": "[[10, 20, 30], [5, 15, 25], 10]", "output": "[10, 30, 55]" }, { "input": "[[5, 5, 5], [10, 10, 10], 1]", "output": "[5, 10, 15]" }, { ...
95
false
95
verified
10
10
1
5,118
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MinimumCosts.Code.Funs /-! # Specifications of `Aegis.MinimumCosts.minimum_costs` LeetCode problem `minimum-costs-using-the-train-line`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.MinimumCosts namespace AegisSpec.MinimumCosts inductiv...
14
count-number-of-bad-pairs
2,364
Medium
[ "Array", "Hash Table", "Math", "Counting" ]
You are given a 0-indexed integer array nums. A pair of indices (i, j) is a bad pair if i < j and j - i != nums[j] - nums[i]. Return the total number of bad pairs in nums.   Example 1: Input: nums = [4,1,3,3] Output: 5 Explanation: The pair (0, 1) is a bad pair since 1 - 0 != 1 - 4. The pair (0, 2) is a bad pair since...
countBadPairs(nums: list_int) -> int
pub fn count_bad_pairs(nums: &[i64]) -> i64
Aegis.CountBadPairs.count_bad_pairs
pub fn count_bad_pairs(nums: &[i64]) -> i64 { let n: usize = nums.len(); let mut cap: usize = 1; while cap < 2 * n + 1 { cap = cap * 2; } let mut keys: Vec<i64> = Vec::new(); let mut counts: Vec<i64> = Vec::new(); let mut t: usize = 0; while t < cap { keys.push(0); ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [count_bad_pairs]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linte...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [count_bad_pairs]: function definitions module public import Aeneas public import Aegis.CountBadPairs.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.CountBadPairs.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval aegisCa...
[ { "input": "[[1, 1, 1, 1]]", "output": "6" }, { "input": "[[4, 1, 3, 3]]", "output": "5" }, { "input": "[[1, 3, 2, 4, 5]]", "output": "7" }, { "input": "[[1000000000, 1000000000, 1000000000, 1000000000, 1000000000]]", "output": "10" }, { "input": "[[9, 7, 5, 3, 1]...
132
false
132
verified
10
10
1
4,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.CountBadPairs.Code.Funs /-! # Specifications of `Aegis.CountBadPairs.count_bad_pairs` LeetCode problem `count-number-of-bad-pairs`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.CountBadPairs def elemAt (nums : Slice I64) (i : Nat...
9
task-scheduler-ii
2,365
Medium
[ "Array", "Hash Table", "Simulation" ]
You are given a 0-indexed array of positive integers tasks, representing tasks that need to be completed in order, where tasks[i] represents the type of the ith task. You are also given a positive integer space, which represents the minimum number of days that must pass after the completion of a task before another tas...
taskSchedulerII(tasks: list_int, space: int) -> int
pub fn task_scheduler_ii(tasks: &[i64], space: i64) -> i64
Aegis.TaskSchedulerIi.task_scheduler_ii
pub fn task_scheduler_ii(tasks: &[i64], space: i64) -> i64 { let n: usize = tasks.len(); let mut cap: usize = 1; let target: usize = 2 * n; while cap < target { cap = cap * 2; } let mut keys: Vec<i64> = Vec::new(); let mut lasts: Vec<i64> = Vec::new(); let mut init: usize = 0; ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [task_scheduler_ii]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option lin...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [task_scheduler_ii]: function definitions module public import Aeneas public import Aegis.TaskSchedulerIi.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.TaskSchedulerIi.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval aegis...
[ { "input": "[[1, 1, 1, 1], 2]", "output": "10" }, { "input": "[[1, 1, 1, 1], 1]", "output": "7" }, { "input": "[[5, 8, 8, 5], 2]", "output": "6" }, { "input": "[[1, 2, 3, 4, 5], 5]", "output": "5" }, { "input": "[[1, 1, 1, 1, 1], 1]", "output": "9" }, { ...
102
false
102
verified
10
10
1
6,064
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.TaskSchedulerIi.Code.Funs /-! # Specifications of `Aegis.TaskSchedulerIi.task_scheduler_ii` LeetCode problem `task-scheduler-ii`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.TaskSchedulerIi def taskValue (tasks : List Std.I64) (...
14
minimum-replacements-to-sort-the-array
2,366
Hard
[ "Greedy", "Array", "Math" ]
You are given a 0-indexed integer array nums. In one operation you can replace any element of the array with any two elements that sum to it. For example, consider nums = [5,6,7]. In one operation, we can replace nums[1] with 2 and 4 and convert nums to [5,2,4,7]. Return the minimum number of operations to make an ar...
minimumReplacement(nums: list_int) -> int
pub fn minimum_replacement(nums: &[i64]) -> i64
Aegis.MinimumReplacement.minimum_replacement
pub fn minimum_replacement(nums: &[i64]) -> i64 { let n = nums.len(); if n <= 1 { return 0; } let mut operations: i64 = 0; let mut prev: i64 = nums[n - 1]; let mut i: usize = n - 1; while i > 0 { i -= 1; let value = nums[i]; if value <= prev { p...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [minimum_replacement]: type definitions module public import Aeneas @[expose] public section 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 -- [minimum_replacement]: function definitions module public import Aeneas public import Aegis.MinimumReplacement.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand fals...
import Aegis.MinimumReplacement.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval ae...
[ { "input": "[[1]]", "output": "0" }, { "input": "[[1, 1000000000]]", "output": "0" }, { "input": "[[1000000000, 1000000000]]", "output": "0" }, { "input": "[[10, 5, 3]]", "output": "5" }, { "input": "[[100, 75, 50]]", "output": "3" }, { "input": "[[100...
107
false
107
verified
10
10
1
866
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MinimumReplacement.Code.Funs /-! # Specifications of `Aegis.MinimumReplacement.minimum_replacement` LeetCode problem `minimum-replacements-to-sort-the-array`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.MinimumReplacement def co...
13
number-of-arithmetic-triplets
2,367
Easy
[ "Array", "Hash Table", "Two Pointers", "Enumeration" ]
You are given a 0-indexed, strictly increasing integer array nums and a positive integer diff. A triplet (i, j, k) is an arithmetic triplet if the following conditions are met: i < j < k, nums[j] - nums[i] == diff, and nums[k] - nums[j] == diff. Return the number of unique arithmetic triplets.   Example 1: Input: nu...
arithmeticTriplets(nums: list_int, diff: int) -> int
pub fn arithmetic_triplets(nums: &[i64], diff: i64) -> i64
Aegis.ArithmeticTriplets.arithmetic_triplets
pub fn arithmetic_triplets(nums: &[i64], diff: 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[j] - nums[i] == diff { let mut k: usize = j + 1; while...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [arithmetic_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 -- [arithmetic_triplets]: function definitions module public import Aeneas public import Aegis.ArithmeticTriplets.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand fals...
import Aegis.ArithmeticTriplets.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval ae...
[ { "input": "[[1, 3, 5, 7, 9], 2]", "output": "3" }, { "input": "[[0, 3, 6, 9, 12], 3]", "output": "3" }, { "input": "[[10, 20, 30, 40, 50], 10]", "output": "3" }, { "input": "[[5, 10, 15, 20, 25], 5]", "output": "3" }, { "input": "[[5, 10, 15, 20, 25, 30], 5]", ...
104
false
104
verified
10
10
1
396
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.ArithmeticTriplets.Code.Funs /-! # Specifications of `Aegis.ArithmeticTriplets.arithmetic_triplets` LeetCode problem `number-of-arithmetic-triplets`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.ArithmeticTriplets (arithmetic_triplets) namespa...
8
check-if-there-is-a-valid-partition-for-the-array
2,369
Medium
[ "Array", "Dynamic Programming" ]
You are given a 0-indexed integer array nums. You have to partition the array into one or more contiguous subarrays. We call a partition of the array valid if each of the obtained subarrays satisfies one of the following conditions: The subarray consists of exactly 2, equal elements. For example, the subarray [2,2] is...
validPartition(nums: list_int) -> bool
pub fn valid_partition(nums: &[i64]) -> bool
Aegis.ValidPartition.valid_partition
pub fn valid_partition(nums: &[i64]) -> bool { let n = nums.len(); let mut dp: Vec<i64> = Vec::new(); let mut k: usize = 0; while k <= n { dp.push(0); k += 1; } dp[0] = 1; let mut i: usize = 1; while i <= n { if i >= 2 { if nums[i - 1] == nums[i - 2...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [valid_partition]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linte...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [valid_partition]: function definitions module public import Aeneas public import Aegis.ValidPartition.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.ValidPartition.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval aegisC...
[ { "input": "[[1000000, 1000000]]", "output": "true" }, { "input": "[[2, 2]]", "output": "true" }, { "input": "[[1, 2, 3]]", "output": "true" }, { "input": "[[1, 1, 1, 1]]", "output": "true" }, { "input": "[[1, 1, 1, 2]]", "output": "false" }, { "input"...
134
false
134
verified
10
10
1
1,294
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.ValidPartition.Code.Funs /-! # Specifications of `Aegis.ValidPartition.valid_partition` LeetCode problem `check-if-there-is-a-valid-partition-for-the-array`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std open Aeneas.Std.Result namespace AegisSpec.ValidPartition ...
12