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
nth-magical-number
878
Hard
[ "Math", "Binary Search" ]
A positive integer is magical if it is divisible by either a or b. Given the three integers n, a, and b, return the nth magical number. Since the answer may be very large, return it modulo 109 + 7.   Example 1: Input: n = 1, a = 2, b = 3 Output: 2 Example 2: Input: n = 4, a = 2, b = 3 Output: 6   Constraints: 1 <=...
nthMagicalNumber(n: int, a: int, b: int) -> int
pub fn nth_magical_number(n: i64, a: i64, b: i64) -> i64
Aegis.NthMagicalNumber.nth_magical_number
fn gcd(mut x: i64, mut y: i64) -> i64 { while y != 0 { let t = x % y; x = y; y = t; } x } pub fn nth_magical_number(n: i64, a: i64, b: i64) -> i64 { let g = gcd(a, b); let lcm = (a / g) * b; let m = if a < b { a } else { b }; let mut lo: i64 = 1; let mut hi: i64...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [nth_magical_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 li...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [nth_magical_number]: function definitions module public import Aeneas public import Aegis.NthMagicalNumber.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.NthMagicalNumber.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.NthMagicalNumber.nth_magical_number 5#i64 6#i64 5#i64) (15#i64))}") #eval (s!"CASE 1 {(Result.reducesTo (Aegis.NthMagicalNumber.nth_magical_numb...
[ { "input": "[5, 6, 5]", "output": "15" }, { "input": "[10, 3, 7]", "output": "24" }, { "input": "[1000000000, 2, 3]", "output": "499999993" }, { "input": "[10, 7, 3]", "output": "24" }, { "input": "[5, 3, 5]", "output": "10" }, { "input": "[5, 7, 5]", ...
104
false
104
verified
10
10
1
1,605
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.NthMagicalNumber.Code.Funs /-! # Specifications of `Aegis.NthMagicalNumber.nth_magical_number` LeetCode problem `nth-magical-number`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.NthMagicalNumber def MOD : ℤ := 1000000007 def countC...
13
boats-to-save-people
881
Medium
[ "Greedy", "Array", "Two Pointers", "Sorting" ]
You are given an array people where people[i] is the weight of the ith person, and an infinite number of boats where each boat can carry a maximum weight of limit. Each boat carries at most two people at the same time, provided the sum of the weight of those people is at most limit. Return the minimum number of boats t...
numRescueBoats(people: list_int, limit: int) -> int
pub fn num_rescue_boats(people: &[i64], limit: i64) -> i64
Aegis.NumRescueBoats.num_rescue_boats
pub fn num_rescue_boats(people: &[i64], limit: i64) -> i64 { let lim = limit as usize; let mut counts: Vec<i64> = Vec::new(); let mut i = 0usize; while i <= lim { counts.push(0); i += 1; } let mut p = 0usize; while p < people.len() { let w = people[p] as usize; ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [num_rescue_boats]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option lint...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [num_rescue_boats]: function definitions module public import Aeneas public import Aegis.NumRescueBoats.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.NumRescueBoats.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.NumRescueBoats.num_rescue_boats (Slice.from [1#i64, 2#i64] (by scalar_tac) : Slice Std.I64) 3#i64) (1#i64))}") #eval (s!"CASE 1 {(Result.reducesTo...
[ { "input": "[[1, 2], 3]", "output": "1" }, { "input": "[[30, 20, 10], 50]", "output": "2" }, { "input": "[[3, 2, 2, 1], 3]", "output": "3" }, { "input": "[[3, 5, 3, 4], 5]", "output": "4" }, { "input": "[[5, 5, 5, 5, 5], 10]", "output": "3" }, { "input...
89
false
89
verified
10
10
1
1,546
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.NumRescueBoats.Code.Funs /-! # Specifications of `Aegis.NumRescueBoats.num_rescue_boats` LeetCode problem `boats-to-save-people`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.NumRescueBoats open scoped BigOperators namespace AegisSpec.Nu...
14
reachable-nodes-in-subdivided-graph
882
Hard
[ "Graph", "Shortest Path", "Heap (Priority Queue)" ]
You are given an undirected graph (the "original graph") with n nodes labeled from 0 to n - 1. You decide to subdivide each edge in the graph into a chain of nodes, with the number of new nodes varying between each edge. The graph is given as a 2D array of edges where edges[i] = [ui, vi, cnti] indicates that there is a...
reachableNodes(edges: list_list_int, maxMoves: int, n: int) -> int
pub fn reachable_nodes(edges: &[Vec<i64>], maxMoves: i64, n: i64) -> i64
Aegis.ReachableNodes.reachable_nodes
pub fn reachable_nodes(edges: &[Vec<i64>], maxMoves: i64, n: i64) -> i64 { if n <= 0 { return 0; } let n_usize = n as usize; let mut adj: Vec<Vec<i64>> = Vec::new(); let mut i: usize = 0; while i < n_usize { adj.push(Vec::new()); i += 1; } let m = edges.len(); ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [reachable_nodes]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linte...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [reachable_nodes]: function definitions module public import Aeneas public import Aegis.ReachableNodes.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.ReachableNodes.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.ReachableNodes.reachable_nodes (Slice.from [] (by scalar_tac) : Slice (alloc.vec.Vec Std.I64)) 0#i64 1#i64) (1#i64))}") #eval (s!"CASE 1 {(Result....
[ { "input": "[[], 0, 1]", "output": "1" }, { "input": "[[], 5, 1]", "output": "1" }, { "input": "[[], 10, 1]", "output": "1" }, { "input": "[[[0, 1, 5]], 5, 2]", "output": "6" }, { "input": "[[[0, 1, 5]], 10, 2]", "output": "7" }, { "input": "[[[0, 1, 0...
103
false
103
verified
10
10
1
7,402
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.ReachableNodes.Code.Funs /-! # Specifications of `Aegis.ReachableNodes.reachable_nodes` LeetCode problem `reachable-nodes-in-subdivided-graph`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.ReachableNodes abbrev EdgeVec : Type := ...
11
projection-area-of-3d-shapes
883
Easy
[ "Geometry", "Array", "Math", "Matrix" ]
You are given an n x n grid where we place some 1 x 1 x 1 cubes that are axis-aligned with the x, y, and z axes. Each value v = grid[i][j] represents a tower of v cubes placed on top of the cell (i, j). We view the projection of these cubes onto the xy, yz, and zx planes. A projection is like a shadow, that maps our 3-...
projectionArea(grid: list_list_int) -> int
pub fn projection_area(grid: &[Vec<i64>]) -> i64
Aegis.ProjectionArea.projection_area
pub fn projection_area(grid: &[Vec<i64>]) -> i64 { let n = grid.len(); let mut total: i64 = 0; let mut i: usize = 0; while i < n { let row = &grid[i]; let mut row_max: i64 = 0; let mut j: usize = 0; while j < row.len() { let v = row[j]; if v > 0 ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [projection_area]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linte...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [projection_area]: function definitions module public import Aeneas public import Aegis.ProjectionArea.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.ProjectionArea.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.ProjectionArea.projection_area (Slice.from [(alloc.vec.Vec.from [2#i64] (by scalar_tac) : alloc.vec.Vec Std.I64)] (by scalar_tac) : Slice (alloc.v...
[ { "input": "[[[2]]]", "output": "5" }, { "input": "[[[1, 2], [3, 4]]]", "output": "17" }, { "input": "[[[1, 0], [0, 2]]]", "output": "8" }, { "input": "[[[2, 2, 2], [2, 1, 2], [2, 2, 2]]]", "output": "21" }, { "input": "[[[1, 1, 1], [1, 0, 1], [1, 1, 1]]]", "o...
72
false
72
verified
10
10
1
836
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.ProjectionArea.Code.Funs /-! # Specifications of `Aegis.ProjectionArea.projection_area` LeetCode problem `projection-area-of-3d-shapes`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open scoped BigOperators namespace AegisSpec.ProjectionArea def nrows (...
11
uncommon-words-from-two-sentences
884
Easy
[ "Hash Table", "String", "Counting" ]
A sentence is a string of single-space separated words where each word consists only of lowercase letters. A word is uncommon if it appears exactly once in one of the sentences, and does not appear in the other sentence. Given two sentences s1 and s2, return a list of all the uncommon words. You may return the answer i...
uncommonFromSentences(s1: str, s2: str) -> list_str
pub fn uncommon_from_sentences(s1: &[u8], s2: &[u8]) -> Vec<Vec<u8>>
Aegis.UncommonFromSentences.uncommon_from_sentences
pub fn uncommon_from_sentences(s1: &[u8], s2: &[u8]) -> Vec<Vec<u8>> { let w1 = split_words(s1); let w2 = split_words(s2); let mut out: Vec<Vec<u8>> = Vec::new(); let mut i: usize = 0; while i < w1.len() { let mut count: i64 = 0; let mut j: usize = 0; while j < w1.len() { ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [uncommon_from_sentences]: type definitions module public import Aeneas @[expose] public 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 -- [uncommon_from_sentences]: function definitions module public import Aeneas public import Aegis.UncommonFromSentences.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashComma...
import Aegis.UncommonFromSentences.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(match (Aegis.UncommonFromSentences.uncommon_from_sentences (Slice.from [115#u8, 97#u8, 109#u8, 101#u8, 32#u8, 115#u8, 97#u8, 109#u8, 101#u8] (by scalar_tac) : Slic...
[ { "input": "[\"same same\", \"same same\"]", "output": "[]" }, { "input": "[\"one two three\", \"three two one\"]", "output": "[]" }, { "input": "[\"shared unique shared\", \"unique shared unique\"]", "output": "[]" }, { "input": "[\"abc def ghi jkl mno pqr stu vwx yz\", \"st...
130
true
130
verified
10
10
1
6,206
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.UncommonFromSentences.Code.Funs /-! # Specifications of `Aegis.UncommonFromSentences.uncommon_from_sentences` LeetCode problem `uncommon-words-from-two-sentences`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.UncommonFromSentences ...
2
spiral-matrix-iii
885
Medium
[ "Array", "Matrix", "Simulation" ]
You start at the cell (rStart, cStart) of an rows x cols grid facing east. The northwest corner is at the first row and column in the grid, and the southeast corner is at the last row and column. You will walk in a clockwise spiral shape to visit every position in this grid. Whenever you move outside the grid's boundar...
spiralMatrixIII(rows: int, cols: int, rStart: int, cStart: int) -> list_list_int
pub fn spiral_matrix_iii(rows: i64, cols: i64, rStart: i64, cStart: i64) -> Vec<Vec<i64>>
Aegis.SpiralMatrixIii.spiral_matrix_iii
pub fn spiral_matrix_iii(rows: i64, cols: i64, rStart: i64, cStart: i64) -> Vec<Vec<i64>> { let total: i64 = rows * cols; let mut out: Vec<Vec<i64>> = Vec::new(); let mut r: i64 = rStart; let mut c: i64 = cStart; let mut first: Vec<i64> = Vec::new(); first.push(r); first.push(c); out.p...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [spiral_matrix_iii]: type definitions module public import Aeneas @[expose] public section 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 -- [spiral_matrix_iii]: function definitions module public import Aeneas public import Aegis.SpiralMatrixIii.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.SpiralMatrixIii.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.SpiralMatrixIii.spiral_matrix_iii 1#i64 4#i64 0#i64 0#i64) ((alloc.vec.Vec.from [(alloc.vec.Vec.from [0#i64, 0#i64] (by scalar_tac) : alloc.vec.V...
[ { "input": "[1, 4, 0, 0]", "output": "[[0, 0], [0, 1], [0, 2], [0, 3]]" }, { "input": "[2, 3, 0, 1]", "output": "[[0, 1], [0, 2], [1, 2], [1, 1], [1, 0], [0, 0]]" }, { "input": "[3, 3, 1, 1]", "output": "[[1, 1], [1, 2], [2, 2], [2, 1], [2, 0], [1, 0], [0, 0], [0, 1], [0, 2]]" }, ...
70
false
70
verified
10
10
1
9,910
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.SpiralMatrixIii.Code.Funs /-! # Specifications of `Aegis.SpiralMatrixIii.spiral_matrix_iii` LeetCode problem `spiral-matrix-iii`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.SpiralMatrixIii def IsInBox (rows cols : ℤ) (p : ℤ × ℤ) : ...
11
possible-bipartition
886
Medium
[ "Depth-First Search", "Breadth-First Search", "Union Find", "Graph" ]
We want to split a group of n people (labeled from 1 to n) into two groups of any size. Each person may dislike some other people, and they should not go into the same group. Given the integer n and the array dislikes where dislikes[i] = [ai, bi] indicates that the person labeled ai does not like the person labeled bi,...
possibleBipartition(n: int, dislikes: list_list_int) -> bool
pub fn possible_bipartition(n: i64, dislikes: &[Vec<i64>]) -> bool
Aegis.PossibleBipartition.possible_bipartition
pub fn possible_bipartition(n: i64, dislikes: &[Vec<i64>]) -> bool { let m = n as usize + 1; // color[v] = -1 (unvisited), 0 or 1 (the two groups) let mut color: Vec<i64> = Vec::new(); let mut ci: usize = 0; while ci < m { color.push(-1); ci += 1; } let mut ok: bool = true;...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [possible_bipartition]: type definitions module public import Aeneas @[expose] public section 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 -- [possible_bipartition]: function definitions module public import Aeneas public import Aegis.PossibleBipartition.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand fa...
import Aegis.PossibleBipartition.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.PossibleBipartition.possible_bipartition 1#i64 (Slice.from [] (by scalar_tac) : Slice (alloc.vec.Vec Std.I64))) (true))}") #eval (s!"CASE 1 {...
[ { "input": "[1, []]", "output": "true" }, { "input": "[3, [[1, 2]]]", "output": "true" }, { "input": "[3, [[1, 2], [2, 3]]]", "output": "true" }, { "input": "[5, [[1, 2], [3, 4]]]", "output": "true" }, { "input": "[4, [[1, 2], [1, 3], [2, 4]]]", "output": "tru...
76
false
76
verified
10
10
3
37,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.PossibleBipartition.Code.Funs /-! # Specifications of `Aegis.PossibleBipartition.possible_bipartition` LeetCode problem `possible-bipartition`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.PossibleBipartition def entries (dislike...
10
super-egg-drop
887
Hard
[ "Math", "Binary Search", "Dynamic Programming" ]
You are given k identical eggs and you have access to a building with n floors labeled from 1 to n. You know that there exists a floor f where 0 <= f <= n such that any egg dropped at a floor higher than f will break, and any egg dropped at or below floor f will not break. Each move, you may take an unbroken egg and dr...
superEggDrop(k: int, n: int) -> int
pub fn super_egg_drop(k: i64, n: i64) -> i64
Aegis.SuperEggDrop.super_egg_drop
pub fn super_egg_drop(k: i64, n: i64) -> i64 { if n <= 0 { return 0; } if k <= 0 { return 0; } let kk = k as usize; let target = n; let mut dp: Vec<i64> = Vec::new(); let mut i = 0usize; while i <= kk { dp.push(0); i += 1; } let mut moves: i...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [super_egg_drop]: type definitions module public import Aeneas @[expose] public section 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 -- [super_egg_drop]: function definitions module public import Aeneas public import Aegis.SuperEggDrop.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.SuperEggDrop.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.SuperEggDrop.super_egg_drop 2#i64 1#i64) (1#i64))}") #eval (s!"CASE 1 {(Result.reducesTo (Aegis.SuperEggDrop.super_egg_drop 5#i64 1000#i64) (11#i64)...
[ { "input": "[2, 1]", "output": "1" }, { "input": "[5, 1000]", "output": "11" }, { "input": "[1, 100]", "output": "100" }, { "input": "[1, 2]", "output": "2" }, { "input": "[2, 6]", "output": "3" }, { "input": "[50, 10000]", "output": "14" }, { ...
92
false
92
verified
10
10
1
1,514
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.SuperEggDrop.Code.Funs /-! # Specifications of `Aegis.SuperEggDrop.super_egg_drop` LeetCode problem `super-egg-drop`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.SuperEggDrop def binomial (m i : ℕ) : ℕ := m.choose i def F (e m : ℕ)...
14
construct-binary-tree-from-preorder-and-postorder-traversal
889
Medium
[ "Tree", "Array", "Hash Table", "Divide and Conquer", "Binary Tree" ]
Given two integer arrays, preorder and postorder where preorder is the preorder traversal of a binary tree of distinct values and postorder is the postorder traversal of the same tree, reconstruct and return the binary tree. If there exist multiple answers, you can return any of them.   Example 1: Input: preorder = [...
constructFromPrePost(preorder: list_int, postorder: list_int) -> tree
pub fn construct_from_pre_post(preorder: &[i64], postorder: &[i64]) -> Tree
Aegis.ConstructFromPrePost.construct_from_pre_post
fn find_in_post(postorder: &[i64], start: usize, end: usize, target: i64) -> usize { let mut i = start; while i < end { if postorder[i] == target { return i; } i += 1; } start } fn build_tree( preorder: &[i64], postorder: &[i64], pre_l: usize, pre_r: ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [construct_from_pre_post]: type definitions module public import Aeneas @[expose] public 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 -- [construct_from_pre_post]: function definitions module public import Aeneas public import Aegis.ConstructFromPrePost.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashComman...
import Aegis.ConstructFromPrePost.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 deriving instance DecidableEq for Aegis.ConstructFromPrePost.Tree #eval (s!"CASE 0 {(match (Aegis.ConstructFromPrePost.construct_from_pre_post (Slice.from [1#i64] (by scalar_tac) : S...
[ { "input": "[[1], [1]]", "output": "[1]" }, { "input": "[[1, 3, 2], [3, 2, 1]]", "output": "[1, 3, 2]" }, { "input": "[[1, 2, 3], [2, 3, 1]]", "output": "[1, 2, 3]" }, { "input": "[[1, 2, 4, 5, 3], [4, 5, 2, 3, 1]]", "output": "[1, 2, 3, 4, 5]" }, { "input": "[[1,...
29
false
29
verified
10
10
1
12,198
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.ConstructFromPrePost.Code.Funs /-! # Specifications of `Aegis.ConstructFromPrePost.construct_from_pre_post` LeetCode problem `construct-binary-tree-from-preorder-and-postorder-traversal`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec...
8
sum-of-subsequence-widths
891
Hard
[ "Array", "Math", "Sorting" ]
The width of a sequence is the difference between the maximum and minimum elements in the sequence. Given an array of integers nums, return the sum of the widths of all the non-empty subsequences of nums. Since the answer may be very large, return it modulo 109 + 7. A subsequence is a sequence that can be derived from ...
sumSubseqWidths(nums: list_int) -> int
pub fn sum_subseq_widths(nums: &[i64]) -> i64
Aegis.SumSubseqWidths.sum_subseq_widths
pub fn sum_subseq_widths(nums: &[i64]) -> i64 { let n = nums.len(); if n <= 1 { return 0; } let mut a: Vec<i64> = Vec::new(); let mut i: usize = 0; while i < n { a.push(nums[i]); i += 1; } // Build a max-heap. let mut start: usize = n / 2; while start > ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [sum_subseq_widths]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option lin...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [sum_subseq_widths]: function definitions module public import Aeneas public import Aegis.SumSubseqWidths.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.SumSubseqWidths.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := 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": "0" }, { "input": "[[2]]", "output": "0" }, { "input": "[[100000]]", "output": "0" }, { "input": "[[1, 100000]]", "output": "99999" }, { "input": "[[10, 20, 30]]", "output": "60" }, { "input": "[[2, 1, 3]]", "output": ...
86
false
86
verified
10
10
2
13,732
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.SumSubseqWidths.Code.Funs /-! # Specifications of `Aegis.SumSubseqWidths.sum_subseq_widths` LeetCode problem `sum-of-subsequence-widths`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.SumSubseqWidths def modulus : Int := 1000000007 d...
6
groups-of-special-equivalent-strings
893
Medium
[ "Array", "Hash Table", "String", "Sorting" ]
You are given an array of strings of the same length words. In one move, you can swap any two even indexed characters or any two odd indexed characters of a string words[i]. Two strings words[i] and words[j] are special-equivalent if after any number of moves, words[i] == words[j]. For example, words[i] = "zzxy" and w...
numSpecialEquivGroups(words: list_str) -> int
pub fn num_special_equiv_groups(words: &[Vec<u8>]) -> i64
Aegis.NumSpecialEquivGroups.num_special_equiv_groups
pub fn num_special_equiv_groups(words: &[Vec<u8>]) -> i64 { let mut seen: Vec<Vec<i64>> = Vec::new(); let mut groups: i64 = 0; let mut wi: usize = 0; while wi < words.len() { let mut sig: Vec<i64> = Vec::new(); let mut k: usize = 0; while k < 52 { sig.push(0); ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [num_special_equiv_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_opt...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [num_special_equiv_groups]: function definitions module public import Aeneas public import Aegis.NumSpecialEquivGroups.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashComm...
import Aegis.NumSpecialEquivGroups.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.NumSpecialEquivGroups.num_special_equiv_groups (Slice.from [(alloc.vec.Vec.from [97#u8, 98#u8, 99#u8, 100#u8] (by scalar_tac) : alloc.vec.V...
[ { "input": "[[\"abcd\", \"abdc\", \"cdab\", \"cdba\"]]", "output": "3" }, { "input": "[[\"abcde\", \"edcba\", \"abced\", \"decba\"]]", "output": "2" }, { "input": "[[\"aabb\", \"bbaa\", \"abab\", \"baba\"]]", "output": "3" }, { "input": "[[\"abcd\", \"abdc\", \"cdab\", \"cdba...
81
false
81
verified
10
10
1
1,925
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.NumSpecialEquivGroups.Code.Funs /-! # Specifications of `Aegis.NumSpecialEquivGroups.num_special_equiv_groups` LeetCode problem `groups-of-special-equivalent-strings`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.NumSpecialEquivGroups...
12
monotonic-array
896
Easy
[ "Array" ]
An array is monotonic if it is either monotone increasing or monotone decreasing. An array nums is monotone increasing if for all i <= j, nums[i] <= nums[j]. An array nums is monotone decreasing if for all i <= j, nums[i] >= nums[j]. Given an integer array nums, return true if the given array is monotonic, or false oth...
isMonotonic(nums: list_int) -> bool
pub fn is_monotonic(nums: &[i64]) -> bool
Aegis.IsMonotonic.is_monotonic
pub fn is_monotonic(nums: &[i64]) -> bool { let n = nums.len(); let mut increasing: bool = true; let mut decreasing: bool = true; let mut i: usize = 1; while i < n { if nums[i] < nums[i - 1] { increasing = false; } if nums[i] > nums[i - 1] { decreasin...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [is_monotonic]: type definitions module public import Aeneas @[expose] public section 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 -- [is_monotonic]: function definitions module public import Aeneas public import Aegis.IsMonotonic.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.IsMonotonic.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.IsMonotonic.is_monotonic (Slice.from [1#i64] (by scalar_tac) : Slice Std.I64)) (true))}") #eval (s!"CASE 1 {(Result.reducesTo (Aegis.IsMonotonic.is_m...
[ { "input": "[[1]]", "output": "true" }, { "input": "[[5]]", "output": "true" }, { "input": "[[-100000, 100000]]", "output": "true" }, { "input": "[[100000, -100000]]", "output": "true" }, { "input": "[[1, 1, 1]]", "output": "true" }, { "input": "[[-100...
151
false
151
verified
10
10
1
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.IsMonotonic.Code.Funs /-! # Specifications of `Aegis.IsMonotonic.is_monotonic` LeetCode problem `monotonic-array`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.IsMonotonic def len (s : Slice Std.I64) : Nat := s.val.length def nth (s...
15
increasing-order-search-tree
897
Easy
[ "Stack", "Tree", "Depth-First Search", "Binary Search Tree", "Binary Tree" ]
Given the root of a binary search tree, rearrange the tree in in-order so that the leftmost node in the tree is now the root of the tree, and every node has no left child and only one right child.   Example 1: Input: root = [5,3,6,2,4,null,8,1,null,null,null,7,9] Output: [1,null,2,null,3,null,4,null,5,null,6,null,7,n...
increasingBST(root: tree) -> tree
pub fn increasing_bst(root: &Tree) -> Tree
Aegis.IncreasingBst.increasing_bst
fn collect_inorder(t: &Tree) -> Vec<i64> { let mut out: Vec<i64> = Vec::new(); match t { Tree::Null => {} Tree::Node(v, l, r) => { let left_vals = collect_inorder(l); let mut i: usize = 0; while i < left_vals.len() { out.push(left_vals[i]); ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [increasing_bst]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [increasing_bst]: function definitions module public import Aeneas public import Aegis.IncreasingBst.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.IncreasingBst.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 deriving instance DecidableEq for Aegis.IncreasingBst.Tree #eval (s!"CASE 0 {(match (Aegis.IncreasingBst.increasing_bst ((.Node 1#i64 (.Null) (.Null)) : Aegis.IncreasingBst.Tree)).match wit...
[ { "input": "[[1]]", "output": "[1]" }, { "input": "[[5, 1, 7]]", "output": "[1, null, 5, null, 7]" }, { "input": "[[7, 4, 9, 2, 6, 8, 10, 1, 3, 5]]", "output": "[1, null, 2, null, 3, null, 4, null, 5, null, 6, null, 7, null, 8, null, 9, null, 10]" }, { "input": "[[20, 10, 30,...
24
false
24
verified
10
10
1
3,585
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.IncreasingBst.Code.Funs /-! # Specifications of `Aegis.IncreasingBst.increasing_bst` LeetCode problem `increasing-order-search-tree`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.IncreasingBst open Aegis.IncreasingBst def node...
12
bitwise-ors-of-subarrays
898
Medium
[ "Bit Manipulation", "Array", "Dynamic Programming" ]
Given an integer array arr, return the number of distinct bitwise ORs of all the non-empty subarrays of arr. The bitwise OR of a subarray is the bitwise OR of each integer in the subarray. The bitwise OR of a subarray of one integer is that integer. A subarray is a contiguous non-empty sequence of elements within an ar...
subarrayBitwiseORs(arr: list_int) -> int
pub fn subarray_bitwise_o_rs(arr: &[i64]) -> i64
Aegis.SubarrayBitwiseORs.subarray_bitwise_o_rs
pub fn subarray_bitwise_o_rs(arr: &[i64]) -> i64 { let mut cap: usize = 8; let mut table: Vec<i64> = Vec::new(); let mut z: usize = 0; while z < cap { table.push(-1); z += 1; } let mut used: usize = 0; let mut count: i64 = 0; let mut prev: Vec<i64> = Vec::new(); let...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [subarray_bitwise_o_rs]: type definitions module public import Aeneas @[expose] public section 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 -- [subarray_bitwise_o_rs]: function definitions module public import Aeneas public import Aegis.SubarrayBitwiseORs.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand fa...
import Aegis.SubarrayBitwiseORs.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.SubarrayBitwiseORs.subarray_bitwise_o_rs (Slice.from [0#i64] (by scalar_tac) : Slice Std.I64)) (1#i64))}") #eval (s!"CASE 1 {(Result.reducesTo...
[ { "input": "[[0]]", "output": "1" }, { "input": "[[8, 16, 32]]", "output": "6" }, { "input": "[[1, 1, 2]]", "output": "3" }, { "input": "[[1, 0, 1]]", "output": "2" }, { "input": "[[1, 2, 4]]", "output": "6" }, { "input": "[[0, 0, 0]]", "output": "...
93
false
93
verified
10
10
1
7,734
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.SubarrayBitwiseORs.Code.Funs /-! # Specifications of `Aegis.SubarrayBitwiseORs.subarray_bitwise_o_rs` LeetCode problem `bitwise-ors-of-subarrays`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result set_option autoImplicit false namespace AegisSpec.Subarra...
9
numbers-at-most-n-given-digit-set
902
Hard
[ "Array", "Math", "String", "Binary Search", "Dynamic Programming" ]
Given an array of digits which is sorted in non-decreasing order. You can write numbers using each digits[i] as many times as we want. For example, if digits = ['1','3','5'], we may write numbers such as '13', '551', and '1351315'. Return the number of positive integers that can be generated that are less than or equal...
atMostNGivenDigitSet(digits: list_str, n: int) -> int
pub fn at_most_n_given_digit_set(digits: &[Vec<u8>], n: i64) -> i64
Aegis.AtMostNGivenDigitSet.at_most_n_given_digit_set
pub fn at_most_n_given_digit_set(digits: &[Vec<u8>], n: i64) -> i64 { let m = digits.len(); let mut ds: Vec<i64> = Vec::new(); let mut md: i64 = 0; let mut i: usize = 0; while i < m { let b = digits[i][0]; let mut v: i64 = 0; if b == b'1' { v = 1; } els...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [at_most_n_given_digit_set]: type definitions module public import Aeneas @[expose] public 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 -- [at_most_n_given_digit_set]: function definitions module public import Aeneas public import Aegis.AtMostNGivenDigitSet.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashComm...
import Aegis.AtMostNGivenDigitSet.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.AtMostNGivenDigitSet.at_most_n_given_digit_set (Slice.from [(alloc.vec.Vec.from [55#u8] (by scalar_tac) : alloc.vec.Vec Std.U8)] (by scalar_...
[ { "input": "[[\"7\"], 8]", "output": "1" }, { "input": "[[\"5\"], 1000000000]", "output": "9" }, { "input": "[[\"9\"], 999999999]", "output": "9" }, { "input": "[[\"1\"], 1000000000]", "output": "9" }, { "input": "[[\"1\"], 1000000]", "output": "6" }, { ...
113
false
113
verified
10
10
1
5,615
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.AtMostNGivenDigitSet.Code.Funs /-! # Specifications of `Aegis.AtMostNGivenDigitSet.at_most_n_given_digit_set` LeetCode problem `numbers-at-most-n-given-digit-set`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result set_option autoImplicit false open Aegis...
16
valid-permutations-for-di-sequence
903
Hard
[ "String", "Dynamic Programming", "Prefix Sum" ]
You are given a string s of length n where s[i] is either: 'D' means decreasing, or 'I' means increasing. A permutation perm of n + 1 integers of all the integers in the range [0, n] is called a valid permutation if for all valid i: If s[i] == 'D', then perm[i] > perm[i + 1], and If s[i] == 'I', then perm[i] < perm[...
numPermsDISequence(s: str) -> int
pub fn num_perms_di_sequence(s: &[u8]) -> i64
Aegis.NumPermsDiSequence.num_perms_di_sequence
pub fn num_perms_di_sequence(s: &[u8]) -> i64 { const MOD: i64 = 1000000007; let n: usize = s.len(); let mut dp: Vec<i64> = Vec::new(); dp.push(1); let mut i: usize = 0; while i < n { let len: usize = dp.len(); let mut next: Vec<i64> = Vec::new(); if s[i] == b'I' { ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [num_perms_di_sequence]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [num_perms_di_sequence]: function definitions module public import Aeneas public import Aegis.NumPermsDiSequence.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand fa...
import Aegis.NumPermsDiSequence.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.NumPermsDiSequence.num_perms_di_sequence (Slice.from [68#u8, 68#u8, 68#u8, 68#u8, 68#u8, 68#u8, 68#u8, 68#u8, 68#u8, 68#u8, 68#u8, 68#u8] (by ...
[ { "input": "[\"DDDDDDDDDDDD\"]", "output": "1" }, { "input": "[\"DII\"]", "output": "3" }, { "input": "[\"IIDII\"]", "output": "19" }, { "input": "[\"DIDDDDDD\"]", "output": "35" }, { "input": "[\"IIIIIIIIIIII\"]", "output": "1" }, { "input": "[\"DDI\"...
247
false
247
verified
10
10
1
5,184
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.NumPermsDiSequence.Code.Funs /-! # Specifications of `Aegis.NumPermsDiSequence.num_perms_di_sequence` LeetCode problem `valid-permutations-for-di-sequence`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result ControlFlow Error namespace AegisSpec.NumPermsDiSe...
10
fruit-into-baskets
904
Medium
[ "Array", "Hash Table", "Sliding Window" ]
You are visiting a farm that has a single row of fruit trees arranged from left to right. The trees are represented by an integer array fruits where fruits[i] is the type of fruit the ith tree produces. You want to collect as much fruit as possible. However, the owner has some strict rules that you must follow: You on...
totalFruit(fruits: list_int) -> int
pub fn total_fruit(fruits: &[i64]) -> i64
Aegis.TotalFruit.total_fruit
pub fn total_fruit(fruits: &[i64]) -> i64 { let n = fruits.len(); let mut left: usize = 0; let mut right: usize = 0; let mut type_a: i64 = -1; let mut type_b: i64 = -1; let mut count_a: i64 = 0; let mut count_b: i64 = 0; let mut best: i64 = 0; while right < n { let f = fru...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [total_fruit]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter.st...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [total_fruit]: function definitions module public import Aeneas public import Aegis.TotalFruit.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.TotalFruit.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.TotalFruit.total_fruit (Slice.from [0#i64] (by scalar_tac) : Slice Std.I64)) (1#i64))}") #eval (s!"CASE 1 {(Result.reducesTo (Aegis.TotalFruit.total_f...
[ { "input": "[[0]]", "output": "1" }, { "input": "[[1]]", "output": "1" }, { "input": "[[1, 2, 1]]", "output": "3" }, { "input": "[[0, 0, 1, 1]]", "output": "4" }, { "input": "[[0, 1, 2, 2]]", "output": "3" }, { "input": "[[1, 2, 3, 2, 2]]", "output...
98
false
98
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.TotalFruit.Code.Funs /-! # Specifications of `Aegis.TotalFruit.total_fruit` LeetCode problem `fruit-into-baskets`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.TotalFruit def window (l : List Std.I64) (s m : Nat) : List Std.I64 := (l...
11
sort-array-by-parity
905
Easy
[ "Array", "Two Pointers", "Sorting" ]
Given an integer array nums, move all the even integers at the beginning of the array followed by all the odd integers. Return any array that satisfies this condition.   Example 1: Input: nums = [3,1,2,4] Output: [2,4,3,1] Explanation: The outputs [4,2,3,1], [2,4,1,3], and [4,2,1,3] would also be accepted. Example 2:...
sortArrayByParity(nums: list_int) -> list_int
pub fn sort_array_by_parity(nums: &[i64]) -> Vec<i64>
Aegis.SortArrayByParity.sort_array_by_parity
pub fn sort_array_by_parity(nums: &[i64]) -> Vec<i64> { let mut res: Vec<i64> = Vec::new(); let mut k: usize = 0; while k < nums.len() { res.push(nums[k]); k += 1; } let n: usize = nums.len(); if n == 0 { return res; } let mut i: usize = 0; let mut j: usize ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [sort_array_by_parity]: type definitions module public import Aeneas @[expose] public section 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 -- [sort_array_by_parity]: function definitions module public import Aeneas public import Aegis.SortArrayByParity.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand fals...
import Aegis.SortArrayByParity.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.SortArrayByParity.sort_array_by_parity (Slice.from [1#i64] (by scalar_tac) : Slice Std.I64)) ((alloc.vec.Vec.from [1#i64] (by scalar_tac) : all...
[ { "input": "[[1]]", "output": "[1]" }, { "input": "[[2]]", "output": "[2]" }, { "input": "[[0]]", "output": "[0]" }, { "input": "[[2, 1]]", "output": "[2, 1]" }, { "input": "[[1, 2]]", "output": "[2, 1]" }, { "input": "[[3, 1, 2, 4]]", "output": "[...
98
false
98
verified
10
10
1
1,718
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.SortArrayByParity.Code.Funs /-! # Specifications of `Aegis.SortArrayByParity.sort_array_by_parity` LeetCode problem `sort-array-by-parity`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.SortArrayByParity def countVal (l : List Std.I64...
10
sum-of-subarray-minimums
907
Medium
[ "Stack", "Array", "Dynamic Programming", "Monotonic Stack" ]
Given an array of integers arr, find the sum of min(b), where b ranges over every (contiguous) subarray of arr. Since the answer may be large, return the answer modulo 109 + 7.   Example 1: Input: arr = [3,1,2,4] Output: 17 Explanation: Subarrays are [3], [1], [2], [4], [3,1], [1,2], [2,4], [3,1,2], [1,2,4], [3,1,2,4...
sumSubarrayMins(arr: list_int) -> int
pub fn sum_subarray_mins(arr: &[i64]) -> i64
Aegis.SumSubarrayMins.sum_subarray_mins
pub fn sum_subarray_mins(arr: &[i64]) -> i64 { let n = arr.len(); let modv: i64 = 1000000007; let mut left: Vec<i64> = Vec::new(); let mut stack: Vec<usize> = Vec::new(); let mut i: usize = 0; while i < n { while stack.len() > 0 { let top = stack[stack.len() - 1]; ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [sum_subarray_mins]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option lin...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [sum_subarray_mins]: function definitions module public import Aeneas public import Aegis.SumSubarrayMins.Code.Types public import Aegis.SumSubarrayMins.Code.FunsExternal @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupN...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [sum_subarray_mins]: external functions. -- This is a template file: rename it to "FunsExternal.lean" and fill the holes. module public import Aeneas public import Aegis.SumSubarrayMins.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Er...
import Aegis.SumSubarrayMins.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.SumSubarrayMins.sum_subarray_mins (Slice.from [1#i64] (by scalar_tac) : Slice Std.I64)) (1#i64))}") #eval (s!"CASE 1 {(Result.reducesTo (Aegis.Su...
[ { "input": "[[1]]", "output": "1" }, { "input": "[[1, 2, 2, 1]]", "output": "13" }, { "input": "[[3, 1, 2, 4]]", "output": "17" }, { "input": "[[5, 4, 3, 2, 1]]", "output": "35" }, { "input": "[[9, 7, 5, 3, 1]]", "output": "55" }, { "input": "[[10, 20,...
93
false
93
verified
10
10
1
6,078
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.SumSubarrayMins.Code.Funs /-! # Specifications of `Aegis.SumSubarrayMins.sum_subarray_mins` LeetCode problem `sum-of-subarray-minimums`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.SumSubarrayMins def modulus : Int := 1000000007...
11
smallest-range-i
908
Easy
[ "Array", "Math" ]
You are given an integer array nums and an integer k. In one operation, you can choose any index i where 0 <= i < nums.length and change nums[i] to nums[i] + x where x is an integer from the range [-k, k]. You can apply this operation at most once for each index i. The score of nums is the difference between the maximu...
smallestRangeI(nums: list_int, k: int) -> int
pub fn smallest_range_i(nums: &[i64], k: i64) -> i64
Aegis.SmallestRangeI.smallest_range_i
pub fn smallest_range_i(nums: &[i64], k: i64) -> i64 { let n = nums.len(); if n == 0 { return 0; } let mut mn = nums[0]; let mut mx = nums[0]; let mut i: usize = 1; while i < n { let v = nums[i]; if v < mn { mn = v; } if v > mx { ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [smallest_range_i]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option lint...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [smallest_range_i]: function definitions module public import Aeneas public import Aegis.SmallestRangeI.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.SmallestRangeI.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.SmallestRangeI.smallest_range_i (Slice.from [1#i64] (by scalar_tac) : Slice Std.I64) 0#i64) (0#i64))}") #eval (s!"CASE 1 {(Result.reducesTo (Aegis...
[ { "input": "[[1], 0]", "output": "0" }, { "input": "[[1, 10000], 10000]", "output": "0" }, { "input": "[[1, 10000], 5000]", "output": "0" }, { "input": "[[0, 10], 2]", "output": "6" }, { "input": "[[1, 10000], 5000]", "output": "0" }, { "input": "[[1, ...
126
false
126
verified
10
10
1
444
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.SmallestRangeI.Code.Funs /-! # Specifications of `Aegis.SmallestRangeI.smallest_range_i` LeetCode problem `smallest-range-i`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.SmallestRangeI def values (s : Aeneas.Std.Slice Aeneas.Std...
11
smallest-range-ii
910
Medium
[ "Greedy", "Array", "Math", "Sorting" ]
You are given an integer array nums and an integer k. For each index i where 0 <= i < nums.length, change nums[i] to be either nums[i] + k or nums[i] - k. The score of nums is the difference between the maximum and minimum elements in nums. Return the minimum score of nums after changing the values at each index.   Exa...
smallestRangeII(nums: list_int, k: int) -> int
pub fn smallest_range_ii(nums: &[i64], k: i64) -> i64
Aegis.SmallestRangeIi.smallest_range_ii
pub fn smallest_range_ii(nums: &[i64], k: i64) -> i64 { let n = nums.len(); if n == 0 { return 0; } let mut a: Vec<i64> = Vec::new(); let mut i = 0; while i < n { a.push(nums[i]); i += 1; } let mut start = n / 2; while start > 0 { start -= 1; ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [smallest_range_ii]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option lin...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [smallest_range_ii]: function definitions module public import Aeneas public import Aegis.SmallestRangeIi.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.SmallestRangeIi.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.SmallestRangeIi.smallest_range_ii (Slice.from [1#i64] (by scalar_tac) : Slice Std.I64) 0#i64) (0#i64))}") #eval (s!"CASE 1 {(Result.reducesTo (Ae...
[ { "input": "[[1], 0]", "output": "0" }, { "input": "[[0, 10], 2]", "output": "6" }, { "input": "[[1, 5, 8], 2]", "output": "3" }, { "input": "[[4, 9, 6], 2]", "output": "2" }, { "input": "[[1, 3, 6], 3]", "output": "3" }, { "input": "[[6, 3, 4, 7], 3]"...
107
false
107
verified
10
10
1
7,737
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.SmallestRangeIi.Code.Funs /-! # Specifications of `Aegis.SmallestRangeIi.smallest_range_ii` LeetCode problem `smallest-range-ii`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.SmallestRangeIi open Aegis.SmallestRangeIi def ival...
10
sort-an-array
912
Medium
[ "Array", "Divide and Conquer", "Bucket Sort", "Counting Sort", "Radix Sort", "Sorting", "Heap (Priority Queue)", "Merge Sort" ]
Given an array of integers nums, sort the array in ascending order and return it. You must solve the problem without using any built-in functions in O(nlog(n)) time complexity and with the smallest space complexity possible.   Example 1: Input: nums = [5,2,3,1] Output: [1,2,3,5] Explanation: After sorting the array, t...
sortArray(nums: list_int) -> list_int
pub fn sort_array(nums: &[i64]) -> Vec<i64>
Aegis.SortArray.sort_array
pub fn sort_array(nums: &[i64]) -> Vec<i64> { let mut a: Vec<i64> = Vec::new(); let mut i: usize = 0; while i < nums.len() { a.push(nums[i]); i = i + 1; } let n: usize = a.len(); if n > 1 { let mut start: usize = n / 2; while start > 0 { start = start...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [sort_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.sty...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [sort_array]: function definitions module public import Aeneas public import Aegis.SortArray.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.SortArray.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.SortArray.sort_array (Slice.from [0#i64] (by scalar_tac) : Slice Std.I64)) ((alloc.vec.Vec.from [0#i64] (by scalar_tac) : alloc.vec.Vec Std.I64)))}") #...
[ { "input": "[[0]]", "output": "[0]" }, { "input": "[[-1]]", "output": "[-1]" }, { "input": "[[50000]]", "output": "[50000]" }, { "input": "[[-50000]]", "output": "[-50000]" }, { "input": "[[1]]", "output": "[1]" } ]
5
false
5
verified
5
5
1
2,655
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.SortArray.Code.Funs /-! # Specifications of `Aegis.SortArray.sort_array` LeetCode problem `sort-an-array`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.SortArray namespace AegisSpec.SortArray def vals (l : List Std.I64) : List Int := l.map (f...
11
cat-and-mouse
913
Hard
[ "Graph", "Topological Sort", "Memoization", "Math", "Dynamic Programming", "Game Theory" ]
A game on an undirected graph is played by two players, Mouse and Cat, who alternate turns. The graph is given as follows: graph[a] is a list of all nodes b such that ab is an edge of the graph. The mouse starts at node 1 and goes first, the cat starts at node 2 and goes second, and there is a hole at node 0. During ea...
catMouseGame(graph: list_list_int) -> int
pub fn cat_mouse_game(graph: &[Vec<i64>]) -> i64
Aegis.CatMouseGame.cat_mouse_game
pub fn cat_mouse_game(graph: &[Vec<i64>]) -> i64 { let n = graph.len(); let total = n * n * 2; let mut res: Vec<i64> = Vec::new(); let mut degree: Vec<i64> = Vec::new(); let mut z = 0; while z < total { res.push(0); degree.push(0); z += 1; } let mut queue: Vec<i...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [cat_mouse_game]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [cat_mouse_game]: function definitions module public import Aeneas public import Aegis.CatMouseGame.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.CatMouseGame.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.CatMouseGame.cat_mouse_game (Slice.from [(alloc.vec.Vec.from [1#i64, 2#i64] (by scalar_tac) : alloc.vec.Vec Std.I64), (alloc.vec.Vec.from [0#i64] (b...
[ { "input": "[[[1, 2], [0], [0]]]", "output": "1" }, { "input": "[[[1, 2, 3], [0], [0], [0]]]", "output": "1" }, { "input": "[[[1, 3], [0], [3], [0, 2]]]", "output": "1" }, { "input": "[[[1, 4], [0, 2, 3], [1], [1], [0]]]", "output": "1" }, { "input": "[[[3, 4], [3...
63
false
63
verified
10
10
2
62,007
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.CatMouseGame.Code.Funs /-! # Specifications of `Aegis.CatMouseGame.cat_mouse_game` LeetCode problem `cat-and-mouse`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.CatMouseGame def rows (graph : Slice (alloc.vec.Vec Std.I64)) : List (L...
12
x-of-a-kind-in-a-deck-of-cards
914
Easy
[ "Array", "Hash Table", "Math", "Counting", "Number Theory" ]
You are given an integer array deck where deck[i] represents the number written on the ith card. Partition the cards into one or more groups such that: Each group has exactly x cards where x > 1, and All the cards in one group have the same integer written on them. Return true if such partition is possible, or false ...
hasGroupsSizeX(deck: list_int) -> bool
pub fn has_groups_size_x(deck: &[i64]) -> bool
Aegis.HasGroupsSizeX.has_groups_size_x
fn gcd(mut a: i64, mut b: i64) -> i64 { while b != 0 { let t = a % b; a = b; b = t; } a } pub fn has_groups_size_x(deck: &[i64]) -> bool { let n = deck.len(); if n == 0 { return false; } let mut max_val = deck[0]; let mut i = 0; while i < n { ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [has_groups_size_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_option lin...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [has_groups_size_x]: function definitions module public import Aeneas public import Aegis.HasGroupsSizeX.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.HasGroupsSizeX.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.HasGroupsSizeX.has_groups_size_x (Slice.from [1#i64] (by scalar_tac) : Slice Std.I64)) (false))}") #eval (s!"CASE 1 {(Result.reducesTo (Aegis.HasG...
[ { "input": "[[1]]", "output": "false" }, { "input": "[[1, 1]]", "output": "true" }, { "input": "[[1, 1, 1]]", "output": "true" }, { "input": "[[1, 1, 2, 2, 2, 2]]", "output": "true" }, { "input": "[[1, 1, 1, 2, 2, 2, 3, 3]]", "output": "false" }, { "in...
113
false
113
verified
10
10
1
1,347
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.HasGroupsSizeX.Code.Funs /-! # Specifications of `Aegis.HasGroupsSizeX.has_groups_size_x` LeetCode problem `x-of-a-kind-in-a-deck-of-cards`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.HasGroupsSizeX def count (deck : Slice Std....
8
partition-array-into-disjoint-intervals
915
Medium
[ "Array" ]
Given an integer array nums, partition it into two (contiguous) subarrays left and right so that: Every element in left is less than or equal to every element in right. left and right are non-empty. left has the smallest possible size. Return the length of left after such a partitioning. Test cases are generated such...
partitionDisjoint(nums: list_int) -> int
pub fn partition_disjoint(nums: &[i64]) -> i64
Aegis.PartitionDisjoint.partition_disjoint
pub fn partition_disjoint(nums: &[i64]) -> i64 { let n = nums.len(); let mut max_left: i64 = nums[0]; let mut max_right: i64 = nums[0]; let mut left_size: i64 = 1; let mut i: usize = 1; while i < n { let x = nums[i]; if x < max_left { left_size = i as i64 + 1; ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [partition_disjoint]: type definitions module public import Aeneas @[expose] public section 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 -- [partition_disjoint]: function definitions module public import Aeneas public import Aegis.PartitionDisjoint.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false ...
import Aegis.PartitionDisjoint.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.PartitionDisjoint.partition_disjoint (Slice.from [1#i64, 3#i64, 2#i64, 4#i64, 5#i64] (by scalar_tac) : Slice Std.I64)) (1#i64))}") #eval (s!"CA...
[ { "input": "[[1, 3, 2, 4, 5]]", "output": "1" }, { "input": "[[1, 2, 3, 4, 5]]", "output": "1" }, { "input": "[[5, 0, 3, 8, 6]]", "output": "3" }, { "input": "[[1, 1, 1, 0, 6, 12]]", "output": "4" }, { "input": "[[1, 2, 3, 4, 5, 0]]", "output": "6" }, { ...
95
false
95
verified
10
10
1
7,218
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.PartitionDisjoint.Code.Funs /-! # Specifications of `Aegis.PartitionDisjoint.partition_disjoint` LeetCode problem `partition-array-into-disjoint-intervals`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.PartitionDisjoint set_option autoImpl...
13
maximum-sum-circular-subarray
918
Medium
[ "Queue", "Array", "Divide and Conquer", "Dynamic Programming", "Monotonic Queue" ]
Given a circular integer array nums of length n, return the maximum possible sum of a non-empty subarray of nums. A circular array means the end of the array connects to the beginning of the array. Formally, the next element of nums[i] is nums[(i + 1) % n] and the previous element of nums[i] is nums[(i - 1 + n) % n]. A...
maxSubarraySumCircular(nums: list_int) -> int
pub fn max_subarray_sum_circular(nums: &[i64]) -> i64
Aegis.MaxSubarraySumCircular.max_subarray_sum_circular
pub fn max_subarray_sum_circular(nums: &[i64]) -> i64 { let n = nums.len(); if n == 0 { return 0; } let first = nums[0]; let mut cur_max: i64 = first; let mut best_max: i64 = first; let mut cur_min: i64 = first; let mut best_min: i64 = first; let mut total: i64 = first; ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [max_subarray_sum_circular]: type definitions module public import Aeneas @[expose] public 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_subarray_sum_circular]: function definitions module public import Aeneas public import Aegis.MaxSubarraySumCircular.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCo...
import Aegis.MaxSubarraySumCircular.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.MaxSubarraySumCircular.max_subarray_sum_circular (Slice.from [5#i64, (-3)#i64, 5#i64] (by scalar_tac) : Slice Std.I64)) (10#i64))}") #eval...
[ { "input": "[[5, -3, 5]]", "output": "10" }, { "input": "[[-3, -2, -3]]", "output": "-2" }, { "input": "[[1, -2, 3, -2]]", "output": "3" }, { "input": "[[3, -1, 2, -1]]", "output": "4" }, { "input": "[[2, -2, 2, 7]]", "output": "11" }, { "input": "[[-1...
117
false
117
verified
10
10
1
989
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MaxSubarraySumCircular.Code.Funs /-! # Specifications of `Aegis.MaxSubarraySumCircular.max_subarray_sum_circular` LeetCode problem `maximum-sum-circular-subarray`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.MaxSubarraySumCircular d...
11
number-of-music-playlists
920
Hard
[ "Math", "Dynamic Programming", "Combinatorics" ]
Your music player contains n different songs. You want to listen to goal songs (not necessarily different) during your trip. To avoid boredom, you will create a playlist so that: Every song is played at least once. A song can only be played again only if k other songs have been played. Given n, goal, and k, return th...
numMusicPlaylists(n: int, goal: int, k: int) -> int
pub fn num_music_playlists(n: i64, goal: i64, k: i64) -> i64
Aegis.NumMusicPlaylists.num_music_playlists
pub fn num_music_playlists(n: i64, goal: i64, k: i64) -> i64 { let modulo: i64 = 1000000007; let n_us = n as usize; let goal_us = goal as usize; let mut dp: Vec<Vec<i64>> = Vec::new(); let mut i = 0usize; while i <= goal_us { let mut row: Vec<i64> = Vec::new(); let mut j = 0usi...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [num_music_playlists]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option l...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [num_music_playlists]: function definitions module public import Aeneas public import Aegis.NumMusicPlaylists.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false...
import Aegis.NumMusicPlaylists.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.NumMusicPlaylists.num_music_playlists 5#i64 5#i64 2#i64) (120#i64))}") #eval (s!"CASE 1 {(Result.reducesTo (Aegis.NumMusicPlaylists.num_music_p...
[ { "input": "[5, 5, 2]", "output": "120" }, { "input": "[3, 4, 1]", "output": "18" }, { "input": "[4, 6, 2]", "output": "168" }, { "input": "[3, 3, 1]", "output": "6" }, { "input": "[2, 3, 1]", "output": "2" }, { "input": "[10, 10, 5]", "output": "3...
88
false
88
verified
10
10
1
2,018
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.NumMusicPlaylists.Code.Funs /-! # Specifications of `Aegis.NumMusicPlaylists.num_music_playlists` LeetCode problem `number-of-music-playlists`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.NumMusicPlaylists open Aegis.NumMusicPla...
10
minimum-add-to-make-parentheses-valid
921
Medium
[ "Stack", "Greedy", "String" ]
A parentheses string is valid if and only if: It is the empty string, It can be written as AB (A concatenated with B), where A and B are valid strings, or It can be written as (A), where A is a valid string. You are given a parentheses string s. In one move, you can insert a parenthesis at any position of the string....
minAddToMakeValid(s: str) -> int
pub fn min_add_to_make_valid(s: &[u8]) -> i64
Aegis.MinAddToMakeValid.min_add_to_make_valid
pub fn min_add_to_make_valid(s: &[u8]) -> i64 { let n: usize = s.len(); let mut i: usize = 0; let mut open_needed: i64 = 0; let mut unmatched_open: i64 = 0; while i < n { if s[i] == b'(' { unmatched_open += 1; } else if s[i] == b')' { if unmatched_open > 0 { ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [min_add_to_make_valid]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [min_add_to_make_valid]: function definitions module public import Aeneas public import Aegis.MinAddToMakeValid.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand fal...
import Aegis.MinAddToMakeValid.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.MinAddToMakeValid.min_add_to_make_valid (Slice.from [40#u8, 40#u8, 41#u8, 41#u8, 41#u8] (by scalar_tac) : Slice Std.U8)) (1#i64))}") #eval (s!"...
[ { "input": "[\"(()))\"]", "output": "1" }, { "input": "[\"())\"]", "output": "1" }, { "input": "[\"()\"]", "output": "0" }, { "input": "[\"((((((()))\"]", "output": "4" }, { "input": "[\"())(()\"]", "output": "2" }, { "input": "[\"((()))\"]", "outp...
115
false
115
verified
10
10
1
332
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MinAddToMakeValid.Code.Funs /-! # Specifications of `Aegis.MinAddToMakeValid.min_add_to_make_valid` LeetCode problem `minimum-add-to-make-parentheses-valid`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.MinAddToMakeValid open Aegis.M...
15
sort-array-by-parity-ii
922
Easy
[ "Array", "Two Pointers", "Sorting" ]
Given an array of integers nums, half of the integers in nums are odd, and the other half are even. Sort the array so that whenever nums[i] is odd, i is odd, and whenever nums[i] is even, i is even. Return any answer array that satisfies this condition.   Example 1: Input: nums = [4,2,5,7] Output: [4,5,2,7] Explanatio...
sortArrayByParityII(nums: list_int) -> list_int
pub fn sort_array_by_parity_ii(nums: &[i64]) -> Vec<i64>
Aegis.SortArrayByParityIi.sort_array_by_parity_ii
pub fn sort_array_by_parity_ii(nums: &[i64]) -> Vec<i64> { let n = nums.len(); // Copy into an owned vector so we can rearrange in place. let mut a: Vec<i64> = Vec::new(); let mut k = 0; while k < n { a.push(nums[k]); k += 1; } // Two pointers: `i` looks for an even value a...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [sort_array_by_parity_ii]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_opti...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [sort_array_by_parity_ii]: function definitions module public import Aeneas public import Aegis.SortArrayByParityIi.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand...
import Aegis.SortArrayByParityIi.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.SortArrayByParityIi.sort_array_by_parity_ii (Slice.from [2#i64, 3#i64] (by scalar_tac) : Slice Std.I64)) ((alloc.vec.Vec.from [2#i64, 3#i64] ...
[ { "input": "[[2, 3]]", "output": "[2, 3]" }, { "input": "[[2, 3, 6, 7]]", "output": "[2, 3, 6, 7]" }, { "input": "[[1, 2, 3, 4]]", "output": "[2, 1, 4, 3]" }, { "input": "[[4, 2, 5, 7]]", "output": "[4, 5, 2, 7]" }, { "input": "[[6, 1, 4, 3]]", "output": "[6, ...
81
false
81
verified
10
10
2
5,960
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.SortArrayByParityIi.Code.Funs /-! # Specifications of `Aegis.SortArrayByParityIi.sort_array_by_parity_ii` LeetCode problem `sort-array-by-parity-ii`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.SortArrayByParityIi set_option aut...
5
minimize-malware-spread
924
Hard
[ "Depth-First Search", "Breadth-First Search", "Union Find", "Graph", "Array", "Hash Table" ]
You are given a network of n nodes represented as an n x n adjacency matrix graph, where the ith node is directly connected to the jth node if graph[i][j] == 1. Some nodes initial are initially infected by malware. Whenever two nodes are directly connected, and at least one of those two nodes is infected by malware, bo...
minMalwareSpread(graph: list_list_int, initial: list_int) -> int
pub fn min_malware_spread(graph: &[Vec<i64>], initial: &[i64]) -> i64
Aegis.MinMalwareSpread.min_malware_spread
pub fn min_malware_spread(graph: &[Vec<i64>], initial: &[i64]) -> i64 { let n = graph.len(); let mut comp: Vec<i64> = Vec::new(); let mut i: usize = 0; while i < n { comp.push(-1); i += 1; } let mut is_initial: Vec<bool> = Vec::new(); i = 0; while i < n { is_ini...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [min_malware_spread]: type definitions module public import Aeneas @[expose] public section 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_malware_spread]: function definitions module public import Aeneas public import Aegis.MinMalwareSpread.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.MinMalwareSpread.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.MinMalwareSpread.min_malware_spread (Slice.from [(alloc.vec.Vec.from [1#i64, 1#i64, 0#i64] (by scalar_tac) : alloc.vec.Vec Std.I64), (alloc.vec....
[ { "input": "[[[1, 1, 0], [1, 1, 0], [0, 0, 1]], [0, 1]]", "output": "0" }, { "input": "[[[1, 1, 1], [1, 1, 1], [1, 1, 1]], [1, 2]]", "output": "1" }, { "input": "[[[1, 0, 0], [0, 1, 0], [0, 0, 1]], [0, 2]]", "output": "0" }, { "input": "[[[1, 1, 0, 0], [1, 1, 1, 0], [0, 1, 1,...
69
false
69
verified
10
10
1
4,230
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MinMalwareSpread.Code.Funs /-! # Specifications of `Aegis.MinMalwareSpread.min_malware_spread` LeetCode problem `minimize-malware-spread`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.MinMalwareSpread open Classical open Aegis....
8
long-pressed-name
925
Easy
[ "Two Pointers", "String" ]
Your friend is typing his name into a keyboard. Sometimes, when typing a character c, the key might get long pressed, and the character will be typed 1 or more times. You examine the typed characters of the keyboard. Return True if it is possible that it was your friends name, with some characters (possibly none) being...
isLongPressedName(name: str, typed: str) -> bool
pub fn is_long_pressed_name(name: &[u8], typed: &[u8]) -> bool
Aegis.IsLongPressedName.is_long_pressed_name
pub fn is_long_pressed_name(name: &[u8], typed: &[u8]) -> bool { let mut i: usize = 0; let mut j: usize = 0; while j < typed.len() { if i < name.len() && typed[j] == name[i] { i += 1; j += 1; } else if j > 0 && typed[j] == typed[j - 1] { j += 1; }...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [is_long_pressed_name]: type definitions module public import Aeneas @[expose] public section 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_long_pressed_name]: function definitions module public import Aeneas public import Aegis.IsLongPressedName.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand fals...
import Aegis.IsLongPressedName.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.IsLongPressedName.is_long_pressed_name (Slice.from [122#u8, 122#u8, 122#u8, 122#u8, 122#u8, 122#u8, 122#u8, 122#u8] (by scalar_tac) : Slice Std...
[ { "input": "[\"zzzzzzzz\", \"zzzzzzzz\"]", "output": "true" }, { "input": "[\"abcd\", \"abcde\"]", "output": "false" }, { "input": "[\"test\", \"ttest\"]", "output": "true" }, { "input": "[\"dfuyalc\", \"fuuyallc\"]", "output": "false" }, { "input": "[\"zzzyyyyy\"...
140
false
140
verified
10
10
1
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.IsLongPressedName.Code.Funs /-! # Specifications of `Aegis.IsLongPressedName.is_long_pressed_name` LeetCode problem `long-pressed-name`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.IsLongPressedName def IsLowerAsciiByte (b : Std.U8)...
13
flip-string-to-monotone-increasing
926
Medium
[ "String", "Dynamic Programming" ]
A binary string is monotone increasing if it consists of some number of 0's (possibly none), followed by some number of 1's (also possibly none). You are given a binary string s. You can flip s[i] changing it from 0 to 1 or from 1 to 0. Return the minimum number of flips to make s monotone increasing.   Example 1: Inp...
minFlipsMonoIncr(s: str) -> int
pub fn min_flips_mono_incr(s: &[u8]) -> i64
Aegis.MinFlipsMonoIncr.min_flips_mono_incr
pub fn min_flips_mono_incr(s: &[u8]) -> i64 { let n = s.len(); let mut zeros: i64 = 0; let mut i: usize = 0; while i < n { if s[i] == b'0' { zeros += 1; } i += 1; } let mut ones: i64 = 0; let mut ans: i64 = zeros; i = 0; while i < n { if ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [min_flips_mono_incr]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option l...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [min_flips_mono_incr]: function definitions module public import Aeneas public import Aegis.MinFlipsMonoIncr.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false ...
import Aegis.MinFlipsMonoIncr.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.MinFlipsMonoIncr.min_flips_mono_incr (Slice.from [49#u8, 49#u8, 48#u8, 48#u8, 49#u8, 49#u8, 48#u8] (by scalar_tac) : Slice Std.U8)) (3#i64))}") ...
[ { "input": "[\"1100110\"]", "output": "3" }, { "input": "[\"1111000011110000\"]", "output": "8" }, { "input": "[\"101010101\"]", "output": "4" }, { "input": "[\"111000111000\"]", "output": "6" }, { "input": "[\"000100110\"]", "output": "2" }, { "input"...
143
false
143
verified
10
10
1
1,141
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MinFlipsMonoIncr.Code.Funs /-! # Specifications of `Aegis.MinFlipsMonoIncr.min_flips_mono_incr` LeetCode problem `flip-string-to-monotone-increasing`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.MinFlipsMonoIncr abbrev minFlips ...
11
three-equal-parts
927
Hard
[ "Array", "Math" ]
You are given an array arr which consists of only zeros and ones, divide the array into three non-empty parts such that all of these parts represent the same binary value. If it is possible, return any [i, j] with i + 1 < j, such that: arr[0], arr[1], ..., arr[i] is the first part, arr[i + 1], arr[i + 2], ..., arr[j -...
threeEqualParts(arr: list_int) -> list_int
pub fn three_equal_parts(arr: &[i64]) -> Vec<i64>
Aegis.ThreeEqualParts.three_equal_parts
fn lower_bound(pref: &[i64], target: i64) -> usize { let n = pref.len(); let mut pos: usize = n; let mut idx: usize = 0; while idx < n { if pref[idx] >= target { if idx < pos { pos = idx; } } idx += 1; } pos } pub fn three_equal_pa...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [three_equal_parts]: type definitions module public import Aeneas @[expose] public section 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 -- [three_equal_parts]: function definitions module public import Aeneas public import Aegis.ThreeEqualParts.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.ThreeEqualParts.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.ThreeEqualParts.three_equal_parts (Slice.from [0#i64, 0#i64, 0#i64] (by scalar_tac) : Slice Std.I64)) ((alloc.vec.Vec.from [0#i64, 2#i64] (by sca...
[ { "input": "[[0, 0, 0]]", "output": "[0, 2]" }, { "input": "[[1, 0, 1, 0, 1]]", "output": "[0, 3]" }, { "input": "[[1, 1, 0, 1, 1]]", "output": "[-1, -1]" }, { "input": "[[1, 1, 0, 0, 1]]", "output": "[0, 2]" }, { "input": "[[0, 0, 0, 0, 0, 0]]", "output": "[0...
99
false
99
verified
10
10
3
32,359
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.ThreeEqualParts.Code.Funs /-! # Specifications of `Aegis.ThreeEqualParts.three_equal_parts` LeetCode problem `three-equal-parts`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result ControlFlow Error namespace AegisSpec.ThreeEqualParts def outVals (r : all...
13
minimize-malware-spread-ii
928
Hard
[ "Depth-First Search", "Breadth-First Search", "Union Find", "Graph", "Array", "Hash Table" ]
You are given a network of n nodes represented as an n x n adjacency matrix graph, where the ith node is directly connected to the jth node if graph[i][j] == 1. Some nodes initial are initially infected by malware. Whenever two nodes are directly connected, and at least one of those two nodes is infected by malware, bo...
minMalwareSpread(graph: list_list_int, initial: list_int) -> int
pub fn min_malware_spread(graph: &[Vec<i64>], initial: &[i64]) -> i64
Aegis.MinMalwareSpread.min_malware_spread
pub fn min_malware_spread(graph: &[Vec<i64>], initial: &[i64]) -> i64 { let n = graph.len(); let k = initial.len(); let n_i64 = n as i64; let mut best_count: i64 = n_i64 + 1; let mut best_node: i64 = -1; let mut a: usize = 0; while a < k { let remove = initial[a]; let remov...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [min_malware_spread]: type definitions module public import Aeneas @[expose] public section 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_malware_spread]: function definitions module public import Aeneas public import Aegis.MinMalwareSpread.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.MinMalwareSpread.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.MinMalwareSpread.min_malware_spread (Slice.from [(alloc.vec.Vec.from [1#i64, 1#i64, 0#i64] (by scalar_tac) : alloc.vec.Vec Std.I64), (alloc.vec....
[ { "input": "[[[1, 1, 0], [1, 1, 0], [0, 0, 1]], [0, 1]]", "output": "0" }, { "input": "[[[1, 1, 1], [1, 1, 1], [1, 1, 1]], [0, 1]]", "output": "0" }, { "input": "[[[1, 1, 1], [1, 1, 1], [1, 1, 1]], [1, 2]]", "output": "1" }, { "input": "[[[1, 1, 1], [1, 1, 1], [1, 1, 1]], [0,...
74
false
74
verified
10
10
1
8,988
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MinMalwareSpread.Code.Funs /-! # Specifications of `Aegis.MinMalwareSpread.min_malware_spread` LeetCode problem `minimize-malware-spread-ii`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.MinMalwareSpread open Aegis.MinMalwareSpread ...
13
unique-email-addresses
929
Easy
[ "Array", "Hash Table", "String" ]
Every valid email consists of a local name and a domain name, separated by the '@' sign. Besides lowercase letters, the email may contain one or more '.' or '+'. For example, in "alice@leetcode.com", "alice" is the local name, and "leetcode.com" is the domain name. If you add periods '.' between some characters in th...
numUniqueEmails(emails: list_str) -> int
pub fn num_unique_emails(emails: &[Vec<u8>]) -> i64
Aegis.NumUniqueEmails.num_unique_emails
pub fn num_unique_emails(emails: &[Vec<u8>]) -> i64 { let mut unique: Vec<Vec<u8>> = Vec::new(); let mut count: i64 = 0; let mut i: usize = 0; while i < emails.len() { let mut key: Vec<u8> = Vec::new(); let mut p: usize = 0; let mut ignoring: bool = false; while p < ema...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [num_unique_emails]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option lin...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [num_unique_emails]: function definitions module public import Aeneas public import Aegis.NumUniqueEmails.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.NumUniqueEmails.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.NumUniqueEmails.num_unique_emails (Slice.from [(alloc.vec.Vec.from [109#u8, 101#u8, 43#u8, 97#u8, 108#u8, 101#u8, 120#u8, 64#u8, 108#u8, 101#u8, ...
[ { "input": "[[\"me+alex@leetcode.com\", \"me@leetcode.com\"]]", "output": "1" }, { "input": "[[\"m.y+name@email.com\", \"my@email.com\"]]", "output": "1" }, { "input": "[[\"alice.z@leetcode.com\", \"alicez@leetcode.com\"]]", "output": "1" }, { "input": "[[\"foo@bar.com\", \"f...
104
false
104
verified
10
10
1
1,541
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.NumUniqueEmails.Code.Funs /-! # Specifications of `Aegis.NumUniqueEmails.num_unique_emails` LeetCode problem `unique-email-addresses`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std open Aeneas.Std.alloc.vec open Aegis.NumUniqueEmails namespace AegisSpec.NumUniqu...
13
binary-subarrays-with-sum
930
Medium
[ "Array", "Hash Table", "Prefix Sum", "Sliding Window" ]
Given a binary array nums and an integer goal, return the number of non-empty subarrays with a sum goal. A subarray is a contiguous part of the array.   Example 1: Input: nums = [1,0,1,0,1], goal = 2 Output: 4 Explanation: The 4 subarrays are bolded and underlined below: [1,0,1,0,1] [1,0,1,0,1] [1,0,1,0,1] [1,0,1,0,1]...
numSubarraysWithSum(nums: list_int, goal: int) -> int
pub fn num_subarrays_with_sum(nums: &[i64], goal: i64) -> i64
Aegis.NumSubarraysWithSum.num_subarrays_with_sum
pub fn num_subarrays_with_sum(nums: &[i64], goal: i64) -> i64 { let n = nums.len(); let mut counts: Vec<i64> = Vec::new(); let mut i = 0usize; while i <= n { counts.push(0); i += 1; } counts[0] = 1; let target = goal as usize; let mut prefix = 0usize; let mut ans =...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [num_subarrays_with_sum]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_optio...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [num_subarrays_with_sum]: function definitions module public import Aeneas public import Aegis.NumSubarraysWithSum.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand ...
import Aegis.NumSubarraysWithSum.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.NumSubarraysWithSum.num_subarrays_with_sum (Slice.from [1#i64, 0#i64, 1#i64, 1#i64, 0#i64] (by scalar_tac) : Slice Std.I64) 1#i64) (6#i64))}"...
[ { "input": "[[1, 0, 1, 1, 0], 1]", "output": "6" }, { "input": "[[0, 0, 0, 0, 0], 0]", "output": "15" }, { "input": "[[1, 0, 1, 0, 1], 2]", "output": "4" }, { "input": "[[1, 1, 1, 1, 1], 3]", "output": "3" }, { "input": "[[1, 0, 0, 0, 1], 1]", "output": "8" ...
72
false
72
verified
10
10
1
1,549
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.NumSubarraysWithSum.Code.Funs /-! # Specifications of `Aegis.NumSubarraysWithSum.num_subarrays_with_sum` LeetCode problem `binary-subarrays-with-sum`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.NumSubarraysWithSum abbrev I64 :=...
14
minimum-falling-path-sum
931
Medium
[ "Array", "Dynamic Programming", "Matrix" ]
Given an n x n array of integers matrix, return the minimum sum of any falling path through matrix. A falling path starts at any element in the first row and chooses the element in the next row that is either directly below or diagonally left/right. Specifically, the next element from position (row, col) will be (row +...
minFallingPathSum(matrix: list_list_int) -> int
pub fn min_falling_path_sum(matrix: &[Vec<i64>]) -> i64
Aegis.MinFallingPathSum.min_falling_path_sum
pub fn min_falling_path_sum(matrix: &[Vec<i64>]) -> i64 { let n = matrix.len(); if n == 0 { return 0; } let m = matrix[0].len(); // The problem specifies an n x n matrix. For malformed rectangular // inputs, the expected convention here is to return 0. if n != m { return 0;...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [min_falling_path_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 -- [min_falling_path_sum]: function definitions module public import Aeneas public import Aegis.MinFallingPathSum.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand fals...
import Aegis.MinFallingPathSum.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.MinFallingPathSum.min_falling_path_sum (Slice.from [(alloc.vec.Vec.from [1#i64] (by scalar_tac) : alloc.vec.Vec Std.I64), (alloc.vec.Vec.from [...
[ { "input": "[[[1], [100]]]", "output": "0" }, { "input": "[[[-19, 57], [-40, -5]]]", "output": "-59" }, { "input": "[[[1], [2], [3], [4], [5]]]", "output": "0" }, { "input": "[[[100, -100, 100], [-100, 100, -100], [100, -100, 100]]]", "output": "-300" }, { "input"...
79
false
79
verified
10
10
1
6,667
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MinFallingPathSum.Code.Funs /-! # Specifications of `Aegis.MinFallingPathSum.min_falling_path_sum` LeetCode problem `minimum-falling-path-sum`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.MinFallingPathSum namespace AegisSpec.MinFallingPa...
9
beautiful-array
932
Medium
[ "Array", "Math", "Divide and Conquer" ]
An array nums of length n is beautiful if: nums is a permutation of the integers in the range [1, n]. For every 0 <= i < j < n, there is no index k with i < k < j where 2 * nums[k] == nums[i] + nums[j]. Given the integer n, return any beautiful array nums of length n. There will be at least one valid answer for the g...
beautifulArray(n: int) -> list_int
pub fn beautiful_array(n: i64) -> Vec<i64>
Aegis.BeautifulArray.beautiful_array
pub fn beautiful_array(n: i64) -> Vec<i64> { let mut arr: Vec<i64> = Vec::new(); arr.push(1); let mut steps: i64 = 0; while steps < 10 { let mut next: Vec<i64> = Vec::new(); let mut i: usize = 0; while i < arr.len() { let x = arr[i]; next.push(2 * x - 1)...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [beautiful_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 -- [beautiful_array]: function definitions module public import Aeneas public import Aegis.BeautifulArray.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.BeautifulArray.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.BeautifulArray.beautiful_array 1#i64) ((alloc.vec.Vec.from [1#i64] (by scalar_tac) : alloc.vec.Vec Std.I64)))}") #eval (s!"CASE 1 {(Result.reduces...
[ { "input": "[1]", "output": "[1]" }, { "input": "[2]", "output": "[1, 2]" }, { "input": "[3]", "output": "[1, 3, 2]" }, { "input": "[4]", "output": "[1, 3, 2, 4]" }, { "input": "[5]", "output": "[1, 5, 3, 2, 4]" }, { "input": "[6]", "output": "[1, ...
50
false
50
verified
10
10
1
4,240
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.BeautifulArray.Code.Funs /-! # Specifications of `Aegis.BeautifulArray.beautiful_array` LeetCode problem `beautiful-array`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.BeautifulArray def toList (r : alloc.vec.Vec Std.I64) : List...
10
knight-dialer
935
Medium
[ "Dynamic Programming" ]
The chess knight has a unique movement, it may move two squares vertically and one square horizontally, or two squares horizontally and one square vertically (with both forming the shape of an L). The possible movements of chess knight are shown in this diagram: A chess knight can move as indicated in the chess diagram...
knightDialer(n: int) -> int
pub fn knight_dialer(n: i64) -> i64
Aegis.KnightDialer.knight_dialer
pub fn knight_dialer(n: i64) -> i64 { let modulus: i64 = 1000000007; let mut a0: i64 = 1; let mut a1: i64 = 1; let mut a2: i64 = 1; let mut a3: i64 = 1; let mut a4: i64 = 1; let mut a5: i64 = 1; let mut a6: i64 = 1; let mut a7: i64 = 1; let mut a8: i64 = 1; let mut a9: i64 =...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [knight_dialer]: type definitions module public import Aeneas @[expose] public section 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 -- [knight_dialer]: function definitions module public import Aeneas public import Aegis.KnightDialer.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.KnightDialer.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.KnightDialer.knight_dialer 3#i64) (46#i64))}") #eval (s!"CASE 1 {(Result.reducesTo (Aegis.KnightDialer.knight_dialer 100#i64) (540641702#i64))}") #e...
[ { "input": "[3]", "output": "46" }, { "input": "[100]", "output": "540641702" }, { "input": "[50]", "output": "267287516" }, { "input": "[2500]", "output": "851996060" }, { "input": "[5000]", "output": "406880451" }, { "input": "[2]", "output": "20...
42
false
42
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.KnightDialer.Code.Funs /-! # Specifications of `Aegis.KnightDialer.knight_dialer` LeetCode problem `knight-dialer`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.KnightDialer def knightPairs : List (Nat × Nat) := [(0, 4), (0, ...
13
reorder-data-in-log-files
937
Medium
[ "Array", "String", "Sorting" ]
You are given an array of logs. Each log is a space-delimited string of words, where the first word is the identifier. There are two types of logs: Letter-logs: All words (except the identifier) consist of lowercase English letters. Digit-logs: All words (except the identifier) consist of digits. Reorder these logs s...
reorderLogFiles(logs: list_str) -> list_str
pub fn reorder_log_files(logs: &[Vec<u8>]) -> Vec<Vec<u8>>
Aegis.ReorderLogFiles.reorder_log_files
fn first_space(s: &[u8]) -> usize { let mut i: usize = 0; let mut result: usize = s.len(); let mut found: bool = false; while i < s.len() && !found { if s[i] == b' ' { result = i; found = true; } i += 1; } result } fn copy_bytes(s: &[u8]) -> Vec<u...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [reorder_log_files]: type definitions module public import Aeneas @[expose] public section 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 -- [reorder_log_files]: function definitions module public import Aeneas public import Aegis.ReorderLogFiles.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.ReorderLogFiles.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.ReorderLogFiles.reorder_log_files (Slice.from [(alloc.vec.Vec.from [100#u8, 105#u8, 103#u8, 49#u8, 32#u8, 56#u8, 32#u8, 49#u8, 32#u8, 53#u8, 32#u...
[ { "input": "[[\"dig1 8 1 5 1\", \"let1 art can\", \"dig2 3 6\", \"let2 own kit dig\", \"let3 art zero\"]]", "output": "[\"let1 art can\", \"let3 art zero\", \"let2 own kit dig\", \"dig1 8 1 5 1\", \"dig2 3 6\"]" }, { "input": "[[\"a1 9 2 3 1\", \"g1 act car\", \"zo4 4 7\", \"ab1 off key dog\", \"a8 ...
53
false
53
verified
10
10
2
14,458
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.ReorderLogFiles.Code.Funs /-! # Specifications of `Aegis.ReorderLogFiles.reorder_log_files` LeetCode problem `reorder-data-in-log-files`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.ReorderLogFiles def spaceByte : Nat := 32 def isL...
9
range-sum-of-bst
938
Easy
[ "Tree", "Depth-First Search", "Binary Search Tree", "Binary Tree" ]
Given the root node of a binary search tree and two integers low and high, return the sum of values of all nodes with a value in the inclusive range [low, high].   Example 1: Input: root = [10,5,15,3,7,null,18], low = 7, high = 15 Output: 32 Explanation: Nodes 7, 10, and 15 are in the range [7, 15]. 7 + 10 + 15 = 32....
rangeSumBST(root: tree, low: int, high: int) -> int
pub fn range_sum_bst(root: &Tree, low: i64, high: i64) -> i64
Aegis.RangeSumBst.range_sum_bst
pub fn range_sum_bst(root: &Tree, low: i64, high: i64) -> i64 { range_sum_bst_helper(root, low, high) } fn range_sum_bst_helper(node: &Tree, low: i64, high: i64) -> i64 { match node { Tree::Null => 0, Tree::Node(value, left, right) => { let val: i64 = *value; let mut tot...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [range_sum_bst]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter....
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [range_sum_bst]: function definitions module public import Aeneas public import Aegis.RangeSumBst.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.RangeSumBst.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.RangeSumBst.range_sum_bst ((.Node 1#i64 (.Null) (.Null)) : Aegis.RangeSumBst.Tree) 1#i64 1#i64) (1#i64))}") #eval (s!"CASE 1 {(Result.reducesTo (Aegi...
[ { "input": "[[1], 1, 1]", "output": "1" }, { "input": "[[2, 1, 3], 1, 3]", "output": "6" }, { "input": "[[1, 0, 2], 1, 3]", "output": "3" }, { "input": "[[1, 3, 2], 1, 3]", "output": "3" }, { "input": "[[20, 10, 30, 5, 15, 25, 35, 3, 7, 12, 17, 23, 27, 32, 38], 10...
58
false
58
verified
10
10
1
6,438
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.RangeSumBst.Code.Funs /-! # Specifications of `Aegis.RangeSumBst.range_sum_bst` LeetCode problem `range-sum-of-bst`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.RangeSumBst open Aegis.RangeSumBst def values : Tree → List ℤ ...
10
distinct-subsequences-ii
940
Hard
[ "String", "Dynamic Programming" ]
Given a string s, return the number of distinct non-empty subsequences of s. Since the answer may be very large, return it modulo 109 + 7. A subsequence of a string is a new string that is formed from the original string by deleting some (can be none) of the characters without disturbing the relative positions of the r...
distinctSubseqII(s: str) -> int
pub fn distinct_subseq_ii(s: &[u8]) -> i64
Aegis.DistinctSubseqIi.distinct_subseq_ii
pub fn distinct_subseq_ii(s: &[u8]) -> i64 { const MOD: i64 = 1_000_000_007; let mut last: Vec<i64> = Vec::new(); let mut i: usize = 0; while i < 26 { last.push(0); i += 1; } let mut total: i64 = 0; let n = s.len(); let mut pos: usize = 0; while pos < n { le...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [distinct_subseq_ii]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option li...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [distinct_subseq_ii]: function definitions module public import Aeneas public import Aegis.DistinctSubseqIi.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.DistinctSubseqIi.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.DistinctSubseqIi.distinct_subseq_ii (Slice.from [97#u8, 98#u8, 99#u8, 100#u8, 101#u8, 102#u8, 103#u8, 104#u8, 105#u8, 106#u8, 107#u8, 108#u8, 10...
[ { "input": "[\"abcdefghijklmnopqrstuvwxyz\"]", "output": "67108863" }, { "input": "[\"abac\"]", "output": "13" }, { "input": "[\"abababababababababab\"]", "output": "28655" }, { "input": "[\"a\"]", "output": "1" }, { "input": "[\"abracadabra\"]", "output": "13...
53
false
53
verified
10
10
1
2,549
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.DistinctSubseqIi.Code.Funs /-! # Specifications of `Aegis.DistinctSubseqIi.distinct_subseq_ii` LeetCode problem `distinct-subsequences-ii`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.DistinctSubseqIi def modulus : Nat := 1000000007...
12
valid-mountain-array
941
Easy
[ "Array" ]
Given an array of integers arr, return true if and only if it is a valid mountain array. Recall that arr is a mountain array if and only if: arr.length >= 3 There exists some i with 0 < i < arr.length - 1 such that: arr[0] < arr[1] < ... < arr[i - 1] < arr[i] arr[i] > arr[i + 1] > ... > arr[arr.length - 1]   Ex...
validMountainArray(arr: list_int) -> bool
pub fn valid_mountain_array(arr: &[i64]) -> bool
Aegis.ValidMountainArray.valid_mountain_array
pub fn valid_mountain_array(arr: &[i64]) -> bool { let n = arr.len(); if n < 3 { return false; } let mut i: usize = 0; while i + 1 < n && arr[i] < arr[i + 1] { i += 1; } if i == 0 || i == n - 1 { return false; } while i + 1 < n && arr[i] > arr[i + 1] { ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [valid_mountain_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 ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [valid_mountain_array]: function definitions module public import Aeneas public import Aegis.ValidMountainArray.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand fal...
import Aegis.ValidMountainArray.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.ValidMountainArray.valid_mountain_array (Slice.from [1#i64] (by scalar_tac) : Slice Std.I64)) (false))}") #eval (s!"CASE 1 {(Result.reducesTo ...
[ { "input": "[[1]]", "output": "false" }, { "input": "[[1, 2]]", "output": "false" }, { "input": "[[2, 1]]", "output": "false" }, { "input": "[[3, 1, 2]]", "output": "false" }, { "input": "[[3, 5, 5]]", "output": "false" }, { "input": "[[1, 3, 2]]", ...
141
false
141
verified
10
10
1
451
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.ValidMountainArray.Code.Funs /-! # Specifications of `Aegis.ValidMountainArray.valid_mountain_array` LeetCode problem `valid-mountain-array`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.ValidMountainArray def len (arr : Slice St...
14
di-string-match
942
Easy
[ "Greedy", "Array", "Two Pointers", "String" ]
A permutation perm of n + 1 integers of all the integers in the range [0, n] can be represented as a string s of length n where: s[i] == 'I' if perm[i] < perm[i + 1], and s[i] == 'D' if perm[i] > perm[i + 1]. Given a string s, reconstruct the permutation perm and return it. If there are multiple valid permutations pe...
diStringMatch(s: str) -> list_int
pub fn di_string_match(s: &[u8]) -> Vec<i64>
Aegis.DiStringMatch.di_string_match
pub fn di_string_match(s: &[u8]) -> Vec<i64> { let n: i64 = s.len() as i64; let mut low: i64 = 0; let mut high: i64 = n; let mut result: Vec<i64> = Vec::new(); let mut i: usize = 0; while i < s.len() { if s[i] == b'I' { result.push(low); low += 1; } else ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [di_string_match]: type definitions module public import Aeneas @[expose] public section 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 -- [di_string_match]: function definitions module public import Aeneas public import Aegis.DiStringMatch.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.DiStringMatch.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.DiStringMatch.di_string_match (Slice.from [73#u8] (by scalar_tac) : Slice Std.U8)) ((alloc.vec.Vec.from [0#i64, 1#i64] (by scalar_tac) : alloc.vec....
[ { "input": "[\"I\"]", "output": "[0, 1]" }, { "input": "[\"D\"]", "output": "[1, 0]" }, { "input": "[\"DDI\"]", "output": "[3, 2, 0, 1]" }, { "input": "[\"III\"]", "output": "[0, 1, 2, 3]" }, { "input": "[\"IDDD\"]", "output": "[0, 4, 3, 2, 1]" }, { "i...
157
false
157
verified
10
10
1
667
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.DiStringMatch.Code.Funs /-! # Specifications of `Aegis.DiStringMatch.di_string_match` LeetCode problem `di-string-match`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.DiStringMatch open Aegis.DiStringMatch def inGet (s : Slice Std.U...
10
minimum-increment-to-make-array-unique
945
Medium
[ "Greedy", "Array", "Counting", "Sorting" ]
You are given an integer array nums. In one move, you can pick an index i where 0 <= i < nums.length and increment nums[i] by 1. Return the minimum number of moves to make every value in nums unique. The test cases are generated so that the answer fits in a 32-bit integer.   Example 1: Input: nums = [1,2,2] Output: 1 ...
minIncrementForUnique(nums: list_int) -> int
pub fn min_increment_for_unique(nums: &[i64]) -> i64
Aegis.MinIncrementForUnique.min_increment_for_unique
pub fn min_increment_for_unique(nums: &[i64]) -> i64 { let n: usize = nums.len(); if n == 0 { return 0; } let mut vals: Vec<i64> = Vec::new(); let mut i: usize = 0; while i < n { vals.push(nums[i]); i = i + 1; } let mut temp: Vec<i64> = Vec::new(); i = 0; ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [min_increment_for_unique]: type definitions module public import Aeneas @[expose] public 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 -- [min_increment_for_unique]: function definitions module public import Aeneas public import Aegis.MinIncrementForUnique.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashComm...
import Aegis.MinIncrementForUnique.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.MinIncrementForUnique.min_increment_for_unique (Slice.from [1#i64, 2#i64, 2#i64] (by scalar_tac) : Slice Std.I64)) (1#i64))}") #eval (s!"CA...
[ { "input": "[[1, 2, 2]]", "output": "1" }, { "input": "[[100000, 100000, 100000]]", "output": "3" }, { "input": "[[0, 0, 0, 0]]", "output": "6" }, { "input": "[[5, 3, 5, 3, 5]]", "output": "4" }, { "input": "[[10, 20, 30, 40, 50]]", "output": "0" }, { ...
104
false
104
verified
10
10
1
7,081
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MinIncrementForUnique.Code.Funs /-! # Specifications of `Aegis.MinIncrementForUnique.min_increment_for_unique` LeetCode problem `minimum-increment-to-make-array-unique`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.MinIncrementForUniq...
14
validate-stack-sequences
946
Medium
[ "Stack", "Array", "Simulation" ]
Given two integer arrays pushed and popped each with distinct values, return true if this could have been the result of a sequence of push and pop operations on an initially empty stack, or false otherwise.   Example 1: Input: pushed = [1,2,3,4,5], popped = [4,5,3,2,1] Output: true Explanation: We might do the followi...
validateStackSequences(pushed: list_int, popped: list_int) -> bool
pub fn validate_stack_sequences(pushed: &[i64], popped: &[i64]) -> bool
Aegis.ValidateStackSequences.validate_stack_sequences
pub fn validate_stack_sequences(pushed: &[i64], popped: &[i64]) -> bool { let n = pushed.len(); let mut stack: Vec<i64> = Vec::new(); let mut popped_index: usize = 0; let mut i: usize = 0; while i < n { stack.push(pushed[i]); while stack.len() > 0 && popped_index < n ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [validate_stack_sequences]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_opt...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [validate_stack_sequences]: function definitions module public import Aeneas public import Aegis.ValidateStackSequences.Code.Types public import Aegis.ValidateStackSequences.Code.FunsExternal @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error s...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [validate_stack_sequences]: external functions. -- This is a template file: rename it to "FunsExternal.lean" and fill the holes. module public import Aeneas public import Aegis.ValidateStackSequences.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ...
import Aegis.ValidateStackSequences.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.ValidateStackSequences.validate_stack_sequences (Slice.from [1#i64] (by scalar_tac) : Slice Std.I64) (Slice.from [1#i64] (by scalar_tac) :...
[ { "input": "[[1], [1]]", "output": "true" }, { "input": "[[2, 1, 0], [0, 1, 2]]", "output": "true" }, { "input": "[[1, 2, 3], [1, 3, 2]]", "output": "true" }, { "input": "[[1, 2, 3], [3, 2, 1]]", "output": "true" }, { "input": "[[1, 2, 3, 4, 5], [4, 5, 3, 2, 1]]",...
101
false
101
verified
10
10
1
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.ValidateStackSequences.Code.Funs /-! # Specifications of `Aegis.ValidateStackSequences.validate_stack_sequences` LeetCode problem `validate-stack-sequences`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.ValidateStackSequences namespace AegisSp...
9
most-stones-removed-with-same-row-or-column
947
Medium
[ "Depth-First Search", "Union Find", "Graph", "Hash Table" ]
On a 2D plane, we place n stones at some integer coordinate points. Each coordinate point may have at most one stone. A stone can be removed if it shares either the same row or the same column as another stone that has not been removed. Given an array stones of length n where stones[i] = [xi, yi] represents the locatio...
removeStones(stones: list_list_int) -> int
pub fn remove_stones(stones: &[Vec<i64>]) -> i64
Aegis.RemoveStones.remove_stones
pub fn remove_stones(stones: &[Vec<i64>]) -> i64 { let n: usize = stones.len(); let mut parent: Vec<i64> = Vec::new(); let mut size: Vec<i64> = Vec::new(); let mut i: usize = 0; while i < n { parent.push(i as i64); size.push(1); i += 1; } let mut i: usize = 0; w...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [remove_stones]: type definitions module public import Aeneas @[expose] public section 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 -- [remove_stones]: function definitions module public import Aeneas public import Aegis.RemoveStones.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.RemoveStones.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.RemoveStones.remove_stones (Slice.from [(alloc.vec.Vec.from [0#i64, 0#i64] (by scalar_tac) : alloc.vec.Vec Std.I64)] (by scalar_tac) : Slice (alloc....
[ { "input": "[[[0, 0]]]", "output": "0" }, { "input": "[[[1, 2], [2, 3], [3, 4]]]", "output": "0" }, { "input": "[[[3, 2], [2, 3], [3, 1], [2, 2]]]", "output": "3" }, { "input": "[[[1, 2], [2, 3], [3, 4], [4, 5]]]", "output": "0" }, { "input": "[[[0, 0], [0, 2], [1...
100
false
100
verified
10
10
1
3,846
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.RemoveStones.Code.Funs /-! # Specifications of `Aegis.RemoveStones.remove_stones` LeetCode problem `most-stones-removed-with-same-row-or-column`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.RemoveStones abbrev Stone := alloc.vec.Vec...
13
bag-of-tokens
948
Medium
[ "Greedy", "Array", "Two Pointers", "Sorting" ]
You start with an initial power of power, an initial score of 0, and a bag of tokens given as an integer array tokens, where each tokens[i] denotes the value of tokeni. Your goal is to maximize the total score by strategically playing these tokens. In one move, you can play an unplayed token in one of the two ways (but...
bagOfTokensScore(tokens: list_int, power: int) -> int
pub fn bag_of_tokens_score(tokens: &[i64], power: i64) -> i64
Aegis.BagOfTokensScore.bag_of_tokens_score
pub fn bag_of_tokens_score(tokens: &[i64], power: i64) -> i64 { let n = tokens.len(); let mut v: Vec<i64> = Vec::new(); let mut i: usize = 0; while i < n { v.push(tokens[i]); i += 1; } // Manual insertion sort in ascending order. let mut a: usize = 1; while a < n { ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [bag_of_tokens_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 l...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [bag_of_tokens_score]: function definitions module public import Aeneas public import Aegis.BagOfTokensScore.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false ...
import Aegis.BagOfTokensScore.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.BagOfTokensScore.bag_of_tokens_score (Slice.from [] (by scalar_tac) : Slice Std.I64) 0#i64) (0#i64))}") #eval (s!"CASE 1 {(Result.reducesTo (Aeg...
[ { "input": "[[], 0]", "output": "0" }, { "input": "[[], 1000]", "output": "0" }, { "input": "[[], 100]", "output": "0" }, { "input": "[[100], 50]", "output": "0" }, { "input": "[[500], 1000]", "output": "1" }, { "input": "[[200, 100], 150]", "outpu...
103
false
103
verified
10
10
1
1,282
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.BagOfTokensScore.Code.Funs /-! # Specifications of `Aegis.BagOfTokensScore.bag_of_tokens_score` LeetCode problem `bag-of-tokens`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.BagOfTokensScore inductive MoveDir where | faceUp...
14
reveal-cards-in-increasing-order
950
Medium
[ "Queue", "Array", "Sorting", "Simulation" ]
You are given an integer array deck. There is a deck of cards where every card has a unique integer. The integer on the ith card is deck[i]. You can order the deck in any order you want. Initially, all the cards start face down (unrevealed) in one deck. You will do the following steps repeatedly until all cards are rev...
deckRevealedIncreasing(deck: list_int) -> list_int
pub fn deck_revealed_increasing(deck: &[i64]) -> Vec<i64>
Aegis.DeckRevealedIncreasing.deck_revealed_increasing
pub fn deck_revealed_increasing(deck: &[i64]) -> Vec<i64> { let n = deck.len(); let mut sorted: Vec<i64> = Vec::new(); let mut i: usize = 0; while i < n { sorted.push(deck[i]); i += 1; } let mut k: usize = 1; while k < n { let key = sorted[k]; let mut j = k;...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [deck_revealed_increasing]: type definitions module public import Aeneas @[expose] public 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 -- [deck_revealed_increasing]: function definitions module public import Aeneas public import Aegis.DeckRevealedIncreasing.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCom...
import Aegis.DeckRevealedIncreasing.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(match (Aegis.DeckRevealedIncreasing.deck_revealed_increasing (Slice.from [10#i64] (by scalar_tac) : Slice Std.I64)).match with | .ok r => r.val.isPerm ((alloc.vec...
[ { "input": "[[10]]", "output": "[10]" }, { "input": "[[5]]", "output": "[5]" }, { "input": "[[1, 1000]]", "output": "[1, 1000]" }, { "input": "[[3, 2, 1]]", "output": "[1, 3, 2]" }, { "input": "[[5, 2, 3, 1, 4]]", "output": "[1, 5, 2, 4, 3]" }, { "inpu...
78
true
78
verified
10
10
1
3,899
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.DeckRevealedIncreasing.Code.Funs /-! # Specifications of `Aegis.DeckRevealedIncreasing.deck_revealed_increasing` LeetCode problem `reveal-cards-in-increasing-order`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.DeckRevealedIncreasing ...
6
flip-equivalent-binary-trees
951
Medium
[ "Tree", "Depth-First Search", "Binary Tree" ]
For a binary tree T, we can define a flip operation as follows: choose any node, and swap the left and right child subtrees. A binary tree X is flip equivalent to a binary tree Y if and only if we can make X equal to Y after some number of flip operations. Given the roots of two binary trees root1 and root2, return tru...
flipEquiv(root1: tree, root2: tree) -> bool
pub fn flip_equiv(root1: &Tree, root2: &Tree) -> bool
Aegis.FlipEquiv.flip_equiv
pub fn flip_equiv(root1: &Tree, root2: &Tree) -> bool { match root1 { Tree::Null => match root2 { Tree::Null => true, Tree::Node(_, _, _) => false, }, Tree::Node(v1, l1, r1) => match root2 { Tree::Null => false, Tree::Node(v2, l2, r2) => { ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [flip_equiv]: type definitions module public import Aeneas @[expose] public section 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 -- [flip_equiv]: function definitions module public import Aeneas public import Aegis.FlipEquiv.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.FlipEquiv.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.FlipEquiv.flip_equiv ((.Null) : Aegis.FlipEquiv.Tree) ((.Null) : Aegis.FlipEquiv.Tree)) (true))}") #eval (s!"CASE 1 {(Result.reducesTo (Aegis.FlipEquiv...
[ { "input": "[[], []]", "output": "true" }, { "input": "[[], [1]]", "output": "false" }, { "input": "[[1], [1]]", "output": "true" }, { "input": "[[1, 2, 3], [1, 3, 2]]", "output": "true" }, { "input": "[[1, 2, 3, 4], [1, 3, 2, 4]]", "output": "false" }, { ...
27
false
27
verified
10
10
1
4,375
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.FlipEquiv.Code.Funs /-! # Specifications of `Aegis.FlipEquiv.flip_equiv` LeetCode problem `flip-equivalent-binary-trees`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.FlipEquiv open Aegis.FlipEquiv def values : Tree → List ℤ ...
14
largest-component-size-by-common-factor
952
Hard
[ "Union Find", "Array", "Hash Table", "Math", "Number Theory" ]
You are given an integer array of unique positive integers nums. Consider the following graph: There are nums.length nodes, labeled nums[0] to nums[nums.length - 1], There is an undirected edge between nums[i] and nums[j] if nums[i] and nums[j] share a common factor greater than 1. Return the size of the largest conn...
largestComponentSize(nums: list_int) -> int
pub fn largest_component_size(nums: &[i64]) -> i64
Aegis.LargestComponentSize.largest_component_size
fn find(parent: &mut Vec<i64>, x: i64) -> i64 { let mut r: usize = x as usize; while parent[r] >= 0 { r = parent[r] as usize; } let mut cur: usize = x as usize; while parent[cur] >= 0 { let nxt: usize = parent[cur] as usize; parent[cur] = r as i64; cur = nxt; } ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [largest_component_size]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_optio...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [largest_component_size]: function definitions module public import Aeneas public import Aegis.LargestComponentSize.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand...
import Aegis.LargestComponentSize.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval ...
[ { "input": "[[20, 50, 9, 63]]", "output": "2" }, { "input": "[[5, 7, 11, 13]]", "output": "1" }, { "input": "[[30, 42, 66, 55]]", "output": "4" }, { "input": "[[4, 6, 15, 35]]", "output": "4" }, { "input": "[[30, 42, 70, 28]]", "output": "4" }, { "inpu...
98
false
98
verified
10
10
2
25,470
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.LargestComponentSize.Code.Funs /-! # Specifications of `Aegis.LargestComponentSize.largest_component_size` LeetCode problem `largest-component-size-by-common-factor`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.LargestComponentSize...
11
array-of-doubled-pairs
954
Medium
[ "Greedy", "Array", "Hash Table", "Sorting" ]
Given an integer array of even length arr, return true if it is possible to reorder arr such that arr[2 * i + 1] = 2 * arr[2 * i] for every 0 <= i < len(arr) / 2, or false otherwise.   Example 1: Input: arr = [3,1,3,6] Output: false Example 2: Input: arr = [2,1,2,6] Output: false Example 3: Input: arr = [4,-2,2,-4...
canReorderDoubled(arr: list_int) -> bool
pub fn can_reorder_doubled(arr: &[i64]) -> bool
Aegis.CanReorderDoubled.can_reorder_doubled
pub fn can_reorder_doubled(arr: &[i64]) -> bool { let n = arr.len(); let mut zeros: usize = 0; let mut pos: Vec<i64> = Vec::new(); let mut neg: Vec<i64> = Vec::new(); let mut i = 0; while i < n { let x = arr[i]; if x == 0 { zeros += 1; } else if x > 0 { ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [can_reorder_doubled]: type definitions module public import Aeneas @[expose] public section 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 -- [can_reorder_doubled]: function definitions module public import Aeneas public import Aegis.CanReorderDoubled.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false...
import Aegis.CanReorderDoubled.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.CanReorderDoubled.can_reorder_doubled (Slice.from [0#i64, 0#i64] (by scalar_tac) : Slice Std.I64)) (true))}") #eval (s!"CASE 1 {(Result.reduces...
[ { "input": "[[0, 0]]", "output": "true" }, { "input": "[[1, 4, 2, 2]]", "output": "true" }, { "input": "[[4, -2, 2, -4]]", "output": "true" }, { "input": "[[1, 2, 2, 4]]", "output": "true" }, { "input": "[[2, 1, 2, 6]]", "output": "false" }, { "input":...
112
false
112
verified
10
10
2
16,153
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.CanReorderDoubled.Code.Funs /-! # Specifications of `Aegis.CanReorderDoubled.can_reorder_doubled` LeetCode problem `array-of-doubled-pairs`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.CanReorderDoubled def sliceVals (arr : Slic...
12
prison-cells-after-n-days
957
Medium
[ "Bit Manipulation", "Array", "Hash Table", "Math" ]
There are 8 prison cells in a row and each cell is either occupied or vacant. Each day, whether the cell is occupied or vacant changes according to the following rules: If a cell has two adjacent neighbors that are both occupied or both vacant, then the cell becomes occupied. Otherwise, it becomes vacant. Note that b...
prisonAfterNDays(cells: list_int, n: int) -> list_int
pub fn prison_after_n_days(cells: &[i64], n: i64) -> Vec<i64>
Aegis.PrisonAfterNDays.prison_after_n_days
fn advance(state: &[i64]) -> Vec<i64> { let len = state.len(); let mut next: Vec<i64> = Vec::new(); let mut i: usize = 0; while i < len { if i == 0 { next.push(0); } else if i + 1 == len { next.push(0); } else if state[i - 1] == state[i + 1] { ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [prison_after_n_days]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option l...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [prison_after_n_days]: function definitions module public import Aeneas public import Aegis.PrisonAfterNDays.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false ...
import Aegis.PrisonAfterNDays.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.PrisonAfterNDays.prison_after_n_days (Slice.from [0#i64, 0#i64, 0#i64, 0#i64, 0#i64, 0#i64, 0#i64, 0#i64] (by scalar_tac) : Slice Std.I64) 5#i64...
[ { "input": "[[0, 0, 0, 0, 0, 0, 0, 0], 5]", "output": "[0, 1, 0, 1, 1, 0, 1, 0]" }, { "input": "[[1, 1, 1, 1, 1, 1, 1, 1], 2]", "output": "[0, 0, 1, 1, 1, 1, 0, 0]" }, { "input": "[[1, 1, 1, 1, 1, 1, 1, 1], 15]", "output": "[0, 1, 1, 1, 1, 1, 1, 0]" }, { "input": "[[1, 0, 1, ...
102
false
102
verified
10
10
1
8,792
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.PrisonAfterNDays.Code.Funs /-! # Specifications of `Aegis.PrisonAfterNDays.prison_after_n_days` LeetCode problem `prison-cells-after-n-days`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.PrisonAfterNDays namespace AegisSpec.PrisonAfterNDays d...
11
check-completeness-of-a-binary-tree
958
Medium
[ "Tree", "Breadth-First Search", "Binary Tree" ]
Given the root of a binary tree, determine if it is a complete binary tree. In a complete binary tree, every level, except possibly the last, is completely filled, and all nodes in the last level are as far left as possible. It can have between 1 and 2h nodes inclusive at the last level h.   Example 1: Input: root = ...
isCompleteTree(root: tree) -> bool
pub fn is_complete_tree(root: &Tree) -> bool
Aegis.IsCompleteTree.is_complete_tree
fn count_nodes(t: &Tree) -> i64 { match t { Tree::Null => 0, Tree::Node(_, left, right) => { 1 + count_nodes(&**left) + count_nodes(&**right) } } } fn check_complete(t: &Tree, index: i64, total: i64) -> bool { match t { Tree::Null => true, Tree::Node(_, l...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [is_complete_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 lint...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [is_complete_tree]: function definitions module public import Aeneas public import Aegis.IsCompleteTree.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.IsCompleteTree.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.IsCompleteTree.is_complete_tree ((.Node 1#i64 (.Null) (.Null)) : Aegis.IsCompleteTree.Tree)) (true))}") #eval (s!"CASE 1 {(Result.reducesTo (Aegis...
[ { "input": "[[1]]", "output": "true" }, { "input": "[[1, 2]]", "output": "true" }, { "input": "[[1, 2, 3, 4]]", "output": "true" }, { "input": "[[1, 2, 3, 4, 5, 6]]", "output": "true" }, { "input": "[[1, 2, 3, 4, 5, 6, 7]]", "output": "true" }, { "inpu...
11
false
11
verified
10
10
1
2,379
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.IsCompleteTree.Code.Funs /-! # Specifications of `Aegis.IsCompleteTree.is_complete_tree` LeetCode problem `check-completeness-of-a-binary-tree`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.IsCompleteTree open Aegis.IsCompleteTre...
9
maximum-width-ramp
962
Medium
[ "Stack", "Array", "Two Pointers", "Monotonic Stack" ]
A ramp in an integer array nums is a pair (i, j) for which i < j and nums[i] <= nums[j]. The width of such a ramp is j - i. Given an integer array nums, return the maximum width of a ramp in nums. If there is no ramp in nums, return 0.   Example 1: Input: nums = [6,0,8,2,1,5] Output: 4 Explanation: The maximum width r...
maxWidthRamp(nums: list_int) -> int
pub fn max_width_ramp(nums: &[i64]) -> i64
Aegis.MaxWidthRamp.max_width_ramp
pub fn max_width_ramp(nums: &[i64]) -> i64 { let n = nums.len(); if n <= 1 { return 0; } let mut stack: Vec<usize> = Vec::new(); let mut i: usize = 0; while i < n { let mut add = false; if stack.len() == 0 { add = true; } else { let top_id...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [max_width_ramp]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [max_width_ramp]: function definitions module public import Aeneas public import Aegis.MaxWidthRamp.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.MaxWidthRamp.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.MaxWidthRamp.max_width_ramp (Slice.from [0#i64, 0#i64, 0#i64, 0#i64, 0#i64] (by scalar_tac) : Slice Std.I64)) (4#i64))}") #eval (s!"CASE 1 {(Result....
[ { "input": "[[0, 0, 0, 0, 0]]", "output": "4" }, { "input": "[[1, 2, 3, 4, 5]]", "output": "4" }, { "input": "[[1, 1, 1, 1, 1]]", "output": "4" }, { "input": "[[5, 4, 3, 2, 1]]", "output": "0" }, { "input": "[[1, 2, 3, 2, 1]]", "output": "4" }, { "inpu...
69
false
69
verified
10
10
1
5,951
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MaxWidthRamp.Code.Funs /-! # Specifications of `Aegis.MaxWidthRamp.max_width_ramp` LeetCode problem `maximum-width-ramp`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.MaxWidthRamp def IsRamp (nums : Slice Std.I64) (i j : ℕ) : Pro...
10
least-operators-to-express-number
964
Hard
[ "Memoization", "Math", "Dynamic Programming" ]
Given a single positive integer x, we will write an expression of the form x (op1) x (op2) x (op3) x ... where each operator op1, op2, etc. is either addition, subtraction, multiplication, or division (+, -, *, or /). For example, with x = 3, we might write 3 * 3 / 3 + 3 - 3 which is a value of 3. When writing such an ...
leastOpsExpressTarget(x: int, target: int) -> int
pub fn least_ops_express_target(x: i64, target: i64) -> i64
Aegis.LeastOpsExpressTarget.least_ops_express_target
pub fn least_ops_express_target(x: i64, target: i64) -> i64 { if target == 0 { return 0; } let mut t = target; let mut dp0: i64 = 0; let mut dp1: i64 = 1000000000000000; let mut i: i64 = 0; while t > 0 { let q = t / x; let r = t - q * x; t = q; let ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [least_ops_express_target]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_opt...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [least_ops_express_target]: function definitions module public import Aeneas public import Aegis.LeastOpsExpressTarget.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashComm...
import Aegis.LeastOpsExpressTarget.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.LeastOpsExpressTarget.least_ops_express_target 2#i64 123456#i64) (44#i64))}") #eval (s!"CASE 1 {(Result.reducesTo (Aegis.LeastOpsExpressTar...
[ { "input": "[2, 123456]", "output": "44" }, { "input": "[2, 3]", "output": "2" }, { "input": "[3, 81]", "output": "3" }, { "input": "[10, 1001]", "output": "4" }, { "input": "[2, 10]", "output": "3" }, { "input": "[2, 100]", "output": "12" }, {...
159
false
159
verified
10
10
1
26,523
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.LeastOpsExpressTarget.Code.Funs /-! # Specifications of `Aegis.LeastOpsExpressTarget.least_ops_express_target` LeetCode problem `least-operators-to-express-number`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.LeastOpsExpressTarget ...
12
univalued-binary-tree
965
Easy
[ "Tree", "Depth-First Search", "Breadth-First Search", "Binary Tree" ]
A binary tree is uni-valued if every node in the tree has the same value. Given the root of a binary tree, return true if the given tree is uni-valued, or false otherwise.   Example 1: Input: root = [1,1,1,1,1,null,1] Output: true Example 2: Input: root = [2,2,2,5,2] Output: false   Constraints: The number of no...
isUnivalTree(root: tree) -> bool
pub fn is_unival_tree(root: &Tree) -> bool
Aegis.IsUnivalTree.is_unival_tree
fn check_unival(t: &Tree, val: i64) -> bool { match t { Tree::Null => true, Tree::Node(v, left, right) => { if *v != val { false } else { check_unival(left, val) && check_unival(right, val) } } } } pub fn is_unival_tree...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [is_unival_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 -- [is_unival_tree]: function definitions module public import Aeneas public import Aegis.IsUnivalTree.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.IsUnivalTree.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.IsUnivalTree.is_unival_tree ((.Node 0#i64 (.Null) (.Null)) : Aegis.IsUnivalTree.Tree)) (true))}") #eval (s!"CASE 1 {(Result.reducesTo (Aegis.IsUniva...
[ { "input": "[[0]]", "output": "true" }, { "input": "[[5]]", "output": "true" }, { "input": "[[1, 1, 2]]", "output": "false" }, { "input": "[[2, 2, 2, 5, 2]]", "output": "false" }, { "input": "[[1, 1, 1, 1, 1, 1, 2]]", "output": "false" }, { "input": "[...
24
false
24
verified
10
10
1
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.IsUnivalTree.Code.Funs /-! # Specifications of `Aegis.IsUnivalTree.is_unival_tree` LeetCode problem `univalued-binary-tree`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.IsUnivalTree open Aegis.IsUnivalTree def reachableNodes ...
8
vowel-spellchecker
966
Medium
[ "Array", "Hash Table", "String" ]
Given a wordlist, we want to implement a spellchecker that converts a query word into a correct word. For a given query word, the spell checker handles two categories of spelling mistakes: Capitalization: If the query matches a word in the wordlist (case-insensitive), then the query word is returned with the same case...
spellchecker(wordlist: list_str, queries: list_str) -> list_str
pub fn spellchecker(wordlist: &[Vec<u8>], queries: &[Vec<u8>]) -> Vec<Vec<u8>>
Aegis.Spellchecker.spellchecker
fn lower_byte(b: u8) -> u8 { if b >= b'A' && b <= b'Z' { b + 32 } else { b } } fn is_vowel(b: u8) -> bool { b == b'a' || b == b'e' || b == b'i' || b == b'o' || b == b'u' } pub fn spellchecker(wordlist: &[Vec<u8>], queries: &[Vec<u8>]) -> Vec<Vec<u8>> { let mut answer: Vec<Vec<u8>> ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [spellchecker]: type definitions module public import Aeneas @[expose] public section 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 -- [spellchecker]: function definitions module public import Aeneas public import Aegis.Spellchecker.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.Spellchecker.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.Spellchecker.spellchecker (Slice.from [(alloc.vec.Vec.from [121#u8, 101#u8, 108#u8, 108#u8, 111#u8, 119#u8] (by scalar_tac) : alloc.vec.Vec Std.U8)]...
[ { "input": "[[\"yellow\"], [\"YellOw\"]]", "output": "[\"yellow\"]" }, { "input": "[[\"aeiou\", \"AEIOU\"], [\"aeio\", \"aeiou\", \"AEIOU\", \"eioua\"]]", "output": "[\"\", \"aeiou\", \"AEIOU\", \"aeiou\"]" }, { "input": "[[\"apple\", \"Apple\", \"apples\"], [\"apples\", \"APPLES\", \"ap...
87
false
87
verified
10
10
1
10,118
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.Spellchecker.Code.Funs /-! # Specifications of `Aegis.Spellchecker.spellchecker` LeetCode problem `vowel-spellchecker`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.Spellchecker abbrev Byte := U8 def IsAsciiLetter (c : Nat) : Prop :...
15
numbers-with-same-consecutive-differences
967
Medium
[ "Breadth-First Search", "Backtracking" ]
Given two integers n and k, return an array of all the integers of length n where the difference between every two consecutive digits is k. You may return the answer in any order. Note that the integers should not have leading zeros. Integers as 02 and 043 are not allowed.   Example 1: Input: n = 3, k = 7 Output: [181...
numsSameConsecDiff(n: int, k: int) -> list_int
pub fn nums_same_consec_diff(n: i64, k: i64) -> Vec<i64>
Aegis.NumsSameConsecDiff.nums_same_consec_diff
pub fn nums_same_consec_diff(n: i64, k: i64) -> Vec<i64> { let mut cur: Vec<i64> = Vec::new(); let mut d: i64 = 1; while d <= 9 { cur.push(d); d += 1; } let mut len: i64 = 1; while len < n { let mut next: Vec<i64> = Vec::new(); let mut i: usize = 0; whi...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [nums_same_consec_diff]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [nums_same_consec_diff]: function definitions module public import Aeneas public import Aegis.NumsSameConsecDiff.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand fa...
import Aegis.NumsSameConsecDiff.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(match (Aegis.NumsSameConsecDiff.nums_same_consec_diff 9#i64 9#i64).match with | .ok r => r.val.isPerm ((alloc.vec.Vec.from [909090909#i64] (by scalar_tac) : alloc.vec...
[ { "input": "[9, 9]", "output": "[909090909]" }, { "input": "[2, 9]", "output": "[90]" }, { "input": "[6, 9]", "output": "[909090]" }, { "input": "[3, 9]", "output": "[909]" }, { "input": "[8, 9]", "output": "[90909090]" }, { "input": "[4, 8]", "out...
58
true
58
verified
10
10
1
2,412
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.NumsSameConsecDiff.Code.Funs /-! # Specifications of `Aegis.NumsSameConsecDiff.nums_same_consec_diff` LeetCode problem `numbers-with-same-consecutive-differences`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.NumsSameConsecDiff def v...
13
binary-tree-cameras
968
Hard
[ "Tree", "Depth-First Search", "Dynamic Programming", "Binary Tree" ]
You are given the root of a binary tree. We install cameras on the tree nodes where each camera at a node can monitor its parent, itself, and its immediate children. Return the minimum number of cameras needed to monitor all nodes of the tree.   Example 1: Input: root = [0,0,null,0,0] Output: 1 Explanation: One camer...
minCameraCover(root: tree) -> int
pub fn min_camera_cover(root: &Tree) -> i64
Aegis.MinCameraCover.min_camera_cover
fn build(t: &Tree, lefts: &mut Vec<i64>, rights: &mut Vec<i64>) -> i64 { match t { Tree::Null => -1, Tree::Node(_, l, r) => { let idx = lefts.len() as i64; lefts.push(-1); rights.push(-1); let li = build(&**l, lefts, rights); let ri = build...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [min_camera_cover]: type definitions module public import Aeneas @[expose] public section 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 -- [min_camera_cover]: function definitions module public import Aeneas public import Aegis.MinCameraCover.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.MinCameraCover.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.MinCameraCover.min_camera_cover ((.Node 0#i64 (.Null) (.Null)) : Aegis.MinCameraCover.Tree)) (1#i64))}") #eval (s!"CASE 1 {(Result.reducesTo (Aegi...
[ { "input": "[[0]]", "output": "1" }, { "input": "[[0, 0, 0, 0, 0, 0]]", "output": "2" }, { "input": "[[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]]", "output": "4" }, { "input": "[[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]]", "output": "5" }, { "input": "[[0, 0, 0, ...
11
false
11
verified
10
10
4
23,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.MinCameraCover.Code.Funs /-! # Specifications of `Aegis.MinCameraCover.min_camera_cover` LeetCode problem `binary-tree-cameras`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.MinCameraCover open Aegis.MinCameraCover inductive P...
8
powerful-integers
970
Medium
[ "Hash Table", "Math", "Enumeration" ]
Given three integers x, y, and bound, return a list of all the powerful integers that have a value less than or equal to bound. An integer is powerful if it can be represented as xi + yj for some integers i >= 0 and j >= 0. You may return the answer in any order. In your answer, each value should occur at most once.   ...
powerfulIntegers(x: int, y: int, bound: int) -> list_int
pub fn powerful_integers(x: i64, y: i64, bound: i64) -> Vec<i64>
Aegis.PowerfulIntegers.powerful_integers
pub fn powerful_integers(x: i64, y: i64, bound: i64) -> Vec<i64> { let mut sums: Vec<i64> = Vec::new(); let mut xi: i64 = 1; let mut stop_x: bool = false; while !stop_x { if xi > bound { stop_x = true; } else { let mut yj: i64 = 1; let mut stop_y: boo...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [powerful_integers]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option lin...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [powerful_integers]: function definitions module public import Aeneas public import Aegis.PowerfulIntegers.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.PowerfulIntegers.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(match (Aegis.PowerfulIntegers.powerful_integers 1#i64 1#i64 1#i64).match with | .ok r => r.val.isPerm ((alloc.vec.Vec.from [] (by scalar_tac) : alloc.vec.Vec Std.I64))....
[ { "input": "[1, 1, 1]", "output": "[]" }, { "input": "[1, 1, 2]", "output": "[2]" }, { "input": "[1, 1, 5]", "output": "[2]" }, { "input": "[1, 1, 10]", "output": "[2]" }, { "input": "[1, 1, 1000]", "output": "[2]" }, { "input": "[1, 100, 500]", "o...
82
true
82
verified
10
10
2
23,236
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.PowerfulIntegers.Code.Funs /-! # Specifications of `Aegis.PowerfulIntegers.powerful_integers` LeetCode problem `powerful-integers`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.PowerfulIntegers def Occurs (l : List Std.I64) (v : ℤ) :...
14
flip-binary-tree-to-match-preorder-traversal
971
Medium
[ "Tree", "Depth-First Search", "Binary Tree" ]
You are given the root of a binary tree with n nodes, where each node is uniquely assigned a value from 1 to n. You are also given a sequence of n values voyage, which is the desired pre-order traversal of the binary tree. Any node in the binary tree can be flipped by swapping its left and right subtrees. For example, ...
flipMatchVoyage(root: tree, voyage: list_int) -> list_int
pub fn flip_match_voyage(root: &Tree, voyage: &[i64]) -> Vec<i64>
Aegis.FlipMatchVoyage.flip_match_voyage
pub fn flip_match_voyage(root: &Tree, voyage: &[i64]) -> Vec<i64> { let mut ans: Vec<i64> = Vec::new(); let mut idx: usize = 0; let ok = dfs_flip(root, voyage, &mut idx, &mut ans); if ok && idx == voyage.len() { ans } else { let mut bad: Vec<i64> = Vec::new(); bad.push(-1);...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [flip_match_voyage]: type definitions module public import Aeneas @[expose] public section 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 -- [flip_match_voyage]: function definitions module public import Aeneas public import Aegis.FlipMatchVoyage.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.FlipMatchVoyage.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(match (Aegis.FlipMatchVoyage.flip_match_voyage ((.Node 1#i64 (.Node 2#i64 (.Null) (.Null)) (.Null)) : Aegis.FlipMatchVoyage.Tree) (Slice.from [2#i64, 1#i64] (by scalar_t...
[ { "input": "[[1, 2], [2, 1]]", "output": "[-1]" }, { "input": "[[1, 2, 3], [1, 2, 3]]", "output": "[]" }, { "input": "[[1, 2, 3], [1, 3, 2]]", "output": "[1]" }, { "input": "[[1, 2, 3, 4, 5], [1, 2, 4, 5, 3]]", "output": "[]" }, { "input": "[[1, 2, 3, 4, 5], [1, 3...
35
true
35
verified
10
10
1
4,468
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.FlipMatchVoyage.Code.Funs /-! # Specifications of `Aegis.FlipMatchVoyage.flip_match_voyage` LeetCode problem `flip-binary-tree-to-match-preorder-traversal`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.FlipMatchVoyage namespace AegisSpec.FlipM...
9
k-closest-points-to-origin
973
Medium
[ "Geometry", "Array", "Math", "Divide and Conquer", "Quickselect", "Sorting", "Heap (Priority Queue)" ]
Given an array of points where points[i] = [xi, yi] represents a point on the X-Y plane and an integer k, return the k closest points to the origin (0, 0). The distance between two points on the X-Y plane is the Euclidean distance (i.e., √(x1 - x2)2 + (y1 - y2)2). You may return the answer in any order. The answer is g...
kClosest(points: list_list_int, k: int) -> list_list_int
pub fn k_closest(points: &[Vec<i64>], k: i64) -> Vec<Vec<i64>>
Aegis.KClosest.k_closest
pub fn k_closest(points: &[Vec<i64>], k: i64) -> Vec<Vec<i64>> { let n = points.len(); let mut used: Vec<bool> = Vec::new(); let mut i = 0; while i < n { used.push(false); i += 1; } let mut out: Vec<Vec<i64>> = Vec::new(); let mut count: i64 = 0; while count < k { ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [k_closest]: type definitions module public import Aeneas @[expose] public section 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 -- [k_closest]: function definitions module public import Aeneas public import Aegis.KClosest.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.KClosest.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(match (Aegis.KClosest.k_closest (Slice.from [(alloc.vec.Vec.from [1#i64, 3#i64] (by scalar_tac) : alloc.vec.Vec Std.I64), (alloc.vec.Vec.from [(-2)#i64, 2#i64] (by scalar_tac) ...
[ { "input": "[[[1, 3], [-2, 2]], 1]", "output": "[[-2, 2]]" }, { "input": "[[[-10000, -10000], [10000, 10000]], 1]", "output": "[[-10000, -10000]]" }, { "input": "[[[-10000, 10000], [10000, -10000]], 1]", "output": "[[-10000, 10000]]" }, { "input": "[[[0, 1], [1, 0]], 2]", ...
98
true
98
verified
10
10
1
2,595
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.KClosest.Code.Funs /-! # Specifications of `Aegis.KClosest.k_closest` LeetCode problem `k-closest-points-to-origin`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.KClosest def coord (p : alloc.vec.Vec I64) (j : Nat) : Int := (p.val[j]...
10
subarray-sums-divisible-by-k
974
Medium
[ "Array", "Hash Table", "Prefix Sum" ]
Given an integer array nums and an integer k, return the number of non-empty subarrays that have a sum divisible by k. A subarray is a contiguous part of an array.   Example 1: Input: nums = [4,5,0,-2,-3,1], k = 5 Output: 7 Explanation: There are 7 subarrays with a sum divisible by k = 5: [4, 5, 0, -2, -3, 1], [5], [5...
subarraysDivByK(nums: list_int, k: int) -> int
pub fn subarrays_div_by_k(nums: &[i64], k: i64) -> i64
Aegis.SubarraysDivByK.subarrays_div_by_k
pub fn subarrays_div_by_k(nums: &[i64], k: i64) -> i64 { if k <= 0 { return 0; } let mut counts: Vec<i64> = Vec::new(); let mut j: i64 = 0; while j < k { counts.push(0); j += 1; } counts[0] = 1; let mut prefix_rem: i64 = 0; let mut answer: i64 = 0; let m...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [subarrays_div_by_k]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option li...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [subarrays_div_by_k]: function definitions module public import Aeneas public import Aegis.SubarraysDivByK.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.SubarraysDivByK.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.SubarraysDivByK.subarrays_div_by_k (Slice.from [5#i64] (by scalar_tac) : Slice Std.I64) 9#i64) (0#i64))}") #eval (s!"CASE 1 {(Result.reducesTo (A...
[ { "input": "[[5], 9]", "output": "0" }, { "input": "[[0, 0, 0, 0], 2]", "output": "10" }, { "input": "[[0, 0, 0, 0], 1]", "output": "10" }, { "input": "[[2, 2, 2, 2, 2], 6]", "output": "3" }, { "input": "[[-1, 2, -3, 4, -5], 2]", "output": "6" }, { "in...
108
false
108
verified
10
10
1
3,161
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.SubarraysDivByK.Code.Funs /-! # Specifications of `Aegis.SubarraysDivByK.subarrays_div_by_k` LeetCode problem `subarray-sums-divisible-by-k`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.SubarraysDivByK namespace AegisSpec.SubarraysDivByK def...
10
largest-perimeter-triangle
976
Easy
[ "Greedy", "Array", "Math", "Sorting" ]
Given an integer array nums, return the largest perimeter of a triangle with a non-zero area, formed from three of these lengths. If it is impossible to form any triangle of a non-zero area, return 0.   Example 1: Input: nums = [2,1,2] Output: 5 Explanation: You can form a triangle with three side lengths: 1, 2, and 2...
largestPerimeter(nums: list_int) -> int
pub fn largest_perimeter(nums: &[i64]) -> i64
Aegis.LargestPerimeter.largest_perimeter
pub fn largest_perimeter(nums: &[i64]) -> i64 { let n = nums.len(); // Copy into an owned Vec so we can sort it. let mut a: Vec<i64> = Vec::new(); let mut i: usize = 0; while i < n { a.push(nums[i]); i += 1; } // Manual bubble sort (ascending). let mut i: usize = 0; ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [largest_perimeter]: type definitions module public import Aeneas @[expose] public section 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 -- [largest_perimeter]: function definitions module public import Aeneas public import Aegis.LargestPerimeter.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.LargestPerimeter.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.LargestPerimeter.largest_perimeter (Slice.from [10#i64, 5#i64, 7#i64] (by scalar_tac) : Slice Std.I64)) (22#i64))}") #eval (s!"CASE 1 {(Result.r...
[ { "input": "[[10, 5, 7]]", "output": "22" }, { "input": "[[1, 1, 1]]", "output": "3" }, { "input": "[[1, 1000000, 1000000]]", "output": "2000001" }, { "input": "[[2, 1, 2]]", "output": "5" }, { "input": "[[1, 1, 1, 1]]", "output": "3" }, { "input": "[[...
114
false
114
verified
10
10
2
9,989
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.LargestPerimeter.Code.Funs /-! # Specifications of `Aegis.LargestPerimeter.largest_perimeter` LeetCode problem `largest-perimeter-triangle`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.LargestPerimeter open Aegis.LargestPerimete...
10
squares-of-a-sorted-array
977
Easy
[ "Array", "Two Pointers", "Sorting" ]
Given an integer array nums sorted in non-decreasing order, return an array of the squares of each number sorted in non-decreasing order.   Example 1: Input: nums = [-4,-1,0,3,10] Output: [0,1,9,16,100] Explanation: After squaring, the array becomes [16,1,0,9,100]. After sorting, it becomes [0,1,9,16,100]. Example 2:...
sortedSquares(nums: list_int) -> list_int
pub fn sorted_squares(nums: &[i64]) -> Vec<i64>
Aegis.SortedSquares.sorted_squares
pub fn sorted_squares(nums: &[i64]) -> Vec<i64> { let n = nums.len(); let mut out: Vec<i64> = Vec::new(); if n == 0 { return out; } let mut k: usize = 0; while k < n { out.push(0); k += 1; } let mut left: usize = 0; let mut right: usize = n - 1; let mut...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [sorted_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 -- [sorted_squares]: function definitions module public import Aeneas public import Aegis.SortedSquares.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.SortedSquares.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.SortedSquares.sorted_squares (Slice.from [(-1)#i64] (by scalar_tac) : Slice Std.I64)) ((alloc.vec.Vec.from [1#i64] (by scalar_tac) : alloc.vec.Vec ...
[ { "input": "[[-1]]", "output": "[1]" }, { "input": "[[0]]", "output": "[0]" }, { "input": "[[-10000, 10000]]", "output": "[100000000, 100000000]" }, { "input": "[[-3, 0, 3]]", "output": "[0, 9, 9]" }, { "input": "[[-10000, 0, 10000]]", "output": "[0, 100000000...
119
false
119
verified
10
10
1
1,763
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.SortedSquares.Code.Funs /-! # Specifications of `Aegis.SortedSquares.sorted_squares` LeetCode problem `squares-of-a-sorted-array`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.SortedSquares def sliceVals (s : Slice Std.I64) : List ℤ ...
13
longest-turbulent-subarray
978
Medium
[ "Array", "Dynamic Programming", "Sliding Window" ]
Given an integer array arr, return the length of a maximum size turbulent subarray of arr. A subarray is turbulent if the comparison sign flips between each adjacent pair of elements in the subarray. More formally, a subarray [arr[i], arr[i + 1], ..., arr[j]] of arr is said to be turbulent if and only if: For i <= k <...
maxTurbulenceSize(arr: list_int) -> int
pub fn max_turbulence_size(arr: &[i64]) -> i64
Aegis.MaxTurbulenceSize.max_turbulence_size
pub fn max_turbulence_size(arr: &[i64]) -> i64 { let n = arr.len(); if n == 0 { return 0; } let mut up: i64 = 1; let mut down: i64 = 1; let mut best: i64 = 1; let mut i: usize = 1; while i < n { if arr[i - 1] < arr[i] { up = down + 1; down = 1; ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [max_turbulence_size]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option l...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [max_turbulence_size]: function definitions module public import Aeneas public import Aegis.MaxTurbulenceSize.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false...
import Aegis.MaxTurbulenceSize.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.MaxTurbulenceSize.max_turbulence_size (Slice.from [100#i64] (by scalar_tac) : Slice Std.I64)) (1#i64))}") #eval (s!"CASE 1 {(Result.reducesTo (...
[ { "input": "[[100]]", "output": "1" }, { "input": "[[9, 9]]", "output": "1" }, { "input": "[[4, 8, 12, 16]]", "output": "2" }, { "input": "[[8, 8, 8, 8, 8, 8]]", "output": "1" }, { "input": "[[9, 9, 9, 9, 9, 9, 9, 10]]", "output": "2" }, { "input": "[[...
150
false
150
verified
10
10
1
1,125
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MaxTurbulenceSize.Code.Funs /-! # Specifications of `Aegis.MaxTurbulenceSize.max_turbulence_size` LeetCode problem `longest-turbulent-subarray`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.MaxTurbulenceSize open Aegis.MaxTurbule...
13
distribute-coins-in-binary-tree
979
Medium
[ "Tree", "Depth-First Search", "Binary Tree" ]
You are given the root of a binary tree with n nodes where each node in the tree has node.val coins. There are n coins in total throughout the whole tree. In one move, we may choose two adjacent nodes and move one coin from one node to another. A move may be from parent to child, or from child to parent. Return the min...
distributeCoins(root: tree) -> int
pub fn distribute_coins(root: &Tree) -> i64
Aegis.DistributeCoins.distribute_coins
fn excess(t: &Tree) -> i64 { match t { Tree::Null => 0, Tree::Node(v, l, r) => { let left_excess = excess(&**l); let right_excess = excess(&**r); *v - 1 + left_excess + right_excess } } } fn abs_val(x: i64) -> i64 { if x < 0 { 0 - x } ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [distribute_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 lint...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [distribute_coins]: function definitions module public import Aeneas public import Aegis.DistributeCoins.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.DistributeCoins.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.DistributeCoins.distribute_coins ((.Node 3#i64 (.Node 0#i64 (.Null) (.Null)) (.Node 0#i64 (.Null) (.Null))) : Aegis.DistributeCoins.Tree)) (2#i64...
[ { "input": "[[3, 0, 0]]", "output": "2" }, { "input": "[[1, 0, 2]]", "output": "2" }, { "input": "[[0, 3, 0]]", "output": "3" }, { "input": "[[0, 0, 0, 3, 3]]", "output": "8" }, { "input": "[[0, 0, 0, 3, 0, 0, 4]]", "output": "8" }, { "input": "[[1, 2,...
22
false
22
verified
10
10
2
4,536
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.DistributeCoins.Code.Funs /-! # Specifications of `Aegis.DistributeCoins.distribute_coins` LeetCode problem `distribute-coins-in-binary-tree`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.DistributeCoins open Aegis.DistributeCoins d...
12
unique-paths-iii
980
Hard
[ "Bit Manipulation", "Array", "Backtracking", "Matrix" ]
You are given an m x n integer array grid where grid[i][j] could be: 1 representing the starting square. There is exactly one starting square. 2 representing the ending square. There is exactly one ending square. 0 representing empty squares we can walk over. -1 representing obstacles that we cannot walk over. Return...
uniquePathsIII(grid: list_list_int) -> int
pub fn unique_paths_iii(grid: &[Vec<i64>]) -> i64
Aegis.UniquePathsIii.unique_paths_iii
pub fn unique_paths_iii(grid: &[Vec<i64>]) -> i64 { let m_usize: usize = grid.len(); let n_usize: usize = grid[0].len(); let m: i64 = m_usize as i64; let n: i64 = n_usize as i64; let mut start: i64 = 0; let mut end: i64 = 0; let mut all_mask: i64 = 0; let mut i: usize = 0; while i ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [unique_paths_iii]: type definitions module public import Aeneas @[expose] public section 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 -- [unique_paths_iii]: function definitions module public import Aeneas public import Aegis.UniquePathsIii.Code.Types public import Aegis.UniquePathsIii.Code.FunsExternal @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupName...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [unique_paths_iii]: external functions. -- This is a template file: rename it to "FunsExternal.lean" and fill the holes. module public import Aeneas public import Aegis.UniquePathsIii.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Erro...
import Aegis.UniquePathsIii.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.UniquePathsIii.unique_paths_iii (Slice.from [(alloc.vec.Vec.from [1#i64, 0#i64, 2#i64] (by scalar_tac) : alloc.vec.Vec Std.I64)] (by scalar_tac) :...
[ { "input": "[[[1, 0, 2]]]", "output": "1" }, { "input": "[[[0, 1], [2, 0]]]", "output": "0" }, { "input": "[[[1, 0], [0, 2]]]", "output": "0" }, { "input": "[[[1, 0, 0, 2]]]", "output": "1" }, { "input": "[[[1], [0], [0], [2]]]", "output": "1" }, { "in...
85
false
85
verified
10
10
1
8,558
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.UniquePathsIii.Code.Funs /-! # Specifications of `Aegis.UniquePathsIii.unique_paths_iii` LeetCode problem `unique-paths-iii`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.UniquePathsIii namespace AegisSpec.UniquePathsIii abbrev Grid : T...
15
minimum-cost-for-tickets
983
Medium
[ "Array", "Dynamic Programming" ]
You have planned some train traveling one year in advance. The days of the year in which you will travel are given as an integer array days. Each day is an integer from 1 to 365. Train tickets are sold in three different ways: a 1-day pass is sold for costs[0] dollars, a 7-day pass is sold for costs[1] dollars, and a ...
mincostTickets(days: list_int, costs: list_int) -> int
pub fn mincost_tickets(days: &[i64], costs: &[i64]) -> i64
Aegis.MincostTickets.mincost_tickets
pub fn mincost_tickets(days: &[i64], costs: &[i64]) -> i64 { let n: usize = days.len(); let mut dp: Vec<i64> = Vec::new(); let mut i: usize = 0; while i <= n { dp.push(0); i += 1; } i = 1; while i <= n { let d: i64 = days[i - 1]; let mut best: i64 = dp[i - ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [mincost_tickets]: type definitions module public import Aeneas @[expose] public section 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 -- [mincost_tickets]: function definitions module public import Aeneas public import Aegis.MincostTickets.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.MincostTickets.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.MincostTickets.mincost_tickets (Slice.from [365#i64] (by scalar_tac) : Slice Std.I64) (Slice.from [2#i64, 7#i64, 15#i64] (by scalar_tac) : Slice S...
[ { "input": "[[365], [2, 7, 15]]", "output": "2" }, { "input": "[[1], [2, 7, 15]]", "output": "2" }, { "input": "[[1, 100, 200, 300, 365], [2, 7, 15]]", "output": "10" }, { "input": "[[1, 100, 200, 300, 365], [5, 10, 15]]", "output": "25" }, { "input": "[[1, 50, 10...
79
false
79
verified
10
10
1
2,058
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MincostTickets.Code.Funs /-! # Specifications of `Aegis.MincostTickets.mincost_tickets` LeetCode problem `minimum-cost-for-tickets`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Aeneas.Std.Result open Aegis.MincostTickets namespace AegisSpec.MincostTickets def...
14
sum-of-even-numbers-after-queries
985
Medium
[ "Array", "Simulation" ]
You are given an integer array nums and an array queries where queries[i] = [vali, indexi]. For each query i, first, apply nums[indexi] = nums[indexi] + vali, then print the sum of the even values of nums. Return an integer array answer where answer[i] is the answer to the ith query.   Example 1: Input: nums = [1,2,3,...
sumEvenAfterQueries(nums: list_int, queries: list_list_int) -> list_int
pub fn sum_even_after_queries(nums: &[i64], queries: &[Vec<i64>]) -> Vec<i64>
Aegis.SumEvenAfterQueries.sum_even_after_queries
pub fn sum_even_after_queries(nums: &[i64], queries: &[Vec<i64>]) -> Vec<i64> { let n = nums.len(); let mut arr: Vec<i64> = Vec::new(); let mut even_sum: i64 = 0; let mut i: usize = 0; while i < n { let x = nums[i]; arr.push(x); if x % 2 == 0 { even_sum = even_su...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [sum_even_after_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 -- [sum_even_after_queries]: function definitions module public import Aeneas public import Aegis.SumEvenAfterQueries.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand ...
import Aegis.SumEvenAfterQueries.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.SumEvenAfterQueries.sum_even_after_queries (Slice.from [1#i64] (by scalar_tac) : Slice Std.I64) (Slice.from [(alloc.vec.Vec.from [4#i64, 0#i6...
[ { "input": "[[1], [[4, 0]]]", "output": "[0]" }, { "input": "[[2, 4, 6, 8], [[1, 0], [2, 1], [3, 2], [4, 3]]]", "output": "[18, 20, 14, 18]" }, { "input": "[[2, 4, 6, 8], [[-2, 0], [2, 1], [-4, 2], [4, 3]]]", "output": "[18, 20, 16, 20]" }, { "input": "[[0, 0, 0, 0], [[1, 0],...
88
false
88
verified
10
10
1
949
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.SumEvenAfterQueries.Code.Funs /-! # Specifications of `Aegis.SumEvenAfterQueries.sum_even_after_queries` LeetCode problem `sum-of-even-numbers-after-queries`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.SumEvenAfterQueries open ...
12
interval-list-intersections
986
Medium
[ "Array", "Two Pointers", "Line Sweep" ]
You are given two lists of closed intervals, firstList and secondList, where firstList[i] = [starti, endi] and secondList[j] = [startj, endj]. Each list of intervals is pairwise disjoint and in sorted order. Return the intersection of these two interval lists. A closed interval [a, b] (with a <= b) denotes the set of r...
intervalIntersection(firstList: list_list_int, secondList: list_list_int) -> list_list_int
pub fn interval_intersection(firstList: &[Vec<i64>], secondList: &[Vec<i64>]) -> Vec<Vec<i64>>
Aegis.IntervalIntersection.interval_intersection
#[cfg(test)] #[macro_export] macro_rules! vec { () => { Vec::<Vec<i64>>::new() }; ($($x:expr),+ $(,)?) => {{ let mut v = Vec::new(); $( v.push($x); )+ v }}; } pub fn interval_intersection(firstList: &[Vec<i64>], secondList: &[Vec<i64>]) -> Vec<Vec<i64>> { let mut res...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [interval_intersection]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [interval_intersection]: function definitions module public import Aeneas public import Aegis.IntervalIntersection.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand ...
import Aegis.IntervalIntersection.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.IntervalIntersection.interval_intersection (Slice.from [] (by scalar_tac) : Slice (alloc.vec.Vec Std.I64)) (Slice.from [(alloc.vec.Vec.from ...
[ { "input": "[[], [[1, 5], [8, 12]]]", "output": "[]" }, { "input": "[[[1, 3], [5, 9]], []]", "output": "[]" }, { "input": "[[[1, 5]], [[2, 3]]]", "output": "[[2, 3]]" }, { "input": "[[[1, 10]], [[5, 5]]]", "output": "[[5, 5]]" }, { "input": "[[[0, 2]], [[1, 2]]]",...
107
false
107
verified
10
10
4
47,912
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Mathlib import Aegis.IntervalIntersection.Code.Funs /-! # Specifications of `Aegis.IntervalIntersection.interval_intersection` LeetCode problem `interval-list-intersections`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.IntervalIntersecti...
13
vertical-order-traversal-of-a-binary-tree
987
Hard
[ "Tree", "Depth-First Search", "Breadth-First Search", "Hash Table", "Binary Tree", "Sorting" ]
Given the root of a binary tree, calculate the vertical order traversal of the binary tree. For each node at position (row, col), its left and right children will be at positions (row + 1, col - 1) and (row + 1, col + 1) respectively. The root of the tree is at (0, 0). The vertical order traversal of a binary tree is a...
verticalTraversal(root: tree) -> list_list_int
pub fn vertical_traversal(root: &Tree) -> Vec<Vec<i64>>
Aegis.VerticalTraversal.vertical_traversal
fn collect( t: &Tree, row: i64, col: i64, cols: &mut Vec<i64>, rows: &mut Vec<i64>, vals: &mut Vec<i64>, ) { match t { Tree::Null => {} Tree::Node(v, l, r) => { cols.push(col); rows.push(row); vals.push(*v); collect(&**l, row + ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [vertical_traversal]: type definitions module public import Aeneas @[expose] public section 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 -- [vertical_traversal]: function definitions module public import Aeneas public import Aegis.VerticalTraversal.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false ...
import Aegis.VerticalTraversal.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.VerticalTraversal.vertical_traversal ((.Node 1#i64 (.Node 2#i64 (.Node 4#i64 (.Null) (.Null)) (.Node 5#i64 (.Null) (.Null))) (.Node 3#i64 (.Nod...
[ { "input": "[[1, 2, 3, 4, 5, 6, 7]]", "output": "[[4], [2], [1, 5, 6], [3], [7]]" }, { "input": "[[1, 2, 3, 4, 6, 5, 7]]", "output": "[[4], [2], [1, 5, 6], [3], [7]]" }, { "input": "[[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]]", "output": "[[7], [3], [1, 8, 9, 11], [0, 4, 5],...
17
false
17
verified
10
10
1
5,622
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.VerticalTraversal.Code.Funs /-! # Specifications of `Aegis.VerticalTraversal.vertical_traversal` LeetCode problem `vertical-order-traversal-of-a-binary-tree`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.VerticalTraversal open Aegis....
14
add-to-array-form-of-integer
989
Easy
[ "Array", "Math" ]
The array-form of an integer num is an array representing its digits in left to right order. For example, for num = 1321, the array form is [1,3,2,1]. Given num, the array-form of an integer, and an integer k, return the array-form of the integer num + k.   Example 1: Input: num = [1,2,0,0], k = 34 Output: [1,2,3,4]...
addToArrayForm(num: list_int, k: int) -> list_int
pub fn add_to_array_form(num: &[i64], k: i64) -> Vec<i64>
Aegis.AddToArrayForm.add_to_array_form
pub fn add_to_array_form(num: &[i64], k: i64) -> Vec<i64> { let mut res: Vec<i64> = Vec::new(); let mut i: usize = num.len(); let mut carry: i64 = k; while i > 0 || carry > 0 { let mut sum: i64 = carry; if i > 0 { i = i - 1; sum = sum + num[i]; } ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [add_to_array_form]: type definitions module public import Aeneas @[expose] public section 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 -- [add_to_array_form]: function definitions module public import Aeneas public import Aegis.AddToArrayForm.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.AddToArrayForm.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.AddToArrayForm.add_to_array_form (Slice.from [1#i64] (by scalar_tac) : Slice Std.I64) 9#i64) ((alloc.vec.Vec.from [1#i64, 0#i64] (by scalar_tac) :...
[ { "input": "[[1], 9]", "output": "[1, 0]" }, { "input": "[[0], 23]", "output": "[2, 3]" }, { "input": "[[5], 5]", "output": "[1, 0]" }, { "input": "[[0], 256]", "output": "[2, 5, 6]" }, { "input": "[[0], 10000]", "output": "[1, 0, 0, 0, 0]" }, { "input...
69
false
69
verified
10
10
1
740
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.AddToArrayForm.Code.Funs /-! # Specifications of `Aegis.AddToArrayForm.add_to_array_form` LeetCode problem `add-to-array-form-of-integer`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.AddToArrayForm (add_to_array_form) namespace AegisSpec....
10
satisfiability-of-equality-equations
990
Medium
[ "Union Find", "Graph", "Array", "String" ]
You are given an array of strings equations that represent relationships between variables where each string equations[i] is of length 4 and takes one of two different forms: "xi==yi" or "xi!=yi".Here, xi and yi are lowercase letters (not necessarily different) that represent one-letter variable names. Return true if i...
equationsPossible(equations: list_str) -> bool
pub fn equations_possible(equations: &[Vec<u8>]) -> bool
Aegis.EquationsPossible.equations_possible
pub fn equations_possible(equations: &[Vec<u8>]) -> bool { let mut parent: Vec<usize> = Vec::new(); let mut i: usize = 0; while i < 26 { parent.push(i); i += 1; } let n: usize = equations.len(); i = 0; while i < n { if equations[i][1] == b'=' { let x: us...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [equations_possible]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option li...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [equations_possible]: function definitions module public import Aeneas public import Aegis.EquationsPossible.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false ...
import Aegis.EquationsPossible.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.EquationsPossible.equations_possible (Slice.from [(alloc.vec.Vec.from [97#u8, 33#u8, 61#u8, 97#u8] (by scalar_tac) : alloc.vec.Vec Std.U8)] (by...
[ { "input": "[[\"a!=a\"]]", "output": "false" }, { "input": "[[\"b==a\", \"a==b\"]]", "output": "true" }, { "input": "[[\"a==b\", \"b!=a\"]]", "output": "false" }, { "input": "[[\"c==c\", \"b==d\", \"x!=z\"]]", "output": "true" }, { "input": "[[\"a==b\", \"b==c\", ...
83
false
83
verified
10
10
1
2,922
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.EquationsPossible.Code.Funs /-! # Specifications of `Aegis.EquationsPossible.equations_possible` LeetCode problem `satisfiability-of-equality-equations`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.EquationsPossible abbrev Vec8 := A...
10
broken-calculator
991
Medium
[ "Greedy", "Math" ]
There is a broken calculator that has the integer startValue on its display initially. In one operation, you can: multiply the number on display by 2, or subtract 1 from the number on display. Given two integers startValue and target, return the minimum number of operations needed to display target on the calculator....
brokenCalc(startValue: int, target: int) -> int
pub fn broken_calc(startValue: i64, target: i64) -> i64
Aegis.BrokenCalc.broken_calc
pub fn broken_calc(startValue: i64, target: i64) -> i64 { let mut start = startValue; let mut t = target; if start >= t { return start - t; } let mut ops: i64 = 0; while t > start { if t % 2 == 0 { t = t / 2; } else { t = t + 1; } ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [broken_calc]: type definitions module public import Aeneas @[expose] public section 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 -- [broken_calc]: function definitions module public import Aeneas public import Aegis.BrokenCalc.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.BrokenCalc.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.BrokenCalc.broken_calc 2#i64 3#i64) (2#i64))}") #eval (s!"CASE 1 {(Result.reducesTo (Aegis.BrokenCalc.broken_calc 1000000000#i64 1#i64) (999999999#i64...
[ { "input": "[2, 3]", "output": "2" }, { "input": "[1000000000, 1]", "output": "999999999" }, { "input": "[7, 15]", "output": "6" }, { "input": "[2, 1]", "output": "1" }, { "input": "[3, 10]", "output": "3" }, { "input": "[100, 99]", "output": "1" ...
96
false
96
verified
10
10
1
1,728
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.BrokenCalc.Code.Funs /-! # Specifications of `Aegis.BrokenCalc.broken_calc` LeetCode problem `broken-calculator`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.BrokenCalc def Allowed (x y : Int) : Prop := y = 2 * x ∨ y = x - 1 def Re...
12
cousins-in-binary-tree
993
Easy
[ "Tree", "Depth-First Search", "Breadth-First Search", "Binary Tree" ]
Given the root of a binary tree with unique values and the values of two different nodes of the tree x and y, return true if the nodes corresponding to the values x and y in the tree are cousins, or false otherwise. Two nodes of a binary tree are cousins if they have the same depth with different parents. Note that in ...
isCousins(root: tree, x: int, y: int) -> bool
pub fn is_cousins(root: &Tree, x: i64, y: i64) -> bool
Aegis.IsCousins.is_cousins
fn depth_of(t: &Tree, target: i64) -> i64 { match t { Tree::Null => -1, Tree::Node(v, l, r) => { if *v == target { 0 } else { let dl = depth_of(&**l, target); if dl >= 0 { dl + 1 } else { ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [is_cousins]: type definitions module public import Aeneas @[expose] public section 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_cousins]: function definitions module public import Aeneas public import Aegis.IsCousins.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.IsCousins.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.IsCousins.is_cousins ((.Node 1#i64 (.Node 2#i64 (.Node 4#i64 (.Null) (.Null)) (.Null)) (.Node 3#i64 (.Null) (.Null))) : Aegis.IsCousins.Tree) 4#i64 3#i...
[ { "input": "[[1, 2, 3, 4], 4, 3]", "output": "false" }, { "input": "[[1, 2, 3, 4, 5, 6, 7], 2, 3]", "output": "false" }, { "input": "[[1, 2, 3, 4, 5, 6, 7], 4, 7]", "output": "true" }, { "input": "[[1, 2, 3, 4, 5, 6, 7], 4, 6]", "output": "true" }, { "input": "[[1...
10
false
10
verified
10
10
1
2,037
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.IsCousins.Code.Funs /-! # Specifications of `Aegis.IsCousins.is_cousins` LeetCode problem `cousins-in-binary-tree`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.IsCousins namespace AegisSpec.IsCousins def values : Tree → List Int | ...
11
rotting-oranges
994
Medium
[ "Breadth-First Search", "Array", "Matrix" ]
You are given an m x n grid where each cell can have one of three values: 0 representing an empty cell, 1 representing a fresh orange, or 2 representing a rotten orange. Every minute, any fresh orange that is 4-directionally adjacent to a rotten orange becomes rotten. Return the minimum number of minutes that must el...
orangesRotting(grid: list_list_int) -> int
pub fn oranges_rotting(grid: &[Vec<i64>]) -> i64
Aegis.OrangesRotting.oranges_rotting
pub fn oranges_rotting(grid: &[Vec<i64>]) -> i64 { let m = grid.len(); let n = grid[0].len(); let mut g: Vec<Vec<i64>> = Vec::new(); let mut fresh: i64 = 0; let mut qr: Vec<i64> = Vec::new(); let mut qc: Vec<i64> = Vec::new(); let mut i: usize = 0; while i < m { let src = &grid...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [oranges_rotting]: type definitions module public import Aeneas @[expose] public section 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 -- [oranges_rotting]: function definitions module public import Aeneas public import Aegis.OrangesRotting.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.OrangesRotting.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.OrangesRotting.oranges_rotting (Slice.from [(alloc.vec.Vec.from [1#i64] (by scalar_tac) : alloc.vec.Vec Std.I64), (alloc.vec.Vec.from [2#i64] (by ...
[ { "input": "[[[1], [2]]]", "output": "1" }, { "input": "[[[0, 2]]]", "output": "0" }, { "input": "[[[1, 2, 1, 1, 2, 1, 1]]]", "output": "2" }, { "input": "[[[1, 1, 1], [1, 1, 1], [1, 1, 1]]]", "output": "-1" }, { "input": "[[[2, 2, 2], [2, 1, 2], [2, 2, 2]]]", ...
96
false
96
verified
10
10
1
2,687
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.OrangesRotting.Code.Funs /-! # Specifications of `Aegis.OrangesRotting.oranges_rotting` LeetCode problem `rotting-oranges`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.OrangesRotting namespace AegisSpec.OrangesRotting abbrev Grid : Type := S...
13
minimum-number-of-k-consecutive-bit-flips
995
Hard
[ "Bit Manipulation", "Queue", "Array", "Prefix Sum", "Sliding Window" ]
You are given a binary array nums and an integer k. A k-bit flip is choosing a subarray of length k from nums and simultaneously changing every 0 in the subarray to 1, and every 1 in the subarray to 0. Return the minimum number of k-bit flips required so that there is no 0 in the array. If it is not possible, return -1...
minKBitFlips(nums: list_int, k: int) -> int
pub fn min_k_bit_flips(nums: &[i64], k: i64) -> i64
Aegis.MinKBitFlips.min_k_bit_flips
pub fn min_k_bit_flips(nums: &[i64], k: i64) -> i64 { let n = nums.len(); let kk = k as usize; let mut flip_start: Vec<i64> = Vec::new(); let mut p: usize = 0; while p < n { flip_start.push(0); p += 1; } let mut active_flips: i64 = 0; let mut answer: i64 = 0; let mu...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [min_k_bit_flips]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linte...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [min_k_bit_flips]: function definitions module public import Aeneas public import Aegis.MinKBitFlips.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.MinKBitFlips.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.MinKBitFlips.min_k_bit_flips (Slice.from [1#i64, 1#i64, 0#i64] (by scalar_tac) : Slice Std.I64) 2#i64) ((-1)#i64))}") #eval (s!"CASE 1 {(Result.redu...
[ { "input": "[[1, 1, 0], 2]", "output": "-1" }, { "input": "[[0, 1, 0], 1]", "output": "2" }, { "input": "[[0, 0, 0, 0, 0], 2]", "output": "-1" }, { "input": "[[1, 1, 1, 1, 1], 2]", "output": "0" }, { "input": "[[0, 0, 0, 0, 0], 5]", "output": "1" }, { ...
100
false
100
verified
10
10
1
1,975
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MinKBitFlips.Code.Funs /-! # Specifications of `Aegis.MinKBitFlips.min_k_bit_flips` LeetCode problem `minimum-number-of-k-consecutive-bit-flips`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.MinKBitFlips open Classical def bit...
12
number-of-squareful-arrays
996
Hard
[ "Bit Manipulation", "Array", "Hash Table", "Math", "Dynamic Programming", "Backtracking", "Bitmask" ]
An array is squareful if the sum of every pair of adjacent elements is a perfect square. Given an integer array nums, return the number of permutations of nums that are squareful. Two permutations perm1 and perm2 are different if there is some index i such that perm1[i] != perm2[i].   Example 1: Input: nums = [1,17,8]...
numSquarefulPerms(nums: list_int) -> int
pub fn num_squareful_perms(nums: &[i64]) -> i64
Aegis.NumSquarefulPerms.num_squareful_perms
pub fn num_squareful_perms(nums: &[i64]) -> i64 { let n: usize = nums.len(); if n == 0 { return 0; } let total_masks: usize = 1usize << n; let dp_size: usize = total_masks * n; let mut dp: Vec<i64> = Vec::new(); let mut k: usize = 0; while k < dp_size { dp.push(0); ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [num_squareful_perms]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option l...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [num_squareful_perms]: function definitions module public import Aeneas public import Aegis.NumSquarefulPerms.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false...
import Aegis.NumSquarefulPerms.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.NumSquarefulPerms.num_squareful_perms (Slice.from [2#i64, 2#i64, 2#i64] (by scalar_tac) : Slice Std.I64)) (1#i64))}") #eval (s!"CASE 1 {(Result...
[ { "input": "[[2, 2, 2]]", "output": "1" }, { "input": "[[1, 17, 8]]", "output": "2" }, { "input": "[[9, 0, 9]]", "output": "1" }, { "input": "[[0, 0, 0]]", "output": "1" }, { "input": "[[0, 1, 1, 0]]", "output": "3" }, { "input": "[[1, 1, 1, 1]]", ...
109
false
109
verified
10
10
1
6,558
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.NumSquarefulPerms.Code.Funs /-! # Specifications of `Aegis.NumSquarefulPerms.num_squareful_perms` LeetCode problem `number-of-squareful-arrays`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Classical namespace AegisSpec.NumSquarefulPerms def IsSqua...
12
find-the-town-judge
997
Easy
[ "Graph", "Array", "Hash Table" ]
In a town, there are n people labeled from 1 to n. There is a rumor that one of these people is secretly the town judge. If the town judge exists, then: The town judge trusts nobody. Everybody (except for the town judge) trusts the town judge. There is exactly one person that satisfies properties 1 and 2. You are giv...
findJudge(n: int, trust: list_list_int) -> int
pub fn find_judge(n: i64, trust: &[Vec<i64>]) -> i64
Aegis.FindJudge.find_judge
pub fn find_judge(n: i64, trust: &[Vec<i64>]) -> i64 { let size = n as usize; let mut indegree: Vec<i64> = Vec::new(); let mut outdegree: Vec<i64> = Vec::new(); let mut i = 0usize; while i <= size { indegree.push(0); outdegree.push(0); i += 1; } let m = trust.len()...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [find_judge]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter.sty...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [find_judge]: function definitions module public import Aeneas public import Aegis.FindJudge.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.FindJudge.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.FindJudge.find_judge 1#i64 (Slice.from [] (by scalar_tac) : Slice (alloc.vec.Vec Std.I64))) (1#i64))}") #eval (s!"CASE 1 {(Result.reducesTo (Aegis.Find...
[ { "input": "[1, []]", "output": "1" }, { "input": "[2, [[1, 2]]]", "output": "2" }, { "input": "[3, [[1, 3], [2, 3]]]", "output": "3" }, { "input": "[3, [[1, 3], [2, 3], [3, 1]]]", "output": "-1" }, { "input": "[4, [[1, 2], [1, 3], [1, 4]]]", "output": "-1" ...
86
false
86
verified
10
10
1
1,232
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.FindJudge.Code.Funs /-! # Specifications of `Aegis.FindJudge.find_judge` LeetCode problem `find-the-town-judge`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.FindJudge abbrev TrustVec := Slice (alloc.vec.Vec Std.I64) def trust...
10
maximum-binary-tree-ii
998
Medium
[ "Tree", "Binary Tree" ]
A maximum tree is a tree where every node has a value greater than any other value in its subtree. You are given the root of a maximum binary tree and an integer val. Just as in the previous problem, the given tree was constructed from a list a (root = Construct(a)) recursively with the following Construct(a) routine: ...
insertIntoMaxTree(root: tree, val: int) -> tree
pub fn insert_into_max_tree(root: &Tree, val: i64) -> Tree
Aegis.InsertIntoMaxTree.insert_into_max_tree
fn clone_tree(t: &Tree) -> Tree { match t { Tree::Null => Tree::Null, Tree::Node(v, l, r) => Tree::Node( *v, Box::new(clone_tree(&**l)), Box::new(clone_tree(&**r)), ), } } fn insert_into_max_tree_helper(t: &Tree, val: i64) -> Tree { match t { ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [insert_into_max_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 ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [insert_into_max_tree]: function definitions module public import Aeneas public import Aegis.InsertIntoMaxTree.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand fals...
import Aegis.InsertIntoMaxTree.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 deriving instance DecidableEq for Aegis.InsertIntoMaxTree.Tree #eval (s!"CASE 0 {(match (Aegis.InsertIntoMaxTree.insert_into_max_tree ((.Node 1#i64 (.Null) (.Null)) : Aegis.InsertIntoMa...
[ { "input": "[[1], 2]", "output": "[2, 1]" }, { "input": "[[2, 1], 3]", "output": "[3, 2, null, 1]" }, { "input": "[[3, 2, 1], 4]", "output": "[4, 3, null, 2, 1]" }, { "input": "[[5, 3, 7, 2, 4, 6, 8], 1]", "output": "[5, 3, 7, 2, 4, 6, 8, null, null, null, null, null, nul...
16
false
16
verified
10
10
1
3,626
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.InsertIntoMaxTree.Code.Funs /-! # Specifications of `Aegis.InsertIntoMaxTree.insert_into_max_tree` LeetCode problem `maximum-binary-tree-ii`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.InsertIntoMaxTree open Aegis.InsertIntoMax...
11
minimum-cost-to-merge-stones
1,000
Hard
[ "Array", "Dynamic Programming", "Prefix Sum" ]
There are n piles of stones arranged in a row. The ith pile has stones[i] stones. A move consists of merging exactly k consecutive piles into one pile, and the cost of this move is equal to the total number of stones in these k piles. Return the minimum cost to merge all piles of stones into one pile. If it is impossib...
mergeStones(stones: list_int, k: int) -> int
pub fn merge_stones(stones: &[i64], k: i64) -> i64
Aegis.MergeStones.merge_stones
pub fn merge_stones(stones: &[i64], k: i64) -> i64 { let n = stones.len(); if n == 0 { return 0; } if n == 1 { return 0; } if k <= 1 { return -1; } let k_usize = k as usize; if k_usize < 2 { return -1; } let km1 = k_usize - 1; if (n - 1)...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [merge_stones]: type definitions module public import Aeneas @[expose] public section 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 -- [merge_stones]: function definitions module public import Aeneas public import Aegis.MergeStones.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.MergeStones.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.MergeStones.merge_stones (Slice.from [4#i64, 3#i64, 2#i64] (by scalar_tac) : Slice Std.I64) 2#i64) (14#i64))}") #eval (s!"CASE 1 {(Result.reducesTo (...
[ { "input": "[[4, 3, 2], 2]", "output": "14" }, { "input": "[[3, 2, 1], 3]", "output": "6" }, { "input": "[[1, 2, 3], 4]", "output": "-1" }, { "input": "[[3, 2, 4, 1], 3]", "output": "-1" }, { "input": "[[4, 4, 4, 4], 2]", "output": "32" }, { "input": "...
235
false
235
verified
10
10
1
6,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.MergeStones.Code.Funs /-! # Specifications of `Aegis.MergeStones.merge_stones` LeetCode problem `minimum-cost-to-merge-stones`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.MergeStones abbrev Config : Type := List Int def LegalMove ...
9
grid-illumination
1,001
Hard
[ "Array", "Hash Table" ]
There is a 2D grid of size n x n where each cell of this grid has a lamp that is initially turned off. You are given a 2D array of lamp positions lamps, where lamps[i] = [rowi, coli] indicates that the lamp at grid[rowi][coli] is turned on. Even if the same lamp is listed more than once, it is turned on. When a lamp is...
gridIllumination(n: int, lamps: list_list_int, queries: list_list_int) -> list_int
pub fn grid_illumination(n: i64, lamps: &[Vec<i64>], queries: &[Vec<i64>]) -> Vec<i64>
Aegis.GridIllumination.grid_illumination
fn lower_bound(a: &[i64], x: i64) -> usize { let mut lo: usize = 0; let mut hi: usize = a.len(); while lo < hi { let mid = lo + (hi - lo) / 2; if a[mid] < x { lo = mid + 1; } else { hi = mid; } } lo } // Manual iterative bottom-up merge sort (...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [grid_illumination]: type definitions module public import Aeneas @[expose] public section 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 -- [grid_illumination]: function definitions module public import Aeneas public import Aegis.GridIllumination.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.GridIllumination.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.GridIllumination.grid_illumination 5#i64 (Slice.from [(alloc.vec.Vec.from [0#i64, 0#i64] (by scalar_tac) : alloc.vec.Vec Std.I64), (alloc.vec.Ve...
[ { "input": "[5, [[0, 0], [4, 4]], [[1, 1], [1, 1]]]", "output": "[1, 1]" }, { "input": "[5, [[0, 0], [4, 4]], [[1, 1], [1, 0]]]", "output": "[1, 0]" }, { "input": "[5, [[0, 0], [0, 4]], [[0, 4], [0, 1], [1, 4]]]", "output": "[1, 1, 0]" }, { "input": "[500, [[100, 100], [200, ...
85
false
85
verified
10
10
2
16,271
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.GridIllumination.Code.Funs /-! # Specifications of `Aegis.GridIllumination.grid_illumination` LeetCode problem `grid-illumination`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.GridIllumination (grid_illumination) namespace AegisSpec.GridI...
15
find-common-characters
1,002
Easy
[ "Array", "Hash Table", "String" ]
Given a string array words, return an array of all characters that show up in all strings within the words (including duplicates). You may return the answer in any order.   Example 1: Input: words = ["bella","label","roller"] Output: ["e","l","l"] Example 2: Input: words = ["cool","lock","cook"] Output: ["c","o"]   Co...
commonChars(words: list_str) -> list_str
pub fn common_chars(words: &[Vec<u8>]) -> Vec<Vec<u8>>
Aegis.CommonChars.common_chars
pub fn common_chars(words: &[Vec<u8>]) -> Vec<Vec<u8>> { let mut out: Vec<Vec<u8>> = Vec::new(); if words.len() == 0 { return out; } // min_counts will hold the minimum frequency of each lowercase letter // across all words processed so far. let mut min_counts: Vec<i64> = Vec::new(); ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [common_chars]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter.s...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [common_chars]: function definitions module public import Aeneas public import Aegis.CommonChars.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.CommonChars.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(match (Aegis.CommonChars.common_chars (Slice.from [(alloc.vec.Vec.from [112#u8, 121#u8, 116#u8, 104#u8, 111#u8, 110#u8] (by scalar_tac) : alloc.vec.Vec Std.U8), (alloc.vec.V...
[ { "input": "[[\"python\", \"java\", \"javascript\"]]", "output": "[]" }, { "input": "[[\"a\", \"b\", \"c\"]]", "output": "[]" }, { "input": "[[\"a\", \"a\", \"a\"]]", "output": "[\"a\"]" }, { "input": "[[\"abracadabra\", \"alakazam\", \"alchemy\"]]", "output": "[\"a\"]" ...
103
true
103
verified
10
10
1
2,494
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.CommonChars.Code.Funs /-! # Specifications of `Aegis.CommonChars.common_chars` LeetCode problem `find-common-characters`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.CommonChars (common_chars) namespace AegisSpec.CommonChars def count (c : N...
6
check-if-word-is-valid-after-substitutions
1,003
Medium
[ "Stack", "String" ]
Given a string s, determine if it is valid. A string s is valid if, starting with an empty string t = "", you can transform t into s after performing the following operation any number of times: Insert string "abc" into any position in t. More formally, t becomes tleft + "abc" + tright, where t == tleft + tright. Note...
isValid(s: str) -> bool
pub fn is_valid(s: &[u8]) -> bool
Aegis.IsValid.is_valid
pub fn is_valid(s: &[u8]) -> bool { let mut stack: Vec<u8> = Vec::new(); let mut top: usize = 0; let mut i: usize = 0; while i < s.len() { let ch = s[i]; if top < stack.len() { stack[top] = ch; } else { stack.push(ch); } top += 1; ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [is_valid]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter.style...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [is_valid]: function definitions module public import Aeneas public import Aegis.IsValid.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.un...
import Aegis.IsValid.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.IsValid.is_valid (Slice.from [97#u8, 97#u8, 97#u8, 98#u8, 98#u8, 98#u8, 99#u8, 99#u8, 99#u8] (by scalar_tac) : Slice Std.U8)) (false))}") #eval (s!"CASE ...
[ { "input": "[\"aaabbbccc\"]", "output": "false" }, { "input": "[\"aababcbccabc\"]", "output": "false" }, { "input": "[\"cababc\"]", "output": "false" }, { "input": "[\"abcabcabc\"]", "output": "true" }, { "input": "[\"aababcbabc\"]", "output": "false" }, {...
140
false
140
verified
10
10
1
2,944
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.IsValid.Code.Funs /-! # Specifications of `Aegis.IsValid.is_valid` LeetCode problem `check-if-word-is-valid-after-substitutions`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.IsValid def bytes (s : Slice Std.U8) : List Nat := s.val.m...
14
clumsy-factorial
1,006
Medium
[ "Stack", "Math", "Simulation" ]
The factorial of a positive integer n is the product of all positive integers less than or equal to n. For example, factorial(10) = 10 * 9 * 8 * 7 * 6 * 5 * 4 * 3 * 2 * 1. We make a clumsy factorial using the integers in decreasing order by swapping out the multiply operations for a fixed rotation of operations with ...
clumsy(n: int) -> int
pub fn clumsy(n: i64) -> i64
Aegis.Clumsy.clumsy
pub fn clumsy(n: i64) -> i64 { let mut total: i64 = 0; let mut term: i64 = n; let mut sign: i64 = 1; let mut x: i64 = n - 1; let mut op: i64 = 0; while x >= 1 { if op == 0 { term = term * x; } else if op == 1 { term = term / x; } else if op == 2 {...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [clumsy]: type definitions module public import Aeneas @[expose] public section 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.w...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [clumsy]: function definitions module public import Aeneas public import Aegis.Clumsy.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.unuse...
import Aegis.Clumsy.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.Clumsy.clumsy 8#i64) (9#i64))}") #eval (s!"CASE 1 {(Result.reducesTo (Aegis.Clumsy.clumsy 3#i64) (6#i64))}") #eval (s!"CASE 2 {(Result.reducesTo (Aegis.Cl...
[ { "input": "[8]", "output": "9" }, { "input": "[3]", "output": "6" }, { "input": "[100]", "output": "101" }, { "input": "[4]", "output": "7" }, { "input": "[10000]", "output": "10001" }, { "input": "[9]", "output": "11" }, { "input": "[5000...
38
false
38
verified
10
10
1
2,579
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.Clumsy.Code.Funs /-! # Specifications of `Aegis.Clumsy.clumsy` LeetCode problem `clumsy-factorial`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.Clumsy def aVal (n : ℤ) (i : ℤ) : ℤ := n - i def floorDiv (x y : ℤ) : ℤ := x / y def B...
11
complement-of-base-10-integer
1,009
Easy
[ "Bit Manipulation" ]
The complement of an integer is the integer you get when you flip all the 0's to 1's and all the 1's to 0's in its binary representation. For example, The integer 5 is "101" in binary and its complement is "010" which is the integer 2. Given an integer n, return its complement.   Example 1: Input: n = 5 Output: 2 Ex...
bitwiseComplement(n: int) -> int
pub fn bitwise_complement(n: i64) -> i64
Aegis.BitwiseComplement.bitwise_complement
pub fn bitwise_complement(n: i64) -> i64 { if n == 0 { return 1; } let mut x = n; let mut mask: i64 = 0; while x > 0 { mask = mask * 2 + 1; x = x / 2; } mask - n }
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [bitwise_complement]: type definitions module public import Aeneas @[expose] public section 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 -- [bitwise_complement]: function definitions module public import Aeneas public import Aegis.BitwiseComplement.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false ...
import Aegis.BitwiseComplement.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.BitwiseComplement.bitwise_complement 0#i64) (1#i64))}") #eval (s!"CASE 1 {(Result.reducesTo (Aegis.BitwiseComplement.bitwise_complement 8#i64) ...
[ { "input": "[0]", "output": "1" }, { "input": "[8]", "output": "7" }, { "input": "[100]", "output": "27" }, { "input": "[15]", "output": "0" }, { "input": "[31]", "output": "0" }, { "input": "[123456789]", "output": "10760938" }, { "input":...
37
false
37
verified
10
10
1
537
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.BitwiseComplement.Code.Funs /-! # Specifications of `Aegis.BitwiseComplement.bitwise_complement` LeetCode problem `complement-of-base-10-integer`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.BitwiseComplement namespace AegisSpec.BitwiseCo...
16
pairs-of-songs-with-total-durations-divisible-by-60
1,010
Medium
[ "Array", "Hash Table", "Counting" ]
You are given a list of songs where the ith song has a duration of time[i] seconds. Return the number of pairs of songs for which their total duration in seconds is divisible by 60. Formally, we want the number of indices i, j such that i < j with (time[i] + time[j]) % 60 == 0.   Example 1: Input: time = [30,20,150,10...
numPairsDivisibleBy60(time: list_int) -> int
pub fn num_pairs_divisible_by60(time: &[i64]) -> i64
Aegis.NumPairsDivisibleBy60.num_pairs_divisible_by60
pub fn num_pairs_divisible_by60(time: &[i64]) -> i64 { let mut counts: Vec<i64> = Vec::new(); let mut i: usize = 0; while i < 60 { counts.push(0); i += 1; } let mut total: i64 = 0; let mut j: usize = 0; while j < time.len() { let r: usize = (time[j] % 60) as usize; ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [num_pairs_divisible_by60]: type definitions module public import Aeneas @[expose] public 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 -- [num_pairs_divisible_by60]: function definitions module public import Aeneas public import Aegis.NumPairsDivisibleBy60.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashComm...
import Aegis.NumPairsDivisibleBy60.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.NumPairsDivisibleBy60.num_pairs_divisible_by60 (Slice.from [60#i64, 60#i64, 60#i64] (by scalar_tac) : Slice Std.I64)) (3#i64))}") #eval (s!...
[ { "input": "[[60, 60, 60]]", "output": "3" }, { "input": "[[40, 20, 50, 30, 10]]", "output": "2" }, { "input": "[[60, 120, 180, 240, 300]]", "output": "10" }, { "input": "[[30, 60, 90, 120, 150]]", "output": "4" }, { "input": "[[10, 20, 30, 40, 50]]", "output"...
89
false
89
verified
10
10
1
787
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.NumPairsDivisibleBy60.Code.Funs /-! # Specifications of `Aegis.NumPairsDivisibleBy60.num_pairs_divisible_by60` LeetCode problem `pairs-of-songs-with-total-durations-divisible-by-60`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.NumPai...
12
capacity-to-ship-packages-within-d-days
1,011
Medium
[ "Array", "Binary Search" ]
A conveyor belt has packages that must be shipped from one port to another within days days. The ith package on the conveyor belt has a weight of weights[i]. Each day, we load the ship with packages on the conveyor belt (in the order given by weights). We may not load more weight than the maximum weight capacity of the...
shipWithinDays(weights: list_int, days: int) -> int
pub fn ship_within_days(weights: &[i64], days: i64) -> i64
Aegis.ShipWithinDays.ship_within_days
pub fn ship_within_days(weights: &[i64], days: i64) -> i64 { let n = weights.len(); let mut lo: i64 = 0; let mut hi: i64 = 0; let mut i: usize = 0; while i < n { let w = weights[i]; if w > lo { lo = w; } hi = hi + w; i += 1; } while lo < ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [ship_within_days]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option lint...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [ship_within_days]: function definitions module public import Aeneas public import Aegis.ShipWithinDays.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.ShipWithinDays.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.ShipWithinDays.ship_within_days (Slice.from [1#i64, 2#i64, 3#i64, 1#i64, 1#i64] (by scalar_tac) : Slice Std.I64) 4#i64) (3#i64))}") #eval (s!"CASE...
[ { "input": "[[1, 2, 3, 1, 1], 4]", "output": "3" }, { "input": "[[5, 5, 5, 5, 5], 2]", "output": "15" }, { "input": "[[10, 50, 100, 100, 50, 10], 2]", "output": "160" }, { "input": "[[10, 50, 100, 100, 50, 10], 3]", "output": "160" }, { "input": "[[3, 2, 2, 4, 1, ...
80
false
80
verified
10
10
1
804
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.ShipWithinDays.Code.Funs /-! # Specifications of `Aegis.ShipWithinDays.ship_within_days` LeetCode problem `capacity-to-ship-packages-within-d-days`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.ShipWithinDays namespace AegisSpec.ShipWithinDays...
15
numbers-with-repeated-digits
1,012
Hard
[ "Math", "Dynamic Programming" ]
Given an integer n, return the number of positive integers in the range [1, n] that have at least one repeated digit.   Example 1: Input: n = 20 Output: 1 Explanation: The only positive number (<= 20) with at least 1 repeated digit is 11. Example 2: Input: n = 100 Output: 10 Explanation: The positive numbers (<= 100...
numDupDigitsAtMostN(n: int) -> int
pub fn num_dup_digits_at_most_n(n: i64) -> i64
Aegis.NumDupDigitsAtMostN.num_dup_digits_at_most_n
pub fn num_dup_digits_at_most_n(n: i64) -> i64 { if n <= 0 { return 0; } // Extract the decimal digits of n into most-significant-first order. let mut temp: i64 = n; let mut rev: Vec<i64> = Vec::new(); while temp > 0 { rev.push(temp % 10); temp = temp / 10; } le...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [num_dup_digits_at_most_n]: type definitions module public import Aeneas @[expose] public 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 -- [num_dup_digits_at_most_n]: function definitions module public import Aeneas public import Aegis.NumDupDigitsAtMostN.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashComman...
import Aegis.NumDupDigitsAtMostN.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.NumDupDigitsAtMostN.num_dup_digits_at_most_n 99999#i64) (67509#i64))}") #eval (s!"CASE 1 {(Result.reducesTo (Aegis.NumDupDigitsAtMostN.num_du...
[ { "input": "[99999]", "output": "67509" }, { "input": "[999999999]", "output": "994388229" }, { "input": "[9999999]", "output": "9287109" }, { "input": "[100]", "output": "10" }, { "input": "[56789]", "output": "37493" }, { "input": "[1000]", "outp...
59
false
59
verified
10
10
1
6,870
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.NumDupDigitsAtMostN.Code.Funs /-! # Specifications of `Aegis.NumDupDigitsAtMostN.num_dup_digits_at_most_n` LeetCode problem `numbers-with-repeated-digits`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.NumDupDigitsAtMostN def digi...
10
partition-array-into-three-parts-with-equal-sum
1,013
Easy
[ "Greedy", "Array" ]
Given an array of integers arr, return true if we can partition the array into three non-empty parts with equal sums. Formally, we can partition the array if we can find indexes i + 1 < j with (arr[0] + arr[1] + ... + arr[i] == arr[i + 1] + arr[i + 2] + ... + arr[j - 1] == arr[j] + arr[j + 1] + ... + arr[arr.length - 1...
canThreePartsEqualSum(arr: list_int) -> bool
pub fn can_three_parts_equal_sum(arr: &[i64]) -> bool
Aegis.CanThreePartsEqualSum.can_three_parts_equal_sum
pub fn can_three_parts_equal_sum(arr: &[i64]) -> bool { let n = arr.len(); if n < 3 { return false; } let mut total: i64 = 0; let mut idx: usize = 0; while idx < n { total = total + arr[idx]; idx = idx + 1; } if total % 3 != 0 { return false; } ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [can_three_parts_equal_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_op...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [can_three_parts_equal_sum]: function definitions module public import Aeneas public import Aegis.CanThreePartsEqualSum.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCom...
import Aegis.CanThreePartsEqualSum.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.CanThreePartsEqualSum.can_three_parts_equal_sum (Slice.from [(-10000)#i64, 10000#i64, (-10000)#i64, 10000#i64, (-10000)#i64, 10000#i64] (by...
[ { "input": "[[-10000, 10000, -10000, 10000, -10000, 10000]]", "output": "true" }, { "input": "[[10, -10, 10, -10, 10, -10, 10, -10]]", "output": "true" }, { "input": "[[1, -1, 1, -1, 1, -1, 1, -1]]", "output": "true" }, { "input": "[[1, 2, 3, 0, 0, 0, 1, 2, 3]]", "output"...
77
false
77
verified
10
10
1
6,278
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.CanThreePartsEqualSum.Code.Funs /-! # Specifications of `Aegis.CanThreePartsEqualSum.can_three_parts_equal_sum` LeetCode problem `partition-array-into-three-parts-with-equal-sum`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.CanThreeP...
13
best-sightseeing-pair
1,014
Medium
[ "Array", "Dynamic Programming" ]
You are given an integer array values where values[i] represents the value of the ith sightseeing spot. Two sightseeing spots i and j have a distance j - i between them. The score of a pair (i < j) of sightseeing spots is values[i] + values[j] + i - j: the sum of the values of the sightseeing spots, minus the distance ...
maxScoreSightseeingPair(values: list_int) -> int
pub fn max_score_sightseeing_pair(values: &[i64]) -> i64
Aegis.MaxScoreSightseeingPair.max_score_sightseeing_pair
pub fn max_score_sightseeing_pair(values: &[i64]) -> i64 { let n = values.len(); if n < 2 { return 0; } let mut best = values[0]; let mut ans = values[0] + values[1] - 1; let mut j: usize = 1; let mut pos: i64 = 1; while j < n { let candidate = best + values[j] - pos; ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [max_score_sightseeing_pair]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_o...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [max_score_sightseeing_pair]: function definitions module public import Aeneas public import Aegis.MaxScoreSightseeingPair.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hash...
import Aegis.MaxScoreSightseeingPair.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.MaxScoreSightseeingPair.max_score_sightseeing_pair (Slice.from [1#i64, 2#i64] (by scalar_tac) : Slice Std.I64)) (2#i64))}") #eval (s!"CAS...
[ { "input": "[[1, 2]]", "output": "2" }, { "input": "[[3, 7, 2, 5]]", "output": "10" }, { "input": "[[9, 4, 3, 2]]", "output": "12" }, { "input": "[[8, 1, 5, 2, 6]]", "output": "11" }, { "input": "[[1000, 1, 1000, 1, 1000]]", "output": "1998" }, { "inpu...
106
false
106
verified
10
10
1
1,108
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MaxScoreSightseeingPair.Code.Funs /-! # Specifications of `Aegis.MaxScoreSightseeingPair.max_score_sightseeing_pair` LeetCode problem `best-sightseeing-pair`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.MaxScoreSightseeingPair namespace A...
10
smallest-integer-divisible-by-k
1,015
Medium
[ "Hash Table", "Math" ]
Given a positive integer k, you need to find the length of the smallest positive integer n such that n is divisible by k, and n only contains the digit 1. Return the length of n. If there is no such n, return -1. Note: n may not fit in a 64-bit signed integer.   Example 1: Input: k = 1 Output: 1 Explanation: The small...
smallestRepunitDivByK(k: int) -> int
pub fn smallest_repunit_div_by_k(k: i64) -> i64
Aegis.SmallestRepunitDivByK.smallest_repunit_div_by_k
pub fn smallest_repunit_div_by_k(k: i64) -> i64 { if k % 2 == 0 || k % 5 == 0 { return -1; } let mut rem: i64 = 0; let mut length: i64 = 1; while length <= k { rem = (rem * 10 + 1) % k; if rem == 0 { return length; } length += 1; } -1 ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [smallest_repunit_div_by_k]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_op...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [smallest_repunit_div_by_k]: function definitions module public import Aeneas public import Aegis.SmallestRepunitDivByK.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCom...
import Aegis.SmallestRepunitDivByK.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.SmallestRepunitDivByK.smallest_repunit_div_by_k 29#i64) (28#i64))}") #eval (s!"CASE 1 {(Result.reducesTo (Aegis.SmallestRepunitDivByK.small...
[ { "input": "[29]", "output": "28" }, { "input": "[101]", "output": "4" }, { "input": "[83]", "output": "41" }, { "input": "[43]", "output": "21" }, { "input": "[89]", "output": "44" }, { "input": "[17]", "output": "16" }, { "input": "[73]",...
90
false
90
verified
10
10
1
430
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.SmallestRepunitDivByK.Code.Funs /-! # Specifications of `Aegis.SmallestRepunitDivByK.smallest_repunit_div_by_k` LeetCode problem `smallest-integer-divisible-by-k`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.SmallestRepunitDivByK ...
7
binary-string-with-substrings-representing-1-to-n
1,016
Medium
[ "String" ]
Given a binary string s and a positive integer n, return true if the binary representation of all the integers in the range [1, n] are substrings of s, or false otherwise. A substring is a contiguous sequence of characters within a string.   Example 1: Input: s = "0110", n = 3 Output: true Example 2: Input: s = "0110",...
queryString(s: str, n: int) -> bool
pub fn query_string(s: &[u8], n: i64) -> bool
Aegis.QueryString.query_string
pub fn query_string(s: &[u8], n: i64) -> bool { if n < 1 { return true; } // To contain all numbers up to n >= 2048, s would need to contain // all 1024 distinct 10-bit binary strings. Since s.len() <= 1000, // this is impossible. if n >= 2048 { return false; } // Conve...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [query_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.s...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [query_string]: function definitions module public import Aeneas public import Aegis.QueryString.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.QueryString.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.QueryString.query_string (Slice.from [48#u8, 49#u8, 49#u8, 48#u8] (by scalar_tac) : Slice Std.U8) 3#i64) (true))}") #eval (s!"CASE 1 {(Result.reduces...
[ { "input": "[\"0110\", 3]", "output": "true" }, { "input": "[\"1111111111\", 10]", "output": "false" }, { "input": "[\"0000000000\", 1]", "output": "false" }, { "input": "[\"0110\", 4]", "output": "false" }, { "input": "[\"000000\", 1]", "output": "false" },...
96
false
96
verified
10
10
1
15,966
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.QueryString.Code.Funs /-! # Specifications of `Aegis.QueryString.query_string` LeetCode problem `binary-string-with-substrings-representing-1-to-n`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.QueryString def binDigits (k : ℕ) :...
11
binary-prefix-divisible-by-5
1,018
Easy
[ "Bit Manipulation", "Array" ]
You are given a binary array nums (0-indexed). We define xi as the number whose binary representation is the subarray nums[0..i] (from most-significant-bit to least-significant-bit). For example, if nums = [1,0,1], then x0 = 1, x1 = 2, and x2 = 5. Return an array of booleans answer where answer[i] is true if xi is di...
prefixesDivBy5(nums: list_int) -> list_bool
pub fn prefixes_div_by5(nums: &[i64]) -> Vec<bool>
Aegis.PrefixesDivBy5.prefixes_div_by5
pub fn prefixes_div_by5(nums: &[i64]) -> Vec<bool> { let mut answer: Vec<bool> = Vec::new(); let mut rem: i64 = 0; let mut i: usize = 0; while i < nums.len() { rem = (rem * 2 + nums[i]) % 5; answer.push(rem == 0); i += 1; } answer }
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [prefixes_div_by5]: type definitions module public import Aeneas @[expose] public section 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 -- [prefixes_div_by5]: function definitions module public import Aeneas public import Aegis.PrefixesDivBy5.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.PrefixesDivBy5.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.PrefixesDivBy5.prefixes_div_by5 (Slice.from [1#i64] (by scalar_tac) : Slice Std.I64)) ((alloc.vec.Vec.from [false] (by scalar_tac) : alloc.vec.Vec...
[ { "input": "[[1]]", "output": "[false]" }, { "input": "[[1, 1, 1]]", "output": "[false, false, false]" }, { "input": "[[0, 1, 1]]", "output": "[true, false, false]" }, { "input": "[[0, 0, 0, 0, 0]]", "output": "[true, true, true, true, true]" }, { "input": "[[1, 0...
69
false
69
verified
10
10
1
323
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.PrefixesDivBy5.Code.Funs /-! # Specifications of `Aegis.PrefixesDivBy5.prefixes_div_by5` LeetCode problem `binary-prefix-divisible-by-5`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.PrefixesDivBy5 def ival (nums : Slice Std.I64) (j ...
6
next-greater-node-in-linked-list
1,019
Medium
[ "Stack", "Array", "Linked List", "Monotonic Stack" ]
You are given the head of a linked list with n nodes. For each node in the list, find the value of the next greater node. That is, for each node, find the value of the first node that is next to it and has a strictly larger value than it. Return an integer array answer where answer[i] is the value of the next greater n...
nextLargerNodes(head: linkedlist) -> list_int
pub fn next_larger_nodes(head: &List) -> Vec<i64>
Aegis.NextLargerNodes.next_larger_nodes
fn collect_values(list: &List, vals: &mut Vec<i64>) { match list { List::Nil => {} List::Cons(v, next) => { vals.push(*v); collect_values(&**next, vals); } } } pub fn next_larger_nodes(head: &List) -> Vec<i64> { let mut vals: Vec<i64> = Vec::new(); collec...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [next_larger_nodes]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option lin...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [next_larger_nodes]: function definitions module public import Aeneas public import Aegis.NextLargerNodes.Code.Types public import Aegis.NextLargerNodes.Code.FunsExternal @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupN...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [next_larger_nodes]: external functions. -- This is a template file: rename it to "FunsExternal.lean" and fill the holes. module public import Aeneas public import Aegis.NextLargerNodes.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Er...
import Aegis.NextLargerNodes.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.NextLargerNodes.next_larger_nodes ((.Cons 1#i64 (.Nil)) : Aegis.NextLargerNodes.List)) ((alloc.vec.Vec.from [0#i64] (by scalar_tac) : alloc.vec.V...
[ { "input": "[[1]]", "output": "[0]" }, { "input": "[[2, 1, 5]]", "output": "[5, 5, 0]" }, { "input": "[[5, 4, 3, 2, 1]]", "output": "[0, 0, 0, 0, 0]" }, { "input": "[[9, 7, 5, 3, 1]]", "output": "[0, 0, 0, 0, 0]" }, { "input": "[[1, 2, 3, 4, 5]]", "output": "[...
115
false
115
verified
10
10
1
3,164
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.NextLargerNodes.Code.Funs /-! # Specifications of `Aegis.NextLargerNodes.next_larger_nodes` LeetCode problem `next-greater-node-in-linked-list`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.NextLargerNodes (next_larger_nodes) namespace Aeg...
15
number-of-enclaves
1,020
Medium
[ "Depth-First Search", "Breadth-First Search", "Union Find", "Array", "Matrix" ]
You are given an m x n binary matrix grid, where 0 represents a sea cell and 1 represents a land cell. A move consists of walking from one land cell to another adjacent (4-directionally) land cell or walking off the boundary of the grid. Return the number of land cells in grid for which we cannot walk off the boundary ...
numEnclaves(grid: list_list_int) -> int
pub fn num_enclaves(grid: &[Vec<i64>]) -> i64
Aegis.NumEnclaves.num_enclaves
pub fn num_enclaves(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 seen: Vec<Vec<i64>> = Vec::new(); let mut i = 0; while i < m { let mut row: Vec<i64> = Vec::new(); let m...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [num_enclaves]: type definitions module public import Aeneas @[expose] public section 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 -- [num_enclaves]: function definitions module public import Aeneas public import Aegis.NumEnclaves.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.NumEnclaves.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.NumEnclaves.num_enclaves (Slice.from [(alloc.vec.Vec.from [0#i64, 0#i64, 0#i64, 0#i64] (by scalar_tac) : alloc.vec.Vec Std.I64), (alloc.vec.Vec.from ...
[ { "input": "[[[0, 0, 0, 0], [1, 0, 1, 0], [0, 1, 1, 0], [0, 0, 0, 0]]]", "output": "3" }, { "input": "[[[1, 1, 1, 1], [1, 0, 0, 1], [1, 0, 0, 1], [1, 1, 1, 1]]]", "output": "0" }, { "input": "[[[0, 1, 1, 0], [0, 0, 1, 0], [0, 0, 1, 0], [0, 0, 0, 0]]]", "output": "0" }, { "inp...
67
false
67
verified
10
10
1
2,779
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.NumEnclaves.Code.Funs /-! # Specifications of `Aegis.NumEnclaves.num_enclaves` LeetCode problem `number-of-enclaves`. Each `spec_<n>` theorem states one property of the function. -/ open Aegis.NumEnclaves open Aeneas Aeneas.Std Result namespace AegisSpec.NumEnclaves def rows (grid : Slice (alloc...
12
sum-of-root-to-leaf-binary-numbers
1,022
Easy
[ "Tree", "Depth-First Search", "Binary Tree" ]
You are given the root of a binary tree where each node has a value 0 or 1. Each root-to-leaf path represents a binary number starting with the most significant bit. For example, if the path is 0 -> 1 -> 1 -> 0 -> 1, then this could represent 01101 in binary, which is 13. For all leaves in the tree, consider the numb...
sumRootToLeaf(root: tree) -> int
pub fn sum_root_to_leaf(root: &Tree) -> i64
Aegis.SumRootToLeaf.sum_root_to_leaf
fn sum_helper(t: &Tree, acc: i64) -> i64 { match t { Tree::Null => 0, Tree::Node(v, l, r) => { let cur = acc * 2 + *v; let left_null = match &**l { Tree::Null => true, _ => false, }; let right_null = match &**r { ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [sum_root_to_leaf]: type definitions module public import Aeneas @[expose] public section 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 -- [sum_root_to_leaf]: function definitions module public import Aeneas public import Aegis.SumRootToLeaf.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.SumRootToLeaf.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.SumRootToLeaf.sum_root_to_leaf ((.Node 0#i64 (.Null) (.Null)) : Aegis.SumRootToLeaf.Tree)) (0#i64))}") #eval (s!"CASE 1 {(Result.reducesTo (Aegis.S...
[ { "input": "[[0]]", "output": "0" }, { "input": "[[1, 1, 1]]", "output": "6" }, { "input": "[[0, 0, 0]]", "output": "0" }, { "input": "[[1, 1, 0, 1, 0, 0, 1]]", "output": "22" }, { "input": "[[0, 0, 0, 0, 0, 0, 0]]", "output": "0" }, { "input": "[[1, 0...
98
false
98
verified
10
10
1
1,760
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.SumRootToLeaf.Code.Funs /-! # Specifications of `Aegis.SumRootToLeaf.sum_root_to_leaf` LeetCode problem `sum-of-root-to-leaf-binary-numbers`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.SumRootToLeaf namespace AegisSpec.SumRootToLeaf def nod...
15
video-stitching
1,024
Medium
[ "Greedy", "Array", "Dynamic Programming" ]
You are given a series of video clips from a sporting event that lasted time seconds. These video clips can be overlapping with each other and have varying lengths. Each video clip is described by an array clips where clips[i] = [starti, endi] indicates that the ith clip started at starti and ended at endi. We can cut ...
videoStitching(clips: list_list_int, time: int) -> int
pub fn video_stitching(clips: &[Vec<i64>], time: i64) -> i64
Aegis.VideoStitching.video_stitching
pub fn video_stitching(clips: &[Vec<i64>], time: i64) -> i64 { let n = clips.len(); let mut count: i64 = 0; let mut covered: i64 = 0; while covered < time { let mut best: i64 = covered; let mut i: usize = 0; while i < n { let start = clips[i][0]; let end...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [video_stitching]: type definitions module public import Aeneas @[expose] public section 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 -- [video_stitching]: function definitions module public import Aeneas public import Aegis.VideoStitching.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.VideoStitching.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.VideoStitching.video_stitching (Slice.from [(alloc.vec.Vec.from [0#i64, 10#i64] (by scalar_tac) : alloc.vec.Vec Std.I64)] (by scalar_tac) : Slice ...
[ { "input": "[[[0, 10]], 10]", "output": "1" }, { "input": "[[[0, 1], [1, 2]], 5]", "output": "-1" }, { "input": "[[[0, 1], [1, 100]], 100]", "output": "2" }, { "input": "[[[0, 5], [1, 5], [1, 6], [3, 4], [3, 5]], 5]", "output": "1" }, { "input": "[[[0, 2], [4, 6],...
95
false
95
verified
10
10
1
2,507
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.VideoStitching.Code.Funs import Mathlib.Data.Real.Basic /-! # Specifications of `Aegis.VideoStitching.video_stitching` LeetCode problem `video-stitching`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.VideoStitching open Aegis.VideoSt...
14