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-the-number-of-houses-at-a-certain-distance-ii
3,017
Hard
[ "Graph", "Prefix Sum" ]
You are given three positive integers n, x, and y. In a city, there exist houses numbered 1 to n connected by n streets. There is a street connecting the house numbered i with the house numbered i + 1 for all 1 <= i <= n - 1 . An additional street connects the house numbered x with the house numbered y. For each k, suc...
countOfPairs(n: int, x: int, y: int) -> list_int
pub fn count_of_pairs(n: i64, x: i64, y: i64) -> Vec<i64>
Aegis.CountOfPairs.count_of_pairs
pub fn count_of_pairs(n: i64, x: i64, y: i64) -> Vec<i64> { let mut ans: Vec<i64> = Vec::new(); let mut i: i64 = 0; while i < n { ans.push(0); i += 1; } // If x == y, the extra street does not change the graph: // it is just a path 1 - 2 - ... - n. if x == y { let mu...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [count_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 linter...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [count_of_pairs]: function definitions module public import Aeneas public import Aegis.CountOfPairs.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.CountOfPairs.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": "[3, 1, 3]", "output": "[6, 0, 0]" }, { "input": "[4, 1, 1]", "output": "[6, 4, 2, 0]" }, { "input": "[5, 2, 4]", "output": "[10, 8, 2, 0, 0]" }, { "input": "[5, 1, 5]", "output": "[10, 10, 0, 0, 0]" }, { "input": "[6, 2, 5]", "output": "[12, 12, 6,...
75
false
75
verified
10
10
1
13,264
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.CountOfPairs.Code.Funs import Mathlib.Data.Int.Interval /-! # Specifications of `Aegis.CountOfPairs.count_of_pairs` LeetCode problem `count-the-number-of-houses-at-a-certain-distance-ii`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.CountOfPa...
13
maximum-number-of-removal-queries-that-can-be-processed-i
3,018
Hard
[ "Array", "Dynamic Programming" ]
You are given a 0-indexed array nums and a 0-indexed array queries. You can do the following operation at the beginning at most once: Replace nums with a subsequence of nums. We start processing queries in the given order; for each query, we do the following: If the first and the last element of nums is less than qu...
maximumProcessableQueries(nums: list_int, queries: list_int) -> int
pub fn maximum_processable_queries(nums: &[i64], queries: &[i64]) -> i64
Aegis.MaximumProcessableQueries.maximum_processable_queries
pub fn maximum_processable_queries(nums: &[i64], queries: &[i64]) -> i64 { let n = nums.len(); let m = queries.len(); if n == 0 || m == 0 { return 0; } // dp[i][j] = maximum number of queries processed when we have removed // i elements from the left end and j elements from the right en...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [maximum_processable_queries]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [maximum_processable_queries]: function definitions module public import Aeneas public import Aegis.MaximumProcessableQueries.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.h...
import Aegis.MaximumProcessableQueries.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}" #...
[ { "input": "[[1, 2, 3], [3, 2, 1]]", "output": "3" }, { "input": "[[1, 2, 3], [4, 5, 6]]", "output": "0" }, { "input": "[[2, 3, 2], [2, 2, 3]]", "output": "3" }, { "input": "[[3, 4, 3], [4, 3, 2]]", "output": "2" }, { "input": "[[10, 20, 30], [5, 15, 25, 35]]", ...
118
false
118
verified
10
10
2
66,167
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MaximumProcessableQueries.Code.Funs /-! # Specifications of `Aegis.MaximumProcessableQueries.maximum_processable_queries` LeetCode problem `maximum-number-of-removal-queries-that-can-be-processed-i`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespa...
15
number-of-changing-keys
3,019
Easy
[ "String" ]
You are given a 0-indexed string s typed by a user. Changing a key is defined as using a key different from the last used key. For example, s = "ab" has a change of a key while s = "bBBb" does not have any. Return the number of times the user had to change the key. Note: Modifiers like shift or caps lock won't be coun...
countKeyChanges(s: str) -> int
pub fn count_key_changes(s: &[u8]) -> i64
Aegis.CountKeyChanges.count_key_changes
pub fn count_key_changes(s: &[u8]) -> i64 { let n = s.len(); if n == 0 { return 0; } let mut prev = s[0]; if prev >= b'A' && prev <= b'Z' { prev = prev + 32; } let mut count: i64 = 0; let mut i: usize = 1; while i < n { let mut cur = s[i]; if cur >=...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [count_key_changes]: type definitions module public import Aeneas @[expose] public section 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 -- [count_key_changes]: function definitions module public import Aeneas public import Aegis.CountKeyChanges.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.CountKeyChanges.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": "[\"ZzZzZzZ\"]", "output": "0" }, { "input": "[\"QwErTyUiOpAsDfGhJkLzXcVbNm\"]", "output": "25" }, { "input": "[\"ABCDEFG\"]", "output": "6" }, { "input": "[\"A\"]", "output": "0" }, { "input": "[\"AaAaAaaA\"]", "output": "0" }, { "input": "...
78
false
78
verified
10
10
1
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.CountKeyChanges.Code.Funs /-! # Specifications of `Aegis.CountKeyChanges.count_key_changes` LeetCode problem `number-of-changing-keys`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.CountKeyChanges open Aegis.CountKeyChanges def lowe...
11
find-the-maximum-number-of-elements-in-subset
3,020
Medium
[ "Array", "Hash Table", "Enumeration" ]
You are given an array of positive integers nums. You need to select a subset of nums which satisfies the following condition: You can place the selected elements in a 0-indexed array such that it follows the pattern: [x, x2, x4, ..., xk/2, xk, xk/2, ..., x4, x2, x] (Note that k can be be any non-negative power of 2)....
maximumLength(nums: list_int) -> int
pub fn maximum_length(nums: &[i64]) -> i64
Aegis.MaximumLength.maximum_length
fn find_index(vals: &[i64], target: i64) -> usize { let mut lo: usize = 0; let mut hi: usize = vals.len(); while lo < hi { let mid: usize = lo + (hi - lo) / 2; if vals[mid] < target { lo = mid + 1; } else { hi = mid; } } if lo < vals.len() &&...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [maximum_length]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [maximum_length]: function definitions module public import Aeneas public import Aegis.MaximumLength.Code.Types public import Aegis.MaximumLength.Code.FunsExternal @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespac...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [maximum_length]: external functions. -- This is a template file: rename it to "FunsExternal.lean" and fill the holes. module public import Aeneas public import Aegis.MaximumLength.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error s...
import Aegis.MaximumLength.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": "[[3, 9, 3]]", "output": "3" }, { "input": "[[1, 3, 2, 4]]", "output": "1" }, { "input": "[[1000000000, 1000000000, 1000000000, 1000000000, 1000000000]]", "output": "1" }, { "input": "[[2, 4, 8, 4, 2]]", "output"...
80
false
80
verified
10
10
1
10,205
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MaximumLength.Code.Funs /-! # Specifications of `Aegis.MaximumLength.maximum_length` LeetCode problem `find-the-maximum-number-of-elements-in-subset`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result set_option autoImplicit false namespace AegisSpec.Maximum...
14
alice-and-bob-playing-flower-game
3,021
Medium
[ "Math" ]
Alice and Bob are playing a turn-based game on a circular field surrounded by flowers. The circle represents the field, and there are x flowers in the clockwise direction between Alice and Bob, and y flowers in the anti-clockwise direction between them. The game proceeds as follows: Alice takes the first turn. In each...
flowerGame(n: int, m: int) -> int
pub fn flower_game(n: i64, m: i64) -> i64
Aegis.FlowerGame.flower_game
pub fn flower_game(n: i64, m: i64) -> i64 { (n * m) / 2 }
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [flower_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.st...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [flower_game]: function definitions module public import Aeneas public import Aegis.FlowerGame.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.FlowerGame.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, 7]", "output": "17" }, { "input": "[5, 4]", "output": "10" }, { "input": "[1, 1]", "output": "0" }, { "input": "[100, 200]", "output": "10000" }, { "input": "[4, 3]", "output": "6" }, { "input": "[100000, 100000]", "output": "500000...
66
false
66
verified
10
10
1
448
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.FlowerGame.Code.Funs /-! # Specifications of `Aegis.FlowerGame.flower_game` LeetCode problem `alice-and-bob-playing-flower-game`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.FlowerGame namespace AegisSpec.FlowerGame def intOneTo (n : ℤ) : Fi...
14
minimize-or-of-remaining-elements-using-operations
3,022
Hard
[ "Greedy", "Bit Manipulation", "Array" ]
You are given a 0-indexed integer array nums and an integer k. In one operation, you can pick any index i of nums such that 0 <= i < nums.length - 1 and replace nums[i] and nums[i + 1] with a single occurrence of nums[i] & nums[i + 1], where & represents the bitwise AND operator. Return the minimum possible value of th...
minOrAfterOperations(nums: list_int, k: int) -> int
pub fn min_or_after_operations(nums: &[i64], k: i64) -> i64
Aegis.MinOrAfterOperations.min_or_after_operations
pub fn min_or_after_operations(nums: &[i64], k: i64) -> i64 { let n: i64 = nums.len() as i64; let need: i64 = n - k; let mut forbidden: i64 = 0; let mut answer: i64 = 0; let mut bit: i64 = 1 << 29; while bit > 0 { let test_mask: i64 = forbidden | bit; let mut cur: i64 = test_...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [min_or_after_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_opti...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [min_or_after_operations]: function definitions module public import Aeneas public import Aegis.MinOrAfterOperations.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashComman...
import Aegis.MinOrAfterOperations.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": "[[30, 20, 10, 0], 2]", "output": "0" }, { "input": "[[0, 0, 0, 0, 0], 0]", "output": "0" }, { "input": "[[1, 0, 1, 0, 1], 2]", "output": "1" }, { "input": "[[31, 31, 31, 31, 31], 3]", "output": "31" }, { "input": "[[1, 2, 3, 4, 5], 3]", "output": "...
109
false
109
verified
10
10
1
9,416
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MinOrAfterOperations.Code.Funs /-! # Specifications of `Aegis.MinOrAfterOperations.min_or_after_operations` LeetCode problem `minimize-or-of-remaining-elements-using-operations`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.MinOrAfterOperations...
14
find-the-number-of-ways-to-place-people-ii
3,027
Hard
[ "Geometry", "Array", "Math", "Enumeration", "Sorting" ]
You are given a 2D array points of size n x 2 representing integer coordinates of some points on a 2D-plane, where points[i] = [xi, yi]. We define the right direction as positive x-axis (increasing x-coordinate) and the left direction as negative x-axis (decreasing x-coordinate). Similarly, we define the up direction a...
numberOfPairs(points: list_list_int) -> int
pub fn number_of_pairs(points: &[Vec<i64>]) -> i64
Aegis.NumberOfPairs.number_of_pairs
pub fn number_of_pairs(points: &[Vec<i64>]) -> i64 { let n = points.len(); let mut xs: Vec<i64> = Vec::new(); let mut ys: Vec<i64> = Vec::new(); let mut i: usize = 0; while i < n { xs.push(points[i][0]); ys.push(points[i][1]); i += 1; } // Sort by x ascending, and ...
-- 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": "[[[3, 1], [1, 3], [1, 1]]]", "output": "2" }, { "input": "[[[1, 1], [2, 2], [3, 3]]]", "output": "0" }, { "input": "[[[-1, -1], [-2, -2], [-3, -3]]]", "output": "0" }, { "input": "[[[-1, 1], [1, -1], [0, 0]]]", "output": "2" }, { "input": "[[[6, 2], [4...
120
false
120
verified
10
10
1
8,651
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": 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 `find-the-number-of-ways-to-place-people-ii`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.NumberOfPairs (number_of_pairs) namespace AegisSp...
11
ant-on-the-boundary
3,028
Easy
[ "Array", "Prefix Sum", "Simulation" ]
An ant is on a boundary. It sometimes goes left and sometimes right. You are given an array of non-zero integers nums. The ant starts reading nums from the first element of it to its end. At each step, it moves according to the value of the current element: If nums[i] < 0, it moves left by -nums[i] units. If nums[i] >...
returnToBoundaryCount(nums: list_int) -> int
pub fn return_to_boundary_count(nums: &[i64]) -> i64
Aegis.ReturnToBoundaryCount.return_to_boundary_count
pub fn return_to_boundary_count(nums: &[i64]) -> i64 { let mut position: i64 = 0; let mut count: i64 = 0; let n = nums.len(); for i in 0..n { position += nums[i]; if position == 0 { count += 1; } } count }
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [return_to_boundary_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_opt...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [return_to_boundary_count]: function definitions module public import Aeneas public import Aegis.ReturnToBoundaryCount.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashComm...
import Aegis.ReturnToBoundaryCount.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": "[[10]]", "output": "0" }, { "input": "[[1]]", "output": "0" }, { "input": "[[-10]]", "output": "0" }, { "input": "[[2, 3, -5]]", "output": "1" }, { "input": "[[5, 5, -10]]", "output": "1" }, { "input": "[[10, -5, -5]]", "output": "1" ...
123
false
123
verified
10
10
1
205
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.ReturnToBoundaryCount.Code.Funs /-! # Specifications of `Aegis.ReturnToBoundaryCount.return_to_boundary_count` LeetCode problem `ant-on-the-boundary`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.ReturnToBoundaryCount def elem (n...
11
minimum-time-to-revert-word-to-initial-state-i
3,029
Medium
[ "String", "String Matching", "Hash Function", "Rolling Hash" ]
You are given a 0-indexed string word and an integer k. At every second, you must perform the following operations: Remove the first k characters of word. Add any k characters to the end of word. Note that you do not necessarily need to add the same characters that you removed. However, you must perform both operatio...
minimumTimeToInitialState(word: str, k: int) -> int
pub fn minimum_time_to_initial_state(word: &[u8], k: i64) -> i64
Aegis.MinimumTimeToInitialState.minimum_time_to_initial_state
pub fn minimum_time_to_initial_state(word: &[u8], k: i64) -> i64 { let n: i64 = word.len() as i64; let n_usize: usize = word.len(); let mut t: i64 = 1; while t * k < n { let d: usize = (t * k) as usize; let m: usize = n_usize - d; let mut i: usize = 0; let mut ok: bool =...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [minimum_time_to_initial_state]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false se...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [minimum_time_to_initial_state]: function definitions module public import Aeneas public import Aegis.MinimumTimeToInitialState.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter...
import Aegis.MinimumTimeToInitialState.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}" #...
[ { "input": "[\"aabbcc\", 2]", "output": "3" }, { "input": "[\"hello\", 5]", "output": "1" }, { "input": "[\"xyzxyzxyz\", 4]", "output": "3" }, { "input": "[\"abcdef\", 1]", "output": "6" }, { "input": "[\"ababab\", 2]", "output": "1" }, { "input": "[\"...
108
false
108
verified
10
10
1
2,896
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MinimumTimeToInitialState.Code.Funs /-! # Specifications of `Aegis.MinimumTimeToInitialState.minimum_time_to_initial_state` LeetCode problem `minimum-time-to-revert-word-to-initial-state-i`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisS...
9
find-the-grid-of-region-average
3,030
Medium
[ "Array", "Matrix" ]
You are given m x n grid image which represents a grayscale image, where image[i][j] represents a pixel with intensity in the range [0..255]. You are also given a non-negative integer threshold. Two pixels are adjacent if they share an edge. A region is a 3 x 3 subgrid where the absolute difference in intensity between...
resultGrid(image: list_list_int, threshold: int) -> list_list_int
pub fn result_grid(image: &[Vec<i64>], threshold: i64) -> Vec<Vec<i64>>
Aegis.ResultGrid.result_grid
pub fn result_grid(image: &[Vec<i64>], threshold: i64) -> Vec<Vec<i64>> { let m = image.len(); let n = image[0].len(); let total = m * n; let mut sum: Vec<i64> = Vec::new(); let mut cnt: Vec<i64> = Vec::new(); let mut idx = 0; while idx < total { sum.push(0); cnt.push(0); ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [result_grid]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter.st...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [result_grid]: function definitions module public import Aeneas public import Aegis.ResultGrid.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.ResultGrid.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, 6, 7], [8, 9, 10], [11, 12, 13]], 1]", "output": "[[5, 6, 7], [8, 9, 10], [11, 12, 13]]" }, { "input": "[[[100, 101, 102], [101, 102, 103], [102, 103, 104]], 2]", "output": "[[102, 102, 102], [102, 102, 102], [102, 102, 102]]" }, { "input": "[[[0, 0, 0], [0, 0, 0], [0, ...
90
false
90
verified
10
10
1
4,278
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.ResultGrid.Code.Funs /-! # Specifications of `Aegis.ResultGrid.result_grid` LeetCode problem `find-the-grid-of-region-average`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aeneas.Std.Result open Aegis.ResultGrid namespace AegisSpec.ResultGrid def ...
15
minimum-time-to-revert-word-to-initial-state-ii
3,031
Hard
[ "String", "String Matching", "Hash Function", "Rolling Hash" ]
You are given a 0-indexed string word and an integer k. At every second, you must perform the following operations: Remove the first k characters of word. Add any k characters to the end of word. Note that you do not necessarily need to add the same characters that you removed. However, you must perform both operatio...
minimumTimeToInitialState(word: str, k: int) -> int
pub fn minimum_time_to_initial_state(word: &[u8], k: i64) -> i64
Aegis.MinimumTimeToInitialState.minimum_time_to_initial_state
pub fn minimum_time_to_initial_state(word: &[u8], k: i64) -> i64 { let n: usize = word.len(); if n == 0 { return 1; } let mut z: Vec<i64> = Vec::new(); let mut i: usize = 0; while i < n { z.push(0); i += 1; } let mut l: usize = 0; let mut r: usize = 0; ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [minimum_time_to_initial_state]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false se...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [minimum_time_to_initial_state]: function definitions module public import Aeneas public import Aegis.MinimumTimeToInitialState.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter...
import Aegis.MinimumTimeToInitialState.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}" #...
[ { "input": "[\"abcdefgh\", 2]", "output": "4" }, { "input": "[\"xyz\", 1]", "output": "3" }, { "input": "[\"zzzzzz\", 2]", "output": "1" }, { "input": "[\"abcdabcd\", 4]", "output": "1" }, { "input": "[\"abacaba\", 3]", "output": "2" }, { "input": "[\"...
108
false
108
verified
10
10
1
6,559
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MinimumTimeToInitialState.Code.Funs /-! # Specifications of `Aegis.MinimumTimeToInitialState.minimum_time_to_initial_state` LeetCode problem `minimum-time-to-revert-word-to-initial-state-ii`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace Aegis...
9
count-numbers-with-unique-digits-ii
3,032
Easy
[ "Hash Table", "Math", "Dynamic Programming" ]
Given two positive integers a and b, return the count of numbers having unique digits in the range [a, b] (inclusive).   Example 1: Input: a = 1, b = 20 Output: 19 Explanation: All the numbers in the range [1, 20] have unique digits except 11. Hence, the answer is 19. Example 2: Input: a = 9, b = 19 Output: 10 Expla...
numberCount(a: int, b: int) -> int
pub fn number_count(a: i64, b: i64) -> i64
Aegis.NumberCount.number_count
fn has_unique_digits(n: i64) -> bool { let mut digits: Vec<i64> = Vec::new(); let mut x = n; while x > 0 { digits.push(x % 10); x = x / 10; } let len = digits.len(); let mut unique = true; let mut i = 0usize; while i < len && unique { let mut j = i + 1; ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [number_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.s...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [number_count]: function definitions module public import Aeneas public import Aegis.NumberCount.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.NumberCount.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": "[789, 890]", "output": "74" }, { "input": "[300, 400]", "output": "72" }, { "input": "[100, 150]", "output": "33" }, { "input": "[100, 200]", "output": "72" }, { "input": "[50, 59]", "output": "9" }, { "input": "[9, 19]", "output": "10"...
78
false
78
verified
10
10
2
2,157
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.NumberCount.Code.Funs /-! # Specifications of `Aegis.NumberCount.number_count` LeetCode problem `count-numbers-with-unique-digits-ii`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.NumberCount def decDigitsFrom : Nat → Nat → List Nat ...
9
modify-the-matrix
3,033
Easy
[ "Array", "Matrix" ]
Given a 0-indexed m x n integer matrix matrix, create a new 0-indexed matrix called answer. Make answer equal to matrix, then replace each element with the value -1 with the maximum element in its respective column. Return the matrix answer.   Example 1: Input: matrix = [[1,2,-1],[4,-1,6],[7,8,9]] Output: [[1,2,9],[4...
modifiedMatrix(matrix: list_list_int) -> list_list_int
pub fn modified_matrix(matrix: &[Vec<i64>]) -> Vec<Vec<i64>>
Aegis.ModifiedMatrix.modified_matrix
pub fn modified_matrix(matrix: &[Vec<i64>]) -> Vec<Vec<i64>> { let m = matrix.len(); if m == 0 { return Vec::new(); } let n = matrix[0].len(); let mut col_max: Vec<i64> = Vec::new(); let mut j = 0; while j < n { let mut mx: i64 = -1; let mut i = 0; while i <...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [modified_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 linte...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [modified_matrix]: function definitions module public import Aeneas public import Aegis.ModifiedMatrix.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.ModifiedMatrix.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": "[[[3, -1], [5, 2]]]", "output": "[[3, 2], [5, 2]]" }, { "input": "[[[-1, 1], [-1, 2], [-1, 3]]]", "output": "[[-1, 1], [-1, 2], [-1, 3]]" }, { "input": "[[[-1, -1], [-1, -1], [-1, -1], [2, 2]]]", "output": "[[2, 2], [2, 2], [2, 2], [2, 2]]" }, { "input": "[[[1, 2,...
85
false
85
verified
10
10
1
1,366
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.ModifiedMatrix.Code.Funs /-! # Specifications of `Aegis.ModifiedMatrix.modified_matrix` LeetCode problem `modify-the-matrix`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.ModifiedMatrix namespace AegisSpec.ModifiedMatrix def entryOfRows...
11
number-of-subarrays-that-match-a-pattern-i
3,034
Medium
[ "Array", "String Matching", "Hash Function", "Rolling Hash" ]
You are given a 0-indexed integer array nums of size n, and a 0-indexed integer array pattern of size m consisting of integers -1, 0, and 1. A subarray nums[i..j] of size m + 1 is said to match the pattern if the following conditions hold for each element pattern[k]: nums[i + k + 1] > nums[i + k] if pattern[k] == 1. n...
countMatchingSubarrays(nums: list_int, pattern: list_int) -> int
pub fn count_matching_subarrays(nums: &[i64], pattern: &[i64]) -> i64
Aegis.CountMatchingSubarrays.count_matching_subarrays
pub fn count_matching_subarrays(nums: &[i64], pattern: &[i64]) -> i64 { let n = nums.len(); let m = pattern.len(); if m + 1 > n { return 0; } let total = n - m; // number of valid starting positions let mut count: i64 = 0; let mut i: usize = 0; while i < total { let mut...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [count_matching_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_opt...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [count_matching_subarrays]: function definitions module public import Aeneas public import Aegis.CountMatchingSubarrays.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCom...
import Aegis.CountMatchingSubarrays.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eva...
[ { "input": "[[1, 2, 3, 4, 5, 6], [1, 1]]", "output": "4" }, { "input": "[[1, 1, 1, 1, 1], [0, 0, 0]]", "output": "2" }, { "input": "[[5, 4, 3, 2, 1], [-1, -1, -1]]", "output": "2" }, { "input": "[[10, 10, 10, 10, 10], [0, 0, 0]]", "output": "2" }, { "input": "[[1,...
112
false
112
verified
10
10
1
669
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.CountMatchingSubarrays.Code.Funs /-! # Specifications of `Aegis.CountMatchingSubarrays.count_matching_subarrays` LeetCode problem `number-of-subarrays-that-match-a-pattern-i`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.CountMatching...
8
maximum-palindromes-after-operations
3,035
Medium
[ "Greedy", "Array", "Hash Table", "String", "Counting", "Sorting" ]
You are given a 0-indexed string array words having length n and containing 0-indexed strings. You are allowed to perform the following operation any number of times (including zero): Choose integers i, j, x, and y such that 0 <= i, j < n, 0 <= x < words[i].length, 0 <= y < words[j].length, and swap the characters wor...
maxPalindromesAfterOperations(words: list_str) -> int
pub fn max_palindromes_after_operations(words: &[Vec<u8>]) -> i64
Aegis.MaxPalindromesAfterOperations.max_palindromes_after_operations
pub fn max_palindromes_after_operations(words: &[Vec<u8>]) -> i64 { let mut freq: Vec<i64> = Vec::new(); let mut z = 0; while z < 26 { freq.push(0); z += 1; } let n = words.len(); let mut lengths: Vec<i64> = Vec::new(); let mut i = 0; while i < n { let len = wor...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [max_palindromes_after_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...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [max_palindromes_after_operations]: function definitions module public import Aeneas public import Aegis.MaxPalindromesAfterOperations.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option...
import Aegis.MaxPalindromesAfterOperations.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}...
[ { "input": "[[\"abc\", \"ab\"]]", "output": "2" }, { "input": "[[\"aaaa\", \"bbbb\", \"cccc\"]]", "output": "3" }, { "input": "[[\"abcde\", \"fghij\", \"klmno\"]]", "output": "0" }, { "input": "[[\"abbb\", \"ba\", \"aa\"]]", "output": "3" }, { "input": "[[\"race\"...
95
false
95
verified
10
10
1
5,138
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MaxPalindromesAfterOperations.Code.Funs /-! # Specifications of `Aegis.MaxPalindromesAfterOperations.max_palindromes_after_operations` LeetCode problem `maximum-palindromes-after-operations`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSp...
18
number-of-subarrays-that-match-a-pattern-ii
3,036
Hard
[ "Array", "String Matching", "Hash Function", "Rolling Hash" ]
You are given a 0-indexed integer array nums of size n, and a 0-indexed integer array pattern of size m consisting of integers -1, 0, and 1. A subarray nums[i..j] of size m + 1 is said to match the pattern if the following conditions hold for each element pattern[k]: nums[i + k + 1] > nums[i + k] if pattern[k] == 1. n...
countMatchingSubarrays(nums: list_int, pattern: list_int) -> int
pub fn count_matching_subarrays(nums: &[i64], pattern: &[i64]) -> i64
Aegis.CountMatchingSubarrays.count_matching_subarrays
pub fn count_matching_subarrays(nums: &[i64], pattern: &[i64]) -> i64 { let n = nums.len(); let m = pattern.len(); if m == 0 { return n as i64; } if n <= m { return 0; } let mut lps: Vec<usize> = Vec::new(); let mut z: usize = 0; while z < m { lps.push(0); ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [count_matching_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_opt...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [count_matching_subarrays]: function definitions module public import Aeneas public import Aegis.CountMatchingSubarrays.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCom...
import Aegis.CountMatchingSubarrays.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eva...
[ { "input": "[[10, 10, 10, 10], [0, 0]]", "output": "2" }, { "input": "[[1, 1, 1, 1, 1], [0, 0]]", "output": "3" }, { "input": "[[1, 2, 2, 3, 4], [1, 0, 1]]", "output": "1" }, { "input": "[[1, 2, 3, 4, 5, 6], [1, 1]]", "output": "4" }, { "input": "[[1, 1, 1, 1, 1],...
111
false
111
verified
10
10
1
5,398
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.CountMatchingSubarrays.Code.Funs /-! # Specifications of `Aegis.CountMatchingSubarrays.count_matching_subarrays` LeetCode problem `number-of-subarrays-that-match-a-pattern-ii`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.CountMatch...
8
maximum-number-of-operations-with-the-same-score-i
3,038
Easy
[ "Array", "Simulation" ]
You are given an array of integers nums. Consider the following operation: Delete the first two elements nums and define the score of the operation as the sum of these two elements. You can perform this operation until nums contains fewer than two elements. Additionally, the same score must be achieved in all operati...
maxOperations(nums: list_int) -> int
pub fn max_operations(nums: &[i64]) -> i64
Aegis.MaxOperations.max_operations
pub fn max_operations(nums: &[i64]) -> i64 { let n = nums.len(); if n < 2 { return 0; } let target = nums[0] + nums[1]; let mut count: i64 = 0; let mut i: usize = 0; while i + 1 < n { if nums[i] + nums[i + 1] == target { count += 1; i += 2; }...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [max_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 -- [max_operations]: function definitions module public import Aeneas public import Aegis.MaxOperations.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.MaxOperations.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": "[[5, 3]]", "output": "1" }, { "input": "[[3, 2, 1, 4, 5]]", "output": "2" }, { "input": "[[100, 200, 100, 200, 100]]", "output": "2" }, { "input": "[[10, 20, 30, 40, 50, 60]]", "output": "1" }, { "input": "[[1, 100, 1, 100, 1, 100]]", "output": "3"...
109
false
109
verified
10
10
1
371
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MaxOperations.Code.Funs /-! # Specifications of `Aegis.MaxOperations.max_operations` LeetCode problem `maximum-number-of-operations-with-the-same-score-i`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.MaxOperations def elem (nums...
9
maximum-number-of-operations-with-the-same-score-ii
3,040
Medium
[ "Memoization", "Array", "Dynamic Programming" ]
Given an array of integers called nums, you can perform any of the following operation while nums contains at least 2 elements: Choose the first two elements of nums and delete them. Choose the last two elements of nums and delete them. Choose the first and the last elements of nums and delete them. The score of the ...
maxOperations(nums: list_int) -> int
pub fn max_operations(nums: &[i64]) -> i64
Aegis.MaxOperations.max_operations
fn max_ops_for_score(nums: &[i64], score: i64) -> i64 { let n = nums.len(); if n < 2 { return 0; } let total = n * n; let mut dp: Vec<i64> = Vec::new(); let mut i: usize = 0; while i < total { dp.push(0); i += 1; } let mut len: usize = 2; while len <= n ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [max_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 -- [max_operations]: function definitions module public import Aeneas public import Aegis.MaxOperations.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.MaxOperations.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": "[[1000, 1, 1, 1000]]", "output": "2" }, { "input": "[[1, 3, 2, 3, 1]]", "output": "2" }, { "input": "[[3, 2, 6, 1, 4]]", "output": "2" }, { "input": "[[1, 2, 3, 2, 1]]", "output": "2" }, { "input": "[[10, 10, 10, 10, 10]]", "output": "2" }, { ...
116
false
116
verified
10
10
1
5,114
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MaxOperations.Code.Funs /-! # Specifications of `Aegis.MaxOperations.max_operations` LeetCode problem `maximum-number-of-operations-with-the-same-score-ii`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.MaxOperations namespace AegisSpec.MaxOper...
13
maximize-consecutive-elements-in-an-array-after-modification
3,041
Hard
[ "Array", "Dynamic Programming", "Sorting" ]
You are given a 0-indexed array nums consisting of positive integers. Initially, you can increase the value of any element in the array by at most 1. After that, you need to select one or more elements from the final array such that those elements are consecutive when sorted in increasing order. For example, the elemen...
maxSelectedElements(nums: list_int) -> int
pub fn max_selected_elements(nums: &[i64]) -> i64
Aegis.MaxSelectedElements.max_selected_elements
pub fn max_selected_elements(nums: &[i64]) -> i64 { let n = nums.len(); if n == 0 { return 0; } // Working copy of the values. let mut v: Vec<i64> = Vec::new(); let mut i: usize = 0; while i < n { v.push(nums[i]); i += 1; } // Bubble sort. Inner loop advanc...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [max_selected_elements]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [max_selected_elements]: function definitions module public import Aeneas public import Aegis.MaxSelectedElements.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand f...
import Aegis.MaxSelectedElements.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval a...
[ { "input": "[[1]]", "output": "1" }, { "input": "[[1000000]]", "output": "1" }, { "input": "[[1, 1000000]]", "output": "1" }, { "input": "[[1, 4, 7, 10]]", "output": "1" }, { "input": "[[1, 3, 5, 7, 9]]", "output": "2" }, { "input": "[[1000000, 999999,...
144
false
144
verified
10
10
5
97,266
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MaxSelectedElements.Code.Funs /-! # Specifications of `Aegis.MaxSelectedElements.max_selected_elements` LeetCode problem `maximize-consecutive-elements-in-an-array-after-modification`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.MaxSelectedEle...
15
count-prefix-and-suffix-pairs-i
3,042
Easy
[ "Trie", "Array", "String", "String Matching", "Hash Function", "Rolling Hash" ]
You are given a 0-indexed string array words. Let's define a boolean function isPrefixAndSuffix that takes two strings, str1 and str2: isPrefixAndSuffix(str1, str2) returns true if str1 is both a prefix and a suffix of str2, and false otherwise. For example, isPrefixAndSuffix("aba", "ababa") is true because "aba" is ...
countPrefixSuffixPairs(words: list_str) -> int
pub fn count_prefix_suffix_pairs(words: &[Vec<u8>]) -> i64
Aegis.CountPrefixSuffixPairs.count_prefix_suffix_pairs
pub fn count_prefix_suffix_pairs(words: &[Vec<u8>]) -> i64 { let n: usize = words.len(); let mut ans: i64 = 0; let mut i: usize = 0; while i < n { let mut j: usize = i + 1; while j < n { let a_len: usize = words[i].len(); let b_len: usize = words[j].len(); ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [count_prefix_suffix_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_op...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [count_prefix_suffix_pairs]: function definitions module public import Aeneas public import Aegis.CountPrefixSuffixPairs.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCo...
import Aegis.CountPrefixSuffixPairs.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eva...
[ { "input": "[[\"abab\", \"ab\"]]", "output": "0" }, { "input": "[[\"hello\", \"hellohello\", \"hellohellohello\"]]", "output": "3" }, { "input": "[[\"dog\", \"dogcat\", \"dogcatdog\"]]", "output": "1" }, { "input": "[[\"aabb\", \"aabbcc\", \"aabbccaabb\"]]", "output": "1"...
119
false
119
verified
10
10
1
1,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.CountPrefixSuffixPairs.Code.Funs /-! # Specifications of `Aegis.CountPrefixSuffixPairs.count_prefix_suffix_pairs` LeetCode problem `count-prefix-and-suffix-pairs-i`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.CountPrefixSuffixPair...
13
find-the-length-of-the-longest-common-prefix
3,043
Medium
[ "Trie", "Array", "Hash Table", "String" ]
You are given two arrays with positive integers arr1 and arr2. A prefix of a positive integer is an integer formed by one or more of its digits, starting from its leftmost digit. For example, 123 is a prefix of the integer 12345, while 234 is not. A common prefix of two integers a and b is an integer c, such that c is ...
longestCommonPrefix(arr1: list_int, arr2: list_int) -> int
pub fn longest_common_prefix(arr1: &[i64], arr2: &[i64]) -> i64
Aegis.LongestCommonPrefix.longest_common_prefix
fn highest_power(x: i64) -> i64 { let mut p: i64 = 1; while x / p >= 10 { p = p * 10; } p } pub fn longest_common_prefix(arr1: &[i64], arr2: &[i64]) -> i64 { let mut trie: Vec<i64> = Vec::new(); let mut i: usize = 0; while i < 10 { trie.push(-1); i += 1; } ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [longest_common_prefix]: type definitions module public import Aeneas @[expose] public section 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 -- [longest_common_prefix]: function definitions module public import Aeneas public import Aegis.LongestCommonPrefix.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand f...
import Aegis.LongestCommonPrefix.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval a...
[ { "input": "[[1], [2]]", "output": "0" }, { "input": "[[123456789], [987654321]]", "output": "0" }, { "input": "[[987654321], [9876543210]]", "output": "9" }, { "input": "[[100000000], [10000000, 1000000, 100000]]", "output": "8" }, { "input": "[[987654321], [9876...
121
false
121
verified
10
10
1
6,519
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.LongestCommonPrefix.Code.Funs /-! # Specifications of `Aegis.LongestCommonPrefix.longest_common_prefix` LeetCode problem `find-the-length-of-the-longest-common-prefix`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.LongestCommonPrefi...
12
most-frequent-prime
3,044
Medium
[ "Array", "Hash Table", "Math", "Counting", "Enumeration", "Matrix", "Number Theory" ]
You are given a m x n 0-indexed 2D matrix mat. From every cell, you can create numbers in the following way: There could be at most 8 paths from the cells namely: east, south-east, south, south-west, west, north-west, north, and north-east. Select a path from them and append digits in this path to the number being for...
mostFrequentPrime(mat: list_list_int) -> int
pub fn most_frequent_prime(mat: &[Vec<i64>]) -> i64
Aegis.MostFrequentPrime.most_frequent_prime
fn is_prime(n: i64) -> bool { if n < 2 { return false; } let mut d: i64 = 2; while d * d <= n { if n % d == 0 { return false; } d += 1; } true } pub fn most_frequent_prime(mat: &[Vec<i64>]) -> i64 { let m: usize = mat.len(); if m == 0 { ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [most_frequent_prime]: type definitions module public import Aeneas @[expose] public section 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 -- [most_frequent_prime]: function definitions module public import Aeneas public import Aegis.MostFrequentPrime.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false...
import Aegis.MostFrequentPrime.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": "[[[7]]]", "output": "-1" }, { "input": "[[[1, 1], [9, 9], [1, 1]]]", "output": "19" }, { "input": "[[[2, 3, 5], [3, 5, 7], [5, 7, 1]]]", "output": "53" }, { "input": "[[[9, 7, 8], [4, 6, 5], [2, 8, 6]]]", "output": "97" }, { "input": "[[[3, 3, 3], [3, ...
81
false
81
verified
10
10
2
12,518
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MostFrequentPrime.Code.Funs /-! # Specifications of `Aegis.MostFrequentPrime.most_frequent_prime` LeetCode problem `most-frequent-prime`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result Aegis.MostFrequentPrime namespace AegisSpec.MostFrequentPrime def ...
12
count-prefix-and-suffix-pairs-ii
3,045
Hard
[ "Trie", "Array", "String", "String Matching", "Hash Function", "Rolling Hash" ]
You are given a 0-indexed string array words. Let's define a boolean function isPrefixAndSuffix that takes two strings, str1 and str2: isPrefixAndSuffix(str1, str2) returns true if str1 is both a prefix and a suffix of str2, and false otherwise. For example, isPrefixAndSuffix("aba", "ababa") is true because "aba" is ...
countPrefixSuffixPairs(words: list_str) -> int
pub fn count_prefix_suffix_pairs(words: &[Vec<u8>]) -> i64
Aegis.CountPrefixSuffixPairs.count_prefix_suffix_pairs
fn find_child( head: &[i64], edge_to: &[i64], edge_next: &[i64], edge_ch: &[u8], node: usize, c: u8, ) -> i64 { let mut e = head[node]; while e != -1 { let ei = e as usize; if edge_ch[ei] == c { return edge_to[ei]; } e = edge_next[ei]; } ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [count_prefix_suffix_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_op...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [count_prefix_suffix_pairs]: function definitions module public import Aeneas public import Aegis.CountPrefixSuffixPairs.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCo...
import Aegis.CountPrefixSuffixPairs.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eva...
[ { "input": "[[\"abab\", \"ab\"]]", "output": "0" }, { "input": "[[\"aaaa\", \"aa\", \"a\"]]", "output": "0" }, { "input": "[[\"abc\", \"abcabc\", \"abcabcabc\"]]", "output": "3" }, { "input": "[[\"xyz\", \"xyzxyz\", \"zyxzyx\"]]", "output": "1" }, { "input": "[[\"...
69
false
69
verified
10
10
1
10,349
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.CountPrefixSuffixPairs.Code.Funs /-! # Specifications of `Aegis.CountPrefixSuffixPairs.count_prefix_suffix_pairs` LeetCode problem `count-prefix-and-suffix-pairs-ii`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.CountPrefixSuffixPairs (count_pr...
15
find-the-largest-area-of-square-inside-two-rectangles
3,047
Medium
[ "Geometry", "Array", "Math" ]
There exist n rectangles in a 2D plane with edges parallel to the x and y axis. You are given two 2D integer arrays bottomLeft and topRight where bottomLeft[i] = [a_i, b_i] and topRight[i] = [c_i, d_i] represent the bottom-left and top-right coordinates of the ith rectangle, respectively. You need to find the maximum a...
largestSquareArea(bottomLeft: list_list_int, topRight: list_list_int) -> int
pub fn largest_square_area(bottomLeft: &[Vec<i64>], topRight: &[Vec<i64>]) -> i64
Aegis.LargestSquareArea.largest_square_area
fn min_i64(a: i64, b: i64) -> i64 { if a < b { a } else { b } } fn max_i64(a: i64, b: i64) -> i64 { if a > b { a } else { b } } pub fn largest_square_area(bottomLeft: &[Vec<i64>], topRight: &[Vec<i64>]) -> i64 { let n: usize = bottomLeft.len(); let mut b...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [largest_square_area]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option l...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [largest_square_area]: function definitions module public import Aeneas public import Aegis.LargestSquareArea.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false...
import Aegis.LargestSquareArea.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, 1], [2, 2]], [[3, 3], [4, 4]]]", "output": "1" }, { "input": "[[[1, 1], [1, 1]], [[2, 2], [2, 2]]]", "output": "1" }, { "input": "[[[1, 1], [2, 2], [3, 1]], [[3, 3], [4, 4], [6, 6]]]", "output": "1" }, { "input": "[[[2, 2], [4, 4], [6, 6]], [[4, 4], [6, 6], ...
102
false
102
verified
10
10
1
928
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.LargestSquareArea.Code.Funs /-! # Specifications of `Aegis.LargestSquareArea.largest_square_area` LeetCode problem `find-the-largest-area-of-square-inside-two-rectangles`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.LargestSquareArea name...
11
earliest-second-to-mark-indices-i
3,048
Medium
[ "Array", "Binary Search" ]
You are given two 1-indexed integer arrays, nums and, changeIndices, having lengths n and m, respectively. Initially, all indices in nums are unmarked. Your task is to mark all indices in nums. In each second, s, in order from 1 to m (inclusive), you can perform one of the following operations: Choose an index i in th...
earliestSecondToMarkIndices(nums: list_int, changeIndices: list_int) -> int
pub fn earliest_second_to_mark_indices(nums: &[i64], changeIndices: &[i64]) -> i64
Aegis.EarliestSecondToMarkIndices.earliest_second_to_mark_indices
pub fn earliest_second_to_mark_indices(nums: &[i64], change_indices: &[i64]) -> i64 { let m = change_indices.len(); let mut result: i64 = -1; if can_mark_all(nums, change_indices, m) { let mut lo: usize = 1; let mut hi: usize = m; while lo < hi { let mid = lo + (hi - lo...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [earliest_second_to_mark_indices]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [earliest_second_to_mark_indices]: function definitions module public import Aeneas public import Aegis.EarliestSecondToMarkIndices.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option li...
import Aegis.EarliestSecondToMarkIndices.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}" ...
[ { "input": "[[0, 1], [2, 2, 2]]", "output": "-1" }, { "input": "[[0, 0, 0], [1, 2, 3]]", "output": "3" }, { "input": "[[0, 0, 0, 0], [1, 2, 3, 4]]", "output": "4" }, { "input": "[[1000000000, 1000000000], [1, 2, 1, 2, 1, 2]]", "output": "-1" }, { "input": "[[1, 3]...
113
false
113
verified
10
10
2
11,788
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.EarliestSecondToMarkIndices.Code.Funs /-! # Specifications of `Aegis.EarliestSecondToMarkIndices.earliest_second_to_mark_indices` LeetCode problem `earliest-second-to-mark-indices-i`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.Earli...
15
linked-list-frequency
3,063
Easy
[ "Hash Table", "Linked List", "Counting" ]
Given the head of a linked list containing k distinct elements, return the head to a linked list of length k containing the frequency of each distinct element in the given linked list in any order.   Example 1: Input: head = [1,1,2,1,2,3] Output: [3,2,1] Explanation: There are 3 distinct elements in the list. ...
frequenciesOfElements(head: linkedlist) -> linkedlist
pub fn frequencies_of_elements(head: &List) -> List
Aegis.FrequenciesOfElements.frequencies_of_elements
pub fn frequencies_of_elements(head: &List) -> List { let mut vals: Vec<i64> = Vec::new(); let mut cur: &List = head; let mut done = false; while !done { match cur { List::Nil => { done = true; } List::Cons(v, next) => { vals.p...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [frequencies_of_elements]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_opti...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [frequencies_of_elements]: function definitions module public import Aeneas public import Aegis.FrequenciesOfElements.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashComma...
import Aegis.FrequenciesOfElements.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}" deriv...
[ { "input": "[[1, 1, 2, 2, 2]]", "output": "[3, 2]" }, { "input": "[[1, 1, 2, 1, 2, 3]]", "output": "[1, 2, 3]" }, { "input": "[[200000, 200000, 200000, 200000, 200000, 200000, 200000, 200000, 200000, 200000]]", "output": "[10]" }, { "input": "[[6, 5, 4, 3, 2, 1]]", "outpu...
54
false
54
verified
10
10
2
22,840
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.FrequenciesOfElements.Code.Funs /-! # Specifications of `Aegis.FrequenciesOfElements.frequencies_of_elements` LeetCode problem `linked-list-frequency`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.FrequenciesOfElements abbrev RustLis...
14
minimum-operations-to-exceed-threshold-value-i
3,065
Easy
[ "Array" ]
You are given a 0-indexed integer array nums, and an integer k. In one operation, you can remove one occurrence of the smallest element of nums. Return the minimum number of operations needed so that all elements of the array are greater than or equal to k.   Example 1: Input: nums = [2,11,10,1,3], k = 10 Output: 3 Ex...
minOperations(nums: list_int, k: int) -> int
pub fn min_operations(nums: &[i64], k: i64) -> i64
Aegis.MinOperations.min_operations
pub fn min_operations(nums: &[i64], k: i64) -> i64 { let mut count: i64 = 0; let mut i: usize = 0; let n: usize = nums.len(); while i < n { if nums[i] < k { count += 1; } i += 1; } count }
-- 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": "[[7, 7, 7, 7, 7], 7]", "output": "0" }, { "input": "[[5, 5, 5, 5, 5], 5]", "output": "0" }, { "input": "[[1, 1, 2, 4, 9], 1]", "output": "0" }, { "input": "[[1, 2, 3, 4, 5], 3]", "output": "2" }, { "input": "[[5, 3, 8, 9, 2], 5]", "output": "2" }...
104
false
104
verified
10
10
1
274
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MinOperations.Code.Funs /-! # Specifications of `Aegis.MinOperations.min_operations` LeetCode problem `minimum-operations-to-exceed-threshold-value-i`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.MinOperations (min_operations) namespace Aegis...
14
minimum-operations-to-exceed-threshold-value-ii
3,066
Medium
[ "Array", "Simulation", "Heap (Priority Queue)" ]
You are given a 0-indexed integer array nums, and an integer k. You are allowed to perform some operations on nums, where in a single operation, you can: Select the two smallest integers x and y from nums. Remove x and y from nums. Insert (min(x, y) * 2 + max(x, y)) at any position in the array. Note that you can onl...
minOperations(nums: list_int, k: int) -> int
pub fn min_operations(nums: &[i64], k: i64) -> i64
Aegis.MinOperations.min_operations
pub fn min_operations(nums: &[i64], k: i64) -> i64 { let n: usize = nums.len(); let mut heap: Vec<i64> = Vec::new(); let mut i: usize = 0; while i < n { heap.push(nums[i]); i += 1; } // Build a min-heap in place. let mut start: usize = heap.len() / 2; while start > 0 { ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [min_operations]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [min_operations]: function definitions module public import Aeneas public import Aegis.MinOperations.Code.Types public import Aegis.MinOperations.Code.FunsExternal @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespac...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [min_operations]: external functions. -- This is a template file: rename it to "FunsExternal.lean" and fill the holes. module public import Aeneas public import Aegis.MinOperations.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error s...
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, 1000000000], 1000000000]", "output": "1" }, { "input": "[[1000000000, 1000000000], 1000000000]", "output": "0" }, { "input": "[[1000000000, 1], 2000000000]", "output": "1" }, { "input": "[[1000000000, 1000000000], 1000000000]", "output": "0" }, { ...
103
false
103
verified
10
10
1
13,549
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MinOperations.Code.Funs /-! # Specifications of `Aegis.MinOperations.min_operations` LeetCode problem `minimum-operations-to-exceed-threshold-value-ii`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.MinOperations def vals (nums : ...
14
count-pairs-of-connectable-servers-in-a-weighted-tree-network
3,067
Medium
[ "Tree", "Depth-First Search", "Array" ]
You are given an unrooted weighted tree with n vertices representing servers numbered from 0 to n - 1, an array edges where edges[i] = [ai, bi, weighti] represents a bidirectional edge between vertices ai and bi of weight weighti. You are also given an integer signalSpeed. Two servers a and b are connectable through a ...
countPairsOfConnectableServers(edges: list_list_int, signalSpeed: int) -> list_int
pub fn count_pairs_of_connectable_servers(edges: &[Vec<i64>], signalSpeed: i64) -> Vec<i64>
Aegis.CountPairsOfConnectableServers.count_pairs_of_connectable_servers
pub fn count_pairs_of_connectable_servers(edges: &[Vec<i64>], signalSpeed: i64) -> Vec<i64> { let n = edges.len() + 1; let mut adj: Vec<Vec<i64>> = Vec::new(); let mut i = 0; while i < n { adj.push(Vec::new()); i += 1; } i = 0; while i < edges.len() { let a = edges[...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [count_pairs_of_connectable_servers]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables fal...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [count_pairs_of_connectable_servers]: function definitions module public import Aeneas public import Aegis.CountPairsOfConnectableServers.Code.Types public import Aegis.CountPairsOfConnectableServers.Code.FunsExternal @[expose] public section open Aeneas Aeneas.Std ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [count_pairs_of_connectable_servers]: external functions. -- This is a template file: rename it to "FunsExternal.lean" and fill the holes. module public import Aeneas public import Aegis.CountPairsOfConnectableServers.Code.Types @[expose] public section open Aeneas ...
import Aegis.CountPairsOfConnectableServers.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...
[ { "input": "[[[0, 1, 4], [1, 2, 8], [2, 3, 12]], 4]", "output": "[0, 2, 2, 0]" }, { "input": "[[[0, 1, 4], [1, 2, 5], [2, 3, 6]], 2]", "output": "[0, 0, 0, 0]" }, { "input": "[[[0, 1, 5], [1, 2, 10], [2, 3, 15], [3, 4, 20]], 5]", "output": "[0, 3, 4, 3, 0]" }, { "input": "[[[...
92
false
92
verified
10
10
1
4,681
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.CountPairsOfConnectableServers.Code.Funs /-! # Specifications of `Aegis.CountPairsOfConnectableServers.count_pairs_of_connectable_servers` LeetCode problem `count-pairs-of-connectable-servers-in-a-weighted-tree-network`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas....
14
find-the-maximum-sum-of-node-values
3,068
Hard
[ "Greedy", "Bit Manipulation", "Tree", "Array", "Dynamic Programming", "Sorting" ]
There exists an undirected tree with n nodes numbered 0 to n - 1. You are given a 0-indexed 2D integer array edges of length n - 1, where edges[i] = [ui, vi] indicates that there is an edge between nodes ui and vi in the tree. You are also given a positive integer k, and a 0-indexed array of non-negative integers nums ...
maximumValueSum(nums: list_int, k: int, edges: list_list_int) -> int
pub fn maximum_value_sum(nums: &[i64], k: i64, edges: &[Vec<i64>]) -> i64
Aegis.MaximumValueSum.maximum_value_sum
pub fn maximum_value_sum(nums: &[i64], k: i64, edges: &[Vec<i64>]) -> i64 { let n = nums.len(); let mut total: i64 = 0; let mut flipped: usize = 0; let mut min_loss: i64 = 1000000000000000000; let mut i: usize = 0; while i < n { let a = nums[i]; let b = a ^ k; if b > a ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [maximum_value_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 lin...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [maximum_value_sum]: function definitions module public import Aeneas public import Aegis.MaximumValueSum.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.MaximumValueSum.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": "[[2, 3], 7, [[0, 1]]]", "output": "9" }, { "input": "[[1, 2, 1], 3, [[0, 1], [0, 2]]]", "output": "6" }, { "input": "[[5, 9, 14], 8, [[0, 1], [1, 2]]]", "output": "28" }, { "input": "[[0, 0, 0], 5, [[0, 1], [1, 2]]]", "output": "10" }, { "input": "[[0,...
91
false
91
verified
10
10
1
3,020
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MaximumValueSum.Code.Funs /-! # Specifications of `Aegis.MaximumValueSum.maximum_value_sum` LeetCode problem `find-the-maximum-sum-of-node-values`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.MaximumValueSum def xorInt (a b : Int) :...
12
distribute-elements-into-two-arrays-i
3,069
Easy
[ "Array", "Simulation" ]
You are given a 1-indexed array of distinct integers nums of length n. You need to distribute all the elements of nums between two arrays arr1 and arr2 using n operations. In the first operation, append nums[1] to arr1. In the second operation, append nums[2] to arr2. Afterwards, in the ith operation: If the last elem...
resultArray(nums: list_int) -> list_int
pub fn result_array(nums: &[i64]) -> Vec<i64>
Aegis.ResultArray.result_array
pub fn result_array(nums: &[i64]) -> Vec<i64> { let mut arr1: Vec<i64> = Vec::new(); let mut arr2: Vec<i64> = Vec::new(); arr1.push(nums[0]); arr2.push(nums[1]); let mut i: usize = 2; while i < nums.len() { let last1 = arr1[arr1.len() - 1]; let last2 = arr2[arr2.len() - 1]; ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [result_array]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter.s...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [result_array]: function definitions module public import Aeneas public import Aegis.ResultArray.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.ResultArray.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": "[[2, 1, 3]]", "output": "[2, 3, 1]" }, { "input": "[[5, 4, 3, 8]]", "output": "[5, 3, 4, 8]" }, { "input": "[[1, 3, 2, 4, 5]]", "output": "[1, 3, 2, 4, 5]" }, { "input": "[[3, 1, 2, 5, 4]]", "output": "[3, 2, 5, 4, 1]" }, { "input": "[[10, 20, 30, 5, 1...
107
false
107
verified
10
10
1
427
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.ResultArray.Code.Funs /-! # Specifications of `Aegis.ResultArray.result_array` LeetCode problem `distribute-elements-into-two-arrays-i`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.ResultArray (result_array) namespace AegisSpec.ResultArray d...
10
count-submatrices-with-top-left-element-and-sum-less-than-k
3,070
Medium
[ "Array", "Matrix", "Prefix Sum" ]
You are given a 0-indexed integer matrix grid and an integer k. Return the number of submatrices that contain the top-left element of the grid, and have a sum less than or equal to k.   Example 1: Input: grid = [[7,6,3],[6,6,1]], k = 18 Output: 4 Explanation: There are only 4 submatrices, shown in the image above, th...
countSubmatrices(grid: list_list_int, k: int) -> int
pub fn count_submatrices(grid: &[Vec<i64>], k: i64) -> i64
Aegis.CountSubmatrices.count_submatrices
pub fn count_submatrices(grid: &[Vec<i64>], k: i64) -> i64 { let m = grid.len(); if m == 0 { return 0; } let n = grid[0].len(); let mut col_sum: Vec<i64> = Vec::new(); let mut j = 0; while j < n { col_sum.push(0); j += 1; } let mut ans: i64 = 0; let mut ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [count_submatrices]: type definitions module public import Aeneas @[expose] public section 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 -- [count_submatrices]: function definitions module public import Aeneas public import Aegis.CountSubmatrices.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.CountSubmatrices.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": "1" }, { "input": "[[[1, 2], [3, 4]], 10]", "output": "4" }, { "input": "[[[1000, 1000], [1000, 1000]], 3000]", "output": "3" }, { "input": "[[[1000, 1000], [1000, 1000]], 2000]", "output": "3" }, { "input": "[[[999, 999], [999, ...
104
false
104
verified
10
10
1
1,231
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.CountSubmatrices.Code.Funs /-! # Specifications of `Aegis.CountSubmatrices.count_submatrices` LeetCode problem `count-submatrices-with-top-left-element-and-sum-less-than-k`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.CountSubmatrice...
8
distribute-elements-into-two-arrays-ii
3,072
Hard
[ "Binary Indexed Tree", "Segment Tree", "Array", "Simulation" ]
You are given a 1-indexed array of integers nums of length n. We define a function greaterCount such that greaterCount(arr, val) returns the number of elements in arr that are strictly greater than val. You need to distribute all the elements of nums between two arrays arr1 and arr2 using n operations. In the first ope...
resultArray(nums: list_int) -> list_int
pub fn result_array(nums: &[i64]) -> Vec<i64>
Aegis.ResultArray.result_array
fn lower_bound(arr: &[i64], val: i64) -> usize { let mut lo: usize = 0; let mut hi: usize = arr.len(); while lo < hi { let mid = lo + (hi - lo) / 2; if arr[mid] < val { lo = mid + 1; } else { hi = mid; } } lo } pub fn result_array(nums: &[i64]...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [result_array]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter.s...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [result_array]: function definitions module public import Aeneas public import Aegis.ResultArray.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.ResultArray.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": "[[2, 1, 3, 3]]", "output": "[2, 3, 1, 3]" }, { "input": "[[3, 3, 3, 3]]", "output": "[3, 3, 3, 3]" }, { "input": "[[5, 14, 3, 1, 2]]", "output": "[5, 3, 1, 2, 14]" }, { "input": "[[7, 10, 4, 3, 20, 15]]", "output": "[7, 4, 3, 10, 20, 15]" }, { "input":...
106
false
106
verified
10
10
1
17,421
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.ResultArray.Code.Funs /-! # Specifications of `Aegis.ResultArray.result_array` LeetCode problem `distribute-elements-into-two-arrays-ii`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result Aegis.ResultArray namespace AegisSpec.ResultArray def ints (l : List S...
8
maximum-increasing-triplet-value
3,073
Medium
[ "Array", "Ordered Set" ]
Given an array nums, return the maximum value of a triplet (i, j, k) such that i < j < k and nums[i] < nums[j] < nums[k]. The value of a triplet (i, j, k) is nums[i] - nums[j] + nums[k].   Example 1: Input: nums = [5,6,9] Output: 8 Explanation: We only have one choice for an increasing triplet and that is ch...
maximumTripletValue(nums: list_int) -> int
pub fn maximum_triplet_value(nums: &[i64]) -> i64
Aegis.MaximumTripletValue.maximum_triplet_value
fn lower_bound(xs: &[i64], x: i64) -> i64 { let mut lo: i64 = 0; let mut hi: i64 = xs.len() as i64; while lo < hi { let mid = (lo + hi) / 2; if xs[mid as usize] < x { lo = mid + 1; } else { hi = mid; } } lo } pub fn maximum_triplet_value(nums:...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [maximum_triplet_value]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [maximum_triplet_value]: function definitions module public import Aeneas public import Aegis.MaximumTripletValue.Code.Types public import Aegis.MaximumTripletValue.Code.FunsExternal @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [maximum_triplet_value]: external functions. -- This is a template file: rename it to "FunsExternal.lean" and fill the holes. module public import Aeneas public import Aegis.MaximumTripletValue.Code.Types @[expose] public section open Aeneas Aeneas.Std Result Contro...
import Aegis.MaximumTripletValue.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, 6, 9]]", "output": "8" }, { "input": "[[5, 6, 9]]", "output": "8" }, { "input": "[[1, 2, 3]]", "output": "2" }, { "input": "[[1, 5, 3, 6]]", "output": "4" }, { "input": "[[1, 5, 3, 6]]", "output": "4" }, { "input": "[[10, 20, 30, 40, 5...
252
false
252
verified
10
10
1
9,253
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MaximumTripletValue.Code.Funs /-! # Specifications of `Aegis.MaximumTripletValue.maximum_triplet_value` LeetCode problem `maximum-increasing-triplet-value`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.MaximumTripletValue def con...
12
apple-redistribution-into-boxes
3,074
Easy
[ "Greedy", "Array", "Sorting" ]
You are given an array apple of size n and an array capacity of size m. There are n packs where the ith pack contains apple[i] apples. There are m boxes as well, and the ith box has a capacity of capacity[i] apples. Return the minimum number of boxes you need to select to redistribute these n packs of apples into boxes...
minimumBoxes(apple: list_int, capacity: list_int) -> int
pub fn minimum_boxes(apple: &[i64], capacity: &[i64]) -> i64
Aegis.MinimumBoxes.minimum_boxes
pub fn minimum_boxes(apple: &[i64], capacity: &[i64]) -> i64 { let mut total_apples: i64 = 0; let mut i: usize = 0; while i < apple.len() { total_apples += apple[i]; i += 1; } let n = capacity.len(); let mut caps: Vec<i64> = Vec::new(); let mut j: usize = 0; while j < n ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [minimum_boxes]: type definitions module public import Aeneas @[expose] public section 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_boxes]: function definitions module public import Aeneas public import Aegis.MinimumBoxes.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.MinimumBoxes.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": "[[50], [50]]", "output": "1" }, { "input": "[[45, 5], [50]]", "output": "1" }, { "input": "[[49, 1], [50]]", "output": "1" }, { "input": "[[25, 25], [30, 20]]", "output": "2" }, { "input": "[[49, 1], [25, 24, 1]]", "output": "3" }, { "input...
79
false
79
verified
10
10
1
867
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MinimumBoxes.Code.Funs /-! # Specifications of `Aegis.MinimumBoxes.minimum_boxes` LeetCode problem `apple-redistribution-into-boxes`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.MinimumBoxes namespace AegisSpec.MinimumBoxes open scoped...
14
maximize-happiness-of-selected-children
3,075
Medium
[ "Greedy", "Array", "Sorting" ]
You are given an array happiness of length n, and a positive integer k. There are n children standing in a queue, where the ith child has happiness value happiness[i]. You want to select k children from these n children in k turns. In each turn, when you select a child, the happiness value of all the children that have...
maximumHappinessSum(happiness: list_int, k: int) -> int
pub fn maximum_happiness_sum(happiness: &[i64], k: i64) -> i64
Aegis.MaximumHappinessSum.maximum_happiness_sum
pub fn maximum_happiness_sum(happiness: &[i64], k: i64) -> i64 { let n = happiness.len(); let mut v: Vec<i64> = Vec::new(); let mut i: usize = 0; while i < n { v.push(happiness[i]); i = i + 1; } // Iterative bottom-up merge sort, descending. let mut width: usize = 1; wh...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [maximum_happiness_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...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [maximum_happiness_sum]: function definitions module public import Aeneas public import Aegis.MaximumHappinessSum.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand f...
import Aegis.MaximumHappinessSum.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval a...
[ { "input": "[[1], 1]", "output": "1" }, { "input": "[[100000000, 100000000, 100000000], 2]", "output": "199999999" }, { "input": "[[100, 100, 100], 1]", "output": "100" }, { "input": "[[1, 2, 3], 2]", "output": "4" }, { "input": "[[100000000, 100000000, 100000000,...
100
false
100
verified
10
10
1
5,892
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MaximumHappinessSum.Code.Funs /-! # Specifications of `Aegis.MaximumHappinessSum.maximum_happiness_sum` LeetCode problem `maximize-happiness-of-selected-children`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.MaximumHappinessSum ...
13
shortest-uncommon-substring-in-an-array
3,076
Medium
[ "Trie", "Array", "Hash Table", "String" ]
You are given an array arr of size n consisting of non-empty strings. Find a string array answer of size n such that: answer[i] is the shortest substring of arr[i] that does not occur as a substring in any other string in arr. If multiple such substrings exist, answer[i] should be the lexicographically smallest. And i...
shortestSubstrings(arr: list_str) -> list_str
pub fn shortest_substrings(arr: &[Vec<u8>]) -> Vec<Vec<u8>>
Aegis.ShortestSubstrings.shortest_substrings
fn occurs(haystack: &Vec<u8>, needle: &Vec<u8>) -> bool { let h = haystack.len(); let m = needle.len(); if m == 0 { return true; } if m > h { return false; } let maxp = h - m; let mut p = 0usize; while p <= maxp { let mut k = 0usize; let mut same = tru...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [shortest_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 l...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [shortest_substrings]: function definitions module public import Aeneas public import Aegis.ShortestSubstrings.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand fals...
import Aegis.ShortestSubstrings.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": "[[\"abc\", \"bcd\", \"abcd\"]]", "output": "[\"\", \"\", \"abcd\"]" }, { "input": "[[\"xyz\", \"zyx\", \"yzx\"]]", "output": "[\"xy\", \"yx\", \"zx\"]" }, { "input": "[[\"banana\", \"bandana\", \"band\"]]", "output": "[\"nan\", \"da\", \"\"]" }, { "input": "[[\"ab...
109
false
109
verified
10
10
2
8,966
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.ShortestSubstrings.Code.Funs /-! # Specifications of `Aegis.ShortestSubstrings.shortest_substrings` LeetCode problem `shortest-uncommon-substring-in-an-array`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.ShortestSubstrings def Occur...
13
maximum-strength-of-k-disjoint-subarrays
3,077
Hard
[ "Array", "Dynamic Programming", "Prefix Sum" ]
You are given an array of integers nums with length n, and a positive odd integer k. Select exactly k disjoint subarrays sub1, sub2, ..., subk from nums such that the last element of subi appears before the first element of sub{i+1} for all 1 <= i <= k-1. The goal is to maximize their combined strength. The strength of...
maximumStrength(nums: list_int, k: int) -> int
pub fn maximum_strength(nums: &[i64], k: i64) -> i64
Aegis.MaximumStrength.maximum_strength
pub fn maximum_strength(nums: &[i64], k: i64) -> i64 { let n = nums.len(); let kk = k as usize; let neg: i64 = -4_000_000_000_000_000_000; let mut dp: Vec<i64> = Vec::new(); let mut ongoing: Vec<i64> = Vec::new(); let mut t = 0usize; while t <= kk { dp.push(neg); ongoing.pu...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [maximum_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 lint...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [maximum_strength]: function definitions module public import Aeneas public import Aegis.MaximumStrength.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.MaximumStrength.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, -3], 1]", "output": "-1" }, { "input": "[[-10, -20, -30, -40, -50], 3]", "output": "100" }, { "input": "[[12, -2, -2, -2, -2], 5]", "output": "64" }, { "input": "[[10, 20, 30, 40, 50], 5]", "output": "30" }, { "input": "[[0, 0, 0, 0, 0], 5]",...
108
false
108
verified
10
10
1
7,663
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MaximumStrength.Code.Funs /-! # Specifications of `Aegis.MaximumStrength.maximum_strength` LeetCode problem `maximum-strength-of-k-disjoint-subarrays`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.MaximumStrength def len (nums : Slic...
6
match-alphanumerical-pattern-in-matrix-i
3,078
Medium
[ "Array", "Hash Table", "String", "Matrix" ]
You are given a 2D integer matrix board and a 2D character matrix pattern. Where 0 <= board[r][c] <= 9 and each element of pattern is either a digit or a lowercase English letter. Your task is to find a submatrix of board that matches pattern. An integer matrix part matches pattern if we can replace cells containing le...
findPattern(board: list_list_int, pattern: list_str) -> list_int
pub fn find_pattern(board: &[Vec<i64>], pattern: &[Vec<u8>]) -> Vec<i64>
Aegis.FindPattern.find_pattern
fn window_matches( board: &[Vec<i64>], pattern: &[Vec<u8>], sr: usize, sc: usize, ) -> bool { let ph = pattern.len(); let pw = pattern[0].len(); let mut letter_to_digit: Vec<i64> = Vec::new(); let mut k = 0; while k < 26 { letter_to_digit.push(-1); k += 1; } ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [find_pattern]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter.s...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [find_pattern]: function definitions module public import Aeneas public import Aegis.FindPattern.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.FindPattern.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], [2, 1]], [\"xx\"]]", "output": "[-1, -1]" }, { "input": "[[[9, 9], [9, 9]], [\"aa\", \"aa\"]]", "output": "[0, 0]" }, { "input": "[[[1, 2], [3, 4]], [\"ab\", \"cd\"]]", "output": "[0, 0]" }, { "input": "[[[9, 9, 9], [9, 9, 9]], [\"aa\", \"aa\"]]", "o...
96
false
96
verified
10
10
2
24,164
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.FindPattern.Code.Funs /-! # Specifications of `Aegis.FindPattern.find_pattern` LeetCode problem `match-alphanumerical-pattern-in-matrix-i`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.FindPattern def isDigitCode (c : Nat) : Prop := ...
10
find-the-sum-of-encrypted-integers
3,079
Easy
[ "Array", "Math" ]
You are given an integer array nums containing positive integers. We define a function encrypt such that encrypt(x) replaces every digit in x with the largest digit in x. For example, encrypt(523) = 555 and encrypt(213) = 333. Return the sum of encrypted elements.   Example 1: Input: nums = [1,2,3] Output: 6 Explanati...
sumOfEncryptedInt(nums: list_int) -> int
pub fn sum_of_encrypted_int(nums: &[i64]) -> i64
Aegis.SumOfEncryptedInt.sum_of_encrypted_int
fn encrypt(mut x: i64) -> i64 { let mut max_digit: i64 = 0; let mut len: i64 = 0; while x > 0 { let d: i64 = x % 10; if d > max_digit { max_digit = d; } len = len + 1; x = x / 10; } if len == 0 { return 0; } let mut res: i64 = 0;...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [sum_of_encrypted_int]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [sum_of_encrypted_int]: function definitions module public import Aeneas public import Aegis.SumOfEncryptedInt.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand fals...
import Aegis.SumOfEncryptedInt.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": "[[523, 213, 111]]", "output": "999" }, { "input": "[[523, 213, 111]]", "output": "999" }, { "input": "[[999, 100, 101]]", "output": "1221" }, { "input": "[[456, 789, 321]]", "output": "1998" }, { "input": "[[987, 654, 321]]", "output": "1998" }, ...
102
false
102
verified
10
10
1
816
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.SumOfEncryptedInt.Code.Funs /-! # Specifications of `Aegis.SumOfEncryptedInt.sum_of_encrypted_int` LeetCode problem `find-the-sum-of-encrypted-integers`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.SumOfEncryptedInt namespace AegisSpec.Su...
10
mark-elements-on-array-by-performing-queries
3,080
Medium
[ "Array", "Hash Table", "Sorting", "Simulation", "Heap (Priority Queue)" ]
You are given a 0-indexed array nums of size n consisting of positive integers. You are also given a 2D array queries of size m where queries[i] = [indexi, ki]. Initially all elements of the array are unmarked. You need to apply m queries on the array in order, where on the ith query you do the following: Mark the ele...
unmarkedSumArray(nums: list_int, queries: list_list_int) -> list_int
pub fn unmarked_sum_array(nums: &[i64], queries: &[Vec<i64>]) -> Vec<i64>
Aegis.UnmarkedSumArray.unmarked_sum_array
pub fn unmarked_sum_array(nums: &[i64], queries: &[Vec<i64>]) -> Vec<i64> { let n = nums.len(); let mut total: i64 = 0; let mut marked: Vec<bool> = Vec::new(); let mut i = 0; while i < n { total += nums[i]; marked.push(false); i += 1; } let mut order: Vec<usize> = V...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [unmarked_sum_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 li...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [unmarked_sum_array]: function definitions module public import Aeneas public import Aegis.UnmarkedSumArray.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.UnmarkedSumArray.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, 4, 2, 3], [[0, 1]]]", "output": "[7]" }, { "input": "[[10, 20, 30, 40, 50], [[0, 2], [1, 1]]]", "output": "[90, 50]" }, { "input": "[[7, 7, 7, 7, 7], [[0, 3], [2, 2]]]", "output": "[7, 0]" }, { "input": "[[1, 1, 1, 1, 1], [[0, 5], [1, 1]]]", "output": "[0...
111
false
111
verified
10
10
1
5,868
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.UnmarkedSumArray.Code.Funs /-! # Specifications of `Aegis.UnmarkedSumArray.unmarked_sum_array` LeetCode problem `mark-elements-on-array-by-performing-queries`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.UnmarkedSumArray def numAt (...
12
find-the-sum-of-the-power-of-all-subsequences
3,082
Hard
[ "Array", "Dynamic Programming" ]
You are given an integer array nums of length n and a positive integer k. The power of an array of integers is defined as the number of subsequences with their sum equal to k. Return the sum of power of all subsequences of nums. Since the answer may be very large, return it modulo 109 + 7.   Example 1: Input: nums =...
sumOfPower(nums: list_int, k: int) -> int
pub fn sum_of_power(nums: &[i64], k: i64) -> i64
Aegis.SumOfPower.sum_of_power
pub fn sum_of_power(nums: &[i64], k: i64) -> i64 { const MOD: i64 = 1_000_000_007; let kk = k as usize; let mut dp: Vec<i64> = Vec::new(); let mut i = 0; while i <= kk { dp.push(0); i += 1; } dp[0] = 1; let n = nums.len(); let mut idx = 0; while idx < n { ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [sum_of_power]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter.s...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [sum_of_power]: function definitions module public import Aeneas public import Aegis.SumOfPower.Code.Types public import Aegis.SumOfPower.Code.FunsExternal @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [sum_of_power]: external functions. -- This is a template file: rename it to "FunsExternal.lean" and fill the holes. module public import Aeneas public import Aegis.SumOfPower.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_op...
import Aegis.SumOfPower.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval aegisCase ...
[ { "input": "[[1], 1]", "output": "1" }, { "input": "[[10, 20, 30], 60]", "output": "1" }, { "input": "[[100, 200, 300], 100]", "output": "4" }, { "input": "[[100, 200, 300], 600]", "output": "1" }, { "input": "[[2, 3, 3], 5]", "output": "4" }, { "input...
103
false
103
verified
10
10
1
3,453
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.SumOfPower.Code.Funs /-! # Specifications of `Aegis.SumOfPower.sum_of_power` LeetCode problem `find-the-sum-of-the-power-of-all-subsequences`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.SumOfPower def MOD : Int := 1000000007 def v...
13
existence-of-a-substring-in-a-string-and-its-reverse
3,083
Easy
[ "Hash Table", "String" ]
Given a string s, find any substring of length 2 which is also present in the reverse of s. Return true if such a substring exists, and false otherwise.   Example 1: Input: s = "leetcode" Output: true Explanation: Substring "ee" is of length 2 which is also present in reverse(s) == "edocteel". Example 2: Input: s = ...
isSubstringPresent(s: str) -> bool
pub fn is_substring_present(s: &[u8]) -> bool
Aegis.IsSubstringPresent.is_substring_present
pub fn is_substring_present(s: &[u8]) -> bool { let n = s.len(); let mut found = false; if n >= 2 { let mut i: usize = 0; while i + 1 < n && !found { let mut j: usize = 0; while j + 1 < n { if s[i] == s[j + 1] && s[i + 1] == s[j] { ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [is_substring_present]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [is_substring_present]: function definitions module public import Aeneas public import Aegis.IsSubstringPresent.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand fal...
import Aegis.IsSubstringPresent.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": "[\"abcba\"]", "output": "true" }, { "input": "[\"deified\"]", "output": "true" }, { "input": "[\"abab\"]", "output": "true" }, { "input": "[\"ab\"]", "output": "false" }, { "input": "[\"mnopqr\"]", "output": "false" }, { "input": "[\"aa\"]"...
122
false
122
verified
10
10
2
1,246
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.IsSubstringPresent.Code.Funs /-! # Specifications of `Aegis.IsSubstringPresent.is_substring_present` LeetCode problem `existence-of-a-substring-in-a-string-and-its-reverse`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.IsSubstringPresent (is_su...
13
count-substrings-starting-and-ending-with-given-character
3,084
Medium
[ "Math", "String", "Counting" ]
You are given a string s and a character c. Return the total number of substrings of s that start and end with c.   Example 1: Input: s = "abada", c = "a" Output: 6 Explanation: Substrings starting and ending with "a" are: "abada", "abada", "abada", "abada", "abada", "abada". Example 2: Input: s = "zzz", c = "z" Out...
countSubstrings(s: str, c: str) -> int
pub fn count_substrings(s: &[u8], c: &[u8]) -> i64
Aegis.CountSubstrings.count_substrings
pub fn count_substrings(s: &[u8], c: &[u8]) -> i64 { if c.len() == 0 { return 0; } let target = c[0]; let mut count: i64 = 0; let n = s.len(); let mut i: usize = 0; while i < n { if s[i] == target { count += 1; } i += 1; } count * (count...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [count_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 lint...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [count_substrings]: function definitions module public import Aeneas public import Aegis.CountSubstrings.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.CountSubstrings.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": "[\"zzz\", \"z\"]", "output": "6" }, { "input": "[\"abcabcabc\", \"b\"]", "output": "6" }, { "input": "[\"abcdefg\", \"f\"]", "output": "1" }, { "input": "[\"\", \"a\"]", "output": "0" }, { "input": "[\"abcabcabc\", \"a\"]", "output": "6" }, { ...
105
false
105
verified
10
10
1
506
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.CountSubstrings.Code.Funs /-! # Specifications of `Aegis.CountSubstrings.count_substrings` LeetCode problem `count-substrings-starting-and-ending-with-given-character`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.CountSubstrings ...
13
minimum-deletions-to-make-string-k-special
3,085
Medium
[ "Greedy", "Hash Table", "String", "Counting", "Sorting" ]
You are given a string word and an integer k. We consider word to be k-special if |freq(word[i]) - freq(word[j])| <= k for all indices i and j in the string. Here, freq(x) denotes the frequency of the character x in word, and |y| denotes the absolute value of y. Return the minimum number of characters you need to delet...
minimumDeletions(word: str, k: int) -> int
pub fn minimum_deletions(word: &[u8], k: i64) -> i64
Aegis.MinimumDeletions.minimum_deletions
pub fn minimum_deletions(word: &[u8], k: i64) -> i64 { let mut cnt: Vec<i64> = Vec::new(); let mut i: usize = 0; while i < 26 { cnt.push(0); i = i + 1; } let n = word.len(); i = 0; while i < n { let idx: usize = (word[i] - b'a') as usize; cnt[idx] = cnt[idx] ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [minimum_deletions]: type definitions module public import Aeneas @[expose] public section 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_deletions]: function definitions module public import Aeneas public import Aegis.MinimumDeletions.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.MinimumDeletions.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": "[\"abacabadaba\", 2]", "output": "3" }, { "input": "[\"abacabadabacaba\", 3]", "output": "4" }, { "input": "[\"xyz\", 0]", "output": "0" }, { "input": "[\"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\", 10]", "output": "0" }, { "input": "[\"abc...
53
false
53
verified
10
10
1
6,223
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MinimumDeletions.Code.Funs /-! # Specifications of `Aegis.MinimumDeletions.minimum_deletions` LeetCode problem `minimum-deletions-to-make-string-k-special`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.MinimumDeletions namespace AegisSpec.Mini...
10
minimum-moves-to-pick-k-ones
3,086
Hard
[ "Greedy", "Array", "Prefix Sum", "Sliding Window" ]
You are given a binary array nums of length n, a positive integer k and a non-negative integer maxChanges. Alice plays a game, where the goal is for Alice to pick up k ones from nums using the minimum number of moves. When the game starts, Alice picks up any index aliceIndex in the range [0, n - 1] and stands there. If...
minimumMoves(nums: list_int, k: int, maxChanges: int) -> int
pub fn minimum_moves(nums: &[i64], k: i64, maxChanges: i64) -> i64
Aegis.MinimumMoves.minimum_moves
fn lower_bound_pos(ps: &[i64], target: i64) -> usize { let mut lo: usize = 0; let mut hi: usize = ps.len(); while lo < hi { let mid = lo + (hi - lo) / 2; if ps[mid] < target { lo = mid + 1; } else { hi = mid; } } lo } fn upper_bound_pos(ps: &[...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [minimum_moves]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter....
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [minimum_moves]: function definitions module public import Aeneas public import Aegis.MinimumMoves.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option...
import Aegis.MinimumMoves.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 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": "[[0, 0, 0, 0], 2, 3]", "output": "4" }, { "input": "[[0, 1, 0, 1, 0, 1, 0, 1, 0, 1], 5, 5]", "output": "8" }, { "input": "[[1, 1, 0, 0, 0, 0, 0, 0, 0, 1], 3, 2]", "output": "3" }, { "input": "[[1, 0, 0, 0, 0, 0, 0, 0, 0, 1], 2, 1]", "output": "2" }, { ...
95
false
95
verified
10
10
1
22,953
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MinimumMoves.Code.Funs /-! # Specifications of `Aegis.MinimumMoves.minimum_moves` LeetCode problem `minimum-moves-to-pick-k-ones`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.MinimumMoves (minimum_moves) namespace AegisSpec.MinimumMoves ...
13
maximum-length-substring-with-two-occurrences
3,090
Easy
[ "Hash Table", "String", "Sliding Window" ]
Given a string s, return the maximum length of a substring such that it contains at most two occurrences of each character.   Example 1: Input: s = "bcbbbcba" Output: 4 Explanation: The following substring has a length of 4 and contains at most two occurrences of each character: "bcbbbcba". Example 2: Input: s = "aaa...
maximumLengthSubstring(s: str) -> int
pub fn maximum_length_substring(s: &[u8]) -> i64
Aegis.MaximumLengthSubstring.maximum_length_substring
pub fn maximum_length_substring(s: &[u8]) -> i64 { let mut counts: Vec<i64> = Vec::new(); let mut i: usize = 0; while i < 26 { counts.push(0); i = i + 1; } let mut left: usize = 0; let mut right: usize = 0; let mut best: i64 = 0; while right < s.len() { let c: u...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [maximum_length_substring]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_opt...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [maximum_length_substring]: function definitions module public import Aeneas public import Aegis.MaximumLengthSubstring.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCom...
import Aegis.MaximumLengthSubstring.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eva...
[ { "input": "[\"zzzzzzzzz\"]", "output": "2" }, { "input": "[\"aaabbbccc\"]", "output": "4" }, { "input": "[\"aabbaa\"]", "output": "4" }, { "input": "[\"abababab\"]", "output": "4" }, { "input": "[\"aabacbebebe\"]", "output": "6" }, { "input": "[\"abac...
78
false
78
verified
10
10
1
1,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.MaximumLengthSubstring.Code.Funs /-! # Specifications of `Aegis.MaximumLengthSubstring.maximum_length_substring` LeetCode problem `maximum-length-substring-with-two-occurrences`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.MaximumL...
13
apply-operations-to-make-sum-of-array-greater-than-or-equal-to-k
3,091
Medium
[ "Greedy", "Math", "Enumeration" ]
You are given a positive integer k. Initially, you have an array nums = [1]. You can perform any of the following operations on the array any number of times (possibly zero): Choose any element in the array and increase its value by 1. Duplicate any element in the array and add it to the end of the array. Return the ...
minOperations(k: int) -> int
pub fn min_operations(k: i64) -> i64
Aegis.MinOperations.min_operations
pub fn min_operations(k: i64) -> i64 { let mut best: i64 = k - 1; let mut x: i64 = 1; while x <= k { let copies: i64 = (k + x - 1) / x; let operations: i64 = (x - 1) + (copies - 1); if operations < best { best = operations; } x += 1; } best }
-- 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": "[100]", "output": "18" }, { "input": "[20]", "output": "7" }, { "input": "[1]", "output": "0" }, { "input": "[15]", "output": "6" }, { "input": "[11]", "output": "5" }, { "input": "[3]", "output": "2" }, { "input": "[100000]", ...
58
false
58
verified
10
10
1
1,219
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MinOperations.Code.Funs /-! # Specifications of `Aegis.MinOperations.min_operations` LeetCode problem `apply-operations-to-make-sum-of-array-greater-than-or-equal-to-k`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.MinOperations ...
13
shortest-subarray-with-or-at-least-k-i
3,095
Easy
[ "Bit Manipulation", "Array", "Sliding Window" ]
You are given an array nums of non-negative integers and an integer k. An array is called special if the bitwise OR of all of its elements is at least k. Return the length of the shortest special non-empty subarray of nums, or return -1 if no special subarray exists.   Example 1: Input: nums = [1,2,3], k = 2 Output: 1...
minimumSubarrayLength(nums: list_int, k: int) -> int
pub fn minimum_subarray_length(nums: &[i64], k: i64) -> i64
Aegis.MinimumSubarrayLength.minimum_subarray_length
pub fn minimum_subarray_length(nums: &[i64], k: i64) -> i64 { let n = nums.len(); let mut best: i64 = -1; let mut i: usize = 0; while i < n { let mut cur: i64 = 0; let mut j: usize = i; while j < n { cur = cur | nums[j]; if cur >= k { le...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [minimum_subarray_length]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_opti...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [minimum_subarray_length]: function definitions module public import Aeneas public import Aegis.MinimumSubarrayLength.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashComma...
import Aegis.MinimumSubarrayLength.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": "[[1, 2], 0]", "output": "1" }, { "input": "[[0, 0, 0], 1]", "output": "-1" }, { "input": "[[1, 2, 3], 2]", "output": "1" }, { "input": "[[2, 1, 8], 10]", "output": "3" }, { "input": "[[5, 5, 5, 5], 5]", "output": "1" }, { "input": "[[4, 5, ...
109
false
109
verified
10
10
1
844
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MinimumSubarrayLength.Code.Funs /-! # Specifications of `Aegis.MinimumSubarrayLength.minimum_subarray_length` LeetCode problem `shortest-subarray-with-or-at-least-k-i`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.MinimumSubarrayLengt...
12
minimum-levels-to-gain-more-points
3,096
Medium
[ "Array", "Prefix Sum" ]
You are given a binary array possible of length n. Alice and Bob are playing a game that consists of n levels. Some of the levels in the game are impossible to clear while others can always be cleared. In particular, if possible[i] == 0, then the ith level is impossible to clear for both the players. A player gains 1 p...
minimumLevels(possible: list_int) -> int
pub fn minimum_levels(possible: &[i64]) -> i64
Aegis.MinimumLevels.minimum_levels
pub fn minimum_levels(possible: &[i64]) -> i64 { let n: usize = possible.len(); let mut total: i64 = 0; let mut i: usize = 0; while i < n { if possible[i] == 1 { total += 1; } else { total -= 1; } i += 1; } let mut prefix: i64 = 0; le...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [minimum_levels]: type definitions module public import Aeneas @[expose] public section 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_levels]: function definitions module public import Aeneas public import Aegis.MinimumLevels.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.MinimumLevels.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, 0]]", "output": "-1" }, { "input": "[[1, 0, 1, 0]]", "output": "1" }, { "input": "[[1, 1, 1, 1, 1]]", "output": "3" }, { "input": "[[0, 1, 0, 1, 0, 1]]", "output": "-1" }, { "input": "[[1, 1, 0, 0, 1, 1]]", "output": "2" }, { "input": ...
114
false
114
verified
10
10
1
993
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MinimumLevels.Code.Funs /-! # Specifications of `Aegis.MinimumLevels.minimum_levels` LeetCode problem `minimum-levels-to-gain-more-points`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.MinimumLevels def weight (x : Std.I64) : Int := ...
11
shortest-subarray-with-or-at-least-k-ii
3,097
Medium
[ "Bit Manipulation", "Array", "Sliding Window" ]
You are given an array nums of non-negative integers and an integer k. An array is called special if the bitwise OR of all of its elements is at least k. Return the length of the shortest special non-empty subarray of nums, or return -1 if no special subarray exists.   Example 1: Input: nums = [1,2,3], k = 2 Output: 1...
minimumSubarrayLength(nums: list_int, k: int) -> int
pub fn minimum_subarray_length(nums: &[i64], k: i64) -> i64
Aegis.MinimumSubarrayLength.minimum_subarray_length
pub fn minimum_subarray_length(nums: &[i64], k: i64) -> i64 { let n = nums.len(); if n == 0 { return -1; } if k == 0 { return 1; } let mut counts: Vec<i64> = Vec::new(); let mut i: usize = 0; while i < 63 { counts.push(0); i += 1; } let mut cur_o...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [minimum_subarray_length]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_opti...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [minimum_subarray_length]: function definitions module public import Aeneas public import Aegis.MinimumSubarrayLength.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashComma...
import Aegis.MinimumSubarrayLength.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": "[[1000000000], 1000000000]", "output": "1" }, { "input": "[[1073741824], 1073741824]", "output": "1" }, { "input": "[[1, 2], 0]", "output": "1" }, { "input": "[[0, 0, 0], 1]", "output": "-1" }, { "input": "[[1, 2, 3], 2]", "output": "1" }, { ...
95
false
95
verified
10
10
1
4,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.MinimumSubarrayLength.Code.Funs /-! # Specifications of `Aegis.MinimumSubarrayLength.minimum_subarray_length` LeetCode problem `shortest-subarray-with-or-at-least-k-ii`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.MinimumSubarrayLe...
13
find-the-sum-of-subsequence-powers
3,098
Hard
[ "Array", "Dynamic Programming", "Sorting" ]
You are given an integer array nums of length n, and a positive integer k. The power of a subsequence is defined as the minimum absolute difference between any two elements in the subsequence. Return the sum of powers of all subsequences of nums which have length equal to k. Since the answer may be large, return it mod...
sumOfPowers(nums: list_int, k: int) -> int
pub fn sum_of_powers(nums: &[i64], k: i64) -> i64
Aegis.SumOfPowers.sum_of_powers
const MOD: i64 = 1_000_000_007; fn count_with_min_gap_at_least(a: &[i64], k: i64, d: i64) -> i64 { let n = a.len(); if k <= 0 { return 0; } if k == 1 { let mut cnt: i64 = 0; let mut i = 0; while i < n { cnt += 1; i += 1; } return...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [sum_of_powers]: type definitions module public import Aeneas @[expose] public section 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 -- [sum_of_powers]: function definitions module public import Aeneas public import Aegis.SumOfPowers.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.SumOfPowers.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": "[[2, 2], 2]", "output": "0" }, { "input": "[[4, 3, -1], 2]", "output": "10" }, { "input": "[[1, 2, 3, 4], 3]", "output": "4" }, { "input": "[[100, -100, 200, -200], 2]", "output": "1400" }, { "input": "[[100000000, -100000000, 50000000, -50000000], 3]"...
120
false
120
verified
10
10
1
16,813
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.SumOfPowers.Code.Funs /-! # Specifications of `Aegis.SumOfPowers.sum_of_powers` LeetCode problem `find-the-sum-of-subsequence-powers`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.SumOfPowers def MD : ℤ := 1000000007 def values (s :...
9
harshad-number
3,099
Easy
[ "Math" ]
An integer divisible by the sum of its digits is said to be a Harshad number. You are given an integer x. Return the sum of the digits of x if x is a Harshad number, otherwise, return -1.   Example 1: Input: x = 18 Output: 9 Explanation: The sum of digits of x is 9. 18 is divisible by 9. So 18 is a Harshad number and ...
sumOfTheDigitsOfHarshadNumber(x: int) -> int
pub fn sum_of_the_digits_of_harshad_number(x: i64) -> i64
Aegis.SumOfTheDigitsOfHarshadNumber.sum_of_the_digits_of_harshad_number
pub fn sum_of_the_digits_of_harshad_number(x: i64) -> i64 { let mut n: i64 = x; let mut sum: i64 = 0; while n > 0 { sum += n % 10; n /= 10; } if x % sum == 0 { sum } else { -1 } }
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [sum_of_the_digits_of_harshad_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 fa...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [sum_of_the_digits_of_harshad_number]: function definitions module public import Aeneas public import Aegis.SumOfTheDigitsOfHarshadNumber.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_opt...
import Aegis.SumOfTheDigitsOfHarshadNumber.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}...
[ { "input": "[50]", "output": "5" }, { "input": "[23]", "output": "-1" }, { "input": "[10]", "output": "1" }, { "input": "[18]", "output": "9" }, { "input": "[1]", "output": "1" }, { "input": "[90]", "output": "9" }, { "input": "[57]", "...
53
false
53
verified
10
10
1
288
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.SumOfTheDigitsOfHarshadNumber.Code.Funs /-! # Specifications of `Aegis.SumOfTheDigitsOfHarshadNumber.sum_of_the_digits_of_harshad_number` LeetCode problem `harshad-number`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.SumOfTheDigits...
7
water-bottles-ii
3,100
Medium
[ "Math", "Simulation" ]
You are given two integers numBottles and numExchange. numBottles represents the number of full water bottles that you initially have. In one operation, you can perform one of the following operations: Drink any number of full water bottles turning them into empty bottles. Exchange numExchange empty bottles with one f...
maxBottlesDrunk(numBottles: int, numExchange: int) -> int
pub fn max_bottles_drunk(numBottles: i64, numExchange: i64) -> i64
Aegis.MaxBottlesDrunk.max_bottles_drunk
pub fn max_bottles_drunk(numBottles: i64, numExchange: i64) -> i64 { let mut drunk = numBottles; let mut empty = numBottles; let mut exchange = numExchange; while empty >= exchange { empty = empty - exchange; empty = empty + 1; drunk = drunk + 1; exchange = exchange + 1;...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [max_bottles_drunk]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option lin...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [max_bottles_drunk]: function definitions module public import Aeneas public import Aegis.MaxBottlesDrunk.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.MaxBottlesDrunk.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": "[10, 3]", "output": "13" }, { "input": "[2, 3]", "output": "2" }, { "input": "[13, 6]", "output": "15" }, { "input": "[100, 1]", "output": "114" }, { "input": "[5, 5]", "output": "6" }, { "input": "[1, 1]", "output": "2" }, { "i...
86
false
86
verified
10
10
1
1,142
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MaxBottlesDrunk.Code.Funs /-! # Specifications of `Aegis.MaxBottlesDrunk.max_bottles_drunk` LeetCode problem `water-bottles-ii`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.MaxBottlesDrunk def ExchangesFeasible (numBottles numExchan...
12
count-alternating-subarrays
3,101
Medium
[ "Array", "Math" ]
You are given a binary array nums. We call a subarray alternating if no two adjacent elements in the subarray have the same value. Return the number of alternating subarrays in nums.   Example 1: Input: nums = [0,1,1,1] Output: 5 Explanation: The following subarrays are alternating: [0], [1], [1], [1], and [0,1]. Exa...
countAlternatingSubarrays(nums: list_int) -> int
pub fn count_alternating_subarrays(nums: &[i64]) -> i64
Aegis.CountAlternatingSubarrays.count_alternating_subarrays
pub fn count_alternating_subarrays(nums: &[i64]) -> i64 { let n = nums.len(); if n == 0 { return 0; } let mut total: i64 = 1; let mut current: i64 = 1; let mut i: usize = 1; while i < n { if nums[i] == nums[i - 1] { current = 1; } else { curr...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [count_alternating_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_...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [count_alternating_subarrays]: function definitions module public import Aeneas public import Aegis.CountAlternatingSubarrays.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.h...
import Aegis.CountAlternatingSubarrays.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}" #...
[ { "input": "[[1]]", "output": "1" }, { "input": "[[0]]", "output": "1" }, { "input": "[[0, 1]]", "output": "3" }, { "input": "[[1, 0]]", "output": "3" }, { "input": "[[1, 1, 1, 1]]", "output": "4" }, { "input": "[[0, 1, 1, 1]]", "output": "5" }, ...
110
false
110
verified
10
10
1
626
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.CountAlternatingSubarrays.Code.Funs /-! # Specifications of `Aegis.CountAlternatingSubarrays.count_alternating_subarrays` LeetCode problem `count-alternating-subarrays`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.CountAlternatingSub...
13
find-longest-self-contained-substring
3,104
Hard
[ "Hash Table", "String", "Binary Search", "Prefix Sum" ]
Given a string s, your task is to find the length of the longest self-contained substring of s. A substring t of a string s is called self-contained if t != s and for every character in t, it doesn't exist in the rest of s. Return the length of the longest self-contained substring of s if it exists, otherwise, return -...
maxSubstringLength(s: str) -> int
pub fn max_substring_length(s: &[u8]) -> i64
Aegis.MaxSubstringLength.max_substring_length
pub fn max_substring_length(s: &[u8]) -> i64 { let n = s.len(); let mut first: Vec<i64> = Vec::new(); let mut last: Vec<i64> = Vec::new(); let mut i = 0; while i < 26 { first.push(-1); last.push(-1); i += 1; } i = 0; while i < n { let idx = (s[i] - b'a')...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [max_substring_length]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [max_substring_length]: function definitions module public import Aeneas public import Aegis.MaxSubstringLength.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand fal...
import Aegis.MaxSubstringLength.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": "[\"abcdeabcde\"]", "output": "-1" }, { "input": "[\"abba\"]", "output": "2" }, { "input": "[\"zzzzzz\"]", "output": "-1" }, { "input": "[\"aabbcc\"]", "output": "4" }, { "input": "[\"abacabadabacaba\"]", "output": "1" }, { "input": "[\"abca...
87
false
87
verified
10
10
1
8,860
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MaxSubstringLength.Code.Funs /-! # Specifications of `Aegis.MaxSubstringLength.max_substring_length` LeetCode problem `find-longest-self-contained-substring`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.MaxSubstringLength namespace AegisS...
14
longest-strictly-increasing-or-strictly-decreasing-subarray
3,105
Easy
[ "Array" ]
You are given an array of integers nums. Return the length of the longest subarray of nums which is either strictly increasing or strictly decreasing.   Example 1: Input: nums = [1,4,3,3,2] Output: 2 Explanation: The strictly increasing subarrays of nums are [1], [2], [3], [3], [4], and [1,4]. The strictly decreasing ...
longestMonotonicSubarray(nums: list_int) -> int
pub fn longest_monotonic_subarray(nums: &[i64]) -> i64
Aegis.LongestMonotonicSubarray.longest_monotonic_subarray
pub fn longest_monotonic_subarray(nums: &[i64]) -> i64 { let n = nums.len(); if n == 0 { return 0; } let mut best: i64 = 1; let mut inc: i64 = 1; let mut dec: i64 = 1; let mut i: usize = 1; while i < n { if nums[i] > nums[i - 1] { inc = inc + 1; ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [longest_monotonic_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_o...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [longest_monotonic_subarray]: function definitions module public import Aeneas public import Aegis.LongestMonotonicSubarray.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.has...
import Aegis.LongestMonotonicSubarray.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": "1" }, { "input": "[[3, 2, 1]]", "output": "3" }, { "input": "[[3, 3, 3, 3]]", "output": "1" }, { "input": "[[1, 3, 5, 4, 7]]", "output": "3" }, { "input": "[[1, 2, 3, 4, 5]]", "output": "5" }, { "input": "[[1, 4, 3, 3, 2]...
139
false
139
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.LongestMonotonicSubarray.Code.Funs /-! # Specifications of `Aegis.LongestMonotonicSubarray.longest_monotonic_subarray` LeetCode problem `longest-strictly-increasing-or-strictly-decreasing-subarray`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace ...
12
minimum-operations-to-make-median-of-array-equal-to-k
3,107
Medium
[ "Greedy", "Array", "Sorting" ]
You are given an integer array nums and a non-negative integer k. In one operation, you can increase or decrease any element by 1. Return the minimum number of operations needed to make the median of nums equal to k. The median of an array is defined as the middle element of the array when it is sorted in non-decreasin...
minOperationsToMakeMedianK(nums: list_int, k: int) -> int
pub fn min_operations_to_make_median_k(nums: &[i64], k: i64) -> i64
Aegis.MinOperationsToMakeMedianK.min_operations_to_make_median_k
pub fn min_operations_to_make_median_k(nums: &[i64], k: i64) -> i64 { let n = nums.len(); let mut a: Vec<i64> = Vec::new(); let mut i = 0; while i < n { a.push(nums[i]); i += 1; } a.sort(); let m = n / 2; let mut ans: i64 = 0; if a[m] > k { let mut j = 0; ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [min_operations_to_make_median_k]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [min_operations_to_make_median_k]: function definitions module public import Aeneas public import Aegis.MinOperationsToMakeMedianK.Code.Types public import Aegis.MinOperationsToMakeMedianK.Code.FunsExternal @[expose] public section open Aeneas Aeneas.Std Result Cont...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [min_operations_to_make_median_k]: external functions. -- This is a template file: rename it to "FunsExternal.lean" and fill the holes. module public import Aeneas public import Aegis.MinOperationsToMakeMedianK.Code.Types @[expose] public section open Aeneas Aeneas....
import Aegis.MinOperationsToMakeMedianK.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}" ...
[ { "input": "[[5, 5, 5, 5, 5], 5]", "output": "0" }, { "input": "[[1, 1000000000, 2, 999999999, 3], 500000000]", "output": "499999997" }, { "input": "[[2, 5, 6, 8, 5], 7]", "output": "3" }, { "input": "[[1, 1, 1, 1, 1], 3]", "output": "6" }, { "input": "[[2, 5, 6, ...
87
false
87
verified
10
10
1
2,631
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MinOperationsToMakeMedianK.Code.Funs /-! # Specifications of `Aegis.MinOperationsToMakeMedianK.min_operations_to_make_median_k` LeetCode problem `minimum-operations-to-make-median-of-array-equal-to-k`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespa...
11
minimum-cost-walk-in-weighted-graph
3,108
Hard
[ "Bit Manipulation", "Union Find", "Graph", "Array" ]
There is an undirected weighted graph with n vertices labeled from 0 to n - 1. You are given the integer n and an array edges, where edges[i] = [ui, vi, wi] indicates that there is an edge between vertices ui and vi with a weight of wi. A walk on a graph is a sequence of vertices and edges. The walk starts and ends wit...
minimumCost(n: int, edges: list_list_int, query: list_list_int) -> list_int
pub fn minimum_cost(n: i64, edges: &[Vec<i64>], query: &[Vec<i64>]) -> Vec<i64>
Aegis.MinimumCost.minimum_cost
fn find(parent: &mut Vec<i64>, mut x: usize) -> usize { while parent[x] != (x as i64) { let p: usize = parent[x] as usize; let gp: usize = parent[p] as usize; parent[x] = gp as i64; x = gp; } x } pub fn minimum_cost(n: i64, edges: &[Vec<i64>], query: &[Vec<i64>]) -> Vec<i64>...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [minimum_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 -- [minimum_cost]: function definitions module public import Aeneas public import Aegis.MinimumCost.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.MinimumCost.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, [], [[0, 4], [1, 3]]]", "output": "[-1, -1]" }, { "input": "[3, [], [[0, 1], [1, 2], [2, 0]]]", "output": "[-1, -1, -1]" }, { "input": "[7, [], [[0, 1], [2, 3], [4, 5]]]", "output": "[-1, -1, -1]" }, { "input": "[5, [], [[0, 1], [1, 2], [2, 3], [3, 4]]]", ...
95
false
95
verified
10
10
1
8,104
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MinimumCost.Code.Funs /-! # Specifications of `Aegis.MinimumCost.minimum_cost` LeetCode problem `minimum-cost-walk-in-weighted-graph`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.MinimumCost open Aegis.MinimumCost (minimum_cost)...
9
find-the-index-of-permutation
3,109
Medium
[ "Binary Indexed Tree", "Segment Tree", "Array", "Binary Search", "Divide and Conquer", "Ordered Set", "Merge Sort" ]
Given an array perm of length n which is a permutation of [1, 2, ..., n], return the index of perm in the lexicographically sorted array of all of the permutations of [1, 2, ..., n]. Since the answer may be very large, return it modulo 109 + 7.   Example 1: Input: perm = [1,2] Output: 0 Explanation: There are only two...
getPermutationIndex(perm: list_int) -> int
pub fn get_permutation_index(perm: &[i64]) -> i64
Aegis.GetPermutationIndex.get_permutation_index
const MOD: i64 = 1_000_000_007; pub fn get_permutation_index(perm: &[i64]) -> i64 { let n = perm.len(); if n == 0 { return 0; } let mut fact: Vec<i64> = Vec::new(); fact.push(1); let mut i: usize = 1; while i < n { let v = fact[i - 1] * (i as i64) % MOD; fact.push(...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [get_permutation_index]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [get_permutation_index]: function definitions module public import Aeneas public import Aegis.GetPermutationIndex.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand f...
import Aegis.GetPermutationIndex.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval a...
[ { "input": "[[1, 2]]", "output": "0" }, { "input": "[[3, 1, 2]]", "output": "4" }, { "input": "[[1, 3, 2]]", "output": "1" }, { "input": "[[4, 3, 2, 1]]", "output": "23" }, { "input": "[[2, 1, 4, 3]]", "output": "7" }, { "input": "[[5, 3, 1, 2, 4]]", ...
97
false
97
verified
10
10
1
4,077
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.GetPermutationIndex.Code.Funs /-! # Specifications of `Aegis.GetPermutationIndex.get_permutation_index` LeetCode problem `find-the-index-of-permutation`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.GetPermutationIndex def M : Int :=...
11
score-of-a-string
3,110
Easy
[ "String" ]
You are given a string s. The score of a string is defined as the sum of the absolute difference between the ASCII values of adjacent characters. Return the score of s.   Example 1: Input: s = "hello" Output: 13 Explanation: The ASCII values of the characters in s are: 'h' = 104, 'e' = 101, 'l' = 108, 'o' = 111. So, t...
scoreOfString(s: str) -> int
pub fn score_of_string(s: &[u8]) -> i64
Aegis.ScoreOfString.score_of_string
pub fn score_of_string(s: &[u8]) -> i64 { let n = s.len(); if n < 2 { return 0; } let mut score: i64 = 0; let mut i: usize = 1; while i < n { let prev = s[i - 1] as i64; let curr = s[i] as i64; let mut diff = prev - curr; if diff < 0 { diff ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [score_of_string]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linte...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [score_of_string]: function definitions module public import Aeneas public import Aegis.ScoreOfString.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.ScoreOfString.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": "[\"abcdefghijklmnopqrstuvwxyz\"]", "output": "25" }, { "input": "[\"a\"]", "output": "0" }, { "input": "[\"abracadabra\"]", "output": "78" }, { "input": "[\"zzzz\"]", "output": "0" }, { "input": "[\"zyx\"]", "output": "2" }, { "input": "[\"...
87
false
87
verified
10
10
1
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.ScoreOfString.Code.Funs /-! # Specifications of `Aegis.ScoreOfString.score_of_string` LeetCode problem `score-of-a-string`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.ScoreOfString namespace AegisSpec.ScoreOfString def absDiff (a b : Nat) :...
13
minimum-rectangles-to-cover-points
3,111
Medium
[ "Greedy", "Array", "Sorting" ]
You are given a 2D integer array points, where points[i] = [xi, yi]. You are also given an integer w. Your task is to cover all the given points with rectangles. Each rectangle has its lower end at some point (x1, 0) and its upper end at some point (x2, y2), where x1 <= x2, y2 >= 0, and the condition x2 - x1 <= w must ...
minRectanglesToCoverPoints(points: list_list_int, w: int) -> int
pub fn min_rectangles_to_cover_points(points: &[Vec<i64>], w: i64) -> i64
Aegis.MinRectanglesToCoverPoints.min_rectangles_to_cover_points
pub fn min_rectangles_to_cover_points(points: &[Vec<i64>], w: i64) -> i64 { let n = points.len(); let mut xs: Vec<i64> = Vec::new(); let mut i: usize = 0; while i < n { xs.push(points[i][0]); i += 1; } xs.sort(); let mut ans: i64 = 0; let mut idx: usize = 0; while...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [min_rectangles_to_cover_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 s...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [min_rectangles_to_cover_points]: function definitions module public import Aeneas public import Aegis.MinRectanglesToCoverPoints.Code.Types public import Aegis.MinRectanglesToCoverPoints.Code.FunsExternal @[expose] public section open Aeneas Aeneas.Std Result Contr...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [min_rectangles_to_cover_points]: external functions. -- This is a template file: rename it to "FunsExternal.lean" and fill the holes. module public import Aeneas public import Aegis.MinRectanglesToCoverPoints.Code.Types @[expose] public section open Aeneas Aeneas.S...
import Aegis.MinRectanglesToCoverPoints.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}" ...
[ { "input": "[[[2, 3], [1, 2]], 0]", "output": "2" }, { "input": "[[[5, 5], [10, 10], [15, 15]], 5]", "output": "2" }, { "input": "[[[10, 10], [20, 20], [30, 30]], 10]", "output": "2" }, { "input": "[[[100, 100], [101, 101], [102, 102], [103, 103]], 2]", "output": "2" },...
118
false
118
verified
10
10
1
1,953
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MinRectanglesToCoverPoints.Code.Funs /-! # Specifications of `Aegis.MinRectanglesToCoverPoints.min_rectangles_to_cover_points` LeetCode problem `minimum-rectangles-to-cover-points`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.MinRe...
14
minimum-time-to-visit-disappearing-nodes
3,112
Medium
[ "Graph", "Array", "Shortest Path", "Heap (Priority Queue)" ]
There is an undirected graph of n nodes. You are given a 2D array edges, where edges[i] = [ui, vi, lengthi] describes an edge between node ui and node vi with a traversal time of lengthi units. Additionally, you are given an array disappear, where disappear[i] denotes the time when the node i disappears from the graph ...
minimumTime(n: int, edges: list_list_int, disappear: list_int) -> list_int
pub fn minimum_time(n: i64, edges: &[Vec<i64>], disappear: &[i64]) -> Vec<i64>
Aegis.MinimumTime.minimum_time
fn heap_push(heap: &mut Vec<i64>, key: i64) { heap.push(key); let mut idx = heap.len() - 1; while idx > 0 { let parent = (idx - 1) / 2; if heap[parent] <= heap[idx] { break; } let tmp = heap[parent]; heap[parent] = heap[idx]; heap[idx] = tmp; ...
-- 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 public import Aegis.MinimumTime.Code.FunsExternal @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace fals...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [minimum_time]: external functions. -- This is a template file: rename it to "FunsExternal.lean" and fill the holes. module public import Aeneas public import Aegis.MinimumTime.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_o...
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": "[1, [], [1]]", "output": "[0]" }, { "input": "[2, [[0, 1, 1]], [1, 1]]", "output": "[0, -1]" }, { "input": "[3, [[0, 1, 2], [1, 2, 1], [0, 2, 4]], [1, 3, 5]]", "output": "[0, 2, 3]" }, { "input": "[3, [[0, 1, 2], [1, 2, 1], [0, 2, 4]], [1, 1, 5]]", "output": "...
103
false
103
verified
10
10
1
6,185
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": 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 `minimum-time-to-visit-disappearing-nodes`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.MinimumTime def ivals (s : Slice I64) : List...
14
find-the-number-of-subarrays-where-boundary-elements-are-maximum
3,113
Hard
[ "Stack", "Array", "Binary Search", "Monotonic Stack" ]
You are given an array of positive integers nums. Return the number of subarrays of nums, where the first and the last elements of the subarray are equal to the largest element in the subarray.   Example 1: Input: nums = [1,4,3,3,2] Output: 6 Explanation: There are 6 subarrays which have the first and the last element...
numberOfSubarrays(nums: list_int) -> int
pub fn number_of_subarrays(nums: &[i64]) -> i64
Aegis.NumberOfSubarrays.number_of_subarrays
pub fn number_of_subarrays(nums: &[i64]) -> i64 { let n = nums.len(); let mut vals: Vec<i64> = Vec::new(); let mut counts: Vec<i64> = Vec::new(); let mut top: usize = 0; let mut ans: i64 = 0; let mut i: usize = 0; while i < n { let x = nums[i]; while top > 0 && vals[top - ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [number_of_subarrays]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option l...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [number_of_subarrays]: function definitions module public import Aeneas public import Aegis.NumberOfSubarrays.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false...
import Aegis.NumberOfSubarrays.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 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": "[[2, 1, 2]]", "output": "4" }, { "input": "[[3, 3, 3]]", "output": "6" }, { "input": "[[1, 2, 2, 1]]", "output": "5" }, { "input": "[[5, 4, 5, 4, 5]]", "output": "8" }, { "input": "[[2, 1, 2, 1, 2]]", ...
110
false
110
verified
10
10
1
3,298
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.NumberOfSubarrays.Code.Funs /-! # Specifications of `Aegis.NumberOfSubarrays.number_of_subarrays` LeetCode problem `find-the-number-of-subarrays-where-boundary-elements-are-maximum`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.Number...
10
maximum-prime-difference
3,115
Medium
[ "Array", "Math", "Number Theory" ]
You are given an integer array nums. Return an integer that is the maximum distance between the indices of two (not necessarily different) prime numbers in nums.   Example 1: Input: nums = [4,2,9,5,3] Output: 3 Explanation: nums[1], nums[3], and nums[4] are prime. So the answer is |4 - 1| = 3. Example 2: Input: nums...
maximumPrimeDifference(nums: list_int) -> int
pub fn maximum_prime_difference(nums: &[i64]) -> i64
Aegis.MaximumPrimeDifference.maximum_prime_difference
fn is_prime(n: i64) -> bool { if n < 2 { return false; } if n == 2 { return true; } if n % 2 == 0 { return false; } let mut d: i64 = 3; while d * d <= n { if n % d == 0 { return false; } d += 2; } true } pub fn maximu...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [maximum_prime_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_opt...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [maximum_prime_difference]: function definitions module public import Aeneas public import Aegis.MaximumPrimeDifference.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCom...
import Aegis.MaximumPrimeDifference.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eva...
[ { "input": "[[2]]", "output": "0" }, { "input": "[[3, 3, 3, 3]]", "output": "3" }, { "input": "[[4, 8, 2, 8]]", "output": "0" }, { "input": "[[97, 1, 97, 1, 97]]", "output": "4" }, { "input": "[[4, 2, 9, 5, 3]]", "output": "3" }, { "input": "[[2, 100, ...
50
false
50
verified
10
10
1
1,119
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MaximumPrimeDifference.Code.Funs /-! # Specifications of `Aegis.MaximumPrimeDifference.maximum_prime_difference` LeetCode problem `maximum-prime-difference`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.MaximumPrimeDifference def IsP...
11
minimum-sum-of-values-by-dividing-array
3,117
Hard
[ "Bit Manipulation", "Segment Tree", "Queue", "Array", "Binary Search", "Dynamic Programming" ]
You are given two arrays nums and andValues of length n and m respectively. The value of an array is equal to the last element of that array. You have to divide nums into m disjoint contiguous subarrays such that for the ith subarray [li, ri], the bitwise AND of the subarray elements is equal to andValues[i], in other ...
minimumValueSum(nums: list_int, andValues: list_int) -> int
pub fn minimum_value_sum(nums: &[i64], andValues: &[i64]) -> i64
Aegis.MinimumValueSum.minimum_value_sum
pub fn minimum_value_sum(nums: &[i64], andValues: &[i64]) -> i64 { let n = nums.len(); let m = andValues.len(); let inf: i64 = 1_000_000_000_000_000_000; let mut dp_prev: Vec<i64> = Vec::new(); let mut i = 0; while i <= n { dp_prev.push(inf); i += 1; } dp_prev[0] = 0; ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [minimum_value_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 lin...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [minimum_value_sum]: function definitions module public import Aeneas public import Aegis.MinimumValueSum.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.MinimumValueSum.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, 3, 4], [2]]", "output": "-1" }, { "input": "[[15, 15, 15, 15], [15]]", "output": "15" }, { "input": "[[5, 5, 5, 5], [5, 5]]", "output": "10" }, { "input": "[[8, 12, 10, 14], [8, 14]]", "output": "24" }, { "input": "[[10, 15, 7, 3], [10, 7]]", ...
170
false
170
verified
10
10
1
7,250
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MinimumValueSum.Code.Funs /-! # Specifications of `Aegis.MinimumValueSum.minimum_value_sum` LeetCode problem `minimum-sum-of-values-by-dividing-array`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.MinimumValueSum def listAnd : Li...
13
maximum-number-of-potholes-that-can-be-fixed
3,119
Medium
[ "Greedy", "String", "Sorting" ]
You are given a string road, consisting only of characters "x" and ".", where each "x" denotes a pothole and each "." denotes a smooth road, and an integer budget. In one repair operation, you can repair n consecutive potholes for a price of n + 1. Return the maximum number of potholes that can be fixed such that the s...
maxPotholes(road: str, budget: int) -> int
pub fn max_potholes(road: &[u8], budget: i64) -> i64
Aegis.MaxPotholes.max_potholes
pub fn max_potholes(road: &[u8], budget: i64) -> i64 { let n = road.len(); // counts[len] = number of maximal consecutive runs of 'x' of that length. let mut counts: Vec<i64> = Vec::new(); let mut i: usize = 0; while i <= n { counts.push(0); i += 1; } let mut idx: usize = 0...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [max_potholes]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter.s...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [max_potholes]: function definitions module public import Aeneas public import Aegis.MaxPotholes.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.MaxPotholes.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": "[\"xxxx\", 6]", "output": "4" }, { "input": "[\"..\", 5]", "output": "0" }, { "input": "[\"x.x.xxx...x\", 14]", "output": "6" }, { "input": "[\"xxxx.xxxx\", 12]", "output": "8" }, { "input": "[\"xx.xx.xx.xx\", 15]", "output": "8" }, { "inpu...
128
false
128
verified
10
10
2
14,421
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MaxPotholes.Code.Funs /-! # Specifications of `Aegis.MaxPotholes.max_potholes` LeetCode problem `maximum-number-of-potholes-that-can-be-fixed`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.MaxPotholes def dotByte : ℕ := 46 def xByte...
16
count-the-number-of-special-characters-i
3,120
Easy
[ "Hash Table", "String" ]
You are given a string word. A letter is called special if it appears both in lowercase and uppercase in word. Return the number of special letters in word.   Example 1: Input: word = "aaAbcBC" Output: 3 Explanation: The special characters in word are 'a', 'b', and 'c'. Example 2: Input: word = "abc" Output: 0 Expla...
numberOfSpecialChars(word: str) -> int
pub fn number_of_special_chars(word: &[u8]) -> i64
Aegis.NumberOfSpecialChars.number_of_special_chars
pub fn number_of_special_chars(word: &[u8]) -> i64 { let mut lower: Vec<bool> = Vec::new(); let mut upper: Vec<bool> = Vec::new(); let mut i: usize = 0; while i < 26 { lower.push(false); upper.push(false); i += 1; } let mut pos: usize = 0; while pos < word.len() { ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [number_of_special_chars]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_opti...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [number_of_special_chars]: function definitions module public import Aeneas public import Aegis.NumberOfSpecialChars.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashComman...
import Aegis.NumberOfSpecialChars.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": "[\"abc\"]", "output": "0" }, { "input": "[\"xyzXYZ\"]", "output": "3" }, { "input": "[\"aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ\"]", "output": "26" }, { "input": "[\"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ\"]", "output": "26" }, {...
159
false
159
verified
10
10
1
1,040
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.NumberOfSpecialChars.Code.Funs /-! # Specifications of `Aegis.NumberOfSpecialChars.number_of_special_chars` LeetCode problem `count-the-number-of-special-characters-i`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.NumberOfSpecialCha...
6
count-the-number-of-special-characters-ii
3,121
Medium
[ "Hash Table", "String" ]
You are given a string word. A letter c is called special if it appears both in lowercase and uppercase in word, and every lowercase occurrence of c appears before the first uppercase occurrence of c. Return the number of special letters in word.   Example 1: Input: word = "aaAbcBC" Output: 3 Explanation: The special ...
numberOfSpecialChars(word: str) -> int
pub fn number_of_special_chars(word: &[u8]) -> i64
Aegis.NumberOfSpecialChars.number_of_special_chars
pub fn number_of_special_chars(word: &[u8]) -> i64 { let mut last_lower: Vec<i64> = Vec::new(); let mut first_upper: Vec<i64> = Vec::new(); let mut k: usize = 0; while k < 26 { last_lower.push(-1); first_upper.push(-1); k += 1; } let mut i: usize = 0; while i < word...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [number_of_special_chars]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_opti...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [number_of_special_chars]: function definitions module public import Aeneas public import Aegis.NumberOfSpecialChars.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashComman...
import Aegis.NumberOfSpecialChars.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": "[\"aAbBcCdDeEfFgG\"]", "output": "7" }, { "input": "[\"AaBbCc\"]", "output": "0" }, { "input": "[\"aabbCC\"]", "output": "0" }, { "input": "[\"Aabbcc\"]", "output": "0" }, { "input": "[\"abABcdCD\"]", "output": "4" }, { "input": "[\"zZaA\"]...
100
false
100
verified
10
10
1
2,522
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.NumberOfSpecialChars.Code.Funs /-! # Specifications of `Aegis.NumberOfSpecialChars.number_of_special_chars` LeetCode problem `count-the-number-of-special-characters-ii`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.NumberOfSpecialChar...
15
minimum-number-of-operations-to-satisfy-conditions
3,122
Medium
[ "Array", "Dynamic Programming", "Matrix" ]
You are given a 2D matrix grid of size m x n. In one operation, you can change the value of any cell to any non-negative number. You need to perform some operations such that each cell grid[i][j] is: Equal to the cell below it, i.e. grid[i][j] == grid[i + 1][j] (if it exists). Different from the cell to its right, i.e...
minimumOperations(grid: list_list_int) -> int
pub fn minimum_operations(grid: &[Vec<i64>]) -> i64
Aegis.MinimumOperations.minimum_operations
pub fn minimum_operations(grid: &[Vec<i64>]) -> i64 { let m = grid.len(); if m == 0 { return 0; } let n = grid[0].len(); if n == 0 { return 0; } let mut dp: Vec<i64> = Vec::new(); let mut v: usize = 0; while v < 10 { let val = v as i64; let mut cost...
-- 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": "[[[0]]]", "output": "0" }, { "input": "[[[1], [2], [3]]]", "output": "2" }, { "input": "[[[1, 2], [2, 1]]]", "output": "2" }, { "input": "[[[1, 2], [3, 4]]]", "output": "2" }, { "input": "[[[1, 1, 1], [0, 0, 0]]]", "output": "3" }, { "input...
108
false
108
verified
10
10
1
6,735
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": 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 `minimum-number-of-operations-to-satisfy-conditions`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.MinimumOperations open scop...
14
find-edges-in-shortest-paths
3,123
Hard
[ "Depth-First Search", "Breadth-First Search", "Graph", "Shortest Path", "Heap (Priority Queue)" ]
You are given an undirected weighted graph of n nodes numbered from 0 to n - 1. The graph consists of m edges represented by a 2D array edges, where edges[i] = [ai, bi, wi] indicates that there is an edge between nodes ai and bi with weight wi. Consider all the shortest paths from node 0 to node n - 1 in the graph. You...
findAnswer(n: int, edges: list_list_int) -> list_bool
pub fn find_answer(n: i64, edges: &[Vec<i64>]) -> Vec<bool>
Aegis.FindAnswer.find_answer
const INF: i64 = 1_000_000_000_000_000_000; fn heap_push(heap: &mut Vec<i64>, x: i64) { let mut i: usize = heap.len(); heap.push(x); while i > 0 { let p = (i - 1) / 2; if heap[p] <= heap[i] { break; } let tmp = heap[p]; heap[p] = heap[i]; heap[i]...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [find_answer]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter.st...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [find_answer]: function definitions module public import Aeneas public import Aegis.FindAnswer.Code.Types public import Aegis.FindAnswer.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 -- [find_answer]: external functions. -- This is a template file: rename it to "FunsExternal.lean" and fill the holes. module public import Aeneas public import Aegis.FindAnswer.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_opt...
import Aegis.FindAnswer.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], [0, 2, 5], [1, 2, 2]]]", "output": "[true, false, true]" }, { "input": "[3, [[0, 1, 1], [1, 2, 1], [0, 2, 4]]]", "output": "[true, true, false]" }, { "input": "[4, [[2, 0, 1], [0, 1, 1], [0, 3, 4], [3, 2, 2]]]", "output": "[true, false, false, true]" }, ...
67
false
67
verified
10
10
1
10,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.FindAnswer.Code.Funs /-! # Specifications of `Aegis.FindAnswer.find_answer` LeetCode problem `find-edges-in-shortest-paths`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result set_option autoImplicit false namespace AegisSpec.FindAnswer def edgeRows (ed...
10
right-triangles
3,128
Medium
[ "Array", "Hash Table", "Math", "Combinatorics", "Counting" ]
You are given a 2D boolean matrix grid. A collection of 3 elements of grid is a right triangle if one of its elements is in the same row with another element and in the same column with the third element. The 3 elements may not be next to each other. Return an integer that is the number of right triangles that can be m...
numberOfRightTriangles(grid: list_list_int) -> int
pub fn number_of_right_triangles(grid: &[Vec<i64>]) -> i64
Aegis.NumberOfRightTriangles.number_of_right_triangles
pub fn number_of_right_triangles(grid: &[Vec<i64>]) -> i64 { let n = grid.len(); if n == 0 { return 0; } let m = grid[0].len(); if m == 0 { return 0; } let mut col_sums: Vec<i64> = Vec::new(); let mut j: usize = 0; while j < m { col_sums.push(0); j +...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [number_of_right_triangles]: type definitions module public import Aeneas @[expose] public 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 -- [number_of_right_triangles]: function definitions module public import Aeneas public import Aegis.NumberOfRightTriangles.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCo...
import Aegis.NumberOfRightTriangles.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eva...
[ { "input": "[[[1, 1, 1], [1, 1, 1], [1, 1, 1]]]", "output": "36" }, { "input": "[[[0, 1, 0], [0, 1, 1], [0, 1, 0]]]", "output": "2" }, { "input": "[[[0, 0, 0], [0, 0, 0], [0, 0, 0]]]", "output": "0" }, { "input": "[[[1, 0, 0], [0, 1, 0], [0, 0, 1]]]", "output": "0" }, ...
67
false
67
verified
10
10
1
1,431
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.NumberOfRightTriangles.Code.Funs /-! # Specifications of `Aegis.NumberOfRightTriangles.number_of_right_triangles` LeetCode problem `right-triangles`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.NumberOfRightTriangles abbrev nrt : Sl...
12
find-all-possible-stable-binary-arrays-i
3,129
Medium
[ "Dynamic Programming", "Prefix Sum" ]
You are given 3 positive integers zero, one, and limit. A binary array arr is called stable if: The number of occurrences of 0 in arr is exactly zero. The number of occurrences of 1 in arr is exactly one. Each subarray of arr with a size greater than limit must contain both 0 and 1. Return the total number of stable ...
numberOfStableArrays(zero: int, one: int, limit: int) -> int
pub fn number_of_stable_arrays(zero: i64, one: i64, limit: i64) -> i64
Aegis.NumberOfStableArrays.number_of_stable_arrays
pub fn number_of_stable_arrays(zero: i64, one: i64, limit: i64) -> i64 { let modv: i64 = 1000000007; let nz: usize = zero as usize; let no: usize = one as usize; let lim: usize = limit as usize; let width: usize = no + 1; let size: usize = (nz + 1) * width; let mut dp0: Vec<i64> = Vec::ne...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [number_of_stable_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_opti...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [number_of_stable_arrays]: function definitions module public import Aeneas public import Aegis.NumberOfStableArrays.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashComman...
import Aegis.NumberOfStableArrays.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, 5, 3]", "output": "40" }, { "input": "[5, 5, 4]", "output": "242" }, { "input": "[5, 5, 2]", "output": "84" }, { "input": "[1, 1, 1]", "output": "2" }, { "input": "[2, 2, 3]", "output": "6" }, { "input": "[1, 5, 1]", "output": "0" ...
128
false
128
verified_partial
10
6
1
6,113
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.NumberOfStableArrays.Code.Funs /-! # Specifications of `Aegis.NumberOfStableArrays.number_of_stable_arrays` LeetCode problem `find-all-possible-stable-binary-arrays-i`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Classical namespace AegisSpec.N...
11
find-all-possible-stable-binary-arrays-ii
3,130
Hard
[ "Dynamic Programming", "Prefix Sum" ]
You are given 3 positive integers zero, one, and limit. A binary array arr is called stable if: The number of occurrences of 0 in arr is exactly zero. The number of occurrences of 1 in arr is exactly one. Each subarray of arr with a size greater than limit must contain both 0 and 1. Return the total number of stable ...
numberOfStableArrays(zero: int, one: int, limit: int) -> int
pub fn number_of_stable_arrays(zero: i64, one: i64, limit: i64) -> i64
Aegis.NumberOfStableArrays.number_of_stable_arrays
const MOD: i64 = 1_000_000_007; fn mod_pow(mut base: i64, mut exp: i64) -> i64 { base %= MOD; let mut result: i64 = 1; while exp > 0 { if exp % 2 == 1 { result = result * base % MOD; } base = base * base % MOD; exp /= 2; } result } fn comb(n: usize, k: u...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [number_of_stable_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_opti...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [number_of_stable_arrays]: function definitions module public import Aeneas public import Aegis.NumberOfStableArrays.Code.Types public import Aegis.NumberOfStableArrays.Code.FunsExternal @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_op...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [number_of_stable_arrays]: external functions. -- This is a template file: rename it to "FunsExternal.lean" and fill the holes. module public import Aeneas public import Aegis.NumberOfStableArrays.Code.Types @[expose] public section open Aeneas Aeneas.Std Result Con...
import Aegis.NumberOfStableArrays.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": "[5, 5, 4]", "output": "242" }, { "input": "[100, 100, 50]", "output": "375840050" }, { "input": "[5, 5, 2]", "output": "84" }, { "input": "[4, 4, 3]", "output": "62" }, { "input": "[2, 2, 3]", "output": "6" }, { "input": "[3, 2, 1]", "o...
66
false
66
verified
10
10
2
23,582
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.NumberOfStableArrays.Code.Funs /-! # Specifications of `Aegis.NumberOfStableArrays.number_of_stable_arrays` LeetCode problem `find-all-possible-stable-binary-arrays-ii`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.NumberOfStableArray...
10
find-the-integer-added-to-array-i
3,131
Easy
[ "Array" ]
You are given two arrays of equal length, nums1 and nums2. Each element in nums1 has been increased (or decreased in the case of negative) by an integer, represented by the variable x. As a result, nums1 becomes equal to nums2. Two arrays are considered equal when they contain the same integers with the same frequencie...
addedInteger(nums1: list_int, nums2: list_int) -> int
pub fn added_integer(nums1: &[i64], nums2: &[i64]) -> i64
Aegis.AddedInteger.added_integer
pub fn added_integer(nums1: &[i64], nums2: &[i64]) -> i64 { let mut min1: i64 = nums1[0]; let mut min2: i64 = nums2[0]; let mut i: usize = 1; while i < nums1.len() { if nums1[i] < min1 { min1 = nums1[i]; } i += 1; } i = 1; while i < nums2.len() { ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [added_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 linter....
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [added_integer]: function definitions module public import Aeneas public import Aegis.AddedInteger.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.AddedInteger.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": "[[10], [5]]", "output": "-5" }, { "input": "[[100, 200, 300], [150, 250, 350]]", "output": "50" }, { "input": "[[7, 7, 7], [10, 10, 10]]", "output": "3" }, { "input": "[[1000, 0, 500], [900, 1000, 400]]", "output": "400" }, { "input": "[[500, 500, 500]...
100
false
100
verified
10
10
1
520
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.AddedInteger.Code.Funs /-! # Specifications of `Aegis.AddedInteger.added_integer` LeetCode problem `find-the-integer-added-to-array-i`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.AddedInteger def entries (nums : Slice Std.I64) : Li...
12
minimum-array-end
3,133
Medium
[ "Bit Manipulation" ]
You are given two integers n and x. You have to construct an array of positive integers nums of size n where for every 0 <= i < n - 1, nums[i + 1] is greater than nums[i], and the result of the bitwise AND operation between all elements of nums is x. Return the minimum possible value of nums[n - 1].   Example 1: Input...
minEnd(n: int, x: int) -> int
pub fn min_end(n: i64, x: i64) -> i64
Aegis.MinEnd.min_end
pub fn min_end(n: i64, x: i64) -> i64 { let mut ans: i64 = x; let mut k: i64 = n - 1; let mut mask: i64 = 1; while k > 0 { if (ans / mask) % 2 == 0 { if k % 2 == 1 { ans = ans + mask; } k = k / 2; } mask = mask * 2; } ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [min_end]: type definitions module public import Aeneas @[expose] public section 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_end]: function definitions module public import Aeneas public import Aegis.MinEnd.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unus...
import Aegis.MinEnd.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval aegisCase "eva...
[ { "input": "[4, 8]", "output": "11" }, { "input": "[5, 1]", "output": "9" }, { "input": "[10, 1]", "output": "19" }, { "input": "[5, 3]", "output": "19" }, { "input": "[2, 7]", "output": "15" }, { "input": "[1, 10]", "output": "10" }, { "in...
106
false
106
verified
10
10
1
6,114
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MinEnd.Code.Funs /-! # Specifications of `Aegis.MinEnd.min_end` LeetCode problem `minimum-array-end`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.MinEnd open Aegis.MinEnd def bAnd (a b : ℤ) : ℤ := (Nat.land a.toNat b.toNat : ℤ) de...
13
find-the-median-of-the-uniqueness-array
3,134
Hard
[ "Array", "Hash Table", "Binary Search", "Sliding Window" ]
You are given an integer array nums. The uniqueness array of nums is the sorted array that contains the number of distinct elements of all the subarrays of nums. In other words, it is a sorted array consisting of distinct(nums[i..j]), for all 0 <= i <= j < nums.length. Here, distinct(nums[i..j]) denotes the number of d...
medianOfUniquenessArray(nums: list_int) -> int
pub fn median_of_uniqueness_array(nums: &[i64]) -> i64
Aegis.MedianOfUniquenessArray.median_of_uniqueness_array
pub fn median_of_uniqueness_array(nums: &[i64]) -> i64 { let n = nums.len(); if n == 0 { return 0; } // Find the maximum value to size the frequency array. let mut max_val: usize = 0; let mut i = 0; while i < n { let v = nums[i] as usize; if v > max_val { ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [median_of_uniqueness_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_o...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [median_of_uniqueness_array]: function definitions module public import Aeneas public import Aegis.MedianOfUniquenessArray.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hash...
import Aegis.MedianOfUniquenessArray.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": "[[1]]", "output": "1" }, { "input": "[[1, 2, 3]]", "output": "1" }, { "input": "[[4, 3, 5, 4]]", "output": "2" }, { "input": "[[5, 4, 3, 2, 1]]", "output": "2" }, { "input": "[[100000, 99999, 99998, 99997, 99996]]", "output": "2" }, { "inpu...
101
false
101
verified_partial
10
4
1
8,154
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MedianOfUniquenessArray.Code.Funs /-! # Specifications of `Aegis.MedianOfUniquenessArray.median_of_uniqueness_array` LeetCode problem `find-the-median-of-the-uniqueness-array`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.MedianOfUniq...
14
equalize-strings-by-adding-or-removing-characters-at-ends
3,135
Medium
[ "String", "Binary Search", "Dynamic Programming", "Sliding Window", "Hash Function" ]
Given two strings initial and target, your task is to modify initial by performing a series of operations to make it equal to target. In one operation, you can add or remove one character only at the beginning or the end of the string initial. Return the minimum number of operations required to transform initial into t...
minOperations(initial: str, target: str) -> int
pub fn min_operations(initial: &[u8], target: &[u8]) -> i64
Aegis.MinOperations.min_operations
pub fn min_operations(initial: &[u8], target: &[u8]) -> i64 { let n: usize = initial.len(); let m: usize = target.len(); let mut prev: Vec<i64> = Vec::new(); let mut z: usize = 0; while z < m + 1 { prev.push(0); z += 1; } let mut best: i64 = 0; let mut i: usize = 0; ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [min_operations]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [min_operations]: function definitions module public import Aeneas public import Aegis.MinOperations.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_opti...
import Aegis.MinOperations.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 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": "[\"hello\", \"billion\"]", "output": "8" }, { "input": "[\"aabbcc\", \"abc\"]", "output": "5" }, { "input": "[\"aaa\", \"aaa\"]", "output": "0" }, { "input": "[\"a\", \"b\"]", "output": "2" }, { "input": "[\"hello\", \"world\"]", "output": "8" },...
147
false
147
verified
10
10
1
2,269
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MinOperations.Code.Funs /-! # Specifications of `Aegis.MinOperations.min_operations` LeetCode problem `equalize-strings-by-adding-or-removing-characters-at-ends`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.MinOperations def byteVal...
12
valid-word
3,136
Easy
[ "String" ]
A word is considered valid if: It contains a minimum of 3 characters. It contains only digits (0-9), and English letters (uppercase and lowercase). It includes at least one vowel. It includes at least one consonant. You are given a string word. Return true if word is valid, otherwise, return false. Notes: 'a', 'e', ...
isValid(word: str) -> bool
pub fn is_valid(word: &[u8]) -> bool
Aegis.IsValid.is_valid
pub fn is_valid(word: &[u8]) -> bool { let n = word.len(); if n < 3 { return false; } let mut has_vowel: bool = false; let mut has_consonant: bool = false; let mut has_invalid: bool = false; let mut i: usize = 0; while i < n { let c: u8 = word[i]; let is_lower ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [is_valid]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter.style...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [is_valid]: function definitions module public import Aeneas public import Aegis.IsValid.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.IsValid.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": "[\"N0C0ns0n4nts\"]", "output": "false" }, { "input": "[\"Zebra123\"]", "output": "true" }, { "input": "[\"1234567890\"]", "output": "false" }, { "input": "[\"Aeiou9\"]", "output": "false" }, { "input": "[\"123Aeiou\"]", "output": "false" }, { ...
46
false
46
verified
10
10
2
9,617
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.IsValid.Code.Funs /-! # Specifications of `Aegis.IsValid.is_valid` LeetCode problem `valid-word`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.IsValid namespace AegisSpec.IsValid def codes (word : Slice Std.U8) : List ℕ := word.val.map (fun c...
5
minimum-number-of-operations-to-make-word-k-periodic
3,137
Medium
[ "Hash Table", "String", "Counting" ]
You are given a string word of size n, and an integer k such that k divides n. In one operation, you can pick any two indices i and j, that are divisible by k, then replace the substring of length k starting at i with the substring of length k starting at j. That is, replace the substring word[i..i + k - 1] with the su...
minimumOperationsToMakeKPeriodic(word: str, k: int) -> int
pub fn minimum_operations_to_make_k_periodic(word: &[u8], k: i64) -> i64
Aegis.MinimumOperationsToMakeKPeriodic.minimum_operations_to_make_k_periodic
fn block_cmp(word: &[u8], k: usize, a: usize, b: usize) -> i64 { let sa = a * k; let sb = b * k; let mut i: usize = 0; while i < k { let ca = word[sa + i]; let cb = word[sb + i]; if ca < cb { return -1; } if ca > cb { return 1; } ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [minimum_operations_to_make_k_periodic]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [minimum_operations_to_make_k_periodic]: function definitions module public import Aeneas public import Aegis.MinimumOperationsToMakeKPeriodic.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false se...
import Aegis.MinimumOperationsToMakeKPeriodic.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} ...
[ { "input": "[\"xyzxyzxyzxyzxyzxyz\", 3]", "output": "0" }, { "input": "[\"xyzxyzxyzxyz\", 3]", "output": "0" }, { "input": "[\"abcdefghijabcdefghij\", 5]", "output": "2" }, { "input": "[\"abcabcabc\", 3]", "output": "0" }, { "input": "[\"aaaaaaa\", 1]", "outpu...
105
false
105
verified
10
10
1
9,353
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MinimumOperationsToMakeKPeriodic.Code.Funs /-! # Specifications of `Aegis.MinimumOperationsToMakeKPeriodic.minimum_operations_to_make_k_periodic` LeetCode problem `minimum-number-of-operations-to-make-word-k-periodic`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.St...
11
minimum-length-of-anagram-concatenation
3,138
Medium
[ "Hash Table", "String", "Counting" ]
You are given a string s, which is known to be a concatenation of anagrams of some string t. Return the minimum possible length of the string t. An anagram is formed by rearranging the letters of a string. For example, "aab", "aba", and, "baa" are anagrams of "aab".   Example 1: Input: s = "abba" Output: 2 Explanation...
minAnagramLength(s: str) -> int
pub fn min_anagram_length(s: &[u8]) -> i64
Aegis.MinAnagramLength.min_anagram_length
pub fn min_anagram_length(s: &[u8]) -> i64 { let n: usize = s.len(); if n == 0 { return 0; } let mut base: Vec<i64> = Vec::new(); let mut cur: Vec<i64> = Vec::new(); let mut c: usize = 0; while c < 26 { base.push(0); cur.push(0); c += 1; } let mut k:...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [min_anagram_length]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option li...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [min_anagram_length]: function definitions module public import Aeneas public import Aegis.MinAnagramLength.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.MinAnagramLength.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": "[\"zzzzzzzzz\"]", "output": "1" }, { "input": "[\"abcdefghijklmnopqrstuvwxyz\"]", "output": "26" }, { "input": "[\"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\"]", "output": "1" }, { "input": "[\"abababab\"]", "output": "2" }, { "input": "[\"a\...
73
false
73
verified
10
10
1
2,109
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MinAnagramLength.Code.Funs /-! # Specifications of `Aegis.MinAnagramLength.min_anagram_length` LeetCode problem `minimum-length-of-anagram-concatenation`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.MinAnagramLength namespace AegisSpec.MinAna...
16
minimum-cost-to-equalize-array
3,139
Hard
[ "Greedy", "Array", "Enumeration" ]
You are given an integer array nums and two integers cost1 and cost2. You are allowed to perform either of the following operations any number of times: Choose an index i from nums and increase nums[i] by 1 for a cost of cost1. Choose two different indices i, j, from nums and increase nums[i] and nums[j] by 1 for a co...
minCostToEqualizeArray(nums: list_int, cost1: int, cost2: int) -> int
pub fn min_cost_to_equalize_array(nums: &[i64], cost1: i64, cost2: i64) -> i64
Aegis.MinCostToEqualizeArray.min_cost_to_equalize_array
fn eval_cost(t: i64, minv: i64, sum: i64, n: i64, cost1: i64, cost2: i64) -> i64 { let s = n * t - sum; if s <= 0 { return 0; } if cost2 >= cost1 + cost1 { return s * cost1; } let max_def = t - minv; let mut pairs = s / 2; if max_def + max_def >= s { pairs = s ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [min_cost_to_equalize_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_o...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [min_cost_to_equalize_array]: function definitions module public import Aeneas public import Aegis.MinCostToEqualizeArray.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashC...
import Aegis.MinCostToEqualizeArray.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eva...
[ { "input": "[[4, 1], 5, 2]", "output": "15" }, { "input": "[[1, 1000000], 1, 1000000]", "output": "999999" }, { "input": "[[1, 1000000], 1, 1]", "output": "999999" }, { "input": "[[1, 1000000], 1, 2]", "output": "999999" }, { "input": "[[1, 2], 2, 1]", "output...
122
false
122
verified
10
10
1
15,389
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MinCostToEqualizeArray.Code.Funs /-! # Specifications of `Aegis.MinCostToEqualizeArray.min_cost_to_equalize_array` LeetCode problem `minimum-cost-to-equalize-array`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.MinCostToEqualizeArra...
14
maximum-hamming-distances
3,141
Hard
[ "Bit Manipulation", "Breadth-First Search", "Array" ]
Given an array nums and an integer m, with each element nums[i] satisfying 0 <= nums[i] < 2m, return an array answer. The answer array should be of the same length as nums, where each element answer[i] represents the maximum Hamming distance between nums[i] and any other element nums[j] in the array. The Hamming distan...
maxHammingDistances(nums: list_int, m: int) -> list_int
pub fn max_hamming_distances(nums: &[i64], m: i64) -> Vec<i64>
Aegis.MaxHammingDistances.max_hamming_distances
pub fn max_hamming_distances(nums: &[i64], m: i64) -> Vec<i64> { let mut n_states: i64 = 1; let mut t: i64 = 0; while t < m { n_states = n_states * 2; t += 1; } let n_usize = n_states as usize; let mut dist: Vec<i64> = Vec::new(); let mut i: usize = 0; while i < n_usize...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [max_hamming_distances]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [max_hamming_distances]: function definitions module public import Aeneas public import Aegis.MaxHammingDistances.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand f...
import Aegis.MaxHammingDistances.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": "[[3, 4, 6, 10], 4]", "output": "[3, 3, 2, 3]" }, { "input": "[[9, 12, 9, 11], 4]", "output": "[2, 3, 2, 3]" }, { "input": "[[1, 2, 4, 8, 16], 5]", "output": "[2, 2, 2, 2, 2]" }, { "input": "[[1, 2, 3, 4, 5, 6, 7, 8], 4]", "output": "[3, 3, 3, 3, 3, 3, 4, 4]" ...
72
false
72
verified
10
10
1
5,791
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MaxHammingDistances.Code.Funs /-! # Specifications of `Aegis.MaxHammingDistances.max_hamming_distances` LeetCode problem `maximum-hamming-distances`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.MaxHammingDistances def bit (k : N...
11
check-if-grid-satisfies-conditions
3,142
Easy
[ "Array", "Matrix" ]
You are given a 2D matrix grid of size m x n. You need to check if each cell grid[i][j] is: Equal to the cell below it, i.e. grid[i][j] == grid[i + 1][j] (if it exists). Different from the cell to its right, i.e. grid[i][j] != grid[i][j + 1] (if it exists). Return true if all the cells satisfy these conditions, other...
satisfiesConditions(grid: list_list_int) -> bool
pub fn satisfies_conditions(grid: &[Vec<i64>]) -> bool
Aegis.SatisfiesConditions.satisfies_conditions
pub fn satisfies_conditions(grid: &[Vec<i64>]) -> bool { let m = grid.len(); if m == 0 { return true; } let n = grid[0].len(); let mut ok: bool = true; let mut i: usize = 0; while i < m && ok { let mut j: usize = 0; while j < n && ok { if j + 1 < n { ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [satisfies_conditions]: type definitions module public import Aeneas @[expose] public section 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 -- [satisfies_conditions]: function definitions module public import Aeneas public import Aegis.SatisfiesConditions.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand fa...
import Aegis.SatisfiesConditions.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": "[[[6]]]", "output": "true" }, { "input": "[[[7]]]", "output": "true" }, { "input": "[[[6], [6]]]", "output": "true" }, { "input": "[[[1], [2], [3]]]", "output": "false" }, { "input": "[[[5, 4], [5, 3]]]", "output": "false" }, { "input": "[[...
116
false
116
verified
10
10
2
840
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.SatisfiesConditions.Code.Funs /-! # Specifications of `Aegis.SatisfiesConditions.satisfies_conditions` LeetCode problem `check-if-grid-satisfies-conditions`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.SatisfiesConditions open A...
10
maximum-points-inside-the-square
3,143
Medium
[ "Array", "Hash Table", "String", "Binary Search", "Sorting" ]
You are given a 2D array points and a string s where, points[i] represents the coordinates of point i, and s[i] represents the tag of point i. A valid square is a square centered at the origin (0, 0), has edges parallel to the axes, and does not contain two points with the same tag. Return the maximum number of points ...
maxPointsInsideSquare(points: list_list_int, s: str) -> int
pub fn max_points_inside_square(points: &[Vec<i64>], s: &[u8]) -> i64
Aegis.MaxPointsInsideSquare.max_points_inside_square
pub fn max_points_inside_square(points: &[Vec<i64>], s: &[u8]) -> i64 { let n = points.len(); let inf: i64 = 2_000_000_000; let mut first: Vec<i64> = Vec::new(); let mut second: Vec<i64> = Vec::new(); let mut k: usize = 0; while k < 26 { first.push(inf); second.push(inf); ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [max_points_inside_square]: type definitions module public import Aeneas @[expose] public 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 -- [max_points_inside_square]: function definitions module public import Aeneas public import Aegis.MaxPointsInsideSquare.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashComm...
import Aegis.MaxPointsInsideSquare.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": "[[[0, 0]], \"a\"]", "output": "1" }, { "input": "[[[1, 1], [-1, -1], [2, -2]], \"ccd\"]", "output": "0" }, { "input": "[[[0, 1], [1, 0], [1, 1]], \"abc\"]", "output": "3" }, { "input": "[[[0, 0], [1, 1], [2, 2]], \"abc\"]", "output": "3" }, { "input": ...
100
false
100
verified
10
10
1
4,686
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MaxPointsInsideSquare.Code.Funs /-! # Specifications of `Aegis.MaxPointsInsideSquare.max_points_inside_square` LeetCode problem `maximum-points-inside-the-square`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aeneas.Std.alloc.vec set_option maxHeart...
13
minimum-substring-partition-of-equal-character-frequency
3,144
Medium
[ "Hash Table", "String", "Dynamic Programming", "Counting" ]
Given a string s, you need to partition it into one or more balanced substrings. For example, if s == "ababcc" then ("abab", "c", "c"), ("ab", "abc", "c"), and ("ababcc") are all valid partitions, but ("a", "bab", "cc"), ("aba", "bc", "c"), and ("ab", "abcc") are not. The unbalanced substrings are bolded. Return the mi...
minimumSubstringsInPartition(s: str) -> int
pub fn minimum_substrings_in_partition(s: &[u8]) -> i64
Aegis.MinimumSubstringsInPartition.minimum_substrings_in_partition
pub fn minimum_substrings_in_partition(s: &[u8]) -> i64 { let n: usize = s.len(); let mut dp: Vec<i64> = Vec::new(); let mut i: usize = 0; while i <= n { dp.push(0); i += 1; } dp[0] = 0; let mut end: usize = 1; while end <= n { let mut cnt: Vec<i64> = Vec::new(...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [minimum_substrings_in_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 ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [minimum_substrings_in_partition]: function definitions module public import Aeneas public import Aegis.MinimumSubstringsInPartition.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option l...
import Aegis.MinimumSubstringsInPartition.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}"...
[ { "input": "[\"zzzzzzzzz\"]", "output": "1" }, { "input": "[\"aaabbbccc\"]", "output": "1" }, { "input": "[\"abcdefghijklmnopqrstuvwxyz\"]", "output": "1" }, { "input": "[\"aabbaabbccddccdd\"]", "output": "1" }, { "input": "[\"abcdef\"]", "output": "1" }, ...
72
false
72
verified
10
10
1
3,073
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MinimumSubstringsInPartition.Code.Funs /-! # Specifications of `Aegis.MinimumSubstringsInPartition.minimum_substrings_in_partition` LeetCode problem `minimum-substring-partition-of-equal-character-frequency`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result ...
12
taking-maximum-energy-from-the-mystic-dungeon
3,147
Medium
[ "Array", "Prefix Sum" ]
In a mystic dungeon, n magicians are standing in a line. Each magician has an attribute that gives you energy. Some magicians can give you negative energy, which means taking energy from you. You have been cursed in such a way that after absorbing energy from magician i, you will be instantly transported to magician (i...
maximumEnergy(energy: list_int, k: int) -> int
pub fn maximum_energy(energy: &[i64], k: i64) -> i64
Aegis.MaximumEnergy.maximum_energy
pub fn maximum_energy(energy: &[i64], k: i64) -> i64 { let n = energy.len(); if n == 0 { return 0; } let kk: usize = k as usize; let mut dp: Vec<i64> = Vec::new(); let mut init = 0; while init < n { dp.push(0); init += 1; } let mut i = n; while i > 0 { ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [maximum_energy]: type definitions module public import Aeneas @[expose] public section 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_energy]: function definitions module public import Aeneas public import Aegis.MaximumEnergy.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.MaximumEnergy.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": "[[-2, -3, -1], 2]", "output": "-1" }, { "input": "[[-1, -2, -3, -4, -5], 3]", "output": "-3" }, { "input": "[[1, 2, 3, 4, 5], 1]", "output": "15" }, { "input": "[[100, -100, 100, -100, 100], 1]", "output": "100" }, { "input": "[[-1, -2, -3, -4, -5], 2]...
120
false
120
verified
10
10
1
2,121
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MaximumEnergy.Code.Funs /-! # Specifications of `Aegis.MaximumEnergy.maximum_energy` LeetCode problem `taking-maximum-energy-from-the-mystic-dungeon`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.MaximumEnergy def energyVals (ene...
10
maximum-difference-score-in-a-grid
3,148
Medium
[ "Array", "Dynamic Programming", "Matrix" ]
You are given an m x n matrix grid consisting of positive integers. You can move from a cell in the matrix to any other cell that is either to the bottom or to the right (not necessarily adjacent). The score of a move from a cell with the value c1 to a cell with the value c2 is c2 - c1. You can start at any cell, and y...
maxScore(grid: list_list_int) -> int
pub fn max_score(grid: &[Vec<i64>]) -> i64
Aegis.MaxScore.max_score
pub fn max_score(grid: &[Vec<i64>]) -> i64 { let m = grid.len(); let n = grid[0].len(); let inf: i64 = 1000000000; let mut top: Vec<i64> = Vec::new(); let mut j: usize = 0; while j < n { top.push(inf); j += 1; } let mut ans: i64 = -1000000000; let mut i: usize = 0; ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [max_score]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter.styl...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [max_score]: function definitions module public import Aeneas public import Aegis.MaxScore.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter....
import Aegis.MaxScore.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 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": "[[[4, 3, 2], [3, 2, 1]]]", "output": "-1" }, { "input": "[[[1, 2], [3, 4], [5, 6], [7, 8]]]", "output": "7" }, { "input": "[[[100, 90, 80], [70, 60, 50], [40, 30, 20]]]", "output": "-10" }, { "input": "[[[5, 1, 3], [4, 1, 5], [7, 9, 3]]]", "output": "8" }, ...
83
false
83
verified
10
10
1
6,400
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MaxScore.Code.Funs /-! # Specifications of `Aegis.MaxScore.max_score` LeetCode problem `maximum-difference-score-in-a-grid`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.MaxScore namespace AegisSpec.MaxScore def cell (grid : Slice (allo...
10
find-the-minimum-cost-array-permutation
3,149
Hard
[ "Bit Manipulation", "Array", "Dynamic Programming", "Bitmask" ]
You are given an array nums which is a permutation of [0, 1, 2, ..., n - 1]. The score of any permutation of [0, 1, 2, ..., n - 1] named perm is defined as: score(perm) = |perm[0] - nums[perm[1]]| + |perm[1] - nums[perm[2]]| + ... + |perm[n - 1] - nums[perm[0]]| Return the permutation perm which has the minimum possibl...
findPermutation(nums: list_int) -> list_int
pub fn find_permutation(nums: &[i64]) -> Vec<i64>
Aegis.FindPermutation.find_permutation
fn abs_diff(a: i64, b: i64) -> i64 { if a >= b { a - b } else { b - a } } fn bit_at(k: usize) -> usize { let mut r: usize = 1; let mut i: usize = 0; while i < k { r = r * 2; i += 1; } r } pub fn find_permutation(nums: &[i64]) -> Vec<i64> { let n = nu...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [find_permutation]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option lint...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [find_permutation]: function definitions module public import Aeneas public import Aegis.FindPermutation.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.FindPermutation.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": "[[0, 2, 1]]", "output": "[0, 2, 1]" }, { "input": "[[1, 0, 2]]", "output": "[0, 1, 2]" }, { "input": "[[2, 0, 1, 3]]", "output": "[0, 1, 2, 3]" }, { "input": "[[1, 2, 0, 3]]", "output": "[0, 2, 3, 1]" }, { "input": "[[3, 1, 2, 0]]", "output": "[0, ...
113
false
113
verified_partial
10
7
1
10,752
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.FindPermutation.Code.Funs /-! # Specifications of `Aegis.FindPermutation.find_permutation` LeetCode problem `find-the-minimum-cost-array-permutation`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.FindPermutation def ival (x : Std.I64...
9
special-array-i
3,151
Easy
[ "Array" ]
An array is considered special if the parity of every pair of adjacent elements is different. In other words, one element in each pair must be even, and the other must be odd. You are given an array of integers nums. Return true if nums is a special array, otherwise, return false.   Example 1: Input: nums = [1] Output...
isArraySpecial(nums: list_int) -> bool
pub fn is_array_special(nums: &[i64]) -> bool
Aegis.IsArraySpecial.is_array_special
pub fn is_array_special(nums: &[i64]) -> bool { let n = nums.len(); if n <= 1 { return true; } let mut i: usize = 1; while i < n { let prev_parity = nums[i - 1] % 2; let curr_parity = nums[i] % 2; if prev_parity == curr_parity { return false; } ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [is_array_special]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option lint...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [is_array_special]: function definitions module public import Aeneas public import Aegis.IsArraySpecial.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_o...
import Aegis.IsArraySpecial.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]]", "output": "true" }, { "input": "[[100]]", "output": "true" }, { "input": "[[15]]", "output": "true" }, { "input": "[[5]]", "output": "true" }, { "input": "[[2, 3]]", "output": "true" }, { "input": "[[1, 2]]", "output": "true" ...
127
false
127
verified
10
10
1
297
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.IsArraySpecial.Code.Funs /-! # Specifications of `Aegis.IsArraySpecial.is_array_special` LeetCode problem `special-array-i`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.IsArraySpecial (is_array_special) namespace AegisSpec.IsArraySpecial def...
7
sum-of-digit-differences-of-all-pairs
3,153
Medium
[ "Array", "Hash Table", "Math", "Counting" ]
You are given an array nums consisting of positive integers where all integers have the same number of digits. The digit difference between two integers is the count of different digits that are in the same position in the two integers. Return the sum of the digit differences between all pairs of integers in nums.   Ex...
sumDigitDifferences(nums: list_int) -> int
pub fn sum_digit_differences(nums: &[i64]) -> i64
Aegis.SumDigitDifferences.sum_digit_differences
pub fn sum_digit_differences(nums: &[i64]) -> i64 { let n_usize = nums.len(); let n = n_usize as i64; let total_pairs = n * (n - 1) / 2; let mut x = nums[0]; let mut digits: i64 = 0; while x > 0 { digits += 1; x = x / 10; } let mut counts: Vec<i64> = Vec::new(); let...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [sum_digit_differences]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [sum_digit_differences]: function definitions module public import Aeneas public import Aegis.SumDigitDifferences.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand f...
import Aegis.SumDigitDifferences.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": "[[12345, 54321, 13245]]", "output": "11" }, { "input": "[[123, 234, 345]]", "output": "9" }, { "input": "[[123, 456, 789]]", "output": "9" }, { "input": "[[99999, 99999, 99999]]", "output": "0" }, { "input": "[[13, 23, 12]]", "output": "4" }, {...
105
false
105
verified
10
10
1
2,580
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.SumDigitDifferences.Code.Funs /-! # Specifications of `Aegis.SumDigitDifferences.sum_digit_differences` LeetCode problem `sum-of-digit-differences-of-all-pairs`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.SumDigitDifferences def di...
13
find-number-of-ways-to-reach-the-k-th-stair
3,154
Hard
[ "Bit Manipulation", "Memoization", "Math", "Dynamic Programming", "Combinatorics" ]
You are given a non-negative integer k. There exists a staircase with an infinite number of stairs, with the lowest stair numbered 0. Alice has an integer jump, with an initial value of 0. She starts on stair 1 and wants to reach stair k using any number of operations. If she is on stair i, in one operation she can: G...
waysToReachStair(k: int) -> int
pub fn ways_to_reach_stair(k: i64) -> i64
Aegis.WaysToReachStair.ways_to_reach_stair
fn comb(n: i64, r: i64) -> i64 { if r < 0 || r > n { return 0; } let mut rr = r; if rr > n - r { rr = n - r; } let mut res: i64 = 1; let mut i: i64 = 1; while i <= rr { res = res * (n - rr + i) / i; i += 1; } res } pub fn ways_to_reach_stair(k: ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [ways_to_reach_stair]: type definitions module public import Aeneas @[expose] public section 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_reach_stair]: function definitions module public import Aeneas public import Aegis.WaysToReachStair.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false ...
import Aegis.WaysToReachStair.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": "[1000]", "output": "0" }, { "input": "[100]", "output": "0" }, { "input": "[20]", "output": "0" }, { "input": "[1000000000]", "output": "0" }, { "input": "[1]", "output": "4" }, { "input": "[10]", "output": "0" }, { "input": "[1...
79
false
79
verified
10
10
1
7,217
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.WaysToReachStair.Code.Funs /-! # Specifications of `Aegis.WaysToReachStair.ways_to_reach_stair` LeetCode problem `find-number-of-ways-to-reach-the-k-th-stair`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.WaysToReachStair def binom (...
7
maximum-number-of-upgradable-servers
3,155
Medium
[ "Array", "Math", "Binary Search" ]
You have n data centers and need to upgrade their servers. You are given four arrays count, upgrade, sell, and money of length n, which show: The number of servers The cost of upgrading a single server The money you get by selling a server The money you initially have for each data center respectively. Return an arra...
maxUpgrades(count: list_int, upgrade: list_int, sell: list_int, money: list_int) -> list_int
pub fn max_upgrades(count: &[i64], upgrade: &[i64], sell: &[i64], money: &[i64]) -> Vec<i64>
Aegis.MaxUpgrades.max_upgrades
pub fn max_upgrades(count: &[i64], upgrade: &[i64], sell: &[i64], money: &[i64]) -> Vec<i64> { let n = count.len(); let mut answer: Vec<i64> = Vec::new(); let mut i: usize = 0; while i < n { let c = count[i]; let total_money = money[i] + c * sell[i]; let cost_per_upgrade = upgra...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [max_upgrades]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter.s...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [max_upgrades]: function definitions module public import Aeneas public import Aegis.MaxUpgrades.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.MaxUpgrades.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": "[[100000], [100000], [100000], [1000000000]]", "output": "[55000]" }, { "input": "[[1], [2], [1], [1]]", "output": "[0]" }, { "input": "[[100], [10], [5], [500]]", "output": "[66]" }, { "input": "[[100000], [1], [1], [100000]]", "output": "[100000]" }, { ...
95
false
95
verified
10
10
1
1,102
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MaxUpgrades.Code.Funs /-! # Specifications of `Aegis.MaxUpgrades.max_upgrades` LeetCode problem `maximum-number-of-upgradable-servers`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result set_option autoImplicit false namespace AegisSpec.MaxUpgrades def...
14
find-the-level-of-tree-with-minimum-sum
3,157
Medium
[ "Tree", "Depth-First Search", "Breadth-First Search", "Binary Tree" ]
Given the root of a binary tree root where each node has a value, return the level of the tree that has the minimum sum of values among all the levels (in case of a tie, return the lowest level). Note that the root of the tree is at level 1 and the level of any other node is its distance from the root + 1.   Example 1:...
minimumLevel(root: tree) -> int
pub fn minimum_level(root: &Tree) -> i64
Aegis.MinimumLevel.minimum_level
pub fn minimum_level(root: &Tree) -> i64 { let mut sums: Vec<i64> = Vec::new(); accumulate_level_sums(root, 0, &mut sums); let n: usize = sums.len(); if n == 0 { return 0; } let mut best_sum: i64 = sums[0]; let mut best_level: i64 = 1; let mut i: usize = 1; let mut level: ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [minimum_level]: type definitions module public import Aeneas @[expose] public section 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_level]: function definitions module public import Aeneas public import Aegis.MinimumLevel.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.MinimumLevel.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": "[[100]]", "output": "1" }, { "input": "[[1]]", "output": "1" }, { "input": "[[50, 6, 2, 30, 80, 7]]", "output": "2" }, { "input": "[[1, 2, 3, 4, 5, 6, 7]]", "output": "1" }, { "input": "[[9, 8, 7, 6, 5, 4, 3, 2, 1]]", "output": "4" }, { "in...
25
false
25
verified
10
10
2
11,326
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MinimumLevel.Code.Funs /-! # Specifications of `Aegis.MinimumLevel.minimum_level` LeetCode problem `find-the-level-of-tree-with-minimum-sum`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.MinimumLevel open Aegis.MinimumLevel (Tree) d...
9
find-the-number-of-distinct-colors-among-the-balls
3,160
Medium
[ "Array", "Hash Table", "Simulation" ]
You are given an integer limit and a 2D array queries of size n x 2. There are limit + 1 balls with distinct labels in the range [0, limit]. Initially, all balls are uncolored. For every query in queries that is of the form [x, y], you mark ball x with the color y. After each query, you need to find the number of color...
queryResults(limit: int, queries: list_list_int) -> list_int
pub fn query_results(limit: i64, queries: &[Vec<i64>]) -> Vec<i64>
Aegis.QueryResults.query_results
fn lower_bound(a: &[i64], x: i64) -> usize { let mut lo: usize = 0; let mut hi: usize = a.len(); while lo < hi { let mid: usize = lo + (hi - lo) / 2; if a[mid] < x { lo = mid + 1; } else { hi = mid; } } lo } fn unique_sorted(mut v: Vec<i64>) -...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [query_results]: type definitions module public import Aeneas @[expose] public section 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 -- [query_results]: function definitions module public import Aeneas public import Aegis.QueryResults.Code.Types public import Aegis.QueryResults.Code.FunsExternal @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace f...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [query_results]: external functions. -- This is a template file: rename it to "FunsExternal.lean" and fill the holes. module public import Aeneas public import Aegis.QueryResults.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set...
import Aegis.QueryResults.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, [[0, 1], [1, 2]]]", "output": "[1, 2]" }, { "input": "[100, [[0, 1], [50, 2], [100, 3]]]", "output": "[1, 2, 3]" }, { "input": "[3, [[0, 1], [1, 2], [2, 3], [0, 1]]]", "output": "[1, 2, 3, 3]" }, { "input": "[1, [[0, 1], [0, 2], [0, 3], [0, 4]]]", "output"...
47
false
47
verified
10
10
1
4,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.QueryResults.Code.Funs /-! # Specifications of `Aegis.QueryResults.query_results` LeetCode problem `find-the-number-of-distinct-colors-among-the-balls`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.QueryResults namespace AegisSpec.QueryResults...
13
block-placement-queries
3,161
Hard
[ "Binary Indexed Tree", "Segment Tree", "Array", "Binary Search" ]
There exists an infinite number line, with its origin at 0 and extending towards the positive x-axis. You are given a 2D array queries, which contains two types of queries: For a query of type 1, queries[i] = [1, x]. Build an obstacle at distance x from the origin. It is guaranteed that there is no obstacle at distanc...
getResults(queries: list_list_int) -> list_bool
pub fn get_results(queries: &[Vec<i64>]) -> Vec<bool>
Aegis.GetResults.get_results
fn seg_update(seg_max: &mut Vec<i64>, size: usize, coord: usize, gap: i64) { let mut p = size + coord; seg_max[p] = gap; p >>= 1; while p > 0 { let left = p << 1; let right = left + 1; let lv = seg_max[left]; let rv = seg_max[right]; if lv >= rv { s...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [get_results]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter.st...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [get_results]: function definitions module public import Aeneas public import Aegis.GetResults.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.GetResults.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, 3], [1, 5], [1, 7], [2, 8, 2]]]", "output": "[true]" }, { "input": "[[[2, 5, 3], [1, 3], [2, 5, 2]]]", "output": "[true, true]" }, { "input": "[[[2, 1, 1], [1, 1], [2, 1, 1]]]", "output": "[true, true]" }, { "input": "[[[2, 5, 1], [1, 3], [1, 4], [2, 5, 1]]]...
131
false
131
verified
10
10
2
47,856
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.GetResults.Code.Funs import Mathlib.Data.Real.Basic /-! # Specifications of `Aegis.GetResults.get_results` LeetCode problem `block-placement-queries`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.GetResults def row (v : alloc.vec.Vec...
12
find-the-number-of-good-pairs-i
3,162
Easy
[ "Array", "Hash Table" ]
You are given 2 integer arrays nums1 and nums2 of lengths n and m respectively. You are also given a positive integer k. A pair (i, j) is called good if nums1[i] is divisible by nums2[j] * k (0 <= i <= n - 1, 0 <= j <= m - 1). Return the total number of good pairs.   Example 1: Input: nums1 = [1,3,4], nums2 = [1,3,4],...
numberOfPairs(nums1: list_int, nums2: list_int, k: int) -> int
pub fn number_of_pairs(nums1: &[i64], nums2: &[i64], k: i64) -> i64
Aegis.NumberOfPairs.number_of_pairs
pub fn number_of_pairs(nums1: &[i64], nums2: &[i64], k: i64) -> i64 { let mut count: i64 = 0; let n = nums1.len(); let m = nums2.len(); let mut i: usize = 0; while i < n { let mut j: usize = 0; while j < m { let divisor = nums2[j] * k; if divisor != 0 && nums...
-- 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": "[[7, 14, 21], [1, 7], 3]", "output": "2" }, { "input": "[[7, 14, 21], [7, 14], 1]", "output": "4" }, { "input": "[[20, 40, 60], [5, 10], 4]", "output": "4" }, { "input": "[[5, 10, 15], [1, 5], 2]", "output": "2" }, { "input": "[[10, 20, 30], [5, 10], 2...
106
false
106
verified
10
10
1
460
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.NumberOfPairs.Code.Funs /-! # Specifications of `Aegis.NumberOfPairs.number_of_pairs` LeetCode problem `find-the-number-of-good-pairs-i`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.NumberOfPairs def ival (l : List I64) (i : ℕ) : ℤ ...
10
find-the-number-of-good-pairs-ii
3,164
Medium
[ "Array", "Hash Table" ]
You are given 2 integer arrays nums1 and nums2 of lengths n and m respectively. You are also given a positive integer k. A pair (i, j) is called good if nums1[i] is divisible by nums2[j] * k (0 <= i <= n - 1, 0 <= j <= m - 1). Return the total number of good pairs.   Example 1: Input: nums1 = [1,3,4], nums2 = [1,3,4],...
numberOfPairs(nums1: list_int, nums2: list_int, k: int) -> int
pub fn number_of_pairs(nums1: &[i64], nums2: &[i64], k: i64) -> i64
Aegis.NumberOfPairs.number_of_pairs
pub fn number_of_pairs(nums1: &[i64], nums2: &[i64], k: i64) -> i64 { let n = nums1.len(); // We only care about nums1[i] values divisible by k. // For those, write nums1[i] = k * q. Then nums2[j] * k divides nums1[i] // exactly when nums2[j] divides q. let mut max_q: i64 = 0; let mut i: usize ...
-- 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": "[[7, 14, 21], [1, 7, 14], 7]", "output": "3" }, { "input": "[[1, 3, 4], [1, 3, 4], 1]", "output": "5" }, { "input": "[[100, 200, 300], [10, 20, 30], 10]", "output": "5" }, { "input": "[[5, 10, 15], [1, 5, 10], 1]", "output": "7" }, { "input": "[[7, 14,...
93
false
93
verified_partial
10
7
1
6,476
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.NumberOfPairs.Code.Funs /-! # Specifications of `Aegis.NumberOfPairs.number_of_pairs` LeetCode problem `find-the-number-of-good-pairs-ii`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.NumberOfPairs open Aegis.NumberOfPairs attribute...
11
maximum-sum-of-subsequence-with-non-adjacent-elements
3,165
Hard
[ "Segment Tree", "Array", "Divide and Conquer", "Dynamic Programming" ]
You are given an array nums consisting of integers. You are also given a 2D array queries, where queries[i] = [posi, xi]. For query i, we first set nums[posi] equal to xi, then we calculate the answer to query i which is the maximum sum of a subsequence of nums where no two adjacent elements are selected. Return the su...
maximumSumSubsequence(nums: list_int, queries: list_list_int) -> int
pub fn maximum_sum_subsequence(nums: &[i64], queries: &[Vec<i64>]) -> i64
Aegis.MaximumSumSubsequence.maximum_sum_subsequence
pub fn maximum_sum_subsequence(nums: &[i64], queries: &[Vec<i64>]) -> i64 { let mod_val: i64 = 1_000_000_007; let neg_inf: i64 = -1_000_000_000_000; let n = nums.len(); let mut size: usize = 1; while size < n { size = size * 2; } let total = size * 2; let mut m00: Vec<i64> = Ve...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [maximum_sum_subsequence]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_opti...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [maximum_sum_subsequence]: function definitions module public import Aeneas public import Aegis.MaximumSumSubsequence.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashComma...
import Aegis.MaximumSumSubsequence.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": "[[123456], [[0, -123456]]]", "output": "0" }, { "input": "[[0, -1], [[0, -5]]]", "output": "0" }, { "input": "[[3, 5, 9], [[1, -2], [0, -3]]]", "output": "21" }, { "input": "[[-10, -20, -30, -40], [[1, 10], [3, 20]]]", "output": "40" }, { "input": "[[1...
87
false
87
verified
10
10
1
18,233
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MaximumSumSubsequence.Code.Funs /-! # Specifications of `Aegis.MaximumSumSubsequence.maximum_sum_subsequence` LeetCode problem `maximum-sum-of-subsequence-with-non-adjacent-elements`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.MaximumSumSubse...
13
minimum-number-of-chairs-in-a-waiting-room
3,168
Easy
[ "String", "Simulation" ]
You are given a string s. Simulate events at each second i: If s[i] == 'E', a person enters the waiting room and takes one of the chairs in it. If s[i] == 'L', a person leaves the waiting room, freeing up a chair. Return the minimum number of chairs needed so that a chair is available for every person who enters the ...
minimumChairs(s: str) -> int
pub fn minimum_chairs(s: &[u8]) -> i64
Aegis.MinimumChairs.minimum_chairs
pub fn minimum_chairs(s: &[u8]) -> i64 { let mut current: i64 = 0; let mut max_people: i64 = 0; let mut i: usize = 0; while i < s.len() { if s[i] == b'E' { current += 1; } else { current -= 1; } if current > max_people { max_people = ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [minimum_chairs]: type definitions module public import Aeneas @[expose] public section 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_chairs]: function definitions module public import Aeneas public import Aegis.MinimumChairs.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.MinimumChairs.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": "[\"ELEELEELLL\"]", "output": "3" }, { "input": "[\"EEEEEEE\"]", "output": "7" }, { "input": "[\"EELLEELLL\"]", "output": "2" }, { "input": "[\"E\"]", "output": "1" }, { "input": "[\"EELLEL\"]", "output": "2" }, { "input": "[\"ELE\"]", "...
144
false
144
verified
10
10
1
728
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MinimumChairs.Code.Funs /-! # Specifications of `Aegis.MinimumChairs.minimum_chairs` LeetCode problem `minimum-number-of-chairs-in-a-waiting-room`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.MinimumChairs abbrev bytes (s : Slice St...
12