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
maximum-or
2,680
Medium
[ "Greedy", "Bit Manipulation", "Array", "Prefix Sum" ]
You are given a 0-indexed integer array nums of length n and an integer k. In an operation, you can choose an element and multiply it by 2. Return the maximum possible value of nums[0] | nums[1] | ... | nums[n - 1] that can be obtained after applying the operation on nums at most k times. Note that a | b denotes the bi...
maximumOr(nums: list_int, k: int) -> int
pub fn maximum_or(nums: &[i64], k: i64) -> i64
Aegis.MaximumOr.maximum_or
pub fn maximum_or(nums: &[i64], k: i64) -> i64 { let n = nums.len(); let mut factor: i64 = 1; let mut t: i64 = 0; while t < k { factor = factor * 2; t += 1; } let mut suffix: Vec<i64> = Vec::new(); let mut z: usize = 0; while z <= n { suffix.push(0); z +...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [maximum_or]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter.sty...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [maximum_or]: function definitions module public import Aeneas public import Aegis.MaximumOr.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linte...
import Aegis.MaximumOr.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval aegisCase "...
[ { "input": "[[1000000000], 15]", "output": "32768000000000" }, { "input": "[[12, 9], 1]", "output": "30" }, { "input": "[[1000000000, 1000000000, 1000000000], 8]", "output": "256554748416" }, { "input": "[[5, 10, 15], 5]", "output": "495" }, { "input": "[[8, 1, 2]...
114
false
114
verified
10
10
1
2,587
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MaximumOr.Code.Funs /-! # Specifications of `Aegis.MaximumOr.maximum_or` LeetCode problem `maximum-or`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.MaximumOr def bor (a b : Int) : Int := ((a.toNat ||| b.toNat : Nat) : Int) def orAl...
11
power-of-heroes
2,681
Hard
[ "Array", "Math", "Dynamic Programming", "Prefix Sum", "Sorting" ]
You are given a 0-indexed integer array nums representing the strength of some heroes. The power of a group of heroes is defined as follows: Let i0, i1, ... ,ik be the indices of the heroes in a group. Then, the power of this group is max(nums[i0], nums[i1], ... ,nums[ik])2 * min(nums[i0], nums[i1], ... ,nums[ik]). R...
sumOfPower(nums: list_int) -> int
pub fn sum_of_power(nums: &[i64]) -> i64
Aegis.SumOfPower.sum_of_power
const MOD: i64 = 1_000_000_007; fn sort_i64(v: &mut Vec<i64>) { let n = v.len(); if n <= 1 { return; } let mut temp: Vec<i64> = Vec::new(); let mut i = 0; while i < n { temp.push(0); i += 1; } let mut width: usize = 1; while width < n { let mut star...
-- 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 @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option li...
import Aegis.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]]", "output": "1" }, { "input": "[[1000000000]]", "output": "999999664" }, { "input": "[[2, 1, 4]]", "output": "141" }, { "input": "[[1, 1, 1]]", "output": "7" }, { "input": "[[1000000000, 1000000000, 1000000000]]", "output": "999997606" }, ...
93
false
93
verified
10
10
1
6,101
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.SumOfPower.Code.Funs /-! # Specifications of `Aegis.SumOfPower.sum_of_power` LeetCode problem `power-of-heroes`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.SumOfPower def MOD : ℤ := 1000000007 def getv (nums : Slice I64) (i ...
8
find-the-losers-of-the-circular-game
2,682
Easy
[ "Array", "Hash Table", "Simulation" ]
There are n friends that are playing a game. The friends are sitting in a circle and are numbered from 1 to n in clockwise order. More formally, moving clockwise from the ith friend brings you to the (i+1)th friend for 1 <= i < n, and moving clockwise from the nth friend brings you to the 1st friend. The rules of the g...
circularGameLosers(n: int, k: int) -> list_int
pub fn circular_game_losers(n: i64, k: i64) -> Vec<i64>
Aegis.CircularGameLosers.circular_game_losers
pub fn circular_game_losers(n: i64, k: i64) -> Vec<i64> { let nn: usize = n as usize; let mut seen: Vec<bool> = Vec::new(); let mut i: usize = 0; while i < nn { seen.push(false); i += 1; } seen[0] = true; let mut pos: i64 = 0; let mut turn: i64 = 1; let mut running...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [circular_game_losers]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [circular_game_losers]: function definitions module public import Aeneas public import Aegis.CircularGameLosers.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand fal...
import Aegis.CircularGameLosers.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": "[5, 2]", "output": "[4, 5]" }, { "input": "[4, 4]", "output": "[2, 3, 4]" }, { "input": "[7, 3]", "output": "[2, 6, 7]" }, { "input": "[6, 1]", "output": "[3, 5, 6]" }, { "input": "[7, 5]", "output": "[4, 5, 7]" }, { "input": "[10, 3]", ...
73
false
73
verified
10
10
1
1,877
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.CircularGameLosers.Code.Funs /-! # Specifications of `Aegis.CircularGameLosers.circular_game_losers` LeetCode problem `find-the-losers-of-the-circular-game`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.CircularGameLosers def pos (k ...
12
neighboring-bitwise-xor
2,683
Medium
[ "Bit Manipulation", "Array" ]
A 0-indexed array derived with length n is derived by computing the bitwise XOR (⊕) of adjacent values in a binary array original of length n. Specifically, for each index i in the range [0, n - 1]: If i = n - 1, then derived[i] = original[i] ⊕ original[0]. Otherwise, derived[i] = original[i] ⊕ original[i + 1]. Given...
doesValidArrayExist(derived: list_int) -> bool
pub fn does_valid_array_exist(derived: &[i64]) -> bool
Aegis.DoesValidArrayExist.does_valid_array_exist
pub fn does_valid_array_exist(derived: &[i64]) -> bool { let n = derived.len(); let mut parity = false; let mut i = 0; while i < n { if derived[i] != 0 { parity = !parity; } i += 1; } !parity }
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [does_valid_array_exist]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_optio...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [does_valid_array_exist]: function definitions module public import Aeneas public import Aegis.DoesValidArrayExist.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand ...
import Aegis.DoesValidArrayExist.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": "false" }, { "input": "[[0]]", "output": "true" }, { "input": "[[1, 0]]", "output": "false" }, { "input": "[[1, 1]]", "output": "true" }, { "input": "[[0, 0, 0]]", "output": "true" }, { "input": "[[1, 1, 0]]", "output"...
91
false
91
verified
10
10
1
476
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.DoesValidArrayExist.Code.Funs /-! # Specifications of `Aegis.DoesValidArrayExist.does_valid_array_exist` LeetCode problem `neighboring-bitwise-xor`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.DoesValidArrayExist def vals (s : S...
9
maximum-number-of-moves-in-a-grid
2,684
Medium
[ "Array", "Dynamic Programming", "Matrix" ]
You are given a 0-indexed m x n matrix grid consisting of positive integers. You can start at any cell in the first column of the matrix, and traverse the grid in the following way: From a cell (row, col), you can move to any of the cells: (row - 1, col + 1), (row, col + 1) and (row + 1, col + 1) such that the value o...
maxMoves(grid: list_list_int) -> int
pub fn max_moves(grid: &[Vec<i64>]) -> i64
Aegis.MaxMoves.max_moves
pub fn max_moves(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 r: usize = 0; while r < m { dp.push(0); r += 1; } let mut best...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [max_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.styl...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [max_moves]: function definitions module public import Aeneas public import Aegis.MaxMoves.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.MaxMoves.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": "[[[9, 8, 7], [6, 5, 4], [3, 2, 1]]]", "output": "2" }, { "input": "[[[10, 15, 20], [5, 9, 12], [7, 8, 10]]]", "output": "2" }, { "input": "[[[3, 2, 4], [2, 1, 9], [1, 1, 7]]]", "output": "0" }, { "input": "[[[1, 2, 3], [4, 5, 6], [7, 8, 9]]]", "output": "2" ...
81
false
81
verified
10
10
1
1,557
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MaxMoves.Code.Funs /-! # Specifications of `Aegis.MaxMoves.max_moves` LeetCode problem `maximum-number-of-moves-in-a-grid`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.MaxMoves def emptyRow : alloc.vec.Vec Std.I64 := alloc.vec.V...
13
count-the-number-of-complete-components
2,685
Medium
[ "Depth-First Search", "Breadth-First Search", "Union Find", "Graph" ]
You are given an integer n. There is an undirected graph with n vertices, numbered from 0 to n - 1. You are given a 2D integer array edges where edges[i] = [ai, bi] denotes that there exists an undirected edge connecting vertices ai and bi. Return the number of complete connected components of the graph. A connected co...
countCompleteComponents(n: int, edges: list_list_int) -> int
pub fn count_complete_components(n: i64, edges: &[Vec<i64>]) -> i64
Aegis.CountCompleteComponents.count_complete_components
pub fn count_complete_components(n: i64, edges: &[Vec<i64>]) -> i64 { let n_usize = n as usize; let mut parent: Vec<usize> = Vec::new(); let mut size: Vec<i64> = Vec::new(); let mut i: usize = 0; while i < n_usize { parent.push(i); size.push(1); i += 1; } let mut e...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [count_complete_components]: type definitions module public import Aeneas @[expose] public 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_complete_components]: function definitions module public import Aeneas public import Aegis.CountCompleteComponents.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashC...
import Aegis.CountCompleteComponents.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": "[5, []]", "output": "5" }, { "input": "[2, [[0, 1]]]", "output": "1" }, { "input": "[4, [[0, 1], [2, 3]]]", "output": "2" }, { "input": "[4, [[0, 1], [1, 2]]]", "output": "1" }, { "input": "[3, [[0, 1]...
69
false
69
verified
10
10
1
2,917
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.CountCompleteComponents.Code.Funs /-! # Specifications of `Aegis.CountCompleteComponents.count_complete_components` LeetCode problem `count-the-number-of-complete-components`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result ControlFlow Error namespace Aeg...
11
minimum-string-length-after-removing-substrings
2,696
Easy
[ "Stack", "String", "Simulation" ]
You are given a string s consisting only of uppercase English letters. You can apply some operations to this string where, in one operation, you can remove any occurrence of one of the substrings "AB" or "CD" from s. Return the minimum possible length of the resulting string that you can obtain. Note that the string co...
minLength(s: str) -> int
pub fn min_length(s: &[u8]) -> i64
Aegis.MinLength.min_length
pub fn min_length(s: &[u8]) -> i64 { let mut stack: Vec<u8> = Vec::new(); let mut i: usize = 0; while i < s.len() { let c = s[i]; let mut removed = false; if stack.len() > 0 { let top = stack[stack.len() - 1]; if (top == b'A' && c == b'B') || (top == b'C' &&...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [min_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.sty...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [min_length]: function definitions module public import Aeneas public import Aegis.MinLength.Code.Types public import Aegis.MinLength.Code.FunsExternal @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [min_length]: external functions. -- This is a template file: rename it to "FunsExternal.lean" and fill the holes. module public import Aeneas public import Aegis.MinLength.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_optio...
import Aegis.MinLength.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": "[\"ABCDBA\"]", "output": "2" }, { "input": "[\"CDCDCD\"]", "output": "0" }, { "input": "[\"ABABAB\"]", "output": "0" }, { "input": "[\"ACBBD\"]", "output": "5" }, { "input": "[\"ABFCACDB\"]", "output": "2" }, { "input": "[\"AAAA\"]", "o...
153
false
153
verified
10
10
1
578
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MinLength.Code.Funs /-! # Specifications of `Aegis.MinLength.min_length` LeetCode problem `minimum-string-length-after-removing-substrings`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.MinLength def IsAllowedPair (a b : Std.U8) : Pr...
13
find-the-punishment-number-of-an-integer
2,698
Medium
[ "Math", "Backtracking" ]
Given a positive integer n, return the punishment number of n. The punishment number of n is defined as the sum of the squares of all integers i such that: 1 <= i <= n The decimal representation of i * i can be partitioned into contiguous substrings such that the sum of the integer values of these substrings equals i....
punishmentNumber(n: int) -> int
pub fn punishment_number(n: i64) -> i64
Aegis.PunishmentNumber.punishment_number
pub fn punishment_number(n: i64) -> i64 { let mut total: i64 = 0; let mut i: i64 = 1; while i <= n { let square: i64 = i * i; let mut x: i64 = square; let mut rev: Vec<i64> = Vec::new(); while x > 0 { rev.push(x % 10); x = x / 10; } ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [punishment_number]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option lin...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [punishment_number]: function definitions module public import Aeneas public import Aegis.PunishmentNumber.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.PunishmentNumber.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": "[700]", "output": "1660140" }, { "input": "[800]", "output": "3353149" }, { "input": "[100]", "output": "41334" }, { "input": "[600]", "output": "772866" }, { "input": "[37]", "output": "1478" }, { "input": "[200]", "output": "41334" ...
21
false
21
verified
10
10
1
4,767
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.PunishmentNumber.Code.Funs /-! # Specifications of `Aegis.PunishmentNumber.punishment_number` LeetCode problem `find-the-punishment-number-of-an-integer`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.PunishmentNumber open Aegis.Punis...
16
modify-graph-edge-weights
2,699
Hard
[ "Graph", "Shortest Path", "Heap (Priority Queue)" ]
You are given an undirected weighted connected graph containing n nodes labeled from 0 to n - 1, and an integer array edges where edges[i] = [ai, bi, wi] indicates that there is an edge between nodes ai and bi with weight wi. Some edges have a weight of -1 (wi = -1), while others have a positive weight (wi > 0). Your t...
modifiedGraphEdges(n: int, edges: list_list_int, source: int, destination: int, target: int) -> list_list_int
pub fn modified_graph_edges(n: i64, edges: &[Vec<i64>], source: i64, destination: i64, target: i64) -> Vec<Vec<i64>>
Aegis.ModifiedGraphEdges.modified_graph_edges
fn dijkstra(adj: &[i64], n: usize, src: usize) -> Vec<i64> { let inf: i64 = 1_000_000_000_000_000_000; let mut dist: Vec<i64> = Vec::new(); let mut i: usize = 0; while i < n { dist.push(inf); i += 1; } dist[src] = 0; let mut visited: Vec<i64> = Vec::new(); i = 0; whi...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [modified_graph_edges]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [modified_graph_edges]: function definitions module public import Aeneas public import Aegis.ModifiedGraphEdges.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand fal...
import Aegis.ModifiedGraphEdges.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval ae...
[ { "input": "[2, [[0, 1, -1]], 0, 1, 1]", "output": "[[0, 1, 1]]" }, { "input": "[3, [[0, 1, -1], [0, 2, 5]], 0, 2, 6]", "output": "[]" }, { "input": "[3, [[0, 1, 1], [1, 2, -1]], 0, 2, 4]", "output": "[[0, 1, 1], [1, 2, 3]]" }, { "input": "[6, [[0, 1, 2], [1, 2, 3], [2, 3, 4]...
77
true
77
verified
10
10
1
26,529
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.ModifiedGraphEdges.Code.Funs /-! # Specifications of `Aegis.ModifiedGraphEdges.modified_graph_edges` LeetCode problem `modify-graph-edge-weights`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aeneas.Std.alloc.vec namespace AegisSpec.ModifiedGrap...
12
minimum-operations-to-make-numbers-non-positive
2,702
Hard
[ "Array", "Binary Search" ]
You are given a 0-indexed integer array nums and two integers x and y. In one operation, you must choose an index i such that 0 <= i < nums.length and perform the following: Decrement nums[i] by x. Decrement values by y at all indices except the ith one. Return the minimum number of operations to make all the integer...
minOperations(nums: list_int, x: int, y: int) -> int
pub fn min_operations(nums: &[i64], x: i64, y: i64) -> i64
Aegis.MinOperations.min_operations
pub fn min_operations(nums: &[i64], x: i64, y: i64) -> i64 { let n = nums.len(); let mut high: i64 = 0; let mut i: usize = 0; while i < n { if nums[i] > high { high = nums[i]; } i += 1; } let mut low: i64 = 0; while low < high { let mid = low + (...
-- 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": "[[1000000000, 1000000000], 1000000000, 1]", "output": "2" }, { "input": "[[10, 20, 30], 5, 1]", "output": "10" }, { "input": "[[1, 2, 1], 2, 1]", "output": "1" }, { "input": "[[5, 15, 25], 10, 3]", "output": "4" }, { "input": "[[10, 20, 30], 5, 2]", ...
104
false
104
verified
10
10
1
6,822
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MinOperations.Code.Funs /-! # Specifications of `Aegis.MinOperations.min_operations` LeetCode problem `minimum-operations-to-make-numbers-non-positive`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.MinOperations def vals (nums : ...
13
buy-two-chocolates
2,706
Easy
[ "Greedy", "Array", "Sorting" ]
You are given an integer array prices representing the prices of various chocolates in a store. You are also given a single integer money, which represents your initial amount of money. You must buy exactly two chocolates in such a way that you still have some non-negative leftover money. You would like to minimize the...
buyChoco(prices: list_int, money: int) -> int
pub fn buy_choco(prices: &[i64], money: i64) -> i64
Aegis.BuyChoco.buy_choco
pub fn buy_choco(prices: &[i64], money: i64) -> i64 { let mut min1: i64 = 101; let mut min2: i64 = 101; let n = prices.len(); let mut i: usize = 0; while i < n { let p = prices[i]; if p < min1 { min2 = min1; min1 = p; } else if p < min2 { ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [buy_choco]: type definitions module public import Aeneas @[expose] public section 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 -- [buy_choco]: function definitions module public import Aeneas public import Aegis.BuyChoco.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.BuyChoco.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": "[[99, 99], 198]", "output": "0" }, { "input": "[[99, 1], 100]", "output": "0" }, { "input": "[[1, 1], 3]", "output": "1" }, { "input": "[[50, 50], 100]", "output": "0" }, { "input": "[[99, 99], 198]", "output": "0" }, { "input": "[[1, 2, 2]...
111
false
111
verified
10
10
1
485
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.BuyChoco.Code.Funs /-! # Specifications of `Aegis.BuyChoco.buy_choco` LeetCode problem `buy-two-chocolates`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.BuyChoco def vals (prices : Slice Std.I64) : List ℤ := prices.val.map (fun ...
11
extra-characters-in-a-string
2,707
Medium
[ "Trie", "Array", "Hash Table", "String", "Dynamic Programming" ]
You are given a 0-indexed string s and a dictionary of words dictionary. You have to break s into one or more non-overlapping substrings such that each substring is present in dictionary. There may be some extra characters in s which are not present in any of the substrings. Return the minimum number of extra character...
minExtraChar(s: str, dictionary: list_str) -> int
pub fn min_extra_char(s: &[u8], dictionary: &[Vec<u8>]) -> i64
Aegis.MinExtraChar.min_extra_char
pub fn min_extra_char(s: &[u8], dictionary: &[Vec<u8>]) -> i64 { let n = s.len(); let mut dp: Vec<i64> = Vec::new(); let mut i = 0usize; while i <= n { dp.push(0); i += 1; } i = 1; while i <= n { let mut best = dp[i - 1] + 1; let mut d = 0usize; whi...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [min_extra_char]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [min_extra_char]: function definitions module public import Aeneas public import Aegis.MinExtraChar.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.MinExtraChar.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": "[\"a\", [\"b\"]]", "output": "1" }, { "input": "[\"sayhelloworld\", [\"hello\", \"world\"]]", "output": "3" }, { "input": "[\"abc\", [\"d\", \"e\"]]", "output": "3" }, { "input": "[\"abcabcabc\", [\"abcabc\", \"abc\"]]", "output": "0" }, { "input": "[\...
97
false
97
verified
10
10
1
1,107
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MinExtraChar.Code.Funs /-! # Specifications of `Aegis.MinExtraChar.min_extra_char` LeetCode problem `extra-characters-in-a-string`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.MinExtraChar def IsLowerByte (b : Std.U8) : Prop := ...
13
maximum-strength-of-a-group
2,708
Medium
[ "Greedy", "Bit Manipulation", "Array", "Dynamic Programming", "Backtracking", "Enumeration", "Sorting" ]
You are given a 0-indexed integer array nums representing the score of students in an exam. The teacher would like to form one non-empty group of students with maximal strength, where the strength of a group of students of indices i0, i1, i2, ... , ik is defined as nums[i0] * nums[i1] * nums[i2] * ... * nums[ik​]. Retu...
maxStrength(nums: list_int) -> int
pub fn max_strength(nums: &[i64]) -> i64
Aegis.MaxStrength.max_strength
pub fn max_strength(nums: &[i64]) -> i64 { let n: usize = nums.len(); let mut total: usize = 1; let mut k: usize = 0; while k < n { total = total * 2; k += 1; } let mut best: i64 = nums[0]; let mut mask: usize = 0; while mask < total { let mut x: usize = mask; ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [max_strength]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter.s...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [max_strength]: function definitions module public import Aeneas public import Aegis.MaxStrength.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.MaxStrength.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": "[[-9]]", "output": "-9" }, { "input": "[[-1]]", "output": "-1" }, { "input": "[[9]]", "output": "9" }, { "input": "[[1]]", "output": "1" }, { "input": "[[0]]", "output": "0" }, { "input": "[[1, -1]]", "output": "1" }, { "input":...
123
false
123
verified
10
10
1
3,828
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MaxStrength.Code.Funs /-! # Specifications of `Aegis.MaxStrength.max_strength` LeetCode problem `maximum-strength-of-a-group`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.MaxStrength open Aegis.MaxStrength def vals (nums : Slice St...
16
difference-of-number-of-distinct-values-on-diagonals
2,711
Medium
[ "Array", "Hash Table", "Matrix" ]
Given a 2D grid of size m x n, you should find the matrix answer of size m x n. The cell answer[r][c] is calculated by looking at the diagonal values of the cell grid[r][c]: Let leftAbove[r][c] be the number of distinct values on the diagonal to the left and above the cell grid[r][c] not including the cell grid[r][c] ...
differenceOfDistinctValues(grid: list_list_int) -> list_list_int
pub fn difference_of_distinct_values(grid: &[Vec<i64>]) -> Vec<Vec<i64>>
Aegis.DifferenceOfDistinctValues.difference_of_distinct_values
pub fn difference_of_distinct_values(grid: &[Vec<i64>]) -> Vec<Vec<i64>> { let m = grid.len(); let mut ans: Vec<Vec<i64>> = Vec::new(); if m == 0 { return ans; } let n = grid[0].len(); let mut r = 0usize; while r < m { let mut row_ans: Vec<i64> = Vec::new(); let mu...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [difference_of_distinct_values]: type definitions module public import Aeneas @[expose] 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 -- [difference_of_distinct_values]: function definitions module public import Aeneas public import Aegis.DifferenceOfDistinctValues.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linte...
import Aegis.DifferenceOfDistinctValues.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": "[[0]]" }, { "input": "[[[4, 5], [5, 4]]]", "output": "[[1, 0], [0, 1]]" }, { "input": "[[[1, 2], [3, 4]]]", "output": "[[1, 0], [0, 1]]" }, { "input": "[[[4, 4], [4, 4]]]", "output": "[[1, 0], [0, 1]]" }, { "input": "[[[1, 2], [2, ...
91
false
91
verified
10
10
1
2,701
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.DifferenceOfDistinctValues.Code.Funs /-! # Specifications of `Aegis.DifferenceOfDistinctValues.difference_of_distinct_values` LeetCode problem `difference-of-number-of-distinct-values-on-diagonals`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace ...
14
minimum-cost-to-make-all-characters-equal
2,712
Medium
[ "Greedy", "String", "Dynamic Programming" ]
You are given a 0-indexed binary string s of length n on which you can apply two types of operations: Choose an index i and invert all characters from index 0 to index i (both inclusive), with a cost of i + 1 Choose an index i and invert all characters from index i to index n - 1 (both inclusive), with a cost of n - i...
minimumCost(s: str) -> int
pub fn minimum_cost(s: &[u8]) -> i64
Aegis.MinimumCost.minimum_cost
pub fn minimum_cost(s: &[u8]) -> i64 { let n: usize = s.len(); let mut ans: i64 = 0; let mut i: usize = 1; while i < n { if s[i] != s[i - 1] { let left: i64 = i as i64; let right: i64 = (n - i) as i64; if left < right { ans += left; ...
-- 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": "[\"100100100\"]", "output": "13" }, { "input": "[\"00000000000000000000000000000000000000000000000000\"]", "output": "0" }, { "input": "[\"110011\"]", "output": "4" }, { "input": "[\"11110000\"]", "output": "4" }, { "input": "[\"1000100010001\"]", ...
162
false
162
verified
10
10
1
754
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MinimumCost.Code.Funs /-! # Specifications of `Aegis.MinimumCost.minimum_cost` LeetCode problem `minimum-cost-to-make-all-characters-equal`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.MinimumCost namespace AegisSpec.MinimumCost def codeAt (...
9
maximum-strictly-increasing-cells-in-a-matrix
2,713
Hard
[ "Memoization", "Array", "Hash Table", "Binary Search", "Dynamic Programming", "Matrix", "Ordered Set", "Sorting" ]
Given a 1-indexed m x n integer matrix mat, you can select any cell in the matrix as your starting cell. From the starting cell, you can move to any other cell in the same row or column, but only if the value of the destination cell is strictly greater than the value of the current cell. You can repeat this process as ...
maxIncreasingCells(mat: list_list_int) -> int
pub fn max_increasing_cells(mat: &[Vec<i64>]) -> i64
Aegis.MaxIncreasingCells.max_increasing_cells
pub fn max_increasing_cells(mat: &[Vec<i64>]) -> i64 { if mat.len() == 0 { return 0; } let m = mat.len(); let n = mat[0].len(); if n == 0 { return 0; } let total = m * n; let total_i = total as i64; let offset: i64 = 1000000; let mut cells: Vec<i64> = Vec::new...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [max_increasing_cells]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [max_increasing_cells]: function definitions module public import Aeneas public import Aegis.MaxIncreasingCells.Code.Types public import Aegis.MaxIncreasingCells.Code.FunsExternal @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option li...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [max_increasing_cells]: external functions. -- This is a template file: rename it to "FunsExternal.lean" and fill the holes. module public import Aeneas public import Aegis.MaxIncreasingCells.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlF...
import Aegis.MaxIncreasingCells.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval ae...
[ { "input": "[[[1]]]", "output": "1" }, { "input": "[[[-100000, 100000], [-100000, 100000]]]", "output": "2" }, { "input": "[[[3, 1], [3, 4]]]", "output": "2" }, { "input": "[[[1, 1], [1, 1]]]", "output": "1" }, { "input": "[[[3, 1, 6], [-9, 5, 7]]]", "output":...
106
false
106
verified
10
10
1
7,954
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MaxIncreasingCells.Code.Funs /-! # Specifications of `Aegis.MaxIncreasingCells.max_increasing_cells` LeetCode problem `maximum-strictly-increasing-cells-in-a-matrix`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.MaxIncreasingCells de...
14
find-shortest-path-with-k-hops
2,714
Hard
[ "Graph", "Shortest Path", "Heap (Priority Queue)" ]
You are given a positive integer n which is the number of nodes of a 0-indexed undirected weighted connected graph and a 0-indexed 2D array edges where edges[i] = [ui, vi, wi] indicates that there is an edge between nodes ui and vi with weight wi. You are also given two nodes s and d, and a positive integer k, your tas...
shortestPathWithHops(n: int, edges: list_list_int, s: int, d: int, k: int) -> int
pub fn shortest_path_with_hops(n: i64, edges: &[Vec<i64>], s: i64, d: i64, k: i64) -> i64
Aegis.ShortestPathWithHops.shortest_path_with_hops
pub fn shortest_path_with_hops(n: i64, edges: &[Vec<i64>], s: i64, d: i64, k: i64) -> i64 { let nn = n as usize; let inf: i64 = 1_000_000_000_000_000_000; // Build adjacency list: for each node, pairs [neighbor, weight, ...]. let mut adj: Vec<Vec<i64>> = Vec::new(); let mut i = 0usize; while i ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [shortest_path_with_hops]: type definitions module public import Aeneas @[expose] public 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 -- [shortest_path_with_hops]: function definitions module public import Aeneas public import Aegis.ShortestPathWithHops.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashComman...
import Aegis.ShortestPathWithHops.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, [[0, 1, 10], [1, 2, 10]], 0, 2, 1]", "output": "10" }, { "input": "[3, [[0, 1, 5], [1, 2, 3]], 0, 2, 1]", "output": "3" }, { "input": "[4, [[0, 1, 4], [0, 2, 2], [2, 3, 6]], 1, 3, 2]", "output": "2" }, { "input": "[6, [[0, 1, 1], [1, 2, 2], [2, 3, 3], [3, 4, 4...
65
false
65
verified
10
10
1
10,662
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.ShortestPathWithHops.Code.Funs /-! # Specifications of `Aegis.ShortestPathWithHops.shortest_path_with_hops` LeetCode problem `find-shortest-path-with-k-hops`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.ShortestPathWithHops namespace AegisSpe...
11
minimize-string-length
2,716
Easy
[ "Hash Table", "String" ]
Given a string s, you have two types of operation: Choose an index i in the string, and let c be the character in position i. Delete the closest occurrence of c to the left of i (if exists). Choose an index i in the string, and let c be the character in position i. Delete the closest occurrence of c to the right of i ...
minimizedStringLength(s: str) -> int
pub fn minimized_string_length(s: &[u8]) -> i64
Aegis.MinimizedStringLength.minimized_string_length
pub fn minimized_string_length(s: &[u8]) -> i64 { let mut distinct: i64 = 0; let mut i: usize = 0; while i < s.len() { let c: u8 = s[i]; let mut seen_before: bool = false; let mut j: usize = 0; while j < i { if s[j] == c { seen_before = true; ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [minimized_string_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 -- [minimized_string_length]: function definitions module public import Aeneas public import Aegis.MinimizedStringLength.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashComma...
import Aegis.MinimizedStringLength.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": "[\"aaabc\"]", "output": "3" }, { "input": "[\"abcdefghijklmnopqrstuvwxyz\"]", "output": "26" }, { "input": "[\"a\"]", "output": "1" }, { "input": "[\"abacabadabacaba\"]", "output": "4" }, { "input": "[\"abcabcabc\"]", "output": "3" }, { "in...
112
false
112
verified
10
10
1
1,030
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MinimizedStringLength.Code.Funs /-! # Specifications of `Aegis.MinimizedStringLength.minimized_string_length` LeetCode problem `minimize-string-length`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.MinimizedStringLength def bytes...
11
sum-of-matrix-after-queries
2,718
Medium
[ "Array", "Hash Table" ]
You are given an integer n and a 0-indexed 2D array queries where queries[i] = [typei, indexi, vali]. Initially, there is a 0-indexed n x n matrix filled with 0's. For each query, you must apply one of the following changes: if typei == 0, set the values in the row with indexi to vali, overwriting any previous values....
matrixSumQueries(n: int, queries: list_list_int) -> int
pub fn matrix_sum_queries(n: i64, queries: &[Vec<i64>]) -> i64
Aegis.MatrixSumQueries.matrix_sum_queries
pub fn matrix_sum_queries(n: i64, queries: &[Vec<i64>]) -> i64 { let n_usize = n as usize; let mut seen_rows: Vec<bool> = Vec::new(); let mut seen_cols: Vec<bool> = Vec::new(); let mut i = 0; while i < n_usize { seen_rows.push(false); seen_cols.push(false); i += 1; } ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [matrix_sum_queries]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option li...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [matrix_sum_queries]: function definitions module public import Aeneas public import Aegis.MatrixSumQueries.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.MatrixSumQueries.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, [[0, 0, 100]]]", "output": "100" }, { "input": "[1, [[0, 0, 10], [1, 0, 20]]]", "output": "20" }, { "input": "[5, [[1, 0, 10], [0, 2, 3], [1, 4, 5]]]", "output": "77" }, { "input": "[4, [[0, 1, 5], [1, 3, 2], [0, 3, 1]]]", "output": "25" }, { "inpu...
91
false
91
verified
10
10
1
1,415
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MatrixSumQueries.Code.Funs /-! # Specifications of `Aegis.MatrixSumQueries.matrix_sum_queries` LeetCode problem `sum-of-matrix-after-queries`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.MatrixSumQueries def queryField (Q : List (al...
13
count-of-integers
2,719
Hard
[ "Math", "String", "Dynamic Programming" ]
You are given two numeric strings num1 and num2 and two integers max_sum and min_sum. We denote an integer x to be good if: num1 <= x <= num2 min_sum <= digit_sum(x) <= max_sum. Return the number of good integers. Since the answer may be large, return it modulo 109 + 7. Note that digit_sum(x) denotes the sum of the d...
count(num1: str, num2: str, min_sum: int, max_sum: int) -> int
pub fn count(num1: &[u8], num2: &[u8], min_sum: i64, max_sum: i64) -> i64
Aegis.Count.count
const MOD: i64 = 1_000_000_007; fn is_zero(s: &[u8]) -> bool { let mut i = 0; while i < s.len() { if s[i] != b'0' { return false; } i += 1; } true } fn dec_one(s: &[u8]) -> Vec<u8> { let mut v: Vec<u8> = Vec::new(); let mut i = 0; while i < s.len() { ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [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.style.wh...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [count]: function definitions module public import Aeneas public import Aegis.Count.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.unusedV...
import Aegis.Count.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval aegisCase "eval...
[ { "input": "[\"1\", \"5\", 1, 5]", "output": "5" }, { "input": "[\"1\", \"1000000000000000000000000000000\", 300, 400]", "output": "0" }, { "input": "[\"999999999999999999999999999999\", \"1000000000000000000000000000000\", 1, 400]", "output": "2" }, { "input": "[\"1234567890...
85
false
85
verified
10
10
1
7,750
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.Count.Code.Funs /-! # Specifications of `Aegis.Count.count` LeetCode problem `count-of-integers`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.Count def modN : ℕ := 1000000007 def digitSum : ℕ → ℕ | 0 => 0 | n + 1 => (...
13
check-if-the-number-is-fascinating
2,729
Easy
[ "Hash Table", "Math" ]
You are given an integer n that consists of exactly 3 digits. We call the number n fascinating if, after the following modification, the resulting number contains all the digits from 1 to 9 exactly once and does not contain any 0's: Concatenate n with the numbers 2 * n and 3 * n. Return true if n is fascinating, or f...
isFascinating(n: int) -> bool
pub fn is_fascinating(n: i64) -> bool
Aegis.IsFascinating.is_fascinating
fn add_digits(mut x: i64, seen: i64) -> i64 { let mut bits = seen; while x > 0 { let d = x % 10; if d == 0 { return -1; } let mut bit: i64 = 1; let mut k: i64 = 0; while k < d { bit = bit * 2; k = k + 1; } if b...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [is_fascinating]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [is_fascinating]: function definitions module public import Aeneas public import Aegis.IsFascinating.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.IsFascinating.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": "[933]", "output": "false" }, { "input": "[147]", "output": "false" }, { "input": "[576]", "output": "false" }, { "input": "[789]", "output": "false" }, { "input": "[579]", "output": "false" }, { "input": "[273]", "output": "true" }, ...
60
false
60
verified
10
10
1
2,600
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.IsFascinating.Code.Funs /-! # Specifications of `Aegis.IsFascinating.is_fascinating` LeetCode problem `check-if-the-number-is-fascinating`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.IsFascinating (is_fascinating) namespace AegisSpec.IsFasci...
7
find-the-longest-semi-repetitive-substring
2,730
Medium
[ "String", "Sliding Window" ]
You are given a digit string s that consists of digits from 0 to 9. A string is called semi-repetitive if there is at most one adjacent pair of the same digit. For example, "0010", "002020", "0123", "2002", and "54944" are semi-repetitive while the following are not: "00101022" (adjacent same digit pairs are 00 and 22)...
longestSemiRepetitiveSubstring(s: str) -> int
pub fn longest_semi_repetitive_substring(s: &[u8]) -> i64
Aegis.LongestSemiRepetitiveSubstring.longest_semi_repetitive_substring
pub fn longest_semi_repetitive_substring(s: &[u8]) -> i64 { let n = s.len(); let mut best: i64 = 0; let mut start: usize = 0; while start < n { let mut end: usize = start; let mut len: i64 = 0; let mut repeated_pairs: i64 = 0; while end < n { if end > start ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [longest_semi_repetitive_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 fals...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [longest_semi_repetitive_substring]: function definitions module public import Aeneas public import Aegis.LongestSemiRepetitiveSubstring.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_opti...
import Aegis.LongestSemiRepetitiveSubstring.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": "[\"1111\"]", "output": "2" }, { "input": "[\"9876543210\"]", "output": "10" }, { "input": "[\"111222333\"]", "output": "3" }, { "input": "[\"88888888888\"]", "output": "2" }, { "input": "[\"87878787878787878\"]", "output": "17" }, { "input"...
197
false
197
verified
10
10
1
2,002
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.LongestSemiRepetitiveSubstring.Code.Funs /-! # Specifications of `Aegis.LongestSemiRepetitiveSubstring.longest_semi_repetitive_substring` LeetCode problem `find-the-longest-semi-repetitive-substring`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespac...
14
neither-minimum-nor-maximum
2,733
Easy
[ "Array", "Sorting" ]
Given an integer array nums containing distinct positive integers, find and return any number from the array that is neither the minimum nor the maximum value in the array, or -1 if there is no such number. Return the selected integer.   Example 1: Input: nums = [3,2,1,4] Output: 2 Explanation: In this example, the mi...
findNonMinOrMax(nums: list_int) -> int
pub fn find_non_min_or_max(nums: &[i64]) -> i64
Aegis.FindNonMinOrMax.find_non_min_or_max
pub fn find_non_min_or_max(nums: &[i64]) -> i64 { let n = nums.len(); if n < 3 { return -1; } let mut min_val = nums[0]; let mut max_val = nums[0]; let mut i: usize = 1; while i < n { let x = nums[i]; if x < min_val { min_val = x; } if x ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [find_non_min_or_max]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option l...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [find_non_min_or_max]: function definitions module public import Aeneas public import Aegis.FindNonMinOrMax.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.FindNonMinOrMax.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval aegis...
[ { "input": "[[1]]", "output": "-1" }, { "input": "[[7]]", "output": "-1" }, { "input": "[[42]]", "output": "-1" }, { "input": "[[100]]", "output": "-1" }, { "input": "[[1, 2]]", "output": "-1" }, { "input": "[[99, 100]]", "output": "-1" }, { ...
94
false
94
verified
10
10
1
581
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.FindNonMinOrMax.Code.Funs /-! # Specifications of `Aegis.FindNonMinOrMax.find_non_min_or_max` LeetCode problem `neither-minimum-nor-maximum`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.FindNonMinOrMax def lenBounds (nums : Slic...
11
collecting-chocolates
2,735
Medium
[ "Array", "Enumeration" ]
You are given a 0-indexed integer array nums of size n representing the cost of collecting different chocolates. The cost of collecting the chocolate at the index i is nums[i]. Each chocolate is of a different type, and initially, the chocolate at the index i is of ith type. In one operation, you can do the following w...
minCost(nums: list_int, x: int) -> int
pub fn min_cost(nums: &[i64], x: i64) -> i64
Aegis.MinCost.min_cost
pub fn min_cost(nums: &[i64], x: i64) -> i64 { let n = nums.len(); let mut cur: Vec<i64> = Vec::new(); let mut sum: i64 = 0; let mut i: usize = 0; while i < n { let v = nums[i]; cur.push(v); sum += v; i += 1; } let mut ans: i64 = sum; let mut k: usize ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [min_cost]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter.style...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [min_cost]: function definitions module public import Aeneas public import Aegis.MinCost.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.un...
import Aegis.MinCost.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval aegisCase "ev...
[ { "input": "[[1], 100]", "output": "1" }, { "input": "[[3, 1, 2], 3]", "output": "6" }, { "input": "[[100, 200, 300], 50]", "output": "400" }, { "input": "[[1, 2, 3], 4]", "output": "6" }, { "input": "[[1000000000, 1000000000, 1000000000], 1000000000]", "outpu...
100
false
100
verified
10
10
1
2,904
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MinCost.Code.Funs /-! # Specifications of `Aegis.MinCost.min_cost` LeetCode problem `collecting-chocolates`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result ControlFlow Error open Aegis.MinCost namespace AegisSpec.MinCost def costs (nums : Slice I64)...
14
maximum-sum-queries
2,736
Hard
[ "Stack", "Binary Indexed Tree", "Segment Tree", "Array", "Binary Search", "Sorting", "Monotonic Stack" ]
You are given two 0-indexed integer arrays nums1 and nums2, each of length n, and a 1-indexed 2D array queries where queries[i] = [xi, yi]. For the ith query, find the maximum value of nums1[j] + nums2[j] among all indices j (0 <= j < n), where nums1[j] >= xi and nums2[j] >= yi, or -1 if there is no j satisfying the co...
maximumSumQueries(nums1: list_int, nums2: list_int, queries: list_list_int) -> list_int
pub fn maximum_sum_queries(nums1: &[i64], nums2: &[i64], queries: &[Vec<i64>]) -> Vec<i64>
Aegis.MaximumSumQueries.maximum_sum_queries
fn sort_i64(mut a: Vec<i64>) -> Vec<i64> { let n = a.len(); if n <= 1 { return a; } let mut buf: Vec<i64> = Vec::new(); let mut i: usize = 0; while i < n { buf.push(0); i += 1; } let mut width: usize = 1; while width < n { let mut start: usize = 0; ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [maximum_sum_queries]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option l...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [maximum_sum_queries]: function definitions module public import Aeneas public import Aegis.MaximumSumQueries.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false...
import Aegis.MaximumSumQueries.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": "[[2, 1], [2, 3], [[3, 3]]]", "output": "[-1]" }, { "input": "[[1000000000, 1000000000, 1000000000], [1000000000, 1000000000, 1000000000], [[1000000000, 1000000000], [999999999, 999999999]]]", "output": "[2000000000, 2000000000]" }, { "input": "[[1000000000, 1000000000, 100000...
78
false
78
verified
10
10
1
13,046
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MaximumSumQueries.Code.Funs /-! # Specifications of `Aegis.MaximumSumQueries.maximum_sum_queries` LeetCode problem `maximum-sum-queries`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.MaximumSumQueries def entry (l : List Std.I64)...
5
find-the-closest-marked-node
2,737
Medium
[ "Graph", "Array", "Shortest Path", "Heap (Priority Queue)" ]
You are given a positive integer n which is the number of nodes of a 0-indexed directed weighted graph and a 0-indexed 2D array edges where edges[i] = [ui, vi, wi] indicates that there is an edge from node ui to node vi with weight wi. You are also given a node s and a node array marked; your task is to find the minimu...
minimumDistance(n: int, edges: list_list_int, s: int, marked: list_int) -> int
pub fn minimum_distance(n: i64, edges: &[Vec<i64>], s: i64, marked: &[i64]) -> i64
Aegis.MinimumDistance.minimum_distance
pub fn minimum_distance(n: i64, edges: &[Vec<i64>], s: i64, marked: &[i64]) -> i64 { let n_usize = n as usize; let inf: i64 = 1_000_000_000_000_000_000; let mut dist: Vec<i64> = Vec::new(); let mut visited: Vec<bool> = Vec::new(); let mut i = 0usize; while i < n_usize { dist.push(inf);...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [minimum_distance]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option lint...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [minimum_distance]: function definitions module public import Aeneas public import Aegis.MinimumDistance.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_...
import Aegis.MinimumDistance.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 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": "[3, [[0, 1, 2], [1, 2, 3]], 0, [2]]", "output": "5" }, { "input": "[3, [[0, 1, 10], [1, 2, 5], [2, 0, 15]], 1, [0]]", "output": "20" }, { "input": "[4, [[0, 1, 1], [1, 2, 3], [2, 3, 2]], 3, [0, 1]]", "output": "-1" }, { "input": "[3, [[0, 1, 1], [1, 2, 2], [2, 0, ...
74
false
74
verified
10
10
1
1,974
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MinimumDistance.Code.Funs /-! # Specifications of `Aegis.MinimumDistance.minimum_distance` LeetCode problem `find-the-closest-marked-node`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.MinimumDistance open Aegis.MinimumDistance ...
12
total-distance-traveled
2,739
Easy
[ "Math", "Simulation" ]
A truck has two fuel tanks. You are given two integers, mainTank representing the fuel present in the main tank in liters and additionalTank representing the fuel present in the additional tank in liters. The truck has a mileage of 10 km per liter. Whenever 5 liters of fuel get used up in the main tank, if the addition...
distanceTraveled(mainTank: int, additionalTank: int) -> int
pub fn distance_traveled(mainTank: i64, additionalTank: i64) -> i64
Aegis.DistanceTraveled.distance_traveled
pub fn distance_traveled(mainTank: i64, additionalTank: i64) -> i64 { let mut main_fuel: i64 = mainTank; let mut add_fuel: i64 = additionalTank; let mut consumed_in_cycle: i64 = 0; let mut distance: i64 = 0; while main_fuel > 0 { main_fuel = main_fuel - 1; consumed_in_cycle = consum...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [distance_traveled]: type definitions module public import Aeneas @[expose] public section 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 -- [distance_traveled]: function definitions module public import Aeneas public import Aegis.DistanceTraveled.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.DistanceTraveled.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval aegi...
[ { "input": "[10, 0]", "output": "100" }, { "input": "[100, 100]", "output": "1240" }, { "input": "[5, 10]", "output": "60" }, { "input": "[3, 0]", "output": "30" }, { "input": "[7, 3]", "output": "80" }, { "input": "[0, 5]", "output": "0" }, { ...
79
false
79
verified
10
10
1
1,641
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.DistanceTraveled.Code.Funs /-! # Specifications of `Aegis.DistanceTraveled.distance_traveled` LeetCode problem `total-distance-traveled`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.DistanceTraveled namespace AegisSpec.DistanceTraveled ...
12
find-the-value-of-the-partition
2,740
Medium
[ "Array", "Sorting" ]
You are given a positive integer array nums. Partition nums into two arrays, nums1 and nums2, such that: Each element of the array nums belongs to either the array nums1 or the array nums2. Both arrays are non-empty. The value of the partition is minimized. The value of the partition is |max(nums1) - min(nums2)|. Her...
findValueOfPartition(nums: list_int) -> int
pub fn find_value_of_partition(nums: &[i64]) -> i64
Aegis.FindValueOfPartition.find_value_of_partition
pub fn find_value_of_partition(nums: &[i64]) -> i64 { let n = nums.len(); if n < 2 { return 0; } let mut v: Vec<i64> = Vec::new(); let mut i: usize = 0; while i < n { v.push(nums[i]); i += 1; } let mut width: usize = 1; while width < n { let mut merg...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [find_value_of_partition]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_opti...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [find_value_of_partition]: function definitions module public import Aeneas public import Aegis.FindValueOfPartition.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashComman...
import Aegis.FindValueOfPartition.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, 1000000000]]", "output": "999999999" }, { "input": "[[100, 1, 10]]", "output": "9" }, { "input": "[[4, 2, 1, 3]]", "output": "1" }, { "input": "[[2, 3, 1, 2]]", "output": "0" }, { "input": "[[2, 2, 2, 2]]", "output": "0" }, { "input": ...
106
false
106
verified
10
10
1
2,384
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.FindValueOfPartition.Code.Funs /-! # Specifications of `Aegis.FindValueOfPartition.find_value_of_partition` LeetCode problem `find-the-value-of-the-partition`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.FindValueOfPartition ope...
14
special-permutations
2,741
Medium
[ "Bit Manipulation", "Array", "Dynamic Programming", "Bitmask" ]
You are given a 0-indexed integer array nums containing n distinct positive integers. A permutation of nums is called special if: For all indexes 0 <= i < n - 1, either nums[i] % nums[i+1] == 0 or nums[i+1] % nums[i] == 0. Return the total number of special permutations. As the answer could be large, return it modulo...
specialPerm(nums: list_int) -> int
pub fn special_perm(nums: &[i64]) -> i64
Aegis.SpecialPerm.special_perm
pub fn special_perm(nums: &[i64]) -> i64 { let n = nums.len(); let total: usize = 1usize << n; let modv: i64 = 1000000007; let mut dp: Vec<i64> = Vec::new(); let mut i: usize = 0; while i < total * n { dp.push(0); i += 1; } let mut start: usize = 0; while start < n ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [special_perm]: type definitions module public import Aeneas @[expose] public section 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 -- [special_perm]: function definitions module public import Aeneas public import Aegis.SpecialPerm.Code.Types public import Aegis.SpecialPerm.Code.FunsExternal @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace fals...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [special_perm]: external functions. -- This is a template file: rename it to "FunsExternal.lean" and fill the holes. module public import Aeneas public import Aegis.SpecialPerm.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_o...
import Aegis.SpecialPerm.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, 3, 6]]", "output": "2" }, { "input": "[[1, 4, 3]]", "output": "2" }, { "input": "[[5, 10, 20, 40]]", "output": "24" }, { "input": "[[11, 22, 33, 44]]", "output": "4" }, { "input": "[[2, 4, 8, 16]]", "output": "24" }, { "input": "[[3, 5...
99
false
99
verified
10
10
1
1,569
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.SpecialPerm.Code.Funs /-! # Specifications of `Aegis.SpecialPerm.special_perm` LeetCode problem `special-permutations`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.SpecialPerm namespace AegisSpec.SpecialPerm noncomputable section def modulu...
14
painting-the-walls
2,742
Hard
[ "Array", "Dynamic Programming" ]
You are given two 0-indexed integer arrays, cost and time, of size n representing the costs and the time taken to paint n different walls respectively. There are two painters available: A paid painter that paints the ith wall in time[i] units of time and takes cost[i] units of money. A free painter that paints any wal...
paintWalls(cost: list_int, time: list_int) -> int
pub fn paint_walls(cost: &[i64], time: &[i64]) -> i64
Aegis.PaintWalls.paint_walls
pub fn paint_walls(cost: &[i64], time: &[i64]) -> i64 { let n = cost.len(); let inf: i64 = 1000000000000000000; let mut dp: Vec<i64> = Vec::new(); let mut i: usize = 0; while i <= n { dp.push(inf); i += 1; } dp[0] = 0; let mut idx: usize = 0; while idx < n { ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [paint_walls]: type definitions module public import Aeneas @[expose] public section 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 -- [paint_walls]: function definitions module public import Aeneas public import Aegis.PaintWalls.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.PaintWalls.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval aegisCase ...
[ { "input": "[[100, 200, 300], [1, 2, 3]]", "output": "200" }, { "input": "[[1000000, 500000, 750000], [500, 250, 375]]", "output": "500000" }, { "input": "[[10, 15, 10], [3, 4, 2]]", "output": "10" }, { "input": "[[3, 2, 1], [1, 2, 3]]", "output": "1" }, { "input"...
93
false
93
verified
10
10
1
4,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.PaintWalls.Code.Funs /-! # Specifications of `Aegis.PaintWalls.paint_walls` LeetCode problem `painting-the-walls`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.PaintWalls namespace AegisSpec.PaintWalls def entryAt (l : List I64) (i : Nat) : I...
14
count-substrings-without-repeating-character
2,743
Medium
[ "Hash Table", "String", "Sliding Window" ]
You are given a string s consisting only of lowercase English letters. We call a substring special if it contains no character which has occurred at least twice (in other words, it does not contain a repeating character). Your task is to count the number of special substrings. For example, in the string "pop", the subs...
numberOfSpecialSubstrings(s: str) -> int
pub fn number_of_special_substrings(s: &[u8]) -> i64
Aegis.NumberOfSpecialSubstrings.number_of_special_substrings
pub fn number_of_special_substrings(s: &[u8]) -> i64 { let mut last: Vec<i64> = Vec::new(); let mut k: usize = 0; while k < 26 { last.push(-1); k += 1; } let n: usize = s.len(); let mut left: i64 = 0; let mut total: i64 = 0; let mut r: usize = 0; while r < n { ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [number_of_special_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...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [number_of_special_substrings]: function definitions module public import Aeneas public import Aegis.NumberOfSpecialSubstrings.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter....
import Aegis.NumberOfSpecialSubstrings.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": "9" }, { "input": "[\"abcdefghijklmnopqrstuvwxyz\"]", "output": "351" }, { "input": "[\"abacbacbacbacbacbacbacbacbacbacbacbacbacbacbacbacbacbacbacbacbacbacb\"]", "output": "200" }, { "input": "[\"pp\"]", "output": "2" }, { "...
133
false
133
verified
10
10
1
1,145
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.NumberOfSpecialSubstrings.Code.Funs /-! # Specifications of `Aegis.NumberOfSpecialSubstrings.number_of_special_substrings` LeetCode problem `count-substrings-without-repeating-character`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.NumberOfS...
14
construct-the-longest-new-string
2,745
Medium
[ "Greedy", "Brainteaser", "Math", "Dynamic Programming" ]
You are given three integers x, y, and z. You have x strings equal to "AA", y strings equal to "BB", and z strings equal to "AB". You want to choose some (possibly all or none) of these strings and concatenate them in some order to form a new string. This new string must not contain "AAA" or "BBB" as a substring. Retur...
longestString(x: int, y: int, z: int) -> int
pub fn longest_string(x: i64, y: i64, z: i64) -> i64
Aegis.LongestString.longest_string
pub fn longest_string(x: i64, y: i64, z: i64) -> i64 { let mut m = x; if y < m { m = y; } let mut extra = 1; if x == y { extra = 0; } 2 * (z + 2 * m + extra) }
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [longest_string]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [longest_string]: function definitions module public import Aeneas public import Aegis.LongestString.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.LongestString.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, 10, 10]", "output": "26" }, { "input": "[50, 50, 50]", "output": "300" }, { "input": "[10, 1, 10]", "output": "26" }, { "input": "[20, 10, 5]", "output": "52" }, { "input": "[10, 10, 100]", "output": "240" }, { "input": "[10, 10, 1]", ...
88
false
88
verified
10
10
1
1,254
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.LongestString.Code.Funs /-! # Specifications of `Aegis.LongestString.longest_string` LeetCode problem `construct-the-longest-new-string`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.LongestString inductive Block where | AA | BB ...
9
decremental-string-concatenation
2,746
Medium
[ "Array", "String", "Dynamic Programming" ]
You are given a 0-indexed array words containing n strings. Let's define a join operation join(x, y) between two strings x and y as concatenating them into xy. However, if the last character of x is equal to the first character of y, one of them is deleted. For example join("ab", "ba") = "aba" and join("ab", "cde") = "...
minimizeConcatenatedLength(words: list_str) -> int
pub fn minimize_concatenated_length(words: &[Vec<u8>]) -> i64
Aegis.MinimizeConcatenatedLength.minimize_concatenated_length
pub fn minimize_concatenated_length(words: &[Vec<u8>]) -> i64 { let n = words.len(); if n == 0 { return 0; } let inf: i64 = 1_000_000_000_000_000_000; let mut dp: Vec<i64> = Vec::new(); let mut z: usize = 0; while z < 676 { dp.push(inf); z += 1; } let first...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [minimize_concatenated_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...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [minimize_concatenated_length]: function definitions module public import Aeneas public import Aegis.MinimizeConcatenatedLength.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter...
import Aegis.MinimizeConcatenatedLength.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": "[[\"ab\", \"b\"]]", "output": "2" }, { "input": "[[\"xyz\", \"zyx\", \"xyz\"]]", "output": "7" }, { "input": "[[\"hello\", \"ollie\", \"elephant\"]]", "output": "16" }, { "input": "[[\"abc\", \"bcd\", \"cde\"]]", "output": "8" }, { "input": "[[\"xyz\",...
85
false
85
verified
10
10
1
3,648
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MinimizeConcatenatedLength.Code.Funs /-! # Specifications of `Aegis.MinimizeConcatenatedLength.minimize_concatenated_length` LeetCode problem `decremental-string-concatenation`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.MinimizeConcatenate...
11
count-zero-request-servers
2,747
Medium
[ "Array", "Hash Table", "Sorting", "Sliding Window" ]
You are given an integer n denoting the total number of servers and a 2D 0-indexed integer array logs, where logs[i] = [server_id, time] denotes that the server with id server_id received a request at time time. You are also given an integer x and a 0-indexed integer array queries. Return a 0-indexed integer array arr ...
countServers(n: int, logs: list_list_int, x: int, queries: list_int) -> list_int
pub fn count_servers(n: i64, logs: &[Vec<i64>], x: i64, queries: &[i64]) -> Vec<i64>
Aegis.CountServers.count_servers
pub fn count_servers(n: i64, logs: &[Vec<i64>], x: i64, queries: &[i64]) -> Vec<i64> { let base = n + 1; let m = logs.len(); let mut log_keys: Vec<i64> = Vec::new(); let mut i: usize = 0; while i < m { let server = logs[i][0]; let time = logs[i][1]; log_keys.push(time * base...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [count_servers]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter....
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [count_servers]: function definitions module public import Aeneas public import Aegis.CountServers.Code.Types public import Aegis.CountServers.Code.FunsExternal @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace f...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [count_servers]: external functions. -- This is a template file: rename it to "FunsExternal.lean" and fill the holes. module public import Aeneas public import Aegis.CountServers.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set...
import Aegis.CountServers.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval aegisCas...
[ { "input": "[1, [[1, 1]], 1, [2]]", "output": "[0]" }, { "input": "[3, [[1, 3], [2, 6], [1, 5]], 5, [10, 11]]", "output": "[1, 2]" }, { "input": "[2, [[1, 1], [1, 2], [2, 3]], 2, [4, 5]]", "output": "[0, 1]" }, { "input": "[3, [[2, 4], [2, 1], [1, 2], [3, 1]], 2, [3, 4]]", ...
92
false
92
verified
10
10
1
4,535
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.CountServers.Code.Funs /-! # Specifications of `Aegis.CountServers.count_servers` LeetCode problem `count-zero-request-servers`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.CountServers noncomputable section def Hit (logs : Slice (...
14
number-of-beautiful-pairs
2,748
Easy
[ "Array", "Hash Table", "Math", "Counting", "Number Theory" ]
You are given a 0-indexed integer array nums. A pair of indices i, j where 0 <= i < j < nums.length is called beautiful if the first digit of nums[i] and the last digit of nums[j] are coprime. Return the total number of beautiful pairs in nums. Two integers x and y are coprime if there is no integer greater than 1 that...
countBeautifulPairs(nums: list_int) -> int
pub fn count_beautiful_pairs(nums: &[i64]) -> i64
Aegis.CountBeautifulPairs.count_beautiful_pairs
fn gcd(mut a: i64, mut b: i64) -> i64 { while b != 0 { let t = a % b; a = b; b = t; } a } fn first_digit(mut x: i64) -> i64 { while x >= 10 { x = x / 10; } x } pub fn count_beautiful_pairs(nums: &[i64]) -> i64 { let n = nums.len(); let mut ans: i64 = 0; ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [count_beautiful_pairs]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [count_beautiful_pairs]: function definitions module public import Aeneas public import Aegis.CountBeautifulPairs.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand f...
import Aegis.CountBeautifulPairs.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": "[[11, 21, 12]]", "output": "2" }, { "input": "[[100, 200, 300, 400]]", "output": "3" }, { "input": "[[33, 14, 25, 78]]", "output": "5" }, { "input": "[[13, 31, 17, 71]]", "output": "6" }, { "input": "[[78, 89, 90, 12]]", "output": "3" }, { ...
102
false
102
verified
10
10
1
2,110
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.CountBeautifulPairs.Code.Funs /-! # Specifications of `Aegis.CountBeautifulPairs.count_beautiful_pairs` LeetCode problem `number-of-beautiful-pairs`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.CountBeautifulPairs abbrev SliceI6...
12
minimum-operations-to-make-the-integer-zero
2,749
Medium
[ "Bit Manipulation", "Brainteaser", "Enumeration" ]
You are given two integers num1 and num2. In one operation, you can choose integer i in the range [0, 60] and subtract 2i + num2 from num1. Return the integer denoting the minimum number of operations needed to make num1 equal to 0. If it is impossible to make num1 equal to 0, return -1.   Example 1: Input: num1 = 3, ...
makeTheIntegerZero(num1: int, num2: int) -> int
pub fn make_the_integer_zero(num1: i64, num2: i64) -> i64
Aegis.MakeTheIntegerZero.make_the_integer_zero
pub fn make_the_integer_zero(num1: i64, num2: i64) -> i64 { let mut k: i64 = 1; while k <= 60 { let x = num1 - k * num2; if x >= k { let mut y = x; let mut bits: i64 = 0; while y > 0 { bits = bits + y % 2; y = y / 2; ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [make_the_integer_zero]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [make_the_integer_zero]: function definitions module public import Aeneas public import Aegis.MakeTheIntegerZero.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand fa...
import Aegis.MakeTheIntegerZero.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval ae...
[ { "input": "[8, 2]", "output": "2" }, { "input": "[8, -1]", "output": "2" }, { "input": "[7, -3]", "output": "3" }, { "input": "[1, 0]", "output": "1" }, { "input": "[15, -3]", "output": "3" }, { "input": "[10, -3]", "output": "2" }, { "inp...
122
false
122
verified
10
10
1
4,023
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MakeTheIntegerZero.Code.Funs /-! # Specifications of `Aegis.MakeTheIntegerZero.make_the_integer_zero` LeetCode problem `minimum-operations-to-make-the-integer-zero`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.MakeTheIntegerZero def...
14
ways-to-split-array-into-good-subarrays
2,750
Medium
[ "Array", "Math", "Dynamic Programming" ]
You are given a binary array nums. A subarray of an array is good if it contains exactly one element with the value 1. Return an integer denoting the number of ways to split the array nums into good subarrays. As the number may be too large, return it modulo 109 + 7. A subarray is a contiguous non-empty sequence of ele...
numberOfGoodSubarraySplits(nums: list_int) -> int
pub fn number_of_good_subarray_splits(nums: &[i64]) -> i64
Aegis.NumberOfGoodSubarraySplits.number_of_good_subarray_splits
pub fn number_of_good_subarray_splits(nums: &[i64]) -> i64 { let n = nums.len(); let modulus: i64 = 1000000007; // First pass: collect the positions of the 1s. let mut positions: Vec<i64> = Vec::new(); let mut i: usize = 0; while i < n { if nums[i] == 1 { positions.push(i as...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [number_of_good_subarray_splits]: type definitions module public import Aeneas @[expose] 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 -- [number_of_good_subarray_splits]: function definitions module public import Aeneas public import Aegis.NumberOfGoodSubarraySplits.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option lint...
import Aegis.NumberOfGoodSubarraySplits.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": "0" }, { "input": "[[0, 1, 0]]", "output": "1" }, { "input": "[[1, 1, 1, 1]]", "output": "1" }, { "input": "[[0, 0, 0, 0]]", "output": "0" }, { "input": "[[0, 0, 0, 1]]", "output": ...
87
false
87
verified
10
10
2
5,382
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.NumberOfGoodSubarraySplits.Code.Funs /-! # Specifications of `Aegis.NumberOfGoodSubarraySplits.number_of_good_subarray_splits` LeetCode problem `ways-to-split-array-into-good-subarrays`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.Nu...
8
robot-collisions
2,751
Hard
[ "Stack", "Array", "Sorting", "Simulation" ]
There are n 1-indexed robots, each having a position on a line, health, and movement direction. You are given 0-indexed integer arrays positions, healths, and a string directions (directions[i] is either 'L' for left or 'R' for right). All integers in positions are unique. All robots start moving on the line simultaneo...
survivedRobotsHealths(positions: list_int, healths: list_int, directions: str) -> list_int
pub fn survived_robots_healths(positions: &[i64], healths: &[i64], directions: &[u8]) -> Vec<i64>
Aegis.SurvivedRobotsHealths.survived_robots_healths
pub fn survived_robots_healths(positions: &[i64], healths: &[i64], directions: &[u8]) -> Vec<i64> { let n = positions.len(); if n == 0 { return Vec::new(); } let m = n as i64 + 1; // Encode each robot as position * m + original_index. // Since original_index < m and positions are disti...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [survived_robots_healths]: type definitions module public import Aeneas @[expose] public 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 -- [survived_robots_healths]: function definitions module public import Aeneas public import Aegis.SurvivedRobotsHealths.Code.Types public import Aegis.SurvivedRobotsHealths.Code.FunsExternal @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [survived_robots_healths]: external functions. -- This is a template file: rename it to "FunsExternal.lean" and fill the holes. module public import Aeneas public import Aegis.SurvivedRobotsHealths.Code.Types @[expose] public section open Aeneas Aeneas.Std Result Co...
import Aegis.SurvivedRobotsHealths.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval...
[ { "input": "[[100, 200, 300], [10, 20, 30], \"LRL\"]", "output": "[10, 29]" }, { "input": "[[1, 3, 5, 7], [5, 5, 5, 5], \"RLRL\"]", "output": "[]" }, { "input": "[[1, 2, 5, 6], [10, 10, 11, 11], \"RLRL\"]", "output": "[]" }, { "input": "[[1, 2, 5, 6], [10, 10, 11, 11], \"RLRL...
138
false
138
verified
10
10
1
8,584
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.SurvivedRobotsHealths.Code.Funs /-! # Specifications of `Aegis.SurvivedRobotsHealths.survived_robots_healths` LeetCode problem `robot-collisions`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.SurvivedRobotsHealths open Aegis.Survived...
8
longest-even-odd-subarray-with-threshold
2,760
Easy
[ "Array", "Sliding Window" ]
You are given a 0-indexed integer array nums and an integer threshold. Find the length of the longest subarray of nums starting at index l and ending at index r (0 <= l <= r < nums.length) that satisfies the following conditions: nums[l] % 2 == 0 For all indices i in the range [l, r - 1], nums[i] % 2 != nums[i + 1] % ...
longestAlternatingSubarray(nums: list_int, threshold: int) -> int
pub fn longest_alternating_subarray(nums: &[i64], threshold: i64) -> i64
Aegis.LongestAlternatingSubarray.longest_alternating_subarray
pub fn longest_alternating_subarray(nums: &[i64], threshold: i64) -> i64 { let n = nums.len(); let mut best: i64 = 0; let mut l: usize = 0; while l < n { if nums[l] <= threshold && nums[l] % 2 == 0 { let mut r: usize = l + 1; let mut good: bool = true; while...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [longest_alternating_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...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [longest_alternating_subarray]: function definitions module public import Aeneas public import Aegis.LongestAlternatingSubarray.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter...
import Aegis.LongestAlternatingSubarray.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], 1]", "output": "0" }, { "input": "[[1, 2], 2]", "output": "1" }, { "input": "[[2, 3, 4, 5], 4]", "output": "3" }, { "input": "[[3, 2, 5, 4], 5]", "output": "3" }, { "input": "[[50, 51, 50, 51, 50], 51]", "output": "5" }, { "input": "[...
124
false
124
verified
10
10
1
1,685
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.LongestAlternatingSubarray.Code.Funs /-! # Specifications of `Aegis.LongestAlternatingSubarray.longest_alternating_subarray` LeetCode problem `longest-even-odd-subarray-with-threshold`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.LongestAlte...
13
prime-pairs-with-target-sum
2,761
Medium
[ "Array", "Math", "Enumeration", "Number Theory" ]
You are given an integer n. We say that two integers x and y form a prime number pair if: 1 <= x <= y <= n x + y == n x and y are prime numbers Return the 2D sorted list of prime number pairs [xi, yi]. The list should be sorted in increasing order of xi. If there are no prime number pairs at all, return an empty arra...
findPrimePairs(n: int) -> list_list_int
pub fn find_prime_pairs(n: i64) -> Vec<Vec<i64>>
Aegis.FindPrimePairs.find_prime_pairs
// Only exists during `cargo test`; invisible to a normal build (and to Charon/Aeneas). // It resolves the `vec![]`-element inference ambiguity in the test harness by // pinning the empty-vector type to `Vec<Vec<i64>>` (the function's return type). #[cfg(test)] macro_rules! vec { () => { ::std::vec::Vec::<V...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [find_prime_pairs]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option lint...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [find_prime_pairs]: function definitions module public import Aeneas public import Aegis.FindPrimePairs.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.FindPrimePairs.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": "[11]", "output": "[]" }, { "input": "[2]", "output": "[]" }, { "input": "[3]", "output": "[]" }, { "input": "[29]", "output": "[]" }, { "input": "[56789]", "output": "[]" }, { "input": "[1009]", "output": "[]" }, { "input": "[37...
49
false
49
verified_partial
10
4
3
74,701
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.FindPrimePairs.Code.Funs /-! # Specifications of `Aegis.FindPrimePairs.find_prime_pairs` LeetCode problem `prime-pairs-with-target-sum`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.FindPrimePairs namespace AegisSpec.FindPrimePairs def ...
15
continuous-subarrays
2,762
Medium
[ "Queue", "Array", "Ordered Set", "Sliding Window", "Monotonic Queue", "Heap (Priority Queue)" ]
You are given a 0-indexed integer array nums. A subarray of nums is called continuous if: Let i, i + 1, ..., j be the indices in the subarray. Then, for each pair of indices i <= i1, i2 <= j, 0 <= |nums[i1] - nums[i2]| <= 2. Return the total number of continuous subarrays. A subarray is a contiguous non-empty sequenc...
continuousSubarrays(nums: list_int) -> int
pub fn continuous_subarrays(nums: &[i64]) -> i64
Aegis.ContinuousSubarrays.continuous_subarrays
pub fn continuous_subarrays(nums: &[i64]) -> i64 { let n = nums.len(); if n == 0 { return 0; } let mut minq: Vec<i64> = Vec::new(); let mut maxq: Vec<i64> = Vec::new(); let mut i: usize = 0; while i < n { minq.push(0); maxq.push(0); i += 1; } let mu...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [continuous_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 ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [continuous_subarrays]: function definitions module public import Aeneas public import Aegis.ContinuousSubarrays.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand fa...
import Aegis.ContinuousSubarrays.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": "[[1000000000]]", "output": "1" }, { "input": "[[1, 1000000000]]", "output": "2" }, { "input": "[[3, 1]]", "output": "3" }, { "input": "[[1, 3]]", "output": "3" }, { "input": "[[1, 2]]", "output": "3"...
234
false
234
verified
10
10
1
7,477
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.ContinuousSubarrays.Code.Funs /-! # Specifications of `Aegis.ContinuousSubarrays.continuous_subarrays` LeetCode problem `continuous-subarrays`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.ContinuousSubarrays set_option autoImplicit false n...
12
sum-of-imbalance-numbers-of-all-subarrays
2,763
Hard
[ "Array", "Hash Table", "Ordered Set" ]
The imbalance number of a 0-indexed integer array arr of length n is defined as the number of indices in sarr = sorted(arr) such that: 0 <= i < n - 1, and sarr[i+1] - sarr[i] > 1 Here, sorted(arr) is the function that returns the sorted version of arr. Given a 0-indexed integer array nums, return the sum of imbalance...
sumImbalanceNumbers(nums: list_int) -> int
pub fn sum_imbalance_numbers(nums: &[i64]) -> i64
Aegis.SumImbalanceNumbers.sum_imbalance_numbers
fn binary_find(vals: &[i64], target: i64) -> i64 { let mut lo: usize = 0; let mut hi: usize = vals.len(); let mut res: i64 = -1; let mut searching: bool = true; while lo < hi && searching { let mid: usize = (lo + hi) / 2; if vals[mid] == target { res = mid as i64; ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [sum_imbalance_numbers]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [sum_imbalance_numbers]: function definitions module public import Aeneas public import Aegis.SumImbalanceNumbers.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand f...
import Aegis.SumImbalanceNumbers.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": "0" }, { "input": "[[2]]", "output": "0" }, { "input": "[[7]]", "output": "0" }, { "input": "[[2, 1]]", "output": "0" }, { "input": "[[1, 1000]]", "output": "1" }, { "input": "[[2, 1]]", "output": "0" }, { "inp...
181
false
181
verified
10
10
1
7,688
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.SumImbalanceNumbers.Code.Funs /-! # Specifications of `Aegis.SumImbalanceNumbers.sum_imbalance_numbers` LeetCode problem `sum-of-imbalance-numbers-of-all-subarrays`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.SumImbalanceNumbers ...
11
longest-alternating-subarray
2,765
Easy
[ "Array", "Enumeration" ]
You are given a 0-indexed integer array nums. A subarray s of length m is called alternating if: m is greater than 1. s1 = s0 + 1. The 0-indexed subarray s looks like [s0, s1, s0, s1,...,s(m-1) % 2]. In other words, s1 - s0 = 1, s2 - s1 = -1, s3 - s2 = 1, s4 - s3 = -1, and so on up to s[m - 1] - s[m - 2] = (-1)m. Ret...
alternatingSubarray(nums: list_int) -> int
pub fn alternating_subarray(nums: &[i64]) -> i64
Aegis.AlternatingSubarray.alternating_subarray
pub fn alternating_subarray(nums: &[i64]) -> i64 { let n = nums.len(); let mut best: i64 = -1; if n < 2 { return -1; } let mut i: usize = 0; while i + 1 < n { if nums[i + 1] == nums[i] + 1 { let mut length: i64 = 2; let mut expected: i64 = -1; ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [alternating_subarray]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [alternating_subarray]: function definitions module public import Aeneas public import Aegis.AlternatingSubarray.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand fa...
import Aegis.AlternatingSubarray.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": "[[4, 5, 6]]", "output": "2" }, { "input": "[[2, 3, 4, 3, 4]]", "output": "4" }, { "input": "[[5, 4, 5, 4, 5]]", "output": "4" }, { "input": "[[2, 1, 2, 1, 2]]", "output": "4" }, { "input": "[[10, 9, 10, 9, 10]]", "output": "4" }, { "input":...
157
false
157
verified
10
10
1
1,311
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.AlternatingSubarray.Code.Funs /-! # Specifications of `Aegis.AlternatingSubarray.alternating_subarray` LeetCode problem `longest-alternating-subarray`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.AlternatingSubarray def len (nums : ...
10
relocate-marbles
2,766
Medium
[ "Array", "Hash Table", "Sorting", "Simulation" ]
You are given a 0-indexed integer array nums representing the initial positions of some marbles. You are also given two 0-indexed integer arrays moveFrom and moveTo of equal length. Throughout moveFrom.length steps, you will change the positions of the marbles. On the ith step, you will move all marbles at position mov...
relocateMarbles(nums: list_int, moveFrom: list_int, moveTo: list_int) -> list_int
pub fn relocate_marbles(nums: &[i64], moveFrom: &[i64], moveTo: &[i64]) -> Vec<i64>
Aegis.RelocateMarbles.relocate_marbles
pub fn relocate_marbles(nums: &[i64], moveFrom: &[i64], moveTo: &[i64]) -> Vec<i64> { let mut coords: Vec<i64> = Vec::new(); let mut i = 0; while i < nums.len() { coords.push(nums[i]); i += 1; } i = 0; while i < moveTo.len() { coords.push(moveTo[i]); i += 1; ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [relocate_marbles]: type definitions module public import Aeneas @[expose] public section 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 -- [relocate_marbles]: function definitions module public import Aeneas public import Aegis.RelocateMarbles.Code.Types public import Aegis.RelocateMarbles.Code.FunsExternal @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNa...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [relocate_marbles]: external functions. -- This is a template file: rename it to "FunsExternal.lean" and fill the holes. module public import Aeneas public import Aegis.RelocateMarbles.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Err...
import Aegis.RelocateMarbles.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": "[[1000000000, 1000000000, 1000000000], [1000000000], [999999999]]", "output": "[999999999]" }, { "input": "[[5, 5, 5, 5], [5], [10]]", "output": "[10]" }, { "input": "[[5, 10, 15], [5, 10], [10, 15]]", "output": "[15]" }, { "input": "[[100, 200, 300], [100, 200], ...
97
false
97
verified
10
10
1
2,693
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.RelocateMarbles.Code.Funs /-! # Specifications of `Aegis.RelocateMarbles.relocate_marbles` LeetCode problem `relocate-marbles`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.RelocateMarbles open Aegis.RelocateMarbles def valsOf (l : ...
13
partition-string-into-minimum-beautiful-substrings
2,767
Medium
[ "Hash Table", "String", "Dynamic Programming", "Backtracking" ]
Given a binary string s, partition the string into one or more substrings such that each substring is beautiful. A string is beautiful if: It doesn't contain leading zeros. It's the binary representation of a number that is a power of 5. Return the minimum number of substrings in such partition. If it is impossible t...
minimumBeautifulSubstrings(s: str) -> int
pub fn minimum_beautiful_substrings(s: &[u8]) -> i64
Aegis.MinimumBeautifulSubstrings.minimum_beautiful_substrings
fn is_beautiful(s: &[u8], start: usize, end: usize) -> bool { if start >= end { return false; } if s[start] == b'0' { return false; } let mut val: i64 = 0; let mut k: usize = start; while k < end { val = val * 2; if s[k] == b'1' { val = val + 1; ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [minimum_beautiful_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...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [minimum_beautiful_substrings]: function definitions module public import Aeneas public import Aegis.MinimumBeautifulSubstrings.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter...
import Aegis.MinimumBeautifulSubstrings.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": "[\"1100101\"]", "output": "-1" }, { "input": "[\"100000000000000\"]", "output": "-1" }, { "input": "[\"101010101010101\"]", "output": "-1" }, { "input": "[\"101010101\"]", "output": "-1" }, { "input": "[\"111\"]", "output": "3" }, { "input"...
148
false
148
verified
10
10
1
1,834
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MinimumBeautifulSubstrings.Code.Funs /-! # Specifications of `Aegis.MinimumBeautifulSubstrings.minimum_beautiful_substrings` LeetCode problem `partition-string-into-minimum-beautiful-substrings`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace Aeg...
11
number-of-black-blocks
2,768
Medium
[ "Array", "Hash Table", "Enumeration" ]
You are given two integers m and n representing the dimensions of a 0-indexed m x n grid. You are also given a 0-indexed 2D integer matrix coordinates, where coordinates[i] = [x, y] indicates that the cell with coordinates [x, y] is colored black. All cells in the grid that do not appear in coordinates are white. A blo...
countBlackBlocks(m: int, n: int, coordinates: list_list_int) -> list_int
pub fn count_black_blocks(m: i64, n: i64, coordinates: &[Vec<i64>]) -> Vec<i64>
Aegis.CountBlackBlocks.count_black_blocks
pub fn count_black_blocks(m: i64, n: i64, coordinates: &[Vec<i64>]) -> Vec<i64> { let mut keys: Vec<i64> = Vec::new(); let coord_len = coordinates.len(); let mut pos: usize = 0; while pos < coord_len { let x = coordinates[pos][0]; let y = coordinates[pos][1]; let mut dx: i64 = ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [count_black_blocks]: type definitions module public import Aeneas @[expose] public section 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 -- [count_black_blocks]: function definitions module public import Aeneas public import Aegis.CountBlackBlocks.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.CountBlackBlocks.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval aegi...
[ { "input": "[2, 2, []]", "output": "[1, 0, 0, 0, 0]" }, { "input": "[3, 3, [[0, 0]]]", "output": "[3, 1, 0, 0, 0]" }, { "input": "[5, 5, [[2, 2], [3, 3], [1, 1]]]", "output": "[6, 8, 2, 0, 0]" }, { "input": "[3, 3, [[0, 0], [1, 1], [0, 2]]]", "output": "[0, 2, 2, 0, 0]" ...
72
false
72
verified
10
10
1
6,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.CountBlackBlocks.Code.Funs /-! # Specifications of `Aegis.CountBlackBlocks.count_black_blocks` LeetCode problem `number-of-black-blocks`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.CountBlackBlocks def coordPairs (coordinates : Sli...
14
find-the-maximum-achievable-number
2,769
Easy
[ "Math" ]
Given two integers, num and t. A number x is achievable if it can become equal to num after applying the following operation at most t times: Increase or decrease x by 1, and simultaneously increase or decrease num by 1. Return the maximum possible value of x.   Example 1: Input: num = 4, t = 1 Output: 6 Explanation...
theMaximumAchievableX(num: int, t: int) -> int
pub fn the_maximum_achievable_x(num: i64, t: i64) -> i64
Aegis.TheMaximumAchievableX.the_maximum_achievable_x
pub fn the_maximum_achievable_x(num: i64, t: i64) -> i64 { num + 2 * t }
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [the_maximum_achievable_x]: type definitions module public import Aeneas @[expose] public 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 -- [the_maximum_achievable_x]: function definitions module public import Aeneas public import Aegis.TheMaximumAchievableX.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashComm...
import Aegis.TheMaximumAchievableX.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, 50]", "output": "101" }, { "input": "[10, 5]", "output": "20" }, { "input": "[50, 50]", "output": "150" }, { "input": "[1, 1]", "output": "3" }, { "input": "[25, 25]", "output": "75" }, { "input": "[3, 2]", "output": "7" }, { ...
82
false
82
verified
10
10
1
103
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.TheMaximumAchievableX.Code.Funs /-! # Specifications of `Aegis.TheMaximumAchievableX.the_maximum_achievable_x` LeetCode problem `find-the-maximum-achievable-number`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.TheMaximumAchievableX...
10
maximum-number-of-jumps-to-reach-the-last-index
2,770
Medium
[ "Array", "Dynamic Programming" ]
You are given a 0-indexed array nums of n integers and an integer target. You are initially positioned at index 0. In one step, you can jump from index i to any index j such that: 0 <= i < j < n -target <= nums[j] - nums[i] <= target Return the maximum number of jumps you can make to reach index n - 1. If there is no...
maximumJumps(nums: list_int, target: int) -> int
pub fn maximum_jumps(nums: &[i64], target: i64) -> i64
Aegis.MaximumJumps.maximum_jumps
pub fn maximum_jumps(nums: &[i64], target: i64) -> i64 { let n = nums.len(); if n == 0 { return -1; } if n == 1 { return 0; } let mut dp: Vec<i64> = Vec::new(); let mut k: usize = 0; while k < n { dp.push(-1); k += 1; } dp[n - 1] = 0; let m...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [maximum_jumps]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter....
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [maximum_jumps]: function definitions module public import Aeneas public import Aegis.MaximumJumps.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.MaximumJumps.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": "[[1000000000, -1000000000, 1000000000, -1000000000], 2000000000]", "output": "3" }, { "input": "[[1, 5, 10, 15, 20], 4]", "output": "-1" }, { "input": "[[10, 8, 6, 4, 2], 2]", "output": "4" }, { "input": "[[0, 0, 0, 0, 0], 0]", "output": "4" }, { "inpu...
141
false
141
verified
10
10
1
935
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MaximumJumps.Code.Funs /-! # Specifications of `Aegis.MaximumJumps.maximum_jumps` LeetCode problem `maximum-number-of-jumps-to-reach-the-last-index`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.MaximumJumps open Aegis.MaximumJum...
17
longest-non-decreasing-subarray-from-two-arrays
2,771
Medium
[ "Array", "Dynamic Programming" ]
You are given two 0-indexed integer arrays nums1 and nums2 of length n. Let's define another 0-indexed integer array, nums3, of length n. For each index i in the range [0, n - 1], you can assign either nums1[i] or nums2[i] to nums3[i]. Your task is to maximize the length of the longest non-decreasing subarray in nums3 ...
maxNonDecreasingLength(nums1: list_int, nums2: list_int) -> int
pub fn max_non_decreasing_length(nums1: &[i64], nums2: &[i64]) -> i64
Aegis.MaxNonDecreasingLength.max_non_decreasing_length
pub fn max_non_decreasing_length(nums1: &[i64], nums2: &[i64]) -> i64 { let n: usize = nums1.len(); if n == 0 { return 0; } let mut dp1: i64 = 1; let mut dp2: i64 = 1; let mut ans: i64 = 1; let mut i: usize = 1; while i < n { let mut next1: i64 = 1; let mut next...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [max_non_decreasing_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_op...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [max_non_decreasing_length]: function definitions module public import Aeneas public import Aegis.MaxNonDecreasingLength.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCo...
import Aegis.MaxNonDecreasingLength.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]]", "output": "1" }, { "input": "[[1], [1]]", "output": "1" }, { "input": "[[1, 1], [2, 2]]", "output": "2" }, { "input": "[[2, 3, 1], [1, 2, 1]]", "output": "2" }, { "input": "[[1000000000, 1, 1000000000], [1, 1000000000, 1]]", "output": ...
125
false
125
verified
10
10
1
1,525
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MaxNonDecreasingLength.Code.Funs /-! # Specifications of `Aegis.MaxNonDecreasingLength.max_non_decreasing_length` LeetCode problem `longest-non-decreasing-subarray-from-two-arrays`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.MaxNonD...
10
apply-operations-to-make-all-array-elements-equal-to-zero
2,772
Medium
[ "Array", "Prefix Sum" ]
You are given a 0-indexed integer array nums and a positive integer k. You can apply the following operation on the array any number of times: Choose any subarray of size k from the array and decrease all its elements by 1. Return true if you can make all the array elements equal to 0, or false otherwise. A subarray ...
checkArray(nums: list_int, k: int) -> bool
pub fn check_array(nums: &[i64], k: i64) -> bool
Aegis.CheckArray.check_array
pub fn check_array(nums: &[i64], k: i64) -> bool { if k <= 0 { return false; } let n = nums.len(); let k_usize = k as usize; let mut diff: Vec<i64> = Vec::new(); let mut i = 0usize; while i <= n { diff.push(0); i += 1; } let mut current: i64 = 0; let mu...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [check_array]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter.st...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [check_array]: function definitions module public import Aeneas public import Aegis.CheckArray.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.CheckArray.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": "[[1000000, 1000000, 1000000], 3]", "output": "true" }, { "input": "[[0, 0, 0, 0], 2]", "output": "true" }, { "input": "[[1, 3, 1, 1], 2]", "output": "false" }, { "input": "[[1, 1, 1, 1], 1]", "output": "true" }, { "input": "[[5, 5, 5, 5, 5], 5]", "...
101
false
101
verified
10
10
1
3,637
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.CheckArray.Code.Funs /-! # Specifications of `Aegis.CheckArray.check_array` LeetCode problem `apply-operations-to-make-all-array-elements-equal-to-zero`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.CheckArray def isum (c : ℕ → ℤ) (l...
15
height-of-special-binary-tree
2,773
Medium
[ "Tree", "Depth-First Search", "Breadth-First Search", "Binary Tree" ]
You are given a root, which is the root of a special binary tree with n nodes. The nodes of the special binary tree are numbered from 1 to n. Suppose the tree has k leaves in the following order: b1 < b2 < ... < bk. The leaves of this tree have a special property! That is, for every leaf bi, the following conditions ho...
heightOfTree(root: tree) -> int
pub fn height_of_tree(root: &Tree) -> i64
Aegis.HeightOfTree.height_of_tree
pub fn height_of_tree(root: &Tree) -> i64 { tree_height(root) } fn tree_height(node: &Tree) -> i64 { match node { Tree::Null => -1, Tree::Node(_, left, right) => { let left_height = tree_height(left); let right_height = tree_height(right); if left_height > ri...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [height_of_tree]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [height_of_tree]: function definitions module public import Aeneas public import Aegis.HeightOfTree.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.HeightOfTree.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval aegisCas...
[ { "input": "[[1, 2]]", "output": "1" }, { "input": "[[1, 2, 3, 4, 5, 6, 7]]", "output": "2" }, { "input": "[[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]]", "output": "3" }, { "input": "[[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23,...
6
false
6
verified
6
6
1
10,418
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.HeightOfTree.Code.Funs /-! # Specifications of `Aegis.HeightOfTree.height_of_tree` LeetCode problem `height-of-special-binary-tree`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.HeightOfTree open Aegis.HeightOfTree def nodeCount : T...
11
sum-of-squares-of-special-elements
2,778
Easy
[ "Array", "Enumeration" ]
You are given a 1-indexed integer array nums of length n. An element nums[i] of nums is called special if i divides n, i.e. n % i == 0. Return the sum of the squares of all special elements of nums.   Example 1: Input: nums = [1,2,3,4] Output: 21 Explanation: There are exactly 3 special elements in nums: nums[1] since...
sumOfSquares(nums: list_int) -> int
pub fn sum_of_squares(nums: &[i64]) -> i64
Aegis.SumOfSquares.sum_of_squares
pub fn sum_of_squares(nums: &[i64]) -> i64 { let n = nums.len(); let mut total: i64 = 0; let mut i: usize = 1; while i <= n { if n % i == 0 { let x = nums[i - 1]; total += x * x; } i += 1; } total }
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [sum_of_squares]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [sum_of_squares]: function definitions module public import Aeneas public import Aegis.SumOfSquares.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.SumOfSquares.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]]", "output": "1" }, { "input": "[[30, 20, 10]]", "output": "1000" }, { "input": "[[1, 2, 3, 4]]", "output": "21" }, { "input": "[[5, 10, 15, 20, 25]]", "output": "650" }, { "input": "[[49, 25, 9, 4, 1]]", "output": "2402" }, { "input":...
105
false
105
verified
10
10
1
400
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.SumOfSquares.Code.Funs /-! # Specifications of `Aegis.SumOfSquares.sum_of_squares` LeetCode problem `sum-of-squares-of-special-elements`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.SumOfSquares def tau (n : Nat) : Nat := (Nat.d...
13
maximum-beauty-of-an-array-after-applying-operation
2,779
Medium
[ "Array", "Binary Search", "Sorting", "Sliding Window" ]
You are given a 0-indexed array nums and a non-negative integer k. In one operation, you can do the following: Choose an index i that hasn't been chosen before from the range [0, nums.length - 1]. Replace nums[i] with any integer from the range [nums[i] - k, nums[i] + k]. The beauty of the array is the length of the ...
maximumBeauty(nums: list_int, k: int) -> int
pub fn maximum_beauty(nums: &[i64], k: i64) -> i64
Aegis.MaximumBeauty.maximum_beauty
pub fn maximum_beauty(nums: &[i64], k: i64) -> i64 { let n = nums.len(); if n == 0 { return 0; } let mut a: Vec<i64> = Vec::new(); let mut i: usize = 0; while i < n { a.push(nums[i]); i += 1; } let mut b: Vec<i64> = Vec::new(); i = 0; while i < n { ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [maximum_beauty]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [maximum_beauty]: function definitions module public import Aeneas public import Aegis.MaximumBeauty.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_opti...
import Aegis.MaximumBeauty.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval aegisCa...
[ { "input": "[[1, 100000], 50000]", "output": "2" }, { "input": "[[100, 100, 100], 5]", "output": "3" }, { "input": "[[100000, 100000, 100000], 0]", "output": "3" }, { "input": "[[5, 15, 25, 35], 5]", "output": "2" }, { "input": "[[4, 6, 1, 2], 2]", "output": "...
119
false
119
verified
10
10
1
5,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.MaximumBeauty.Code.Funs /-! # Specifications of `Aegis.MaximumBeauty.maximum_beauty` LeetCode problem `maximum-beauty-of-an-array-after-applying-operation`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.MaximumBeauty def vals (num...
14
minimum-index-of-a-valid-split
2,780
Medium
[ "Array", "Hash Table", "Sorting" ]
An element x of an integer array arr of length m is dominant if more than half the elements of arr have a value of x. You are given a 0-indexed integer array nums of length n with one dominant element. You can split nums at an index i into two arrays nums[0, ..., i] and nums[i + 1, ..., n - 1], but the split is only va...
minimumIndex(nums: list_int) -> int
pub fn minimum_index(nums: &[i64]) -> i64
Aegis.MinimumIndex.minimum_index
pub fn minimum_index(nums: &[i64]) -> i64 { let n = nums.len(); if n == 0 { return -1; } // Find the dominant element using Boyer-Moore majority vote. let mut candidate = nums[0]; let mut balance: i64 = 0; let mut i: usize = 0; while i < n { if balance == 0 { ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [minimum_index]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter....
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [minimum_index]: function definitions module public import Aeneas public import Aegis.MinimumIndex.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.MinimumIndex.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval aegisCas...
[ { "input": "[[1, 2, 2, 2]]", "output": "2" }, { "input": "[[3, 3, 3, 3, 7, 2, 2]]", "output": "-1" }, { "input": "[[7, 7, 7, 7, 7, 7, 7]]", "output": "0" }, { "input": "[[1, 1, 2, 2, 1, 1, 1]]", "output": "0" }, { "input": "[[1, 1, 1, 1, 2, 2, 2, 3]]", "output...
12
false
12
verified
10
10
1
1,472
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MinimumIndex.Code.Funs /-! # Specifications of `Aegis.MinimumIndex.minimum_index` LeetCode problem `minimum-index-of-a-valid-split`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.MinimumIndex namespace AegisSpec.MinimumIndex def countVal (a : ...
13
length-of-the-longest-valid-substring
2,781
Hard
[ "Array", "Hash Table", "String", "Sliding Window" ]
You are given a string word and an array of strings forbidden. A string is called valid if none of its substrings are present in forbidden. Return the length of the longest valid substring of the string word. A substring is a contiguous sequence of characters in a string, possibly empty.   Example 1: Input: word = "cb...
longestValidSubstring(word: str, forbidden: list_str) -> int
pub fn longest_valid_substring(word: &[u8], forbidden: &[Vec<u8>]) -> i64
Aegis.LongestValidSubstring.longest_valid_substring
pub fn longest_valid_substring(word: &[u8], forbidden: &[Vec<u8>]) -> i64 { let mut head: Vec<i64> = Vec::new(); let mut edge_to: Vec<i64> = Vec::new(); let mut edge_next: Vec<i64> = Vec::new(); let mut edge_ch: Vec<u8> = Vec::new(); let mut terminal: Vec<i64> = Vec::new(); head.push(-1); t...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [longest_valid_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_opti...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [longest_valid_substring]: function definitions module public import Aeneas public import Aegis.LongestValidSubstring.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashComma...
import Aegis.LongestValidSubstring.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": "[\"zzzzzzzzzz\", [\"zz\"]]", "output": "1" }, { "input": "[\"abcde\", [\"fgh\"]]", "output": "5" }, { "input": "[\"aaaaaaa\", [\"aa\"]]", "output": "1" }, { "input": "[\"aaaabaaa\", [\"aa\"]]", "output": "3" }, { "input": "[\"abacab\", [\"ba\", \"ca\"]...
76
false
76
verified
10
10
1
19,256
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.LongestValidSubstring.Code.Funs /-! # Specifications of `Aegis.LongestValidSubstring.longest_valid_substring` LeetCode problem `length-of-the-longest-valid-substring`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.LongestValidSubstring...
13
check-if-array-is-good
2,784
Easy
[ "Array", "Hash Table", "Sorting" ]
You are given an integer array nums. We consider an array good if it is a permutation of an array base[n]. base[n] = [1, 2, ..., n - 1, n, n] (in other words, it is an array of length n + 1 which contains 1 to n - 1 exactly once, plus two occurrences of n). For example, base[1] = [1, 1] and base[3] = [1, 2, 3, 3]. Retu...
isGood(nums: list_int) -> bool
pub fn is_good(nums: &[i64]) -> bool
Aegis.IsGood.is_good
pub fn is_good(nums: &[i64]) -> bool { let len = nums.len(); // Find the maximum value. let mut n: i64 = 0; let mut i: usize = 0; while i < len { if nums[i] > n { n = nums[i]; } i += 1; } // Validate basic shape using flags (no early returns inside loops...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [is_good]: type definitions module public import Aeneas @[expose] public section 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_good]: function definitions module public import Aeneas public import Aegis.IsGood.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.IsGood.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": "[[1]]", "output": "false" }, { "input": "[[2, 2]]", "output": "false" }, { "input": "[[1, 1]]", "output": "true" }, { "input": "[[2, 1, 1]]", "output": "false" }, { "input": "[[2, 1, 2]]", "output": "true" }, { "input": "[[1, 2, 2]]", "...
119
false
119
verified
10
10
2
3,884
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.IsGood.Code.Funs /-! # Specifications of `Aegis.IsGood.is_good` LeetCode problem `check-if-array-is-good`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.IsGood def vals (nums : Slice I64) : List Int := nums.val.map (fun v => v.val...
10
visit-array-positions-to-maximize-score
2,786
Medium
[ "Array", "Dynamic Programming" ]
You are given a 0-indexed integer array nums and a positive integer x. You are initially at position 0 in the array and you can visit other positions according to the following rules: If you are currently in position i, then you can move to any position j such that i < j. For each position i that you visit, you get a ...
maxScore(nums: list_int, x: int) -> int
pub fn max_score(nums: &[i64], x: i64) -> i64
Aegis.MaxScore.max_score
fn max_i64(a: i64, b: i64) -> i64 { if a > b { a } else { b } } pub fn max_score(nums: &[i64], x: i64) -> i64 { let n = nums.len(); if n == 0 { return 0; } let neg_inf: i64 = -1_000_000_000_000_000_000; let mut dp_even: i64 = neg_inf; let mut dp_odd: i64 = ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [max_score]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter.styl...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [max_score]: function definitions module public import Aeneas public import Aegis.MaxScore.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter....
import Aegis.MaxScore.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 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": "[[2, 4, 6, 8], 3]", "output": "20" }, { "input": "[[1, 2, 3, 4, 5], 1]", "output": "11" }, { "input": "[[10, 13, 15, 17, 19], 10]", "output": "64" }, { "input": "[[10, 13, 14, 15, 19], 10]", "output": "48" }, { "input": "[[10, 15, 20, 25, 30], 10]", ...
109
false
109
verified
10
10
1
1,873
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": 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 `visit-array-positions-to-maximize-score`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.MaxScore open Aegis.MaxScore (max_score) def valAt (nums ...
15
ways-to-express-an-integer-as-sum-of-powers
2,787
Medium
[ "Dynamic Programming" ]
Given two positive integers n and x. Return the number of ways n can be expressed as the sum of the xth power of unique positive integers, in other words, the number of sets of unique integers [n1, n2, ..., nk] where n = n1x + n2x + ... + nkx. Since the result can be very large, return it modulo 109 + 7. For example, i...
numberOfWays(n: int, x: int) -> int
pub fn number_of_ways(n: i64, x: i64) -> i64
Aegis.NumberOfWays.number_of_ways
pub fn number_of_ways(n: i64, x: i64) -> i64 { let nn = n as usize; let mut dp: Vec<i64> = Vec::new(); let mut i: usize = 0; while i <= nn { dp.push(0); i += 1; } dp[0] = 1; let md: i64 = 1000000007; let mut base: i64 = 1; while base <= n { let mut p: i64 =...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [number_of_ways]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [number_of_ways]: function definitions module public import Aeneas public import Aegis.NumberOfWays.Code.Types public import Aegis.NumberOfWays.Code.FunsExternal @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [number_of_ways]: external functions. -- This is a template file: rename it to "FunsExternal.lean" and fill the holes. module public import Aeneas public import Aegis.NumberOfWays.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error se...
import Aegis.NumberOfWays.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval aegisCas...
[ { "input": "[100, 4]", "output": "0" }, { "input": "[50, 2]", "output": "3" }, { "input": "[200, 2]", "output": "9" }, { "input": "[300, 5]", "output": "0" }, { "input": "[160, 3]", "output": "1" }, { "input": "[4, 1]", "output": "2" }, { "...
96
false
96
verified
10
10
1
2,203
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.NumberOfWays.Code.Funs /-! # Specifications of `Aegis.NumberOfWays.number_of_ways` LeetCode problem `ways-to-express-an-integer-as-sum-of-powers`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.NumberOfWays namespace AegisSpec.NumberOfWays def...
11
largest-element-in-an-array-after-merge-operations
2,789
Medium
[ "Greedy", "Array" ]
You are given a 0-indexed array nums consisting of positive integers. You can do the following operation on the array any number of times: Choose an integer i such that 0 <= i < nums.length - 1 and nums[i] <= nums[i + 1]. Replace the element nums[i + 1] with nums[i] + nums[i + 1] and delete the element nums[i] from th...
maxArrayValue(nums: list_int) -> int
pub fn max_array_value(nums: &[i64]) -> i64
Aegis.MaxArrayValue.max_array_value
pub fn max_array_value(nums: &[i64]) -> i64 { let n = nums.len(); if n == 0 { return 0; } let mut cur: i64 = nums[n - 1]; let mut i: usize = n - 1; while i > 0 { i -= 1; let x = nums[i]; if cur >= x { cur += x; } else { cur = x; ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [max_array_value]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linte...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [max_array_value]: function definitions module public import Aeneas public import Aegis.MaxArrayValue.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.MaxArrayValue.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]]", "output": "5" }, { "input": "[[1000000]]", "output": "1000000" }, { "input": "[[10, 5, 2]]", "output": "10" }, { "input": "[[5, 3, 3]]", "output": "11" }, { "input": "[[1, 1000000, 1]]", "output": "1000001" }, { "input": "[[10, 5, 2...
124
false
124
verified
10
10
1
410
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MaxArrayValue.Code.Funs /-! # Specifications of `Aegis.MaxArrayValue.max_array_value` LeetCode problem `largest-element-in-an-array-after-merge-operations`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.MaxArrayValue namespace AegisSpec.MaxArra...
13
maximum-number-of-groups-with-increasing-length
2,790
Hard
[ "Greedy", "Array", "Math", "Binary Search", "Sorting" ]
You are given a 0-indexed array usageLimits of length n. Your task is to create groups using numbers from 0 to n - 1, ensuring that each number, i, is used no more than usageLimits[i] times in total across all groups. You must also satisfy the following conditions: Each group must consist of distinct numbers, meaning ...
maxIncreasingGroups(usageLimits: list_int) -> int
pub fn max_increasing_groups(usageLimits: &[i64]) -> i64
Aegis.MaxIncreasingGroups.max_increasing_groups
pub fn max_increasing_groups(usageLimits: &[i64]) -> i64 { let n: usize = usageLimits.len(); let mut a: Vec<i64> = Vec::new(); let mut i: usize = 0; while i < n { a.push(usageLimits[i]); i += 1; } let mut b: Vec<i64> = Vec::new(); i = 0; while i < n { b.push(0);...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [max_increasing_groups]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [max_increasing_groups]: function definitions module public import Aeneas public import Aegis.MaxIncreasingGroups.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand f...
import Aegis.MaxIncreasingGroups.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": "[[1, 1]]", "output": "1" }, { "input": "[[1000000000, 1000000000, 1000000000]]", "output": "3" }, { "input": "[[1, 2, 5]]", "output": "3" }, { "input": "[[3, 3, 3]]", "output": "3" }, { "input": "[[2, 1,...
70
false
70
verified
10
10
1
11,781
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MaxIncreasingGroups.Code.Funs /-! # Specifications of `Aegis.MaxIncreasingGroups.max_increasing_groups` LeetCode problem `maximum-number-of-groups-with-increasing-length`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.MaxIncreasingGroups open sc...
15
count-paths-that-can-form-a-palindrome-in-a-tree
2,791
Hard
[ "Bit Manipulation", "Tree", "Depth-First Search", "Dynamic Programming", "Bitmask" ]
You are given a tree (i.e. a connected, undirected graph that has no cycles) rooted at node 0 consisting of n nodes numbered from 0 to n - 1. The tree is represented by a 0-indexed array parent of size n, where parent[i] is the parent of node i. Since node 0 is the root, parent[0] == -1. You are also given a string s o...
countPalindromePaths(parent: list_int, s: str) -> int
pub fn count_palindrome_paths(parent: &[i64], s: &[u8]) -> i64
Aegis.CountPalindromePaths.count_palindrome_paths
pub fn count_palindrome_paths(parent: &[i64], s: &[u8]) -> i64 { let n = parent.len(); if n == 0 { return 0; } let mut first: Vec<i64> = Vec::new(); let mut next: Vec<i64> = Vec::new(); let mut masks: Vec<i64> = Vec::new(); let mut i: usize = 0; while i < n { first.push...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [count_palindrome_paths]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_optio...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [count_palindrome_paths]: function definitions module public import Aeneas public import Aegis.CountPalindromePaths.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand...
import Aegis.CountPalindromePaths.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, 0, 0, 0, 0], \"aaaaa\"]", "output": "10" }, { "input": "[[-1, 0, 1, 2, 3], \"abcde\"]", "output": "4" }, { "input": "[[-1, 0, 0, 1, 1, 2], \"acaabc\"]", "output": "8" }, { "input": "[[-1, 0, 1, 2, 3, 4, 5], \"abcdefg\"]", "output": "6" }, { "inpu...
49
false
49
verified
10
10
1
18,064
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.CountPalindromePaths.Code.Funs /-! # Specifications of `Aegis.CountPalindromePaths.count_palindrome_paths` LeetCode problem `count-paths-that-can-form-a-palindrome-in-a-tree`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.CountPalindromePaths ...
11
count-nodes-that-are-great-enough
2,792
Hard
[ "Tree", "Depth-First Search", "Divide and Conquer", "Binary Tree" ]
You are given a root to a binary tree and an integer k. A node of this tree is called great enough if the followings hold: Its subtree has at least k nodes. Its value is greater than the value of at least k nodes in its subtree. Return the number of nodes in this tree that are great enough. The node u is in the subtr...
countGreatEnoughNodes(root: tree, k: int) -> int
pub fn count_great_enough_nodes(root: &Tree, k: i64) -> i64
Aegis.CountGreatEnoughNodes.count_great_enough_nodes
pub fn count_great_enough_nodes(root: &Tree, k: i64) -> i64 { let result = dfs(root, k); result[result.len() - 1] } fn dfs(t: &Tree, k: i64) -> Vec<i64> { match t { Tree::Null => { let mut v: Vec<i64> = Vec::new(); v.push(0); // subtree size v.push(0); // number ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [count_great_enough_nodes]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_opt...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [count_great_enough_nodes]: function definitions module public import Aeneas public import Aegis.CountGreatEnoughNodes.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashComm...
import Aegis.CountGreatEnoughNodes.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], 1]", "output": "0" }, { "input": "[[3, 2, 2], 2]", "output": "1" }, { "input": "[[1, 2, 3], 1]", "output": "0" }, { "input": "[[5, 3, 9, 1, 4, 7, 10], 2]", "output": "1" }, { "input": "[[5, 3, 8, 2, 4, 7, 9], 2]", "output": "1" }, { "...
68
false
68
verified
10
10
1
7,333
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.CountGreatEnoughNodes.Code.Funs /-! # Specifications of `Aegis.CountGreatEnoughNodes.count_great_enough_nodes` LeetCode problem `count-nodes-that-are-great-enough`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.CountGreatEnoughNodes ...
12
number-of-employees-who-met-the-target
2,798
Easy
[ "Array" ]
There are n employees in a company, numbered from 0 to n - 1. Each employee i has worked for hours[i] hours in the company. The company requires each employee to work for at least target hours. You are given a 0-indexed array of non-negative integers hours of length n and a non-negative integer target. Return the integ...
numberOfEmployeesWhoMetTarget(hours: list_int, target: int) -> int
pub fn number_of_employees_who_met_target(hours: &[i64], target: i64) -> i64
Aegis.NumberOfEmployeesWhoMetTarget.number_of_employees_who_met_target
pub fn number_of_employees_who_met_target(hours: &[i64], target: i64) -> i64 { let mut count: i64 = 0; let n = hours.len(); let mut i: usize = 0; while i < n { if hours[i] >= target { count += 1; } i += 1; } count }
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [number_of_employees_who_met_target]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables fal...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [number_of_employees_who_met_target]: function definitions module public import Aeneas public import Aegis.NumberOfEmployeesWhoMetTarget.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_opti...
import Aegis.NumberOfEmployeesWhoMetTarget.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], 1]", "output": "1" }, { "input": "[[10, 10, 10], 10]", "output": "3" }, { "input": "[[100, 200, 300], 150]", "output": "2" }, { "input": "[[1, 5, 7, 9], 8]", "output": "1" }, { "input": "[[5, 5, 5, 5, 5], 5]", "output": "5" }, { "inpu...
103
false
103
verified
10
10
1
95
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.NumberOfEmployeesWhoMetTarget.Code.Funs /-! # Specifications of `Aegis.NumberOfEmployeesWhoMetTarget.number_of_employees_who_met_target` LeetCode problem `number-of-employees-who-met-the-target`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace Aeg...
15
count-complete-subarrays-in-an-array
2,799
Medium
[ "Array", "Hash Table", "Sliding Window" ]
You are given an array nums consisting of positive integers. We call a subarray of an array complete if the following condition is satisfied: The number of distinct elements in the subarray is equal to the number of distinct elements in the whole array. Return the number of complete subarrays. A subarray is a contigu...
countCompleteSubarrays(nums: list_int) -> int
pub fn count_complete_subarrays(nums: &[i64]) -> i64
Aegis.CountCompleteSubarrays.count_complete_subarrays
pub fn count_complete_subarrays(nums: &[i64]) -> i64 { let n = nums.len(); let size: usize = 2001; let mut freq: Vec<i64> = Vec::new(); let mut p: usize = 0; while p < size { freq.push(0); p += 1; } let mut total: i64 = 0; let mut i: usize = 0; while i < n { ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [count_complete_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_complete_subarrays]: function definitions module public import Aeneas public import Aegis.CountCompleteSubarrays.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCom...
import Aegis.CountCompleteSubarrays.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": "[[5, 5, 5, 5]]", "output": "10" }, { "input": "[[2000, 1999, 1998, 1997, 1996]]", "output": "1" }, { "input": "[[1, 1, 1, 1, 1]]", "output": "15" }, { "input": "[[1, 2, 3, 2, 1]]", "output": "5" }, { "input": "[[10, 20, 30, 40, 50]]", "output": "1"...
99
false
99
verified
10
10
1
8,862
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.CountCompleteSubarrays.Code.Funs /-! # Specifications of `Aegis.CountCompleteSubarrays.count_complete_subarrays` LeetCode problem `count-complete-subarrays-in-an-array`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.CountCompleteSuba...
10
count-stepping-numbers-in-range
2,801
Hard
[ "String", "Dynamic Programming" ]
Given two positive integers low and high represented as strings, find the count of stepping numbers in the inclusive range [low, high]. A stepping number is an integer such that all of its adjacent digits have an absolute difference of exactly 1. Return an integer denoting the count of stepping numbers in the inclusive...
countSteppingNumbers(low: str, high: str) -> int
pub fn count_stepping_numbers(low: &[u8], high: &[u8]) -> i64
Aegis.CountSteppingNumbers.count_stepping_numbers
const MOD: i64 = 1000000007; fn add_mod(a: i64, b: i64) -> i64 { let s = a + b; if s >= MOD { s - MOD } else { s } } fn sub_mod(a: i64, b: i64) -> i64 { if a >= b { a - b } else { a + MOD - b } } fn digit_val(b: u8) -> usize { if b == b'0' { 0 ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [count_stepping_numbers]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_optio...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [count_stepping_numbers]: function definitions module public import Aeneas public import Aegis.CountSteppingNumbers.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand...
import Aegis.CountSteppingNumbers.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": "[\"123\", \"456\"]", "output": "13" }, { "input": "[\"5555555555\", \"6666666666\"]", "output": "436" }, { "input": "[\"1111111111\", \"2222222222\"]", "output": "307" }, { "input": "[\"1000000000\", \"1000000001\"]", "output": "0" }, { "input": "[\"10...
101
false
101
verified
10
10
5
55,348
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.CountSteppingNumbers.Code.Funs /-! # Specifications of `Aegis.CountSteppingNumbers.count_stepping_numbers` LeetCode problem `count-stepping-numbers-in-range`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.CountSteppingNumbers def M : ...
12
account-balance-after-rounded-purchase
2,806
Easy
[ "Math" ]
Initially, you have a bank account balance of 100 dollars. You are given an integer purchaseAmount representing the amount you will spend on a purchase in dollars, in other words, its price. When making the purchase, first the purchaseAmount is rounded to the nearest multiple of 10. Let us call this value roundedAmount...
accountBalanceAfterPurchase(purchaseAmount: int) -> int
pub fn account_balance_after_purchase(purchaseAmount: i64) -> i64
Aegis.AccountBalanceAfterPurchase.account_balance_after_purchase
pub fn account_balance_after_purchase(purchaseAmount: i64) -> i64 { let roundedAmount = ((purchaseAmount + 5) / 10) * 10; 100 - roundedAmount }
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [account_balance_after_purchase]: type definitions module public import Aeneas @[expose] 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 -- [account_balance_after_purchase]: function definitions module public import Aeneas public import Aegis.AccountBalanceAfterPurchase.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option lin...
import Aegis.AccountBalanceAfterPurchase.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": "[100]", "output": "0" }, { "input": "[85]", "output": "10" }, { "input": "[15]", "output": "80" }, { "input": "[10]", "output": "90" }, { "input": "[45]", "output": "50" }, { "input": "[51]", "output": "50" }, { "input": "[34]",...
54
false
54
verified
10
10
1
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.AccountBalanceAfterPurchase.Code.Funs /-! # Specifications of `Aegis.AccountBalanceAfterPurchase.account_balance_after_purchase` LeetCode problem `account-balance-after-rounded-purchase`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.A...
8
insert-greatest-common-divisors-in-linked-list
2,807
Medium
[ "Linked List", "Math", "Number Theory" ]
Given the head of a linked list head, in which each node contains an integer value. Between every pair of adjacent nodes, insert a new node with a value equal to the greatest common divisor of them. Return the linked list after insertion. The greatest common divisor of two numbers is the largest positive integer that e...
insertGreatestCommonDivisors(head: linkedlist) -> linkedlist
pub fn insert_greatest_common_divisors(head: &List) -> List
Aegis.InsertGreatestCommonDivisors.insert_greatest_common_divisors
fn gcd(mut a: i64, mut b: i64) -> i64 { while b != 0 { let t = a % b; a = b; b = t; } a } fn insert_gcd_list(head: &List) -> List { match head { List::Nil => List::Nil, List::Cons(v, next) => { let transformed_tail = insert_gcd_list(next); ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [insert_greatest_common_divisors]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [insert_greatest_common_divisors]: function definitions module public import Aeneas public import Aegis.InsertGreatestCommonDivisors.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option l...
import Aegis.InsertGreatestCommonDivisors.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": "[[7]]", "output": "[7]" }, { "input": "[[1000, 1000]]", "output": "[1000, 1000, 1000]" }, { "input": "[[33, 51, 68]]", "output": "[33, 3, 51, 17, 68]" }, { "input": "[[48, 18, 30]]", "output": "[48, 6, 18, 6, 30]" }, { "input": "[[100, 200, 300]]", ...
120
false
120
verified
10
10
1
1,387
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.InsertGreatestCommonDivisors.Code.Funs /-! # Specifications of `Aegis.InsertGreatestCommonDivisors.insert_greatest_common_divisors` LeetCode problem `insert-greatest-common-divisors-in-linked-list`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespac...
9
minimum-seconds-to-equalize-a-circular-array
2,808
Medium
[ "Array", "Hash Table" ]
You are given a 0-indexed array nums containing n integers. At each second, you perform the following operation on the array: For every index i in the range [0, n - 1], replace nums[i] with either nums[i], nums[(i - 1 + n) % n], or nums[(i + 1) % n]. Note that all the elements get replaced simultaneously. Return the ...
minimumSeconds(nums: list_int) -> int
pub fn minimum_seconds(nums: &[i64]) -> i64
Aegis.MinimumSeconds.minimum_seconds
fn merge_sort_codes(v: Vec<i64>) -> Vec<i64> { let n = v.len(); let mut cur: Vec<i64> = v; let mut width: usize = 1; while width < n { let mut next: Vec<i64> = Vec::new(); let mut start: usize = 0; let two_width = width * 2; while start < n { let mid = if st...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [minimum_seconds]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linte...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [minimum_seconds]: function definitions module public import Aeneas public import Aegis.MinimumSeconds.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.MinimumSeconds.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": "0" }, { "input": "[[5, 5, 5, 5]]", "output": "0" }, { "input": "[[1, 2, 1, 2]]", "output": "1" }, { "input": "[[10, 20, 10, 20, 10]]", "output": "1" }, { "input": "[[10, 10, 1, 10, 10]]", "output": "1" }, { "input": "[[10...
116
false
116
verified
10
10
1
7,143
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MinimumSeconds.Code.Funs /-! # Specifications of `Aegis.MinimumSeconds.minimum_seconds` LeetCode problem `minimum-seconds-to-equalize-a-circular-array`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.MinimumSeconds theorem val_length_e...
12
minimum-time-to-make-array-sum-at-most-x
2,809
Hard
[ "Array", "Dynamic Programming", "Sorting" ]
You are given two 0-indexed integer arrays nums1 and nums2 of equal length. Every second, for all indices 0 <= i < nums1.length, value of nums1[i] is incremented by nums2[i]. After this is done, you can do the following operation: Choose an index 0 <= i < nums1.length and make nums1[i] = 0. You are also given an inte...
minimumTime(nums1: list_int, nums2: list_int, x: int) -> int
pub fn minimum_time(nums1: &[i64], nums2: &[i64], x: i64) -> i64
Aegis.MinimumTime.minimum_time
pub fn minimum_time(nums1: &[i64], nums2: &[i64], x: i64) -> i64 { let n = nums1.len(); let mut sum1: i64 = 0; let mut sum2: i64 = 0; let mut i: usize = 0; while i < n { sum1 += nums1[i]; sum2 += nums2[i]; i += 1; } if sum1 <= x { return 0; } let mu...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [minimum_time]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter.s...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [minimum_time]: function definitions module public import Aeneas public import Aegis.MinimumTime.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option l...
import Aegis.MinimumTime.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval aegisCase...
[ { "input": "[[100, 200], [50, 100], 1000]", "output": "0" }, { "input": "[[1, 2], [3, 4], 5]", "output": "0" }, { "input": "[[1, 2, 3], [1, 2, 3], 4]", "output": "3" }, { "input": "[[5, 3, 8], [2, 1, 4], 15]", "output": "1" }, { "input": "[[5, 5, 5], [1, 1, 1], 15...
111
false
111
verified
10
10
1
14,491
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MinimumTime.Code.Funs /-! # Specifications of `Aegis.MinimumTime.minimum_time` LeetCode problem `minimum-time-to-make-array-sum-at-most-x`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.MinimumTime open Aegis.MinimumTime (minimum_time...
15
check-if-it-is-possible-to-split-array
2,811
Medium
[ "Greedy", "Array", "Dynamic Programming" ]
You are given an array nums of length n and an integer m. You need to determine if it is possible to split the array into n arrays of size 1 by performing a series of steps. An array is called good if: The length of the array is one, or The sum of the elements of the array is greater than or equal to m. In each step,...
canSplitArray(nums: list_int, m: int) -> bool
pub fn can_split_array(nums: &[i64], m: i64) -> bool
Aegis.CanSplitArray.can_split_array
pub fn can_split_array(nums: &[i64], m: i64) -> bool { let n = nums.len(); if n <= 2 { return true; } let mut i: usize = 0; while i + 1 < n { if nums[i] + nums[i + 1] >= m { return true; } i += 1; } false }
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [can_split_array]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linte...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [can_split_array]: function definitions module public import Aeneas public import Aegis.CanSplitArray.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.CanSplitArray.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], 100]", "output": "true" }, { "input": "[[50, 50], 100]", "output": "true" }, { "input": "[[100, 100], 150]", "output": "true" }, { "input": "[[2, 1, 3], 5]", "output": "false" }, { "input": "[[2, 2, 1], 4]", "output": "true" }, { "i...
113
false
113
verified
10
10
1
446
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.CanSplitArray.Code.Funs /-! # Specifications of `Aegis.CanSplitArray.can_split_array` LeetCode problem `check-if-it-is-possible-to-split-array`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.CanSplitArray namespace AegisSpec.CanSplitArray def ...
6
find-the-safest-path-in-a-grid
2,812
Medium
[ "Breadth-First Search", "Union Find", "Array", "Binary Search", "Matrix", "Heap (Priority Queue)" ]
You are given a 0-indexed 2D matrix grid of size n x n, where (r, c) represents: A cell containing a thief if grid[r][c] = 1 An empty cell if grid[r][c] = 0 You are initially positioned at cell (0, 0). In one move, you can move to any adjacent cell in the grid, including cells containing thieves. The safeness factor ...
maximumSafenessFactor(grid: list_list_int) -> int
pub fn maximum_safeness_factor(grid: &[Vec<i64>]) -> i64
Aegis.MaximumSafenessFactor.maximum_safeness_factor
fn feasible(dist: &[i64], n: usize, k: i64) -> bool { let total = n * n; let target = total - 1; if dist[0] < k { return false; } let mut visited: Vec<bool> = Vec::new(); let mut i: usize = 0; while i < total { visited.push(false); i += 1; } let mut q: Vec<...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [maximum_safeness_factor]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_opti...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [maximum_safeness_factor]: function definitions module public import Aeneas public import Aegis.MaximumSafenessFactor.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashComma...
import Aegis.MaximumSafenessFactor.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, 1], [0, 0, 0], [0, 0, 0]]]", "output": "2" }, { "input": "[[[1, 0, 0], [0, 0, 0], [0, 0, 1]]]", "output": "0" }, { "input": "[[[1, 0, 1], [0, 0, 0], [1, 0, 1]]]", "output": "0" }, { "input": "[[[1, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 1]]]", ...
66
false
66
verified
10
10
1
4,770
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MaximumSafenessFactor.Code.Funs /-! # Specifications of `Aegis.MaximumSafenessFactor.maximum_safeness_factor` LeetCode problem `find-the-safest-path-in-a-grid`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result ControlFlow Error namespace AegisSpec.MaximumS...
13
max-pair-sum-in-an-array
2,815
Easy
[ "Array", "Hash Table" ]
You are given an integer array nums. You have to find the maximum sum of a pair of numbers from nums such that the largest digit in both numbers is equal. For example, 2373 is made up of three distinct digits: 2, 3, and 7, where 7 is the largest among them. Return the maximum sum or -1 if no such pair exists.   Example...
maxSum(nums: list_int) -> int
pub fn max_sum(nums: &[i64]) -> i64
Aegis.MaxSum.max_sum
pub fn max_sum(nums: &[i64]) -> i64 { let n = nums.len(); let mut ans: i64 = -1; let mut i: usize = 0; while i < n { let mut j: usize = i + 1; while j < n { let di = largest_digit(nums[i]); let dj = largest_digit(nums[j]); if di == dj { ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [max_sum]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter.style....
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [max_sum]: function definitions module public import Aeneas public import Aegis.MaxSum.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unus...
import Aegis.MaxSum.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 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": "[[112, 131, 411]]", "output": "-1" }, { "input": "[[123, 321, 213]]", "output": "534" }, { "input": "[[123, 321, 213, 132]]", "output": "534" }, { "input": "[[100, 200, 300, 400]]", "output": "-1" }, { "input": "[[111, 222, 333, 444]]", "output": "...
126
false
126
verified
10
10
1
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.MaxSum.Code.Funs /-! # Specifications of `Aegis.MaxSum.max_sum` LeetCode problem `max-pair-sum-in-an-array`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aeneas.Std.Result open Classical namespace AegisSpec.MaxSum def largestDecimalDigitNat (n : Na...
15
double-a-number-represented-as-a-linked-list
2,816
Medium
[ "Stack", "Linked List", "Math" ]
You are given the head of a non-empty linked list representing a non-negative integer without leading zeroes. Return the head of the linked list after doubling it.   Example 1: Input: head = [1,8,9] Output: [3,7,8] Explanation: The figure above corresponds to the given linked list which represents the number 189. Hen...
doubleIt(head: linkedlist) -> linkedlist
pub fn double_it(head: &List) -> List
Aegis.DoubleIt.double_it
pub fn double_it(head: &List) -> List { let mut digits: Vec<i64> = Vec::new(); let mut cur: &List = head; let mut done: bool = false; while !done { match cur { List::Nil => { done = true; } List::Cons(v, next) => { digits.push(...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [double_it]: type definitions module public import Aeneas @[expose] public section 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 -- [double_it]: function definitions module public import Aeneas public import Aegis.DoubleIt.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.DoubleIt.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" deriving instance ...
[ { "input": "[[0]]", "output": "[0]" }, { "input": "[[1, 8, 9]]", "output": "[3, 7, 8]" }, { "input": "[[9, 9, 9]]", "output": "[1, 9, 9, 8]" }, { "input": "[[5, 0, 0]]", "output": "[1, 0, 0, 0]" }, { "input": "[[1, 0, 0, 0]]", "output": "[2, 0, 0, 0]" }, {...
71
false
71
verified
10
10
1
5,746
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.DoubleIt.Code.Funs /-! # Specifications of `Aegis.DoubleIt.double_it` LeetCode problem `double-a-number-represented-as-a-linked-list`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.DoubleIt def cI64 (n : Int) : Aeneas.Std.I64 := ⟨BitV...
13
minimum-absolute-difference-between-elements-with-constraint
2,817
Medium
[ "Array", "Binary Search", "Ordered Set" ]
You are given a 0-indexed integer array nums and an integer x. Find the minimum absolute difference between two elements in the array that are at least x indices apart. In other words, find two indices i and j such that abs(i - j) >= x and abs(nums[i] - nums[j]) is minimized. Return an integer denoting the minimum abso...
minAbsoluteDifference(nums: list_int, x: int) -> int
pub fn min_absolute_difference(nums: &[i64], x: i64) -> i64
Aegis.MinAbsoluteDifference.min_absolute_difference
pub fn min_absolute_difference(nums: &[i64], x: i64) -> i64 { if x <= 0 { return 0; } let n = nums.len(); let xx = x as usize; // Copy values for coordinate compression. let mut vals: Vec<i64> = Vec::new(); let mut i = 0usize; while i < n { vals.push(nums[i]); i...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [min_absolute_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_opti...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [min_absolute_difference]: function definitions module public import Aeneas public import Aegis.MinAbsoluteDifference.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashComma...
import Aegis.MinAbsoluteDifference.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], 0]", "output": "0" }, { "input": "[[1, 2, 3, 4], 3]", "output": "3" }, { "input": "[[4, 3, 2, 4], 2]", "output": "0" }, { "input": "[[1000000000, 1, 1000000000, 1], 1]", "output": "0" }, { "input": "[[7, 1, 14, 11], 2]", "output": "4" }, ...
212
false
212
verified
10
10
1
12,534
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MinAbsoluteDifference.Code.Funs /-! # Specifications of `Aegis.MinAbsoluteDifference.min_absolute_difference` LeetCode problem `minimum-absolute-difference-between-elements-with-constraint`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisS...
12
minimum-relative-loss-after-buying-chocolates
2,819
Hard
[ "Array", "Binary Search", "Prefix Sum", "Sorting" ]
You are given an integer array prices, which shows the chocolate prices and a 2D integer array queries, where queries[i] = [ki, mi]. Alice and Bob went to buy some chocolates, and Alice suggested a way to pay for them, and Bob agreed. The terms for each query are as follows: If the price of a chocolate is less than or...
minimumRelativeLosses(prices: list_int, queries: list_list_int) -> list_int
pub fn minimum_relative_losses(prices: &[i64], queries: &[Vec<i64>]) -> Vec<i64>
Aegis.MinimumRelativeLosses.minimum_relative_losses
pub fn minimum_relative_losses(prices: &[i64], queries: &[Vec<i64>]) -> Vec<i64> { let n = prices.len(); // Copy prices into a mutable vector for sorting. let mut a: Vec<i64> = Vec::new(); let mut i = 0; while i < n { a.push(prices[i]); i += 1; } // Bottom-up merge sort. ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [minimum_relative_losses]: type definitions module public import Aeneas @[expose] public 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_relative_losses]: function definitions module public import Aeneas public import Aegis.MinimumRelativeLosses.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashComma...
import Aegis.MinimumRelativeLosses.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, 999999999], [[1, 1], [999999999, 1]]]", "output": "[-999999997, 1]" }, { "input": "[[1, 9, 22, 10, 19], [[18, 4], [5, 2]]]", "output": "[34, -21]" }, { "input": "[[5, 6, 7], [[10, 1], [5, 3], [3, 3]]]", "output": "[5, 12, 0]" }, { "input": "[[999999999, 10000...
95
false
95
verified
10
10
1
12,721
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MinimumRelativeLosses.Code.Funs /-! # Specifications of `Aegis.MinimumRelativeLosses.minimum_relative_losses` LeetCode problem `minimum-relative-loss-after-buying-chocolates`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.MinimumRelativeLosses ...
17
count-pairs-whose-sum-is-less-than-target
2,824
Easy
[ "Array", "Two Pointers", "Binary Search", "Sorting" ]
Given a 0-indexed integer array nums of length n and an integer target, return the number of pairs (i, j) where 0 <= i < j < n and nums[i] + nums[j] < target.   Example 1: Input: nums = [-1,1,2,3,1], target = 2 Output: 3 Explanation: There are 3 pairs of indices that satisfy the conditions in the statement: - (0, 1) s...
countPairs(nums: list_int, target: int) -> int
pub fn count_pairs(nums: &[i64], target: i64) -> i64
Aegis.CountPairs.count_pairs
pub fn count_pairs(nums: &[i64], target: i64) -> i64 { let n = nums.len(); let mut count: i64 = 0; let mut i: usize = 0; while i < n { let mut j: usize = i + 1; while j < n { if nums[i] + nums[j] < target { count += 1; } j += 1; ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [count_pairs]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter.st...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [count_pairs]: function definitions module public import Aeneas public import Aegis.CountPairs.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option lin...
import Aegis.CountPairs.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval aegisCase ...
[ { "input": "[[0, 0, 0, 0], 1]", "output": "6" }, { "input": "[[50, -50, 25, -25], 0]", "output": "2" }, { "input": "[[5, 5, 5, 5, 5], 15]", "output": "10" }, { "input": "[[-10, -20, -30, -40, -50], -80]", "output": "1" }, { "input": "[[1, 3, 5, 7, 9], 10]", "o...
112
false
112
verified
10
10
1
388
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.CountPairs.Code.Funs /-! # Specifications of `Aegis.CountPairs.count_pairs` LeetCode problem `count-pairs-whose-sum-is-less-than-target`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.CountPairs namespace AegisSpec.CountPairs def entry (...
13
sorting-three-groups
2,826
Medium
[ "Array", "Binary Search", "Dynamic Programming" ]
You are given an integer array nums. Each element in nums is 1, 2 or 3. In each operation, you can remove an element from nums. Return the minimum number of operations to make nums non-decreasing.   Example 1: Input: nums = [2,1,3,2,1] Output: 3 Explanation: One of the optimal solutions is to remove nums[0], nums[2] a...
minimumOperations(nums: list_int) -> int
pub fn minimum_operations(nums: &[i64]) -> i64
Aegis.MinimumOperations.minimum_operations
fn min_i64(a: i64, b: i64) -> i64 { if a < b { a } else { b } } pub fn minimum_operations(nums: &[i64]) -> i64 { let inf: i64 = 1000000; // c0: minimum deletions when keeping no elements so far // c1: minimum deletions when the largest kept value is 1 // c2: minimum deletio...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [minimum_operations]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option li...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [minimum_operations]: function definitions module public import Aeneas public import Aegis.MinimumOperations.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false ...
import Aegis.MinimumOperations.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval aeg...
[ { "input": "[[1, 1, 1]]", "output": "0" }, { "input": "[[3, 2, 1]]", "output": "2" }, { "input": "[[3, 3, 3]]", "output": "0" }, { "input": "[[1, 2, 3]]", "output": "0" }, { "input": "[[1, 2, 2, 1, 3]]", "output": "1" }, { "input": "[[2, 1, 3, 2, 1]]",...
131
false
131
verified
10
10
1
3,471
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": 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 `sorting-three-groups`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Classical open Aegis.MinimumOperations namespace AegisSpec...
15
number-of-beautiful-integers-in-the-range
2,827
Hard
[ "Math", "Dynamic Programming" ]
You are given positive integers low, high, and k. A number is beautiful if it meets both of the following conditions: The count of even digits in the number is equal to the count of odd digits. The number is divisible by k. Return the number of beautiful integers in the range [low, high].   Example 1: Input: low = 1...
numberOfBeautifulIntegers(low: int, high: int, k: int) -> int
pub fn number_of_beautiful_integers(low: i64, high: i64, k: i64) -> i64
Aegis.NumberOfBeautifulIntegers.number_of_beautiful_integers
pub fn number_of_beautiful_integers(low: i64, high: i64, k: i64) -> i64 { count_leq(high, k) - count_leq(low - 1, k) } // Count completions of `remaining` free digits (each 0..=9) starting from // diff-index `start_diff` and remainder `start_rem`, such that the final // state has diff == cen (equal even/odd counts...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [number_of_beautiful_integers]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [number_of_beautiful_integers]: function definitions module public import Aeneas public import Aegis.NumberOfBeautifulIntegers.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter....
import Aegis.NumberOfBeautifulIntegers.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": "[100, 200, 4]", "output": "0" }, { "input": "[100, 200, 5]", "output": "0" }, { "input": "[10, 20, 3]", "output": "2" }, { "input": "[1, 10, 1]", "output": "1" }, { "input": "[100, 200, 7]", "output": "0" }, { "input": "[123, 456, 7]", ...
99
false
99
verified
10
10
2
31,065
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.NumberOfBeautifulIntegers.Code.Funs /-! # Specifications of `Aegis.NumberOfBeautifulIntegers.number_of_beautiful_integers` LeetCode problem `number-of-beautiful-integers-in-the-range`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.Nu...
12
check-if-a-string-is-an-acronym-of-words
2,828
Easy
[ "Array", "String" ]
Given an array of strings words and a string s, determine if s is an acronym of words. The string s is considered an acronym of words if it can be formed by concatenating the first character of each string in words in order. For example, "ab" can be formed from ["apple", "banana"], but it can't be formed from ["bear", ...
isAcronym(words: list_str, s: str) -> bool
pub fn is_acronym(words: &[Vec<u8>], s: &[u8]) -> bool
Aegis.IsAcronym.is_acronym
pub fn is_acronym(words: &[Vec<u8>], s: &[u8]) -> bool { if words.len() != s.len() { return false; } let mut i: usize = 0; while i < words.len() { let word = &words[i]; if word.len() == 0 { return false; } if word[0] != s[i] { return false...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [is_acronym]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter.sty...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [is_acronym]: function definitions module public import Aeneas public import Aegis.IsAcronym.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linte...
import Aegis.IsAcronym.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": "[[\"single\"], \"s\"]", "output": "true" }, { "input": "[[\"a\"], \"a\"]", "output": "true" }, { "input": "[[\"one\"], \"o\"]", "output": "true" }, { "input": "[[\"dog\", \"cat\"], \"dc\"]", "output": "true" }, { "input": "[[\"an\", \"apple\"], \"a\"]"...
129
false
129
verified
10
10
1
293
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.IsAcronym.Code.Funs /-! # Specifications of `Aegis.IsAcronym.is_acronym` LeetCode problem `check-if-a-string-is-an-acronym-of-words`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.IsAcronym def byteAt? (s : Slice Std.U8) (i : Nat) : O...
11
determine-the-minimum-sum-of-a-k-avoiding-array
2,829
Medium
[ "Greedy", "Math" ]
You are given two integers, n and k. An array of distinct positive integers is called a k-avoiding array if there does not exist any pair of distinct elements that sum to k. Return the minimum possible sum of a k-avoiding array of length n.   Example 1: Input: n = 5, k = 4 Output: 18 Explanation: Consider the k-avoidi...
minimumSum(n: int, k: int) -> int
pub fn minimum_sum(n: i64, k: i64) -> i64
Aegis.MinimumSum.minimum_sum
pub fn minimum_sum(n: i64, k: i64) -> i64 { let half = k / 2; let take = if n < half { n } else { half }; let mut sum = 0i64; let mut i = 1i64; while i <= take { sum += i; i += 1; } let remaining = n - take; let mut j = 0i64; while j < remaining { sum += k +...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [minimum_sum]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter.st...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [minimum_sum]: function definitions module public import Aeneas public import Aegis.MinimumSum.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.MinimumSum.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": "[4, 8]", "output": "10" }, { "input": "[3, 5]", "output": "8" }, { "input": "[10, 15]", "output": "76" }, { "input": "[4, 7]", "output": "13" }, { "input": "[7, 10]", "output": "36" }, { "input": "[2, 6]", "output": "3" }, { "in...
77
false
77
verified
10
10
1
2,350
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MinimumSum.Code.Funs /-! # Specifications of `Aegis.MinimumSum.minimum_sum` LeetCode problem `determine-the-minimum-sum-of-a-k-avoiding-array`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas.Std open Aeneas.Std.Result namespace AegisSpec.MinimumSum def half (k : ℤ) : ℤ := ...
11
find-the-longest-equal-subarray
2,831
Medium
[ "Array", "Hash Table", "Binary Search", "Sliding Window" ]
You are given a 0-indexed integer array nums and an integer k. A subarray is called equal if all of its elements are equal. Note that the empty subarray is an equal subarray. Return the length of the longest possible equal subarray after deleting at most k elements from nums. A subarray is a contiguous, possibly empty ...
longestEqualSubarray(nums: list_int, k: int) -> int
pub fn longest_equal_subarray(nums: &[i64], k: i64) -> i64
Aegis.LongestEqualSubarray.longest_equal_subarray
pub fn longest_equal_subarray(nums: &[i64], k: i64) -> i64 { let n = nums.len(); if n == 0 { return 0; } let mut order: Vec<i64> = Vec::new(); let mut idx = 0; while idx < n { order.push(idx as i64); idx += 1; } let mut temp: Vec<i64> = Vec::new(); idx = 0; ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [longest_equal_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_optio...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [longest_equal_subarray]: function definitions module public import Aeneas public import Aegis.LongestEqualSubarray.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand...
import Aegis.LongestEqualSubarray.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], 1]", "output": "1" }, { "input": "[[1], 0]", "output": "1" }, { "input": "[[1, 2], 1]", "output": "1" }, { "input": "[[10, 10, 1, 10, 10], 1]", "output": "4" }, { "input": "[[1, 2, 3, 4, 5], 4]", "output": "1" }, { "input": "[[1, 2, 3...
120
false
120
verified
10
10
1
12,746
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.LongestEqualSubarray.Code.Funs /-! # Specifications of `Aegis.LongestEqualSubarray.longest_equal_subarray` LeetCode problem `find-the-longest-equal-subarray`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.LongestEqualSubarray namespace AegisSpe...
15
furthest-point-from-origin
2,833
Easy
[ "String", "Counting" ]
You are given a string moves of length n consisting only of characters 'L', 'R', and '_'. The string represents your movement on a number line starting from the origin 0. In the ith move, you can choose one of the following directions: move to the left if moves[i] = 'L' or moves[i] = '_' move to the right if moves[i] ...
furthestDistanceFromOrigin(moves: str) -> int
pub fn furthest_distance_from_origin(moves: &[u8]) -> i64
Aegis.FurthestDistanceFromOrigin.furthest_distance_from_origin
pub fn furthest_distance_from_origin(moves: &[u8]) -> i64 { let mut left: i64 = 0; let mut right: i64 = 0; let mut underscores: i64 = 0; let mut i: usize = 0; while i < moves.len() { let c = moves[i]; if c == b'L' { left += 1; } else if c == b'R' { ri...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [furthest_distance_from_origin]: type definitions module public import Aeneas @[expose] 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 -- [furthest_distance_from_origin]: function definitions module public import Aeneas public import Aegis.FurthestDistanceFromOrigin.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linte...
import Aegis.FurthestDistanceFromOrigin.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": "[\"________R\"]", "output": "9" }, { "input": "[\"L_RL__R\"]", "output": "3" }, { "input": "[\"L_____R\"]", "output": "5" }, { "input": "[\"R_L_R_L\"]", "output": "3" }, { "input": "[\"L________\"]", "output": "9" }, { "input": "[\"R_______...
151
false
151
verified
10
10
1
782
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.FurthestDistanceFromOrigin.Code.Funs /-! # Specifications of `Aegis.FurthestDistanceFromOrigin.furthest_distance_from_origin` LeetCode problem `furthest-point-from-origin`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.FurthestDistance...
10
find-the-minimum-possible-sum-of-a-beautiful-array
2,834
Medium
[ "Greedy", "Math" ]
You are given positive integers n and target. An array nums is beautiful if it meets the following conditions: nums.length == n. nums consists of pairwise distinct positive integers. There doesn't exist two distinct indices, i and j, in the range [0, n - 1], such that nums[i] + nums[j] == target. Return the minimum p...
minimumPossibleSum(n: int, target: int) -> int
pub fn minimum_possible_sum(n: i64, target: i64) -> i64
Aegis.MinimumPossibleSum.minimum_possible_sum
pub fn minimum_possible_sum(n: i64, target: i64) -> i64 { let modu: i64 = 1000000007; let half: i64 = target / 2; let mut k: i64 = n; if half < k { k = half; } let q: i64 = n - k; let sum_low: i64 = k * (k + 1) / 2; let sum_high: i64 = q * (2 * target + q - 1) / 2; (sum_l...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [minimum_possible_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 -- [minimum_possible_sum]: function definitions module public import Aeneas public import Aegis.MinimumPossibleSum.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand fal...
import Aegis.MinimumPossibleSum.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval ae...
[ { "input": "[2, 3]", "output": "4" }, { "input": "[100, 100]", "output": "7500" }, { "input": "[5, 8]", "output": "18" }, { "input": "[1, 1]", "output": "1" }, { "input": "[1000000000, 1000000000]", "output": "750000042" }, { "input": "[3, 3]", "ou...
91
false
91
verified
10
10
1
2,768
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MinimumPossibleSum.Code.Funs /-! # Specifications of `Aegis.MinimumPossibleSum.minimum_possible_sum` LeetCode problem `find-the-minimum-possible-sum-of-a-beautiful-array`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.MinimumPossibleSu...
11
minimum-operations-to-form-subsequence-with-target-sum
2,835
Hard
[ "Greedy", "Bit Manipulation", "Array" ]
You are given a 0-indexed array nums consisting of non-negative powers of 2, and an integer target. In one operation, you must apply the following changes to the array: Choose any element of the array nums[i] such that nums[i] > 1. Remove nums[i] from the array. Add two occurrences of nums[i] / 2 to the end of nums. ...
minOperations(nums: list_int, target: int) -> int
pub fn min_operations(nums: &[i64], target: i64) -> i64
Aegis.MinOperations.min_operations
pub fn min_operations(nums: &[i64], target: i64) -> i64 { let mut cnt: Vec<i64> = Vec::new(); let mut p: usize = 0; while p < 33 { cnt.push(0); p = p + 1; } let mut idx: usize = 0; while idx < nums.len() { let mut x: i64 = nums[idx]; let mut e: 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": "[[64], 32]", "output": "1" }, { "input": "[[1024], 512]", "output": "1" }, { "input": "[[1], 1]", "output": "0" }, { "input": "[[1024], 1]", "output": "10" }, { "input": "[[1073741824], 1073741824]", "output": "0" }, { "input": "[[1, 2, 8],...
117
false
117
verified
10
10
1
21,743
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": 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-form-subsequence-with-target-sum`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.MinOperations namespace AegisSpec....
12
maximize-value-of-function-in-a-ball-passing-game
2,836
Hard
[ "Bit Manipulation", "Array", "Dynamic Programming" ]
You are given an integer array receiver of length n and an integer k. n players are playing a ball-passing game. You choose the starting player, i. The game proceeds as follows: player i passes the ball to player receiver[i], who then passes it to receiver[receiver[i]], and so on, for k passes in total. The game's scor...
getMaxFunctionValue(receiver: list_int, k: int) -> int
pub fn get_max_function_value(receiver: &[i64], k: i64) -> i64
Aegis.GetMaxFunctionValue.get_max_function_value
pub fn get_max_function_value(receiver: &[i64], k: i64) -> i64 { let n = receiver.len(); let mut jump: Vec<i64> = Vec::new(); let mut val: Vec<i64> = Vec::new(); let mut ans: Vec<i64> = Vec::new(); let mut cur: Vec<i64> = Vec::new(); let mut i = 0; while i < n { let r = receiver[i]...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [get_max_function_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_optio...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [get_max_function_value]: function definitions module public import Aeneas public import Aegis.GetMaxFunctionValue.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand ...
import Aegis.GetMaxFunctionValue.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": "[[2, 0, 1], 4]", "output": "6" }, { "input": "[[3, 3, 3, 3], 10]", "output": "33" }, { "input": "[[0, 2, 1, 0], 5]", "output": "9" }, { "input": "[[0, 2, 1, 3], 2]", "output": "9" }, { "input": "[[3, 2, 1, 0], 5]", "output": "9" }, { "input...
109
false
109
verified
10
10
1
5,808
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.GetMaxFunctionValue.Code.Funs /-! # Specifications of `Aegis.GetMaxFunctionValue.get_max_function_value` LeetCode problem `maximize-value-of-function-in-a-ball-passing-game`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.GetMaxFunction...
13
maximum-coins-heroes-can-collect
2,838
Medium
[ "Array", "Two Pointers", "Binary Search", "Prefix Sum", "Sorting" ]
There is a battle and n heroes are trying to defeat m monsters. You are given two 1-indexed arrays of positive integers heroes and monsters of length n and m, respectively. heroes[i] is the power of ith hero, and monsters[i] is the power of ith monster. The ith hero can defeat the jth monster if monsters[j] <= heroes[i...
maximumCoins(heroes: list_int, monsters: list_int, coins: list_int) -> list_int
pub fn maximum_coins(heroes: &[i64], monsters: &[i64], coins: &[i64]) -> Vec<i64>
Aegis.MaximumCoins.maximum_coins
pub fn maximum_coins(heroes: &[i64], monsters: &[i64], coins: &[i64]) -> Vec<i64> { let m = monsters.len(); // Build an order array of monster indices, then sort it by monster power. let mut order: Vec<usize> = Vec::new(); let mut i: usize = 0; while i < m { order.push(i); i += 1; ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [maximum_coins]: type definitions module public import Aeneas @[expose] public section 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_coins]: function definitions module public import Aeneas public import Aegis.MaximumCoins.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.MaximumCoins.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], [10], [100]]", "output": "[0]" }, { "input": "[[1000000000], [1000000000], [1000000000]]", "output": "[1000000000]" }, { "input": "[[1000000000], [1, 1000000000], [1000000000, 1000000000]]", "output": "[2000000000]" }, { "input": "[[100], [1, 10, 100], [10, ...
108
false
108
verified
10
10
1
2,907
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MaximumCoins.Code.Funs /-! # Specifications of `Aegis.MaximumCoins.maximum_coins` LeetCode problem `maximum-coins-heroes-can-collect`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.MaximumCoins namespace AegisSpec.MaximumCoins def toInt...
12
check-if-strings-can-be-made-equal-with-operations-i
2,839
Easy
[ "String" ]
You are given two strings s1 and s2, both of length 4, consisting of lowercase English letters. You can apply the following operation on any of the two strings any number of times: Choose any two indices i and j such that j - i = 2, then swap the two characters at those indices in the string. Return true if you can m...
canBeEqual(s1: str, s2: str) -> bool
pub fn can_be_equal(s1: &[u8], s2: &[u8]) -> bool
Aegis.CanBeEqual.can_be_equal
pub fn can_be_equal(s1: &[u8], s2: &[u8]) -> bool { let even_ok = (s1[0] == s2[0] && s1[2] == s2[2]) || (s1[0] == s2[2] && s1[2] == s2[0]); let odd_ok = (s1[1] == s2[1] && s1[3] == s2[3]) || (s1[1] == s2[3] && s1[3] == s2[1]); even_ok && odd_ok }
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [can_be_equal]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter.s...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [can_be_equal]: function definitions module public import Aeneas public import Aegis.CanBeEqual.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option li...
import Aegis.CanBeEqual.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 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": "[\"abcd\", \"cdab\"]", "output": "true" }, { "input": "[\"acbd\", \"bdac\"]", "output": "true" }, { "input": "[\"abab\", \"abcd\"]", "output": "false" }, { "input": "[\"abdc\", \"cdab\"]", "output": "false" }, { "input": "[\"abcd\", \"dacb\"]", "ou...
63
false
63
verified
10
10
1
865
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.CanBeEqual.Code.Funs /-! # Specifications of `Aegis.CanBeEqual.can_be_equal` LeetCode problem `check-if-strings-can-be-made-equal-with-operations-i`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.CanBeEqual def byteAt (s : Slice Std.U...
7
maximum-sum-of-almost-unique-subarray
2,841
Medium
[ "Array", "Hash Table", "Sliding Window" ]
You are given an integer array nums and two positive integers m and k. Return the maximum sum out of all almost unique subarrays of length k of nums. If no such subarray exists, return 0. A subarray of nums is almost unique if it contains at least m distinct elements. A subarray is a contiguous non-empty sequence of el...
maxSum(nums: list_int, m: int, k: int) -> int
pub fn max_sum(nums: &[i64], m: i64, k: i64) -> i64
Aegis.MaxSum.max_sum
fn find_index(vals: &[i64], x: 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] < x { lo = mid + 1; } else { hi = mid; } } lo } pub fn max_sum(nums: &[i...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [max_sum]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter.style....
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [max_sum]: function definitions module public import Aeneas public import Aegis.MaxSum.Code.Types public import Aegis.MaxSum.Code.FunsExternal @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option li...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [max_sum]: external functions. -- This is a template file: rename it to "FunsExternal.lean" and fill the holes. module public import Aeneas public import Aegis.MaxSum.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option lint...
import Aegis.MaxSum.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": "[[1, 2, 3, 4, 5], 2, 3]", "output": "12" }, { "input": "[[1, 1, 1, 1, 1], 2, 3]", "output": "0" }, { "input": "[[10, 10, 10, 10, 10], 1, 2]", "output": "20" }, { "input": "[[10, 20, 30, 40, 50], 3, 5]", "output": "150" }, { "input": "[[5, 5, 5, 5, 5], ...
108
false
108
verified
10
10
1
4,831
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MaxSum.Code.Funs /-! # Specifications of `Aegis.MaxSum.max_sum` LeetCode problem `maximum-sum-of-almost-unique-subarray`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.MaxSum def natOf {ty : IScalarTy} (x : IScalar ty) : Nat := x.val....
16
count-symmetric-integers
2,843
Easy
[ "Math", "Enumeration" ]
You are given two positive integers low and high. An integer x consisting of 2 * n digits is symmetric if the sum of the first n digits of x is equal to the sum of the last n digits of x. Numbers with an odd number of digits are never symmetric. Return the number of symmetric integers in the range [low, high].   Exampl...
countSymmetricIntegers(low: int, high: int) -> int
pub fn count_symmetric_integers(low: i64, high: i64) -> i64
Aegis.CountSymmetricIntegers.count_symmetric_integers
pub fn count_symmetric_integers(low: i64, high: i64) -> i64 { let mut count: i64 = 0; let mut x: i64 = low; while x <= high { let mut d: i64 = 0; let mut t: i64 = x; while t > 0 { d += 1; t = t / 10; } if d % 2 == 0 { let n: i64 ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [count_symmetric_integers]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_opt...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [count_symmetric_integers]: function definitions module public import Aeneas public import Aegis.CountSymmetricIntegers.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCom...
import Aegis.CountSymmetricIntegers.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, 20]", "output": "1" }, { "input": "[1, 9999]", "output": "624" }, { "input": "[500, 1500]", "output": "20" }, { "input": "[1000, 1000]", "output": "0" }, { "input": "[500, 550]", "output": "0" }, { "input": "[1, 100]", "output": "9...
72
false
72
verified
10
10
1
2,575
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.CountSymmetricIntegers.Code.Funs /-! # Specifications of `Aegis.CountSymmetricIntegers.count_symmetric_integers` LeetCode problem `count-symmetric-integers`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Classical open Aegis.CountSymmetricIntegers...
13
minimum-operations-to-make-a-special-number
2,844
Medium
[ "Greedy", "Math", "String", "Enumeration" ]
You are given a 0-indexed string num representing a non-negative integer. In one operation, you can pick any digit of num and delete it. Note that if you delete all the digits of num, num becomes 0. Return the minimum number of operations required to make num special. An integer x is considered special if it is divisib...
minimumOperations(num: str) -> int
pub fn minimum_operations(num: &[u8]) -> i64
Aegis.MinimumOperations.minimum_operations
fn min_pair(num: &[u8], a: u8, b: u8) -> i64 { let n = num.len(); if n < 2 { return 1_000_000; } let mut j: usize = n; let mut b_idx: usize = n; while j > 0 { j -= 1; if num[j] == b { b_idx = j; break; } } if b_idx == n { ...
-- 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": "[\"10\"]", "output": "1" }, { "input": "[\"00000\"]", "output": "0" }, { "input": "[\"75\"]", "output": "0" }, { "input": "[\"52\"]", "output": "2" }, { "input": "[\"500000\"]", "output": "0" }, { "input": "[\"5252525252\"]", "output": ...
188
false
188
verified
10
10
1
4,994
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": 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-operations-to-make-a-special-number`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.MinimumOperations open ...
12
count-of-interesting-subarrays
2,845
Medium
[ "Array", "Hash Table", "Prefix Sum" ]
You are given a 0-indexed integer array nums, an integer modulo, and an integer k. Your task is to find the count of subarrays that are interesting. A subarray nums[l..r] is interesting if the following condition holds: Let cnt be the number of indices i in the range [l, r] such that nums[i] % modulo == k. Then, cnt %...
countInterestingSubarrays(nums: list_int, modulo: int, k: int) -> int
pub fn count_interesting_subarrays(nums: &[i64], modulo: i64, k: i64) -> i64
Aegis.CountInterestingSubarrays.count_interesting_subarrays
fn lower_bound(xs: &Vec<i64>, target: i64) -> usize { let mut lo: usize = 0; let mut hi: usize = xs.len(); while lo < hi { let mid: usize = lo + (hi - lo) / 2; if xs[mid] < target { lo = mid + 1; } else { hi = mid; } } lo } pub fn count_inte...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [count_interesting_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_interesting_subarrays]: function definitions module public import Aeneas public import Aegis.CountInterestingSubarrays.Code.Types public import Aegis.CountInterestingSubarrays.Code.FunsExternal @[expose] public section open Aeneas Aeneas.Std Result ControlFlo...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [count_interesting_subarrays]: external functions. -- This is a template file: rename it to "FunsExternal.lean" and fill the holes. module public import Aeneas public import Aegis.CountInterestingSubarrays.Code.Types @[expose] public section open Aeneas Aeneas.Std R...
import Aegis.CountInterestingSubarrays.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": "[[3, 2, 4], 2, 1]", "output": "3" }, { "input": "[[3, 1, 9, 6], 3, 0]", "output": "2" }, { "input": "[[5, 5, 5, 5], 5, 0]", "output": "0" }, { "input": "[[8, 12, 16, 20, 24], 4, 0]", "output": "2" }, { "input": "[[1, 3, 5, 7, 9], 2, 1]", "output": ...
110
false
110
verified
10
10
1
4,765
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.CountInterestingSubarrays.Code.Funs /-! # Specifications of `Aegis.CountInterestingSubarrays.count_interesting_subarrays` LeetCode problem `count-of-interesting-subarrays`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.CountInteresting...
11
minimum-edge-weight-equilibrium-queries-in-a-tree
2,846
Hard
[ "Tree", "Graph", "Array", "Strongly Connected Component" ]
There is an undirected tree with n nodes labeled from 0 to n - 1. You are given the integer n and a 2D integer array edges of length n - 1, where edges[i] = [ui, vi, wi] indicates that there is an edge between nodes ui and vi with weight wi in the tree. You are also given a 2D integer array queries of length m, where q...
minOperationsQueries(n: int, edges: list_list_int, queries: list_list_int) -> list_int
pub fn min_operations_queries(n: i64, edges: &[Vec<i64>], queries: &[Vec<i64>]) -> Vec<i64>
Aegis.MinOperationsQueries.min_operations_queries
fn get_lca( mut a: usize, mut b: usize, depth: &[i64], up: &[i64], log: usize, n: usize, ) -> usize { if depth[a] < depth[b] { let tmp = a; a = b; b = tmp; } let diff = depth[a] - depth[b]; let mut bit: usize = 0; let mut p: i64 = 1; while bit < l...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [min_operations_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_optio...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [min_operations_queries]: function definitions module public import Aeneas public import Aegis.MinOperationsQueries.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand...
import Aegis.MinOperationsQueries.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": "[7, [[0, 1, 1], [1, 2, 1], [2, 3, 1], [3, 4, 2], [4, 5, 2], [5, 6, 2]], [[0, 3], [3, 6], [2, 6], [0, 6]]]", "output": "[0, 0, 1, 3]" }, { "input": "[8, [[1, 2, 6], [1, 3, 4], [2, 4, 6], [2, 5, 3], [3, 6, 6], [3, 0, 8], [7, 0, 2]], [[4, 6], [0, 4], [6, 5], [7, 4]]]", "output": "[1, 2,...
26
false
26
verified
10
10
1
15,973
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MinOperationsQueries.Code.Funs /-! # Specifications of `Aegis.MinOperationsQueries.min_operations_queries` LeetCode problem `minimum-edge-weight-equilibrium-queries-in-a-tree`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Classical open Aegis.MinOper...
13
points-that-intersect-with-cars
2,848
Easy
[ "Array", "Hash Table", "Prefix Sum" ]
You are given a 0-indexed 2D integer array nums representing the coordinates of the cars parking on a number line. For any index i, nums[i] = [starti, endi] where starti is the starting point of the ith car and endi is the ending point of the ith car. Return the number of integer points on the line that are covered wit...
numberOfPoints(nums: list_list_int) -> int
pub fn number_of_points(nums: &[Vec<i64>]) -> i64
Aegis.NumberOfPoints.number_of_points
pub fn number_of_points(nums: &[Vec<i64>]) -> i64 { let mut covered: Vec<bool> = Vec::new(); let mut i: usize = 0; while i <= 100 { covered.push(false); i += 1; } let mut j: usize = 0; while j < nums.len() { let start = nums[j][0]; let end = nums[j][1]; ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [number_of_points]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option lint...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [number_of_points]: function definitions module public import Aeneas public import Aegis.NumberOfPoints.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.NumberOfPoints.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, 100]]]", "output": "100" }, { "input": "[[[1, 3], [5, 8]]]", "output": "7" }, { "input": "[[[10, 15], [20, 25]]]", "output": "12" }, { "input": "[[[5, 10], [10, 15]]]", "output": "11" }, { "input": "[[[1, 1], [2, 2], [3, 3]]]", "output": "3" ...
85
false
85
verified
10
10
1
724
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.NumberOfPoints.Code.Funs /-! # Specifications of `Aegis.NumberOfPoints.number_of_points` LeetCode problem `points-that-intersect-with-cars`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.NumberOfPoints noncomputable section def start...
11
determine-if-a-cell-is-reachable-at-a-given-time
2,849
Medium
[ "Math" ]
You are given four integers sx, sy, fx, fy, and a non-negative integer t. In an infinite 2D grid, you start at the cell (sx, sy). Each second, you must move to any of its adjacent cells. Return true if you can reach cell (fx, fy) after exactly t seconds, or false otherwise. A cell's adjacent cells are the 8 cells aroun...
isReachableAtTime(sx: int, sy: int, fx: int, fy: int, t: int) -> bool
pub fn is_reachable_at_time(sx: i64, sy: i64, fx: i64, fy: i64, t: i64) -> bool
Aegis.IsReachableAtTime.is_reachable_at_time
pub fn is_reachable_at_time(sx: i64, sy: i64, fx: i64, fy: i64, t: i64) -> bool { if sx == fx && sy == fy && t == 1 { return false; } let dx = if sx > fx { sx - fx } else { fx - sx }; let dy = if sy > fy { sy - fy } else { fy - sy }; let dist = if dx > dy { dx } else { dy }; t >= dist...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [is_reachable_at_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 ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [is_reachable_at_time]: function definitions module public import Aeneas public import Aegis.IsReachableAtTime.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand fals...
import Aegis.IsReachableAtTime.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, 1]", "output": "true" }, { "input": "[2, 4, 7, 7, 6]", "output": "true" }, { "input": "[1, 1, 10, 10, 14]", "output": "true" }, { "input": "[1000000000, 1000000000, 1000000000, 1000000000, 0]", "output": "true" }, { "input": "[1, 1, 2, 1, ...
89
false
89
verified
10
10
1
1,160
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.IsReachableAtTime.Code.Funs /-! # Specifications of `Aegis.IsReachableAtTime.is_reachable_at_time` LeetCode problem `determine-if-a-cell-is-reachable-at-a-given-time`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.IsReachableAtTime ...
13
minimum-array-length-after-pair-removals
2,856
Medium
[ "Greedy", "Array", "Hash Table", "Two Pointers", "Binary Search", "Counting" ]
Given an integer array num sorted in non-decreasing order. You can perform the following operation any number of times: Choose two indices, i and j, where nums[i] < nums[j]. Then, remove the elements at indices i and j from nums. The remaining elements retain their original order, and the array is re-indexed. Return ...
minLengthAfterRemovals(nums: list_int) -> int
pub fn min_length_after_removals(nums: &[i64]) -> i64
Aegis.MinLengthAfterRemovals.min_length_after_removals
pub fn min_length_after_removals(nums: &[i64]) -> i64 { let n_usize = nums.len(); if n_usize == 0 { return 0; } let n = n_usize as i64; let mut max_freq: i64 = 0; let mut i: usize = 0; while i < n_usize { let value = nums[i]; let mut j: usize = i + 1; while ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [min_length_after_removals]: type definitions module public import Aeneas @[expose] public 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 -- [min_length_after_removals]: function definitions module public import Aeneas public import Aegis.MinLengthAfterRemovals.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCo...
import Aegis.MinLengthAfterRemovals.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]]", "output": "1" }, { "input": "[[1000000000, 1000000000]]", "output": "2" }, { "input": "[[1, 2, 3, 4]]", "output": "0" }, { "input": "[[2, 3, 4, 4, 4]]", "output": "1" }, { "input": "[[1, 1, 2, 2, 3, 3]]", "output": "0" }, { "input":...
121
false
121
verified
10
10
1
811
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MinLengthAfterRemovals.Code.Funs /-! # Specifications of `Aegis.MinLengthAfterRemovals.min_length_after_removals` LeetCode problem `minimum-array-length-after-pair-removals`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.MinLengthAfter...
13
count-pairs-of-points-with-distance-k
2,857
Medium
[ "Bit Manipulation", "Array", "Hash Table" ]
You are given a 2D integer array coordinates and an integer k, where coordinates[i] = [xi, yi] are the coordinates of the ith point in a 2D plane. We define the distance between two points (x1, y1) and (x2, y2) as (x1 XOR x2) + (y1 XOR y2) where XOR is the bitwise XOR operation. Return the number of pairs (i, j) such t...
countPairs(coordinates: list_list_int, k: int) -> int
pub fn count_pairs(coordinates: &[Vec<i64>], k: i64) -> i64
Aegis.CountPairs.count_pairs
pub fn count_pairs(coordinates: &[Vec<i64>], k: i64) -> i64 { let n = coordinates.len(); let mut total: i64 = 0; let mut i: usize = 0; while i < n { let x1 = coordinates[i][0]; let y1 = coordinates[i][1]; let mut j: usize = i + 1; while j < n { let x2 = coordi...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [count_pairs]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter.st...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [count_pairs]: function definitions module public import Aeneas public import Aegis.CountPairs.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option lin...
import Aegis.CountPairs.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval aegisCase ...
[ { "input": "[[[1000000, 1000000], [0, 0], [500000, 500000]], 1000000]", "output": "1" }, { "input": "[[[0, 0], [1, 1], [2, 2], [3, 3]], 2]", "output": "2" }, { "input": "[[[1, 2], [4, 2], [1, 3], [5, 2]], 5]", "output": "2" }, { "input": "[[[0, 0], [0, 1], [1, 0], [1, 1]], 1]...
91
false
91
verified
10
10
3
101,824
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.CountPairs.Code.Funs /-! # Specifications of `Aegis.CountPairs.count_pairs` LeetCode problem `count-pairs-of-points-with-distance-k`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.CountPairs def rows (coordinates : Slice (alloc.vec.Ve...
12
minimum-edge-reversals-so-every-node-is-reachable
2,858
Hard
[ "Depth-First Search", "Breadth-First Search", "Graph", "Dynamic Programming" ]
There is a simple directed graph with n nodes labeled from 0 to n - 1. The graph would form a tree if its edges were bi-directional. You are given an integer n and a 2D integer array edges, where edges[i] = [ui, vi] represents a directed edge going from node ui to node vi. An edge reversal changes the direction of an e...
minEdgeReversals(n: int, edges: list_list_int) -> list_int
pub fn min_edge_reversals(n: i64, edges: &[Vec<i64>]) -> Vec<i64>
Aegis.MinEdgeReversals.min_edge_reversals
pub fn min_edge_reversals(n: i64, edges: &[Vec<i64>]) -> Vec<i64> { let n_us = n as usize; let mut adj: Vec<Vec<i64>> = Vec::new(); let mut cost: Vec<Vec<i64>> = Vec::new(); let mut i: usize = 0; while i < n_us { adj.push(Vec::new()); cost.push(Vec::new()); i += 1; } ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [min_edge_reversals]: type definitions module public import Aeneas @[expose] public section 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_edge_reversals]: function definitions module public import Aeneas public import Aegis.MinEdgeReversals.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.MinEdgeReversals.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": "[3, [[1, 2], [2, 0]]]", "output": "[2, 0, 1]" }, { "input": "[4, [[2, 0], [2, 1], [1, 3]]]", "output": "[1, 1, 0, 2]" }, { "input": "[5, [[0, 1], [1, 2], [2, 3], [3, 4]]]", "output": "[0, 1, 2, 3, 4]" }, { "input": "[5, [[0, 1], [2, 0], [3, 2], [4, 2]]]", "out...
42
false
42
verified
10
10
1
6,378
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MinEdgeReversals.Code.Funs /-! # Specifications of `Aegis.MinEdgeReversals.min_edge_reversals` LeetCode problem `minimum-edge-reversals-so-every-node-is-reachable`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.MinEdgeReversals de...
9
sum-of-values-at-indices-with-k-set-bits
2,859
Easy
[ "Bit Manipulation", "Array" ]
You are given a 0-indexed integer array nums and an integer k. Return an integer that denotes the sum of elements in nums whose corresponding indices have exactly k set bits in their binary representation. The set bits in an integer are the 1's present when it is written in binary. For example, the binary representati...
sumIndicesWithKSetBits(nums: list_int, k: int) -> int
pub fn sum_indices_with_k_set_bits(nums: &[i64], k: i64) -> i64
Aegis.SumIndicesWithKSetBits.sum_indices_with_k_set_bits
pub fn sum_indices_with_k_set_bits(nums: &[i64], k: i64) -> i64 { let mut sum: i64 = 0; let n: usize = nums.len(); let mut i: usize = 0; while i < n { let mut x: usize = i; let mut count: i64 = 0; while x > 0 { if x % 2 == 1 { count += 1; ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [sum_indices_with_k_set_bits]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [sum_indices_with_k_set_bits]: function definitions module public import Aeneas public import Aegis.SumIndicesWithKSetBits.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hash...
import Aegis.SumIndicesWithKSetBits.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, 3, 2, 1], 2]", "output": "1" }, { "input": "[[10, 20, 30, 40, 50], 0]", "output": "10" }, { "input": "[[100, 200, 300, 400, 500], 3]", "output": "0" }, { "input": "[[31, 14, 7, 3, 1], 0]", "output": "31" }, { "input": "[[5, 10, 1, 5, 2], 1]", ...
79
false
79
verified
10
10
1
577
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.SumIndicesWithKSetBits.Code.Funs /-! # Specifications of `Aegis.SumIndicesWithKSetBits.sum_indices_with_k_set_bits` LeetCode problem `sum-of-values-at-indices-with-k-set-bits`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.SumIndicesWi...
11
happy-students
2,860
Medium
[ "Array", "Enumeration", "Sorting" ]
You are given a 0-indexed integer array nums of length n where n is the total number of students in the class. The class teacher tries to select a group of students so that all the students remain happy. The ith student will become happy if one of these two conditions is met: The student is selected and the total numb...
countWays(nums: list_int) -> int
pub fn count_ways(nums: &[i64]) -> i64
Aegis.CountWays.count_ways
pub fn count_ways(nums: &[i64]) -> i64 { let n_usize = nums.len(); let n = n_usize as i64; let mut freq: Vec<i64> = Vec::new(); let mut t: usize = 0; while t <= n_usize { freq.push(0); t += 1; } let mut i: usize = 0; while i < n_usize { let v = nums[i]; ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [count_ways]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter.sty...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [count_ways]: function definitions module public import Aeneas public import Aegis.CountWays.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linte...
import Aegis.CountWays.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval aegisCase "...
[ { "input": "[[1]]", "output": "1" }, { "input": "[[0]]", "output": "1" }, { "input": "[[1, 1]]", "output": "2" }, { "input": "[[3, 2, 1]]", "output": "1" }, { "input": "[[3, 2, 1, 0]]", "output": "1" }, { "input": "[[0, 0, 0, 0]]", "output": "1" ...
120
false
120
verified
10
10
1
4,517
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.CountWays.Code.Funs /-! # Specifications of `Aegis.CountWays.count_ways` LeetCode problem `happy-students`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.CountWays open Aegis.CountWays def vals (nums : Slice I64) : List Int := nums.v...
8
maximum-number-of-alloys
2,861
Medium
[ "Array", "Binary Search" ]
You are the owner of a company that creates alloys using various types of metals. There are n different types of metals available, and you have access to k machines that can be used to create alloys. Each machine requires a specific amount of each metal type to create an alloy. For the ith machine to create an alloy, i...
maxNumberOfAlloys(n: int, k: int, budget: int, composition: list_list_int, stock: list_int, cost: list_int) -> int
pub fn max_number_of_alloys(n: i64, k: i64, budget: i64, composition: &[Vec<i64>], stock: &[i64], cost: &[i64]) -> i64
Aegis.MaxNumberOfAlloys.max_number_of_alloys
fn feasible( m: usize, count: i64, composition: &[Vec<i64>], stock: &[i64], cost: &[i64], budget: i64, ) -> bool { let n = stock.len(); let mut j = 0; let mut spent: i64 = 0; while j < n { let need = composition[m][j] * count; if need > stock[j] { let...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [max_number_of_alloys]: type definitions module public import Aeneas @[expose] public section 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_number_of_alloys]: function definitions module public import Aeneas public import Aegis.MaxNumberOfAlloys.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand fals...
import Aegis.MaxNumberOfAlloys.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, 100, [[5]], [0], [20]]", "output": "1" }, { "input": "[2, 2, 20, [[1, 2], [2, 1]], [10, 10], [1, 1]]", "output": "13" }, { "input": "[3, 1, 50, [[10, 10, 10]], [5, 5, 5], [1, 1, 1]]", "output": "2" }, { "input": "[2, 3, 10, [[2, 1], [1, 2], [1, 1]], [1, 1],...
91
false
91
verified
10
10
1
4,969
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MaxNumberOfAlloys.Code.Funs /-! # Specifications of `Aegis.MaxNumberOfAlloys.max_number_of_alloys` LeetCode problem `maximum-number-of-alloys`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.MaxNumberOfAlloys namespace AegisSpec.MaxNumberOfAlloy...
9