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
divisor-game
1,025
Easy
[ "Brainteaser", "Math", "Dynamic Programming", "Game Theory" ]
Alice and Bob take turns playing a game, with Alice starting first. Initially, there is a number n on the chalkboard. On each player's turn, that player makes a move consisting of: Choosing any x with 0 < x < n and n % x == 0. Replacing the number n on the chalkboard with n - x. Also, if a player cannot make a move, ...
divisorGame(n: int) -> bool
pub fn divisor_game(n: i64) -> bool
Aegis.DivisorGame.divisor_game
pub fn divisor_game(n: i64) -> bool { n % 2 == 0 }
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [divisor_game]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter.s...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [divisor_game]: function definitions module public import Aeneas public import Aegis.DivisorGame.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.DivisorGame.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.DivisorGame.divisor_game 8#i64) (true))}") #eval (s!"CASE 1 {(Result.reducesTo (Aegis.DivisorGame.divisor_game 3#i64) (false))}") #eval (s!"CASE 2 {(...
[ { "input": "[8]", "output": "true" }, { "input": "[3]", "output": "false" }, { "input": "[4]", "output": "true" }, { "input": "[9]", "output": "false" }, { "input": "[6]", "output": "true" }, { "input": "[2]", "output": "true" }, { "input":...
51
false
51
verified
10
10
1
146
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.DivisorGame.Code.Funs /-! # Specifications of `Aegis.DivisorGame.divisor_game` LeetCode problem `divisor-game`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.DivisorGame def W (m : ℕ) : Bool := if m ≤ 1 then false else (List.r...
3
maximum-difference-between-node-and-ancestor
1,026
Medium
[ "Tree", "Depth-First Search", "Binary Tree" ]
Given the root of a binary tree, find the maximum value v for which there exist different nodes a and b where v = |a.val - b.val| and a is an ancestor of b. A node a is an ancestor of b if either: any child of a is equal to b or any child of a is an ancestor of b.   Example 1: Input: root = [8,3,10,1,6,null,14,null,n...
maxAncestorDiff(root: tree) -> int
pub fn max_ancestor_diff(root: &Tree) -> i64
Aegis.MaxAncestorDiff.max_ancestor_diff
fn dfs(t: &Tree, mn: i64, mx: i64) -> i64 { match t { Tree::Null => mx - mn, Tree::Node(v, l, r) => { let val = *v; let nmn = if val < mn { val } else { mn }; let nmx = if val > mx { val } else { mx }; let a = dfs(l, nmn, nmx); let b = dfs(...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [max_ancestor_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 lin...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [max_ancestor_diff]: function definitions module public import Aeneas public import Aegis.MaxAncestorDiff.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.MaxAncestorDiff.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.MaxAncestorDiff.max_ancestor_diff ((.Node 4#i64 (.Node 2#i64 (.Node 1#i64 (.Null) (.Null)) (.Node 3#i64 (.Null) (.Null))) (.Node 6#i64 (.Node 5#i...
[ { "input": "[[4, 2, 6, 1, 3, 5, 7]]", "output": "3" }, { "input": "[[10, 9, 8, 7, 6, 5, 4, 3, 2, 1]]", "output": "9" }, { "input": "[[5, 3, 8, 1, 4, 7, 9, 0, 2, 6, 10]]", "output": "7" }, { "input": "[[9, 6, 12, 4, 7, 10, 14, 3, 5, 8, 11, 13, 15]]", "output": "6" }, {...
27
false
27
verified
10
10
2
16,559
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MaxAncestorDiff.Code.Funs /-! # Specifications of `Aegis.MaxAncestorDiff.max_ancestor_diff` LeetCode problem `maximum-difference-between-node-and-ancestor`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.MaxAncestorDiff open Aegis....
17
longest-arithmetic-subsequence
1,027
Medium
[ "Array", "Hash Table", "Binary Search", "Dynamic Programming" ]
Given an array nums of integers, return the length of the longest arithmetic subsequence in nums. Note that: A subsequence is an array that can be derived from another array by deleting some or no elements without changing the order of the remaining elements. A sequence seq is arithmetic if seq[i + 1] - seq[i] are all...
longestArithSeqLength(nums: list_int) -> int
pub fn longest_arith_seq_length(nums: &[i64]) -> i64
Aegis.LongestArithSeqLength.longest_arith_seq_length
pub fn longest_arith_seq_length(nums: &[i64]) -> i64 { let n = nums.len(); if n == 0 { return 0; } if n == 1 { return 1; } if n == 2 { return 2; } let mut minv = nums[0]; let mut maxv = nums[0]; let mut i = 1usize; while i < n { let x = nums[...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [longest_arith_seq_length]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_opt...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [longest_arith_seq_length]: function definitions module public import Aeneas public import Aegis.LongestArithSeqLength.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashComm...
import Aegis.LongestArithSeqLength.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval...
[ { "input": "[[3, 6, 9, 12]]", "output": "4" }, { "input": "[[2, 4, 6, 8, 10]]", "output": "5" }, { "input": "[[10, 20, 30, 40, 50]]", "output": "5" }, { "input": "[[9, 4, 7, 2, 10]]", "output": "3" }, { "input": "[[5, 5, 5, 5, 5]]", "output": "5" }, { ...
159
false
159
verified
10
10
2
14,576
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.LongestArithSeqLength.Code.Funs /-! # Specifications of `Aegis.LongestArithSeqLength.longest_arith_seq_length` LeetCode problem `longest-arithmetic-subsequence`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.LongestArithSeqLength ...
11
matrix-cells-in-distance-order
1,030
Easy
[ "Geometry", "Array", "Math", "Matrix", "Sorting" ]
You are given four integers row, cols, rCenter, and cCenter. There is a rows x cols matrix and you are on the cell with the coordinates (rCenter, cCenter). Return the coordinates of all cells in the matrix, sorted by their distance from (rCenter, cCenter) from the smallest distance to the largest distance. You may retu...
allCellsDistOrder(rows: int, cols: int, rCenter: int, cCenter: int) -> list_list_int
pub fn all_cells_dist_order(rows: i64, cols: i64, rCenter: i64, cCenter: i64) -> Vec<Vec<i64>>
Aegis.AllCellsDistOrder.all_cells_dist_order
pub fn all_cells_dist_order(rows: i64, cols: i64, rCenter: i64, cCenter: i64) -> Vec<Vec<i64>> { let total = rows * cols; let mut visited: Vec<bool> = Vec::new(); let mut i: i64 = 0; while i < total { visited.push(false); i += 1; } let start = rCenter * cols + cCenter; visi...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [all_cells_dist_order]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [all_cells_dist_order]: function definitions module public import Aeneas public import Aegis.AllCellsDistOrder.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand fals...
import Aegis.AllCellsDistOrder.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(match (Aegis.AllCellsDistOrder.all_cells_dist_order 1#i64 2#i64 0#i64 0#i64).match with | .ok r => r.val.isPerm ((alloc.vec.Vec.from [(alloc.vec.Vec.from [0#i64, 0#i64...
[ { "input": "[1, 2, 0, 0]", "output": "[[0, 0], [0, 1]]" }, { "input": "[2, 2, 0, 1]", "output": "[[0, 1], [1, 1], [0, 0], [1, 0]]" }, { "input": "[2, 3, 1, 2]", "output": "[[1, 2], [0, 2], [1, 1], [0, 1], [1, 0], [0, 0]]" }, { "input": "[3, 3, 2, 2]", "output": "[[2, 2], ...
68
true
68
verified
10
10
1
7,067
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.AllCellsDistOrder.Code.Funs /-! # Specifications of `Aegis.AllCellsDistOrder.all_cells_dist_order` LeetCode problem `matrix-cells-in-distance-order`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result set_option autoImplicit false namespace AegisSpec.AllCells...
14
maximum-sum-of-two-non-overlapping-subarrays
1,031
Medium
[ "Array", "Dynamic Programming", "Sliding Window" ]
Given an integer array nums and two integers firstLen and secondLen, return the maximum sum of elements in two non-overlapping subarrays with lengths firstLen and secondLen. The array with length firstLen could occur before or after the array with length secondLen, but they have to be non-overlapping. A subarray is a c...
maxSumTwoNoOverlap(nums: list_int, firstLen: int, secondLen: int) -> int
pub fn max_sum_two_no_overlap(nums: &[i64], firstLen: i64, secondLen: i64) -> i64
Aegis.MaxSumTwoNoOverlap.max_sum_two_no_overlap
pub fn max_sum_two_no_overlap(nums: &[i64], firstLen: i64, secondLen: i64) -> i64 { let n: usize = nums.len(); let first_len: usize = firstLen as usize; let second_len: usize = secondLen as usize; let mut prefix: Vec<i64> = Vec::new(); prefix.push(0); let mut i: usize = 0; while i < n { ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [max_sum_two_no_overlap]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_optio...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [max_sum_two_no_overlap]: function definitions module public import Aeneas public import Aegis.MaxSumTwoNoOverlap.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand f...
import Aegis.MaxSumTwoNoOverlap.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.MaxSumTwoNoOverlap.max_sum_two_no_overlap (Slice.from [1#i64, 1#i64, 1#i64, 1#i64, 1#i64, 1#i64, 1#i64, 1#i64, 1#i64] (by scalar_tac) : Slice ...
[ { "input": "[[1, 1, 1, 1, 1, 1, 1, 1, 1], 3, 3]", "output": "6" }, { "input": "[[0, 6, 5, 2, 2, 5, 1, 9, 4], 1, 2]", "output": "20" }, { "input": "[[9, 8, 7, 6, 5, 4, 3, 2, 1], 3, 2]", "output": "35" }, { "input": "[[8, 7, 6, 5, 4, 3, 2, 1, 0], 4, 2]", "output": "33" },...
110
false
110
verified
10
10
1
1,446
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MaxSumTwoNoOverlap.Code.Funs /-! # Specifications of `Aegis.MaxSumTwoNoOverlap.max_sum_two_no_overlap` LeetCode problem `maximum-sum-of-two-non-overlapping-subarrays`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.MaxSumTwoNoOverlap d...
11
moving-stones-until-consecutive
1,033
Medium
[ "Brainteaser", "Math" ]
There are three stones in different positions on the X-axis. You are given three integers a, b, and c, the positions of the stones. In one move, you pick up a stone at an endpoint (i.e., either the lowest or highest position stone), and move it to an unoccupied position between those endpoints. Formally, let's say the ...
numMovesStones(a: int, b: int, c: int) -> list_int
pub fn num_moves_stones(a: i64, b: i64, c: i64) -> Vec<i64>
Aegis.NumMovesStones.num_moves_stones
pub fn num_moves_stones(a: i64, b: i64, c: i64) -> Vec<i64> { let mut x = a; let mut y = b; let mut z = c; let mut t: i64 = 0; if x > y { t = x; x = y; y = t; } if y > z { t = y; y = z; z = t; } if x > y { t = x; x = y;...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [num_moves_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 lint...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [num_moves_stones]: function definitions module public import Aeneas public import Aegis.NumMovesStones.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.NumMovesStones.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.NumMovesStones.num_moves_stones 7#i64 8#i64 10#i64) ((alloc.vec.Vec.from [1#i64, 1#i64] (by scalar_tac) : alloc.vec.Vec Std.I64)))}") #eval (s!"CA...
[ { "input": "[7, 8, 10]", "output": "[1, 1]" }, { "input": "[1, 100, 50]", "output": "[2, 97]" }, { "input": "[1, 3, 100]", "output": "[1, 97]" }, { "input": "[10, 12, 14]", "output": "[1, 2]" }, { "input": "[50, 51, 53]", "output": "[1, 1]" }, { "input...
130
false
130
verified
10
10
1
1,849
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.NumMovesStones.Code.Funs /-! # Specifications of `Aegis.NumMovesStones.num_moves_stones` LeetCode problem `moving-stones-until-consecutive`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.NumMovesStones open Aegis.NumMovesStones def m...
13
coloring-a-border
1,034
Medium
[ "Depth-First Search", "Breadth-First Search", "Array", "Matrix" ]
You are given an m x n integer matrix grid, and three integers row, col, and color. Each value in the grid represents the color of the grid square at that location. Two squares are called adjacent if they are next to each other in any of the 4 directions. Two squares belong to the same connected component if they have ...
colorBorder(grid: list_list_int, row: int, col: int, color: int) -> list_list_int
pub fn color_border(grid: &[Vec<i64>], row: i64, col: i64, color: i64) -> Vec<Vec<i64>>
Aegis.ColorBorder.color_border
pub fn color_border(grid: &[Vec<i64>], row: i64, col: i64, color: i64) -> Vec<Vec<i64>> { let m = grid.len(); let n = grid[0].len(); let mut out: Vec<Vec<i64>> = Vec::new(); let mut i = 0; while i < m { let mut new_row: Vec<i64> = Vec::new(); let mut j = 0; while j < n { ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [color_border]: type definitions module public import Aeneas @[expose] public section 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 -- [color_border]: function definitions module public import Aeneas public import Aegis.ColorBorder.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.ColorBorder.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.ColorBorder.color_border (Slice.from [(alloc.vec.Vec.from [1#i64, 1#i64] (by scalar_tac) : alloc.vec.Vec Std.I64), (alloc.vec.Vec.from [1#i64, 2#i64]...
[ { "input": "[[[1, 1], [1, 2]], 0, 0, 3]", "output": "[[3, 3], [3, 2]]" }, { "input": "[[[1000, 1000], [1000, 1000]], 1, 1, 999]", "output": "[[999, 999], [999, 999]]" }, { "input": "[[[1, 2, 2], [2, 3, 2]], 0, 1, 3]", "output": "[[1, 3, 3], [2, 3, 3]]" }, { "input": "[[[1000,...
79
false
79
verified
10
10
1
3,489
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.ColorBorder.Code.Funs /-! # Specifications of `Aegis.ColorBorder.color_border` LeetCode problem `coloring-a-border`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.ColorBorder def rowLen (rows : List (alloc.vec.Vec I64)) (i : Nat) : Na...
12
uncrossed-lines
1,035
Medium
[ "Array", "Dynamic Programming" ]
You are given two integer arrays nums1 and nums2. We write the integers of nums1 and nums2 (in the order they are given) on two separate horizontal lines. We may draw connecting lines: a straight line connecting two numbers nums1[i] and nums2[j] such that: nums1[i] == nums2[j], and the line we draw does not intersect ...
maxUncrossedLines(nums1: list_int, nums2: list_int) -> int
pub fn max_uncrossed_lines(nums1: &[i64], nums2: &[i64]) -> i64
Aegis.MaxUncrossedLines.max_uncrossed_lines
pub fn max_uncrossed_lines(nums1: &[i64], nums2: &[i64]) -> i64 { let n: usize = nums1.len(); let m: usize = nums2.len(); let mut prev: Vec<i64> = Vec::new(); let mut j: usize = 0; while j <= m { prev.push(0); j += 1; } let mut i: usize = 1; while i <= n { let m...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [max_uncrossed_lines]: type definitions module public import Aeneas @[expose] public section 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_uncrossed_lines]: function definitions module public import Aeneas public import Aegis.MaxUncrossedLines.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false...
import Aegis.MaxUncrossedLines.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.MaxUncrossedLines.max_uncrossed_lines (Slice.from [5#i64] (by scalar_tac) : Slice Std.I64) (Slice.from [5#i64] (by scalar_tac) : Slice Std.I64)...
[ { "input": "[[5], [5]]", "output": "1" }, { "input": "[[3], [3]]", "output": "1" }, { "input": "[[1], [1]]", "output": "1" }, { "input": "[[1000, 2000], [2000, 1000]]", "output": "1" }, { "input": "[[3], [3, 3, 3]]", "output": "1" }, { "input": "[[1, 4...
106
false
106
verified
10
10
1
1,086
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MaxUncrossedLines.Code.Funs /-! # Specifications of `Aegis.MaxUncrossedLines.max_uncrossed_lines` LeetCode problem `uncrossed-lines`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.MaxUncrossedLines open Aegis.MaxUncrossedLines def va...
17
escape-a-large-maze
1,036
Hard
[ "Depth-First Search", "Breadth-First Search", "Array", "Hash Table" ]
There is a 1 million by 1 million grid on an XY-plane, and the coordinates of each grid square are (x, y). We start at the source = [sx, sy] square and want to reach the target = [tx, ty] square. There is also an array of blocked squares, where each blocked[i] = [xi, yi] represents a blocked square with coordinates (xi...
isEscapePossible(blocked: list_list_int, source: list_int, target: list_int) -> bool
pub fn is_escape_possible(blocked: &[Vec<i64>], source: &[i64], target: &[i64]) -> bool
Aegis.IsEscapePossible.is_escape_possible
fn encode(x: i64, y: i64) -> i64 { x * 1000000 + y } fn set_contains(table: &Vec<i64>, key: i64) -> bool { let cap = table.len(); let mut found = false; if cap != 0 { let cap_i = cap as i64; let mut h = key % cap_i; let mut idx = h as usize; let mut steps: usize = 0; ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [is_escape_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 -- [is_escape_possible]: function definitions module public import Aeneas public import Aegis.IsEscapePossible.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.IsEscapePossible.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.IsEscapePossible.is_escape_possible (Slice.from [] (by scalar_tac) : Slice (alloc.vec.Vec Std.I64)) (Slice.from [0#i64, 0#i64] (by scalar_tac) :...
[ { "input": "[[], [0, 0], [999999, 999999]]", "output": "true" }, { "input": "[[[5, 5]], [4, 4], [6, 6]]", "output": "true" }, { "input": "[[[500000, 500000]], [499999, 499999], [500001, 500001]]", "output": "true" }, { "input": "[[[999999, 999999]], [0, 0], [999998, 999998]]"...
109
false
109
verified
10
10
2
18,628
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.IsEscapePossible.Code.Funs /-! # Specifications of `Aegis.IsEscapePossible.is_escape_possible` LeetCode problem `escape-a-large-maze`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.IsEscapePossible namespace AegisSpec.IsEscapePossible de...
8
valid-boomerang
1,037
Easy
[ "Geometry", "Array", "Math" ]
Given an array points where points[i] = [xi, yi] represents a point on the X-Y plane, return true if these points are a boomerang. A boomerang is a set of three points that are all distinct and not in a straight line.   Example 1: Input: points = [[1,1],[2,3],[3,2]] Output: true Example 2: Input: points = [[1,1],[2,2],...
isBoomerang(points: list_list_int) -> bool
pub fn is_boomerang(points: &[Vec<i64>]) -> bool
Aegis.IsBoomerang.is_boomerang
pub fn is_boomerang(points: &[Vec<i64>]) -> bool { let x0 = points[0][0]; let y0 = points[0][1]; let x1 = points[1][0]; let y1 = points[1][1]; let x2 = points[2][0]; let y2 = points[2][1]; let cross = (x1 - x0) * (y2 - y0) - (y1 - y0) * (x2 - x0); cross != 0 }
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [is_boomerang]: type definitions module public import Aeneas @[expose] public section 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_boomerang]: function definitions module public import Aeneas public import Aegis.IsBoomerang.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.IsBoomerang.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.IsBoomerang.is_boomerang (Slice.from [(alloc.vec.Vec.from [1#i64, 1#i64] (by scalar_tac) : alloc.vec.Vec Std.I64), (alloc.vec.Vec.from [2#i64, 2#i64]...
[ { "input": "[[[1, 1], [2, 2], [1, 3]]]", "output": "true" }, { "input": "[[[1, 1], [2, 5], [3, 9]]]", "output": "false" }, { "input": "[[[1, 1], [2, 3], [3, 2]]]", "output": "true" }, { "input": "[[[5, 5], [6, 6], [7, 7]]]", "output": "false" }, { "input": "[[[1, ...
116
false
116
verified
10
10
1
659
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.IsBoomerang.Code.Funs /-! # Specifications of `Aegis.IsBoomerang.is_boomerang` LeetCode problem `valid-boomerang`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.IsBoomerang abbrev Points := Slice (alloc.vec.Vec Std.I64) def row (poin...
10
binary-search-tree-to-greater-sum-tree
1,038
Medium
[ "Tree", "Depth-First Search", "Binary Search Tree", "Binary Tree" ]
Given the root of a Binary Search Tree (BST), convert it to a Greater Tree such that every key of the original BST is changed to the original key plus the sum of all keys greater than the original key in BST. As a reminder, a binary search tree is a tree that satisfies these constraints: The left subtree of a node con...
bstToGst(root: tree) -> tree
pub fn bst_to_gst(root: &Tree) -> Tree
Aegis.BstToGst.bst_to_gst
fn build(t: &Tree, acc: &mut i64) -> Tree { match t { Tree::Null => Tree::Null, Tree::Node(v, left, right) => { // reverse inorder: right, node, left let new_right = build(&**right, acc); *acc = *acc + *v; let new_val = *acc; let new_left =...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [bst_to_gst]: type definitions module public import Aeneas @[expose] public section 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 -- [bst_to_gst]: function definitions module public import Aeneas public import Aegis.BstToGst.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.BstToGst.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 deriving instance DecidableEq for Aegis.BstToGst.Tree #eval (s!"CASE 0 {(match (Aegis.BstToGst.bst_to_gst ((.Node 5#i64 (.Node 2#i64 (.Null) (.Null)) (.Node 13#i64 (.Null) (.Null))) : Aegis.BstT...
[ { "input": "[[5, 2, 13]]", "output": "[18, 20, 13]" }, { "input": "[[1, 0, 2]]", "output": "[3, 3, 2]" }, { "input": "[[3, 2, 4, 1]]", "output": "[7, 9, 4, 10]" }, { "input": "[[5, 3, 8, 2, 4, 6, 10, 1, 7, 9, 11]]", "output": "[29, 56, 18, 65, 44, 24, 10, 66, 63, 53, 40]"...
39
false
39
verified
10
10
2
9,972
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.BstToGst.Code.Funs /-! # Specifications of `Aegis.BstToGst.bst_to_gst` LeetCode problem `binary-search-tree-to-greater-sum-tree`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.BstToGst open Aegis.BstToGst inductive Move where | le...
11
moving-stones-until-consecutive-ii
1,040
Medium
[ "Array", "Math", "Two Pointers", "Sorting" ]
There are some stones in different positions on the X-axis. You are given an integer array stones, the positions of the stones. Call a stone an endpoint stone if it has the smallest or largest position. In one move, you pick up an endpoint stone and move it to an unoccupied position so that it is no longer an endpoint ...
numMovesStonesII(stones: list_int) -> list_int
pub fn num_moves_stones_ii(stones: &[i64]) -> Vec<i64>
Aegis.NumMovesStonesIi.num_moves_stones_ii
pub fn num_moves_stones_ii(stones: &[i64]) -> Vec<i64> { let n = stones.len(); let mut a: Vec<i64> = Vec::new(); let mut idx = 0; while idx < n { a.push(stones[idx]); idx += 1; } // Selection sort the copied positions. let mut i = 0; while i < n { let mut min_id...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [num_moves_stones_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 l...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [num_moves_stones_ii]: function definitions module public import Aeneas public import Aegis.NumMovesStonesIi.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false ...
import Aegis.NumMovesStonesIi.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.NumMovesStonesIi.num_moves_stones_ii (Slice.from [1#i64, 1000000000#i64] (by scalar_tac) : Slice Std.I64)) ((alloc.vec.Vec.from [2#i64, 0#i64] (...
[ { "input": "[[1, 1000000000]]", "output": "[2, 0]" }, { "input": "[[1, 1000000000, 2000000000]]", "output": "[2, 999999999]" }, { "input": "[[7, 4, 9]]", "output": "[1, 2]" }, { "input": "[[1, 5, 100]]", "output": "[2, 94]" }, { "input": "[[1, 2, 5]]", "output...
140
false
140
verified
10
10
1
18,817
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.NumMovesStonesIi.Code.Funs /-! # Specifications of `Aegis.NumMovesStonesIi.num_moves_stones_ii` LeetCode problem `moving-stones-until-consecutive-ii`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.NumMovesStonesIi open Aegis.NumMo...
13
robot-bounded-in-circle
1,041
Medium
[ "Math", "String", "Simulation" ]
On an infinite plane, a robot initially stands at (0, 0) and faces north. Note that: The north direction is the positive direction of the y-axis. The south direction is the negative direction of the y-axis. The east direction is the positive direction of the x-axis. The west direction is the negative direction of the ...
isRobotBounded(instructions: str) -> bool
pub fn is_robot_bounded(instructions: &[u8]) -> bool
Aegis.IsRobotBounded.is_robot_bounded
pub fn is_robot_bounded(instructions: &[u8]) -> bool { let mut x: i64 = 0; let mut y: i64 = 0; let mut dir: i64 = 0; // 0 = north, 1 = east, 2 = south, 3 = west let n = instructions.len(); let mut i: usize = 0; while i < n { let c = instructions[i]; if c == b'G' { ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [is_robot_bounded]: type definitions module public import Aeneas @[expose] public section 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_robot_bounded]: function definitions module public import Aeneas public import Aegis.IsRobotBounded.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.IsRobotBounded.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.IsRobotBounded.is_robot_bounded (Slice.from [71#u8, 71#u8, 76#u8, 71#u8, 82#u8, 71#u8, 76#u8, 76#u8] (by scalar_tac) : Slice Std.U8)) (true))}") #...
[ { "input": "[\"GGLGRGLL\"]", "output": "true" }, { "input": "[\"LLLL\"]", "output": "true" }, { "input": "[\"GLLRLLRL\"]", "output": "true" }, { "input": "[\"GRGL\"]", "output": "false" }, { "input": "[\"LLGRL\"]", "output": "true" }, { "input": "[\"LR...
140
false
140
verified
10
10
1
1,279
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "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.IsRobotBounded.Code.Funs /-! # Specifications of `Aegis.IsRobotBounded.is_robot_bounded` LeetCode problem `robot-bounded-in-circle`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.IsRobotBounded namespace AegisSpec.IsRobotBounded ...
15
partition-array-for-maximum-sum
1,043
Medium
[ "Array", "Dynamic Programming" ]
Given an integer array arr, partition the array into (contiguous) subarrays of length at most k. After partitioning, each subarray has their values changed to become the maximum value of that subarray. Return the largest sum of the given array after partitioning. Test cases are generated so that the answer fits in a 32...
maxSumAfterPartitioning(arr: list_int, k: int) -> int
pub fn max_sum_after_partitioning(arr: &[i64], k: i64) -> i64
Aegis.MaxSumAfterPartitioning.max_sum_after_partitioning
pub fn max_sum_after_partitioning(arr: &[i64], k: i64) -> i64 { let n: usize = arr.len(); let mut dp: Vec<i64> = Vec::new(); let mut z: usize = 0; while z <= n { dp.push(0); z += 1; } let ku: usize = k as usize; let mut i: usize = 1; while i <= n { let mut best:...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [max_sum_after_partitioning]: type definitions module public import Aeneas @[expose] public 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_sum_after_partitioning]: function definitions module public import Aeneas public import Aegis.MaxSumAfterPartitioning.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hash...
import Aegis.MaxSumAfterPartitioning.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.MaxSumAfterPartitioning.max_sum_after_partitioning (Slice.from [1#i64] (by scalar_tac) : Slice Std.I64) 1#i64) (1#i64))}") #eval (s!"CASE...
[ { "input": "[[1], 1]", "output": "1" }, { "input": "[[10, 20, 30, 40, 50], 3]", "output": "190" }, { "input": "[[9, 1, 2, 3, 9], 3]", "output": "45" }, { "input": "[[5, 4, 3, 2, 1], 1]", "output": "15" }, { "input": "[[5, 5, 5, 5, 5], 5]", "output": "25" }, ...
104
false
104
verified
10
10
1
1,374
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MaxSumAfterPartitioning.Code.Funs /-! # Specifications of `Aegis.MaxSumAfterPartitioning.max_sum_after_partitioning` LeetCode problem `partition-array-for-maximum-sum`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.MaxSumAfterPartition...
17
last-stone-weight
1,046
Easy
[ "Array", "Heap (Priority Queue)" ]
You are given an array of integers stones where stones[i] is the weight of the ith stone. We are playing a game with the stones. On each turn, we choose the heaviest two stones and smash them together. Suppose the heaviest two stones have weights x and y with x <= y. The result of this smash is: If x == y, both stones...
lastStoneWeight(stones: list_int) -> int
pub fn last_stone_weight(stones: &[i64]) -> i64
Aegis.LastStoneWeight.last_stone_weight
pub fn last_stone_weight(stones: &[i64]) -> i64 { let mut v: Vec<i64> = Vec::new(); let mut i: usize = 0; while i < stones.len() { v.push(stones[i]); i += 1; } while v.len() > 1 { let n: usize = v.len(); let mut max_i: usize = 0; let mut j: usize = 1; ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [last_stone_weight]: type definitions module public import Aeneas @[expose] public section 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 -- [last_stone_weight]: function definitions module public import Aeneas public import Aegis.LastStoneWeight.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.LastStoneWeight.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.LastStoneWeight.last_stone_weight (Slice.from [1#i64] (by scalar_tac) : Slice Std.I64)) (1#i64))}") #eval (s!"CASE 1 {(Result.reducesTo (Aegis.La...
[ { "input": "[[1]]", "output": "1" }, { "input": "[[10, 4, 2, 10]]", "output": "2" }, { "input": "[[3, 7, 8, 9]]", "output": "3" }, { "input": "[[3, 3, 3, 3]]", "output": "0" }, { "input": "[[10, 4, 3, 100]]", "output": "83" }, { "input": "[[9, 3, 2, 10...
124
false
124
verified
10
10
1
1,906
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.LastStoneWeight.Code.Funs /-! # Specifications of `Aegis.LastStoneWeight.last_stone_weight` LeetCode problem `last-stone-weight`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.LastStoneWeight open Aegis.LastStoneWeight (last_stone_wei...
14
longest-string-chain
1,048
Medium
[ "Array", "Hash Table", "Two Pointers", "String", "Dynamic Programming", "Sorting" ]
You are given an array of words where each word consists of lowercase English letters. wordA is a predecessor of wordB if and only if we can insert exactly one letter anywhere in wordA without changing the order of the other characters to make it equal to wordB. For example, "abc" is a predecessor of "abac", while "cb...
longestStrChain(words: list_str) -> int
pub fn longest_str_chain(words: &[Vec<u8>]) -> i64
Aegis.LongestStrChain.longest_str_chain
pub fn longest_str_chain(words: &[Vec<u8>]) -> i64 { let n = words.len(); if n == 0 { return 0; } let mut dp: Vec<i64> = Vec::new(); let mut i: usize = 0; while i < n { dp.push(1); i = i + 1; } let mut max_len: usize = 0; i = 0; while i < n { let...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [longest_str_chain]: type definitions module public import Aeneas @[expose] public section 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 -- [longest_str_chain]: function definitions module public import Aeneas public import Aegis.LongestStrChain.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.LongestStrChain.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.LongestStrChain.longest_str_chain (Slice.from [(alloc.vec.Vec.from [97#u8, 98#u8, 99#u8, 100#u8] (by scalar_tac) : alloc.vec.Vec Std.U8), (alloc....
[ { "input": "[[\"abcd\", \"dbqca\"]]", "output": "1" }, { "input": "[[\"a\", \"abc\", \"bde\", \"abdce\"]]", "output": "1" }, { "input": "[[\"a\", \"abc\", \"bdc\", \"abcde\"]]", "output": "1" }, { "input": "[[\"xbc\", \"pcxbcf\", \"xb\", \"cxbc\", \"pcxbc\"]]", "output": ...
84
false
84
verified
10
10
1
7,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.LongestStrChain.Code.Funs /-! # Specifications of `Aegis.LongestStrChain.longest_str_chain` LeetCode problem `longest-string-chain`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result set_option autoImplicit false namespace AegisSpec.LongestStrChain op...
12
last-stone-weight-ii
1,049
Medium
[ "Array", "Dynamic Programming" ]
You are given an array of integers stones where stones[i] is the weight of the ith stone. We are playing a game with the stones. On each turn, we choose any two stones and smash them together. Suppose the stones have weights x and y with x <= y. The result of this smash is: If x == y, both stones are destroyed, and If...
lastStoneWeightII(stones: list_int) -> int
pub fn last_stone_weight_ii(stones: &[i64]) -> i64
Aegis.LastStoneWeightIi.last_stone_weight_ii
pub fn last_stone_weight_ii(stones: &[i64]) -> i64 { let mut total: i64 = 0; let mut i: usize = 0; while i < stones.len() { total = total + stones[i]; i = i + 1; } let target: i64 = total / 2; let target_usize: usize = target as usize; let mut dp: Vec<i64> = Vec::new(); ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [last_stone_weight_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 ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [last_stone_weight_ii]: function definitions module public import Aeneas public import Aegis.LastStoneWeightIi.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand fals...
import Aegis.LastStoneWeightIi.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.LastStoneWeightIi.last_stone_weight_ii (Slice.from [1#i64] (by scalar_tac) : Slice Std.I64)) (1#i64))}") #eval (s!"CASE 1 {(Result.reducesTo (A...
[ { "input": "[[1]]", "output": "1" }, { "input": "[[100, 1]]", "output": "99" }, { "input": "[[3, 9, 7, 3]]", "output": "2" }, { "input": "[[1, 100, 100, 1]]", "output": "0" }, { "input": "[[10, 10, 10, 10]]", "output": "0" }, { "input": "[[10, 10, 10, ...
99
false
99
verified
10
10
1
1,011
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.LastStoneWeightIi.Code.Funs /-! # Specifications of `Aegis.LastStoneWeightIi.last_stone_weight_ii` LeetCode problem `last-stone-weight-ii`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.LastStoneWeightIi (last_stone_weight_ii) namespace AegisSp...
11
grumpy-bookstore-owner
1,052
Medium
[ "Array", "Sliding Window" ]
There is a bookstore owner that has a store open for n minutes. You are given an integer array customers of length n where customers[i] is the number of the customers that enter the store at the start of the ith minute and all those customers leave after the end of that minute. During certain minutes, the bookstore own...
maxSatisfied(customers: list_int, grumpy: list_int, minutes: int) -> int
pub fn max_satisfied(customers: &[i64], grumpy: &[i64], minutes: i64) -> i64
Aegis.MaxSatisfied.max_satisfied
pub fn max_satisfied(customers: &[i64], grumpy: &[i64], minutes: i64) -> i64 { let n = customers.len(); if n == 0 { return 0; } let mut base: i64 = 0; let mut i: usize = 0; while i < n { if grumpy[i] == 0 { base += customers[i]; } i += 1; } l...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [max_satisfied]: type definitions module public import Aeneas @[expose] public section 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_satisfied]: function definitions module public import Aeneas public import Aegis.MaxSatisfied.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.MaxSatisfied.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.MaxSatisfied.max_satisfied (Slice.from [1#i64] (by scalar_tac) : Slice Std.I64) (Slice.from [0#i64] (by scalar_tac) : Slice Std.I64) 1#i64) (1#i64))...
[ { "input": "[[1], [0], 1]", "output": "1" }, { "input": "[[2, 3, 4, 5], [1, 0, 1, 1], 2]", "output": "12" }, { "input": "[[2, 3, 4, 5], [1, 0, 1, 0], 2]", "output": "12" }, { "input": "[[2, 3, 4, 5], [1, 1, 1, 1], 2]", "output": "9" }, { "input": "[[3, 1, 4, 2, 2]...
89
false
89
verified
10
10
1
958
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MaxSatisfied.Code.Funs /-! # Specifications of `Aegis.MaxSatisfied.max_satisfied` LeetCode problem `grumpy-bookstore-owner`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.MaxSatisfied def cell (s : Slice Std.I64) (i : ℕ) : ℤ := (s...
8
previous-permutation-with-one-swap
1,053
Medium
[ "Greedy", "Array" ]
Given an array of positive integers arr (not necessarily distinct), return the lexicographically largest permutation that is smaller than arr, that can be made with exactly one swap. If it cannot be done, then return the same array. Note that a swap exchanges the positions of two numbers arr[i] and arr[j]   Example 1: ...
prevPermOpt1(arr: list_int) -> list_int
pub fn prev_perm_opt1(arr: &[i64]) -> Vec<i64>
Aegis.PrevPermOpt1.prev_perm_opt1
fn find_pivot(arr: &[i64]) -> usize { let n = arr.len(); let mut k: usize = n - 1; while k > 0 { if arr[k - 1] > arr[k] { return k - 1; } k -= 1; } n } fn find_j0(arr: &[i64], i: usize) -> usize { let n = arr.len(); let mut j: usize = n - 1; while j >...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [prev_perm_opt1]: type definitions module public import Aeneas @[expose] public section 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 -- [prev_perm_opt1]: function definitions module public import Aeneas public import Aegis.PrevPermOpt1.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.PrevPermOpt1.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.PrevPermOpt1.prev_perm_opt1 (Slice.from [3#i64, 2#i64, 1#i64] (by scalar_tac) : Slice Std.I64)) ((alloc.vec.Vec.from [3#i64, 1#i64, 2#i64] (by scala...
[ { "input": "[[3, 2, 1]]", "output": "[3, 1, 2]" }, { "input": "[[5, 1, 1]]", "output": "[1, 5, 1]" }, { "input": "[[1, 1, 5]]", "output": "[1, 1, 5]" }, { "input": "[[1, 2, 1]]", "output": "[1, 1, 2]" }, { "input": "[[1, 3, 2]]", "output": "[1, 2, 3]" }, {...
140
false
140
verified
10
10
2
13,433
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.PrevPermOpt1.Code.Funs /-! # Specifications of `Aegis.PrevPermOpt1.prev_perm_opt1` LeetCode problem `previous-permutation-with-one-swap`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.PrevPermOpt1 open Aegis.PrevPermOpt1 def sl...
17
distant-barcodes
1,054
Medium
[ "Greedy", "Array", "Hash Table", "Counting", "Sorting", "Heap (Priority Queue)" ]
In a warehouse, there is a row of barcodes, where the ith barcode is barcodes[i]. Rearrange the barcodes so that no two adjacent barcodes are equal. You may return any answer, and it is guaranteed an answer exists.   Example 1: Input: barcodes = [1,1,1,2,2,2] Output: [2,1,2,1,2,1] Example 2: Input: barcodes = [1,1,1,1,...
rearrangeBarcodes(barcodes: list_int) -> list_int
pub fn rearrange_barcodes(barcodes: &[i64]) -> Vec<i64>
Aegis.RearrangeBarcodes.rearrange_barcodes
pub fn rearrange_barcodes(barcodes: &[i64]) -> Vec<i64> { let n = barcodes.len(); let mut res: Vec<i64> = Vec::new(); if n == 0 { return res; } // Find the maximum barcode value. let mut max_val: i64 = 0; let mut i: usize = 0; while i < n { let v = barcodes[i]; i...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [rearrange_barcodes]: type definitions module public import Aeneas @[expose] public section 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 -- [rearrange_barcodes]: function definitions module public import Aeneas public import Aegis.RearrangeBarcodes.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false ...
import Aegis.RearrangeBarcodes.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.RearrangeBarcodes.rearrange_barcodes (Slice.from [1#i64, 2#i64, 3#i64, 4#i64] (by scalar_tac) : Slice Std.I64)) ((alloc.vec.Vec.from [1#i64, 3#...
[ { "input": "[[1, 2, 3, 4]]", "output": "[1, 3, 2, 4]" }, { "input": "[[1, 2, 2, 1, 2, 1]]", "output": "[1, 2, 1, 2, 1, 2]" }, { "input": "[[1, 1, 1, 2, 2, 2]]", "output": "[1, 2, 1, 2, 1, 2]" }, { "input": "[[5, 6, 7, 8, 8, 8, 8]]", "output": "[8, 5, 8, 6, 8, 7, 8]" }, ...
96
false
96
verified
10
10
1
7,261
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.RearrangeBarcodes.Code.Funs /-! # Specifications of `Aegis.RearrangeBarcodes.rearrange_barcodes` LeetCode problem `distant-barcodes`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.RearrangeBarcodes (rearrange_barcodes) namespace AegisSpec.Rearr...
8
shortest-way-to-form-string
1,055
Medium
[ "Greedy", "Two Pointers", "String", "Binary Search" ]
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 remaining characters. (i.e., "ace" is a subsequence of "abcde" while "aec" is not). Given two strings source and target, return the minimum ...
shortestWay(source: str, target: str) -> int
pub fn shortest_way(source: &[u8], target: &[u8]) -> i64
Aegis.ShortestWay.shortest_way
pub fn shortest_way(source: &[u8], target: &[u8]) -> i64 { let n: usize = target.len(); if n == 0 { return 0; } let m: usize = source.len(); if m == 0 { return -1; } // First check that every character in target occurs somewhere in source. let mut k: usize = 0; whil...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [shortest_way]: type definitions module public import Aeneas @[expose] public section 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 -- [shortest_way]: function definitions module public import Aeneas public import Aegis.ShortestWay.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.ShortestWay.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.ShortestWay.shortest_way (Slice.from [97#u8, 98#u8, 99#u8, 100#u8] (by scalar_tac) : Slice Std.U8) (Slice.from [100#u8, 100#u8, 100#u8, 98#u8, 98#u8,...
[ { "input": "[\"abcd\", \"dddbbbccccaaa\"]", "output": "12" }, { "input": "[\"a\", \"a\"]", "output": "1" }, { "input": "[\"xyz\", \"xyzxyz\"]", "output": "2" }, { "input": "[\"abcd\", \"abcabcdabcd\"]", "output": "3" }, { "input": "[\"\", \"a\"]", "output": "-...
158
false
158
verified
10
10
1
5,276
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.ShortestWay.Code.Funs /-! # Specifications of `Aegis.ShortestWay.shortest_way` LeetCode problem `shortest-way-to-form-string`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.ShortestWay def IsLower (b : U8) : Prop := 97 ≤ b.val ∧ b...
14
campus-bikes
1,057
Medium
[ "Array", "Sorting", "Heap (Priority Queue)" ]
On a campus represented on the X-Y plane, there are n workers and m bikes, with n <= m. You are given an array workers of length n where workers[i] = [xi, yi] is the position of the ith worker. You are also given an array bikes of length m where bikes[j] = [xj, yj] is the position of the jth bike. All the given positio...
assignBikes(workers: list_list_int, bikes: list_list_int) -> list_int
pub fn assign_bikes(workers: &[Vec<i64>], bikes: &[Vec<i64>]) -> Vec<i64>
Aegis.AssignBikes.assign_bikes
pub fn assign_bikes(workers: &[Vec<i64>], bikes: &[Vec<i64>]) -> Vec<i64> { let n = workers.len(); let m = bikes.len(); let total = n * m; // Find the maximum Manhattan distance. let mut maxd: i64 = 0; let mut i: usize = 0; while i < n { let wx = workers[i][0]; let wy = work...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [assign_bikes]: type definitions module public import Aeneas @[expose] public section 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 -- [assign_bikes]: function definitions module public import Aeneas public import Aegis.AssignBikes.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.AssignBikes.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.AssignBikes.assign_bikes (Slice.from [(alloc.vec.Vec.from [0#i64, 0#i64] (by scalar_tac) : alloc.vec.Vec Std.I64)] (by scalar_tac) : Slice (alloc.vec...
[ { "input": "[[[0, 0]], [[0, 0]]]", "output": "[0]" }, { "input": "[[[0, 0], [2, 1]], [[1, 2], [3, 3]]]", "output": "[1, 0]" }, { "input": "[[[0, 0], [2, 1]], [[1, 2], [3, 3], [2, 2]]]", "output": "[0, 2]" }, { "input": "[[[0, 0], [1000, 1000]], [[500, 500], [250, 250], [750, ...
102
false
102
verified
10
10
1
9,879
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.AssignBikes.Code.Funs /-! # Specifications of `Aegis.AssignBikes.assign_bikes` LeetCode problem `campus-bikes`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.AssignBikes open Aegis.AssignBikes def pt (s : Slice (alloc.vec.Vec I...
11
all-paths-from-source-lead-to-destination
1,059
Medium
[ "Graph", "Topological Sort" ]
Given the edges of a directed graph where edges[i] = [ai, bi] indicates there is an edge between nodes ai and bi, and two nodes source and destination of this graph, determine whether or not all paths starting from source eventually, end at destination, that is: At least one path exists from the source node to the des...
leadsToDestination(n: int, edges: list_list_int, source: int, destination: int) -> bool
pub fn leads_to_destination(n: i64, edges: &[Vec<i64>], source: i64, destination: i64) -> bool
Aegis.LeadsToDestination.leads_to_destination
pub fn leads_to_destination(n: i64, edges: &[Vec<i64>], source: i64, destination: i64) -> bool { let n_usize = n as usize; // Build adjacency list. let mut adj: Vec<Vec<i64>> = Vec::new(); let mut init_i: usize = 0; while init_i < n_usize { let row: Vec<i64> = Vec::new(); adj.push(r...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [leads_to_destination]: type definitions module public import Aeneas @[expose] public section 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 -- [leads_to_destination]: function definitions module public import Aeneas public import Aegis.LeadsToDestination.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand fal...
import Aegis.LeadsToDestination.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.LeadsToDestination.leads_to_destination 1#i64 (Slice.from [] (by scalar_tac) : Slice (alloc.vec.Vec Std.I64)) 0#i64 0#i64) (true))}") #eval (s...
[ { "input": "[1, [], 0, 0]", "output": "true" }, { "input": "[2, [[0, 1]], 0, 1]", "output": "true" }, { "input": "[2, [[0, 1], [1, 0]], 0, 1]", "output": "false" }, { "input": "[3, [[0, 1], [0, 2]], 0, 2]", "output": "false" }, { "input": "[2, [[0, 1], [1, 1]], 0,...
72
false
72
verified
10
10
1
14,990
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.LeadsToDestination.Code.Funs /-! # Specifications of `Aegis.LeadsToDestination.leads_to_destination` LeetCode problem `all-paths-from-source-lead-to-destination`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.LeadsToDestination de...
15
missing-element-in-sorted-array
1,060
Medium
[ "Array", "Binary Search" ]
Given an integer array nums which is sorted in ascending order and all of its elements are unique and given also an integer k, return the kth missing number starting from the leftmost number of the array.   Example 1: Input: nums = [4,7,9,10], k = 1 Output: 5 Explanation: The first missing number is 5. Example 2: In...
missingElement(nums: list_int, k: int) -> int
pub fn missing_element(nums: &[i64], k: i64) -> i64
Aegis.MissingElement.missing_element
pub fn missing_element(nums: &[i64], k: i64) -> i64 { let n = nums.len(); if n == 0 { return k; } let last_missing = nums[n - 1] - nums[0] - ((n - 1) as i64); if k > last_missing { return nums[n - 1] + (k - last_missing); } let mut lo: usize = 0; let mut hi: usize = n...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [missing_element]: type definitions module public import Aeneas @[expose] public section 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 -- [missing_element]: function definitions module public import Aeneas public import Aegis.MissingElement.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.MissingElement.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.MissingElement.missing_element (Slice.from [1#i64, 2#i64, 4#i64] (by scalar_tac) : Slice Std.I64) 3#i64) (6#i64))}") #eval (s!"CASE 1 {(Result.red...
[ { "input": "[[1, 2, 4], 3]", "output": "6" }, { "input": "[[1, 3, 5, 7], 4]", "output": "8" }, { "input": "[[1, 3, 5, 7], 2]", "output": "4" }, { "input": "[[10, 20, 30, 40], 15]", "output": "26" }, { "input": "[[4, 7, 9, 10], 3]", "output": "8" }, { "...
110
false
110
verified
10
10
1
2,162
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MissingElement.Code.Funs /-! # Specifications of `Aegis.MissingElement.missing_element` LeetCode problem `missing-element-in-sorted-array`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.MissingElement def valsOf (nums : Slice Std....
12
longest-repeating-substring
1,062
Medium
[ "String", "Binary Search", "Dynamic Programming", "Suffix Array", "Hash Function", "Rolling Hash" ]
Given a string s, return the length of the longest repeating substrings. If no repeating substring exists, return 0.   Example 1: Input: s = "abcd" Output: 0 Explanation: There is no repeating substring. Example 2: Input: s = "abbaba" Output: 2 Explanation: The longest repeating substrings are "ab" and "ba", each of...
longestRepeatingSubstring(s: str) -> int
pub fn longest_repeating_substring(s: &[u8]) -> i64
Aegis.LongestRepeatingSubstring.longest_repeating_substring
pub fn longest_repeating_substring(s: &[u8]) -> i64 { let n: usize = s.len(); let mut dp: Vec<Vec<i64>> = Vec::new(); let mut i: usize = 0; while i <= n { let mut row: Vec<i64> = Vec::new(); let mut j: usize = 0; while j <= n { row.push(0); j += 1; ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [longest_repeating_substring]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [longest_repeating_substring]: function definitions module public import Aeneas public import Aegis.LongestRepeatingSubstring.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.h...
import Aegis.LongestRepeatingSubstring.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.LongestRepeatingSubstring.longest_repeating_substring (Slice.from [112#u8, 121#u8, 112#u8, 121#u8, 112#u8, 121#u8, 112#u8, 121#u8, 112#...
[ { "input": "[\"pypypypypypypypypyp\"]", "output": "17" }, { "input": "[\"abcdefghijklmnopqrstuvwxyz\"]", "output": "0" }, { "input": "[\"abababab\"]", "output": "6" }, { "input": "[\"abcabcabc\"]", "output": "6" }, { "input": "[\"abracadabra\"]", "output": "4"...
99
false
99
verified
10
10
1
2,677
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.LongestRepeatingSubstring.Code.Funs /-! # Specifications of `Aegis.LongestRepeatingSubstring.longest_repeating_substring` LeetCode problem `longest-repeating-substring`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.LongestRepeatingSubstring na...
12
number-of-valid-subarrays
1,063
Hard
[ "Stack", "Array", "Monotonic Stack" ]
Given an integer array nums, return the number of non-empty subarrays with the leftmost element of the subarray not larger than other elements in the subarray. A subarray is a contiguous part of an array.   Example 1: Input: nums = [1,4,2,5,3] Output: 11 Explanation: There are 11 valid subarrays: [1],[4],[2],[5],[3],[...
validSubarrays(nums: list_int) -> int
pub fn valid_subarrays(nums: &[i64]) -> i64
Aegis.ValidSubarrays.valid_subarrays
pub fn valid_subarrays(nums: &[i64]) -> i64 { let n = nums.len() as i64; let mut ans: i64 = 0; let mut stack: Vec<i64> = Vec::new(); let mut i: i64 = 0; while i < n { let cur = nums[i as usize]; let mut can_pop = true; while can_pop { if stack.is_empty() { ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [valid_subarrays]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linte...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [valid_subarrays]: function definitions module public import Aeneas public import Aegis.ValidSubarrays.Code.Types public import Aegis.ValidSubarrays.Code.FunsExternal @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNames...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [valid_subarrays]: external functions. -- This is a template file: rename it to "FunsExternal.lean" and fill the holes. module public import Aeneas public import Aegis.ValidSubarrays.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error...
import Aegis.ValidSubarrays.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.ValidSubarrays.valid_subarrays (Slice.from [1#i64] (by scalar_tac) : Slice Std.I64)) (1#i64))}") #eval (s!"CASE 1 {(Result.reducesTo (Aegis.ValidS...
[ { "input": "[[1]]", "output": "1" }, { "input": "[[2, 2, 2]]", "output": "6" }, { "input": "[[3, 2, 1]]", "output": "3" }, { "input": "[[1, 2, 2, 1]]", "output": "8" }, { "input": "[[10, 5, 10, 4, 15]]", "output": "7" }, { "input": "[[0, 0, 0, 0, 0]]",...
138
false
138
verified
10
10
1
2,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.ValidSubarrays.Code.Funs /-! # Specifications of `Aegis.ValidSubarrays.valid_subarrays` LeetCode problem `number-of-valid-subarrays`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.ValidSubarrays def entry (nums : Slice Std.I64) (i...
12
fixed-point
1,064
Easy
[ "Array", "Binary Search" ]
Given an array of distinct integers arr, where arr is sorted in ascending order, return the smallest index i that satisfies arr[i] == i. If there is no such index, return -1.   Example 1: Input: arr = [-10,-5,0,3,7] Output: 3 Explanation: For the given array, arr[0] = -10, arr[1] = -5, arr[2] = 0, arr[3] = 3, thus the...
fixedPoint(arr: list_int) -> int
pub fn fixed_point(arr: &[i64]) -> i64
Aegis.FixedPoint.fixed_point
pub fn fixed_point(arr: &[i64]) -> i64 { let n = arr.len(); let mut lo: i64 = 0; let mut hi: i64 = n as i64 - 1; let mut ans: i64 = -1; while lo <= hi { let mid = lo + (hi - lo) / 2; let m = mid as usize; if arr[m] == mid { ans = mid; hi = mid - 1; ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [fixed_point]: type definitions module public import Aeneas @[expose] public section 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 -- [fixed_point]: function definitions module public import Aeneas public import Aegis.FixedPoint.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.FixedPoint.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.FixedPoint.fixed_point (Slice.from [0#i64] (by scalar_tac) : Slice Std.I64)) (0#i64))}") #eval (s!"CASE 1 {(Result.reducesTo (Aegis.FixedPoint.fixed_p...
[ { "input": "[[0]]", "output": "0" }, { "input": "[[-1, 0]]", "output": "-1" }, { "input": "[[0, 1]]", "output": "0" }, { "input": "[[-1, 0, 1]]", "output": "-1" }, { "input": "[[-1, 0, 2, 3, 5]]", "output": "2" }, { "input": "[[-1, -1, 0, 1, 2]]", ...
118
false
118
verified
10
10
2
1,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.FixedPoint.Code.Funs /-! # Specifications of `Aegis.FixedPoint.fixed_point` LeetCode problem `fixed-point`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.FixedPoint def elem? (arr : Slice I64) (i : Nat) : Option Int := (arr.val[i]?)...
13
index-pairs-of-a-string
1,065
Easy
[ "Trie", "Array", "String", "Sorting" ]
Given a string text and an array of strings words, return an array of all index pairs [i, j] so that the substring text[i...j] is in words. Return the pairs [i, j] in sorted order (i.e., sort them by their first coordinate, and in case of ties sort them by their second coordinate).   Example 1: Input: text = "thestory...
indexPairs(text: str, words: list_str) -> list_list_int
pub fn index_pairs(text: &[u8], words: &[Vec<u8>]) -> Vec<Vec<i64>>
Aegis.IndexPairs.index_pairs
pub fn index_pairs(text: &[u8], words: &[Vec<u8>]) -> Vec<Vec<i64>> { let mut out: Vec<Vec<i64>> = Vec::new(); let n = text.len(); let m = words.len(); let mut i = 0usize; while i < n { let mut j = i; while j < n { let len = j - i + 1; let mut matched = false...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [index_pairs]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter.st...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [index_pairs]: function definitions module public import Aeneas public import Aegis.IndexPairs.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.IndexPairs.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.IndexPairs.index_pairs (Slice.from [104#u8, 101#u8, 108#u8, 108#u8, 111#u8] (by scalar_tac) : Slice Std.U8) (Slice.from [(alloc.vec.Vec.from [108#u8, ...
[ { "input": "[\"hello\", [\"ll\", \"o\"]]", "output": "[[2, 3], [4, 4]]" }, { "input": "[\"aaaa\", [\"aa\"]]", "output": "[[0, 1], [1, 2], [2, 3]]" }, { "input": "[\"thestoryofleetcodeandme\", [\"story\", \"fleet\", \"leetcode\"]]", "output": "[[3, 7], [9, 13], [10, 17]]" }, { ...
89
false
89
verified
10
10
1
1,538
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.IndexPairs.Code.Funs /-! # Specifications of `Aegis.IndexPairs.index_pairs` LeetCode problem `index-pairs-of-a-string`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.IndexPairs namespace AegisSpec.IndexPairs def byteAt (l : List Std.U8) (t : ℕ...
14
campus-bikes-ii
1,066
Medium
[ "Bit Manipulation", "Array", "Dynamic Programming", "Backtracking", "Bitmask" ]
On a campus represented as a 2D grid, there are n workers and m bikes, with n <= m. Each worker and bike is a 2D coordinate on this grid. We assign one unique bike to each worker so that the sum of the Manhattan distances between each worker and their assigned bike is minimized. Return the minimum possible sum of Manha...
assignBikes(workers: list_list_int, bikes: list_list_int) -> int
pub fn assign_bikes(workers: &[Vec<i64>], bikes: &[Vec<i64>]) -> i64
Aegis.AssignBikes.assign_bikes
pub fn assign_bikes(workers: &[Vec<i64>], bikes: &[Vec<i64>]) -> i64 { let n = workers.len(); let m = bikes.len(); let mut states: usize = 1; let mut k: usize = 0; while k < m { states = states * 2; k += 1; } let inf: i64 = 1_000_000_000; let total = (n + 1) * states; ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [assign_bikes]: type definitions module public import Aeneas @[expose] public section 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 -- [assign_bikes]: function definitions module public import Aeneas public import Aegis.AssignBikes.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.AssignBikes.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.AssignBikes.assign_bikes (Slice.from [(alloc.vec.Vec.from [0#i64, 0#i64] (by scalar_tac) : alloc.vec.Vec Std.I64), (alloc.vec.Vec.from [2#i64, 1#i64]...
[ { "input": "[[[0, 0], [2, 1]], [[1, 2], [3, 3]]]", "output": "6" }, { "input": "[[[0, 1], [1, 0]], [[2, 3], [3, 2], [4, 5]]]", "output": "8" }, { "input": "[[[0, 0], [1, 1], [2, 0]], [[1, 0], [2, 2], [2, 1]]]", "output": "4" }, { "input": "[[[1, 1], [2, 2], [3, 3]], [[4, 4], ...
89
false
89
verified
10
10
1
3,124
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.AssignBikes.Code.Funs /-! # Specifications of `Aegis.AssignBikes.assign_bikes` LeetCode problem `campus-bikes-ii`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aeneas.Data.ListN open Aegis.AssignBikes namespace AegisSpec.AssignBikes abbrev Pt := al...
16
digit-count-in-range
1,067
Hard
[ "Math", "Dynamic Programming" ]
Given a single-digit integer d and two integers low and high, return the number of times that d occurs as a digit in all integers in the inclusive range [low, high].   Example 1: Input: d = 1, low = 1, high = 13 Output: 6 Explanation: The digit d = 1 occurs 6 times in 1, 10, 11, 12, 13. Note that the digit d = 1 occur...
digitsCount(d: int, low: int, high: int) -> int
pub fn digits_count(d: i64, low: i64, high: i64) -> i64
Aegis.DigitsCount.digits_count
pub fn digits_count(d: i64, low: i64, high: i64) -> i64 { count_upto(d, high) - count_upto(d, low - 1) } fn count_upto(d: i64, n: i64) -> i64 { if n <= 0 { return 0; } let mut total: i64 = 0; let mut factor: i64 = 1; while factor <= n { let base: i64 = factor * 10; let...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [digits_count]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter.s...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [digits_count]: function definitions module public import Aeneas public import Aegis.DigitsCount.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.DigitsCount.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.DigitsCount.digits_count 5#i64 500#i64 550#i64) (57#i64))}") #eval (s!"CASE 1 {(Result.reducesTo (Aegis.DigitsCount.digits_count 9#i64 90#i64 100#i64...
[ { "input": "[5, 500, 550]", "output": "57" }, { "input": "[9, 90, 100]", "output": "11" }, { "input": "[9, 1000, 2000]", "output": "300" }, { "input": "[0, 1, 100]", "output": "11" }, { "input": "[5, 50, 150]", "output": "21" }, { "input": "[5, 123, 45...
100
false
100
verified
10
10
1
3,186
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.DigitsCount.Code.Funs /-! # Specifications of `Aegis.DigitsCount.digits_count` LeetCode problem `digit-count-in-range`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.DigitsCount (digits_count) namespace AegisSpec.DigitsCount def digitsRevAux :...
11
adding-two-negabinary-numbers
1,073
Medium
[ "Array", "Math" ]
Given two numbers arr1 and arr2 in base -2, return the result of adding them together. Each number is given in array format:  as an array of 0s and 1s, from most significant bit to least significant bit.  For example, arr = [1,1,0,1] represents the number (-2)^3 + (-2)^2 + (-2)^0 = -3.  A number arr in array, format is...
addNegabinary(arr1: list_int, arr2: list_int) -> list_int
pub fn add_negabinary(arr1: &[i64], arr2: &[i64]) -> Vec<i64>
Aegis.AddNegabinary.add_negabinary
pub fn add_negabinary(arr1: &[i64], arr2: &[i64]) -> Vec<i64> { let n1 = arr1.len(); let n2 = arr2.len(); let mut n = n1; if n2 > n { n = n2; } let mut rev: Vec<i64> = Vec::new(); let mut carry: i64 = 0; let mut k: usize = 0; while k < n { let mut a: i64 = 0; ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [add_negabinary]: type definitions module public import Aeneas @[expose] public section 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 -- [add_negabinary]: function definitions module public import Aeneas public import Aegis.AddNegabinary.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.AddNegabinary.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.AddNegabinary.add_negabinary (Slice.from [0#i64] (by scalar_tac) : Slice Std.I64) (Slice.from [0#i64] (by scalar_tac) : Slice Std.I64)) ((alloc.vec...
[ { "input": "[[0], [0]]", "output": "[0]" }, { "input": "[[0], [1]]", "output": "[1]" }, { "input": "[[1, 1, 0], [1, 1, 0]]", "output": "[1, 0, 0]" }, { "input": "[[1, 0, 0, 1], [1, 1, 0]]", "output": "[1, 1, 1, 1]" }, { "input": "[[1, 1, 1], [1, 1, 1]]", "outp...
104
false
104
verified
10
10
1
3,968
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.AddNegabinary.Code.Funs /-! # Specifications of `Aegis.AddNegabinary.add_negabinary` LeetCode problem `adding-two-negabinary-numbers`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.AddNegabinary def digits (l : List Std.I64) : List In...
7
number-of-submatrices-that-sum-to-target
1,074
Hard
[ "Array", "Hash Table", "Matrix", "Prefix Sum" ]
Given a matrix and a target, return the number of non-empty submatrices that sum to target. A submatrix x1, y1, x2, y2 is the set of all cells matrix[x][y] with x1 <= x <= x2 and y1 <= y <= y2. Two submatrices (x1, y1, x2, y2) and (x1', y1', x2', y2') are different if they have some coordinate that is different: for ex...
numSubmatrixSumTarget(matrix: list_list_int, target: int) -> int
pub fn num_submatrix_sum_target(matrix: &[Vec<i64>], target: i64) -> i64
Aegis.NumSubmatrixSumTarget.num_submatrix_sum_target
pub fn num_submatrix_sum_target(matrix: &[Vec<i64>], target: i64) -> i64 { let n: usize = matrix.len(); let m: usize = matrix[0].len(); let mut total: i64 = 0; let mut top: usize = 0; while top < n { let mut col_sums: Vec<i64> = Vec::new(); let mut j: usize = 0; while j < m...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [num_submatrix_sum_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 -- [num_submatrix_sum_target]: function definitions module public import Aeneas public import Aegis.NumSubmatrixSumTarget.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashComm...
import Aegis.NumSubmatrixSumTarget.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.NumSubmatrixSumTarget.num_submatrix_sum_target (Slice.from [(alloc.vec.Vec.from [1#i64] (by scalar_tac) : alloc.vec.Vec Std.I64)] (by scala...
[ { "input": "[[[1]], 1]", "output": "1" }, { "input": "[[[904]], 0]", "output": "0" }, { "input": "[[[1, 2], [3, 4]], 3]", "output": "2" }, { "input": "[[[1, -1], [-1, 1]], 0]", "output": "5" }, { "input": "[[[1, 2, 3], [4, 5, 6]], 12]", "output": "1" }, { ...
82
false
82
verified
10
10
1
10,145
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.NumSubmatrixSumTarget.Code.Funs /-! # Specifications of `Aegis.NumSubmatrixSumTarget.num_submatrix_sum_target` LeetCode problem `number-of-submatrices-that-sum-to-target`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open scoped BigOperators namespace A...
14
letter-tile-possibilities
1,079
Medium
[ "Hash Table", "String", "Backtracking", "Counting" ]
You have n  tiles, where each tile has one letter tiles[i] printed on it. Return the number of possible non-empty sequences of letters you can make using the letters printed on those tiles.   Example 1: Input: tiles = "AAB" Output: 8 Explanation: The possible sequences are "A", "B", "AA", "AB", "BA", "AAB", "ABA", "BA...
numTilePossibilities(tiles: str) -> int
pub fn num_tile_possibilities(tiles: &[u8]) -> i64
Aegis.NumTilePossibilities.num_tile_possibilities
fn binom(n: i64, k: i64) -> i64 { if k < 0 { return 0; } if k > n { return 0; } let mut kk = k; if kk > n - kk { kk = n - kk; } let mut res: i64 = 1; let mut i: i64 = 1; while i <= kk { res = res * (n - kk + i); res = res / i; i =...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [num_tile_possibilities]: type definitions module public import Aeneas @[expose] public 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_tile_possibilities]: function definitions module public import Aeneas public import Aegis.NumTilePossibilities.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand...
import Aegis.NumTilePossibilities.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.NumTilePossibilities.num_tile_possibilities (Slice.from [65#u8, 65#u8, 65#u8, 65#u8, 65#u8, 65#u8, 65#u8] (by scalar_tac) : Slice Std.U8)) (...
[ { "input": "[\"AAAAAAA\"]", "output": "7" }, { "input": "[\"QQQ\"]", "output": "3" }, { "input": "[\"ABCDEFG\"]", "output": "13699" }, { "input": "[\"ABC\"]", "output": "15" }, { "input": "[\"AAB\"]", "output": "8" }, { "input": "[\"AABBCC\"]", "ou...
74
false
74
verified
10
10
1
5,033
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.NumTilePossibilities.Code.Funs /-! # Specifications of `Aegis.NumTilePossibilities.num_tile_possibilities` LeetCode problem `letter-tile-possibilities`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.NumTilePossibilities def IsUppe...
11
insufficient-nodes-in-root-to-leaf-paths
1,080
Medium
[ "Tree", "Depth-First Search", "Binary Tree" ]
Given the root of a binary tree and an integer limit, delete all insufficient nodes in the tree simultaneously, and return the root of the resulting binary tree. A node is insufficient if every root to leaf path intersecting this node has a sum strictly less than limit. A leaf is a node with no children.   Example 1: ...
sufficientSubset(root: tree, limit: int) -> tree
pub fn sufficient_subset(root: &Tree, limit: i64) -> Tree
Aegis.SufficientSubset.sufficient_subset
fn is_null(t: &Tree) -> bool { match t { Tree::Null => true, _ => false, } } fn dfs(t: &Tree, sum: i64, limit: i64) -> Tree { match t { Tree::Null => Tree::Null, Tree::Node(v, l, r) => { let val = *v; if is_null(&**l) && is_null(&**r) { ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [sufficient_subset]: type definitions module public import Aeneas @[expose] public section 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 -- [sufficient_subset]: function definitions module public import Aeneas public import Aegis.SufficientSubset.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.SufficientSubset.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 deriving instance DecidableEq for Aegis.SufficientSubset.Tree #eval (s!"CASE 0 {(match (Aegis.SufficientSubset.sufficient_subset ((.Node 1#i64 (.Null) (.Null)) : Aegis.SufficientSubset.T...
[ { "input": "[[1], 1]", "output": "[1]" }, { "input": "[[1, 2], 3]", "output": "[1, 2]" }, { "input": "[[2, -2, -3], -2]", "output": "[2, -2, -3]" }, { "input": "[[2, -5, -2], -4]", "output": "[2, -5, -2]" }, { "input": "[[-5, -6, -7], -15]", "output": "[-5, -6...
18
false
18
verified
10
10
1
4,674
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.SufficientSubset.Code.Funs /-! # Specifications of `Aegis.SufficientSubset.sufficient_subset` LeetCode problem `insufficient-nodes-in-root-to-leaf-paths`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.SufficientSubset open Aegis.S...
12
sum-of-digits-in-the-minimum-number
1,085
Easy
[ "Array", "Math" ]
Given an integer array nums, return 0 if the sum of the digits of the minimum integer in nums is odd, or 1 otherwise.   Example 1: Input: nums = [34,23,1,24,75,33,54,8] Output: 0 Explanation: The minimal element is 1, and the sum of those digits is 1 which is odd, so the answer is 0. Example 2: Input: nums = [99,77,...
sumOfDigits(nums: list_int) -> int
pub fn sum_of_digits(nums: &[i64]) -> i64
Aegis.SumOfDigits.sum_of_digits
pub fn sum_of_digits(nums: &[i64]) -> i64 { let mut min = nums[0]; let mut i = 1; while i < nums.len() { if nums[i] < min { min = nums[i]; } i += 1; } let mut sum = 0; let mut x = min; while x > 0 { sum += x % 10; x = x / 10; } if...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [sum_of_digits]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter....
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [sum_of_digits]: function definitions module public import Aeneas public import Aegis.SumOfDigits.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.SumOfDigits.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.SumOfDigits.sum_of_digits (Slice.from [1#i64] (by scalar_tac) : Slice Std.I64)) (0#i64))}") #eval (s!"CASE 1 {(Result.reducesTo (Aegis.SumOfDigits.su...
[ { "input": "[[1]]", "output": "0" }, { "input": "[[99]]", "output": "1" }, { "input": "[[9, 18, 27, 36, 45]]", "output": "0" }, { "input": "[[81, 72, 45, 63, 29]]", "output": "0" }, { "input": "[[100, 99, 98, 97, 96]]", "output": "0" }, { "input": "[[5...
121
false
121
verified
10
10
1
335
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.SumOfDigits.Code.Funs /-! # Specifications of `Aegis.SumOfDigits.sum_of_digits` LeetCode problem `sum-of-digits-in-the-minimum-number`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.SumOfDigits namespace AegisSpec.SumOfDigits def digitSum...
10
high-five
1,086
Easy
[ "Array", "Hash Table", "Sorting", "Heap (Priority Queue)" ]
Given a list of the scores of different students, items, where items[i] = [IDi, scorei] represents one score from a student with IDi, calculate each student's top five average. Return the answer as an array of pairs result, where result[j] = [IDj, topFiveAveragej] represents the student with IDj and their top five aver...
highFive(items: list_list_int) -> list_list_int
pub fn high_five(items: &[Vec<i64>]) -> Vec<Vec<i64>>
Aegis.HighFive.high_five
pub fn high_five(items: &[Vec<i64>]) -> Vec<Vec<i64>> { let n = items.len(); let mut out: Vec<Vec<i64>> = Vec::new(); let mut last_id: i64 = 0; let mut going: bool = true; while going { let mut next_id: i64 = 0; let mut k: usize = 0; while k < n { let id = item...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [high_five]: type definitions module public import Aeneas @[expose] public section 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 -- [high_five]: function definitions module public import Aeneas public import Aegis.HighFive.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.HighFive.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval aegisCase "e...
[ { "input": "[[[4, 100], [4, 90], [4, 80], [4, 70], [4, 60], [4, 50], [4, 40], [4, 30], [4, 20], [4, 10]]]", "output": "[[4, 80]]" }, { "input": "[[[5, 100], [5, 99], [5, 98], [5, 97], [5, 96], [5, 95], [5, 94], [5, 93], [5, 92], [5, 91]]]", "output": "[[5, 98]]" }, { "input": "[[[3, 85],...
79
false
79
verified
10
10
2
8,716
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.HighFive.Code.Funs /-! # Specifications of `Aegis.HighFive.high_five` LeetCode problem `high-five`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.HighFive (high_five) namespace AegisSpec.HighFive abbrev IVec : Type := alloc.vec.Vec I64 abbrev...
11
confusing-number-ii
1,088
Hard
[ "Math", "Backtracking" ]
A confusing number is a number that when rotated 180 degrees becomes a different number with each digit valid. We can rotate digits of a number by 180 degrees to form new digits. When 0, 1, 6, 8, and 9 are rotated 180 degrees, they become 0, 1, 9, 8, and 6 respectively. When 2, 3, 4, 5, and 7 are rotated 180 degrees, ...
confusingNumberII(n: int) -> int
pub fn confusing_number_ii(n: i64) -> i64
Aegis.ConfusingNumberIi.confusing_number_ii
fn pow5(k: usize) -> i64 { let mut result: i64 = 1; let mut i: usize = 0; while i < k { result = result * 5; i += 1; } result } fn is_valid_digit(d: i64) -> bool { d == 0 || d == 1 || d == 6 || d == 8 || d == 9 } fn rotate_digit(d: i64) -> i64 { if d == 1 { 1 } ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [confusing_number_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 l...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [confusing_number_ii]: function definitions module public import Aeneas public import Aegis.ConfusingNumberIi.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false...
import Aegis.ConfusingNumberIi.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.ConfusingNumberIi.confusing_number_ii 999999999#i64) (1950626#i64))}") #eval (s!"CASE 1 {(Result.reducesTo (Aegis.ConfusingNumberIi.confusing_n...
[ { "input": "[999999999]", "output": "1950626" }, { "input": "[2000]", "output": "226" }, { "input": "[100]", "output": "19" }, { "input": "[50000]", "output": "1196" }, { "input": "[1000]", "output": "107" }, { "input": "[50]", "output": "6" }, ...
60
false
60
verified
10
10
1
25,619
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.ConfusingNumberIi.Code.Funs /-! # Specifications of `Aegis.ConfusingNumberIi.confusing_number_ii` LeetCode problem `confusing-number-ii`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.ConfusingNumberIi def revDigitsAux : Nat → Nat...
12
largest-values-from-labels
1,090
Medium
[ "Greedy", "Array", "Hash Table", "Counting", "Sorting" ]
You are given n item's value and label as two integer arrays values and labels. You are also given two integers numWanted and useLimit. Your task is to find a subset of items with the maximum sum of their values such that: The number of items is at most numWanted. The number of items with the same label is at most use...
largestValsFromLabels(values: list_int, labels: list_int, numWanted: int, useLimit: int) -> int
pub fn largest_vals_from_labels(values: &[i64], labels: &[i64], numWanted: i64, useLimit: i64) -> i64
Aegis.LargestValsFromLabels.largest_vals_from_labels
pub fn largest_vals_from_labels(values: &[i64], labels: &[i64], numWanted: i64, useLimit: i64) -> i64 { let n = values.len(); if n == 0 || numWanted <= 0 || useLimit <= 0 { return 0; } let mut max_value: i64 = 0; let mut max_label: i64 = 0; let mut i: usize = 0; while i < n { ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [largest_vals_from_labels]: type definitions module public import Aeneas @[expose] public 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 -- [largest_vals_from_labels]: function definitions module public import Aeneas public import Aegis.LargestValsFromLabels.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashComm...
import Aegis.LargestValsFromLabels.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.LargestValsFromLabels.largest_vals_from_labels (Slice.from [10#i64, 10#i64, 10#i64, 10#i64] (by scalar_tac) : Slice Std.I64) (Slice.from [1...
[ { "input": "[[10, 10, 10, 10], [1, 1, 1, 1], 3, 2]", "output": "20" }, { "input": "[[10, 10, 10, 10], [1, 2, 3, 4], 4, 1]", "output": "40" }, { "input": "[[9, 8, 8, 7, 6], [0, 0, 0, 1, 1], 3, 1]", "output": "16" }, { "input": "[[10, 20, 30, 40, 50], [1, 2, 3, 4, 5], 5, 1]", ...
99
false
99
verified
10
10
1
3,090
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.LargestValsFromLabels.Code.Funs /-! # Specifications of `Aegis.LargestValsFromLabels.largest_vals_from_labels` LeetCode problem `largest-values-from-labels`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.LargestValsFromLabels namespace Aegi...
15
shortest-path-in-binary-matrix
1,091
Medium
[ "Breadth-First Search", "Array", "Matrix" ]
Given an n x n binary matrix grid, return the length of the shortest clear path in the matrix. If there is no clear path, return -1. A clear path in a binary matrix is a path from the top-left cell (i.e., (0, 0)) to the bottom-right cell (i.e., (n - 1, n - 1)) such that: All the visited cells of the path are 0. All th...
shortestPathBinaryMatrix(grid: list_list_int) -> int
pub fn shortest_path_binary_matrix(grid: &[Vec<i64>]) -> i64
Aegis.ShortestPathBinaryMatrix.shortest_path_binary_matrix
pub fn shortest_path_binary_matrix(grid: &[Vec<i64>]) -> i64 { let n = grid.len(); if n == 0 { return -1; } if grid[0][0] != 0 { return -1; } if grid[n - 1][n - 1] != 0 { return -1; } let mut dist: Vec<i64> = Vec::new(); let mut i: usize = 0; while i < n ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [shortest_path_binary_matrix]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [shortest_path_binary_matrix]: function definitions module public import Aeneas public import Aegis.ShortestPathBinaryMatrix.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.ha...
import Aegis.ShortestPathBinaryMatrix.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.ShortestPathBinaryMatrix.shortest_path_binary_matrix (Slice.from [(alloc.vec.Vec.from [1#i64] (by scalar_tac) : alloc.vec.Vec Std.I64)] ...
[ { "input": "[[[1]]]", "output": "-1" }, { "input": "[[[0]]]", "output": "1" }, { "input": "[[[0, 1], [1, 0]]]", "output": "2" }, { "input": "[[[0, 0, 0], [1, 1, 0], [1, 1, 0]]]", "output": "4" }, { "input": "[[[1, 0, 0], [1, 1, 0], [1, 1, 0]]]", "output": "-1"...
67
false
67
verified
10
10
1
2,396
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.ShortestPathBinaryMatrix.Code.Funs /-! # Specifications of `Aegis.ShortestPathBinaryMatrix.shortest_path_binary_matrix` LeetCode problem `shortest-path-in-binary-matrix`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.ShortestPathBina...
15
two-sum-less-than-k
1,099
Easy
[ "Array", "Two Pointers", "Binary Search", "Sorting" ]
Given an array nums of integers and integer k, return the maximum sum such that there exists i < j with nums[i] + nums[j] = sum and sum < k. If no i, j exist satisfying this equation, return -1.   Example 1: Input: nums = [34,23,1,24,75,33,54,8], k = 60 Output: 58 Explanation: We can use 34 and 24 to sum 58 which is l...
twoSumLessThanK(nums: list_int, k: int) -> int
pub fn two_sum_less_than_k(nums: &[i64], k: i64) -> i64
Aegis.TwoSumLessThanK.two_sum_less_than_k
pub fn two_sum_less_than_k(nums: &[i64], k: i64) -> i64 { let n = nums.len(); let mut best: i64 = -1; let mut i: usize = 0; while i < n { let mut j: usize = i + 1; while j < n { let sum = nums[i] + nums[j]; if sum < k && sum > best { best = sum;...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [two_sum_less_than_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 l...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [two_sum_less_than_k]: function definitions module public import Aeneas public import Aegis.TwoSumLessThanK.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.TwoSumLessThanK.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.TwoSumLessThanK.two_sum_less_than_k (Slice.from [1#i64] (by scalar_tac) : Slice Std.I64) 2#i64) ((-1)#i64))}") #eval (s!"CASE 1 {(Result.reducesT...
[ { "input": "[[1], 2]", "output": "-1" }, { "input": "[[10, 20, 30], 15]", "output": "-1" }, { "input": "[[500, 500, 500, 500], 1000]", "output": "-1" }, { "input": "[[5, 15, 25, 35], 50]", "output": "40" }, { "input": "[[999, 998, 997, 996], 1995]", "output": ...
98
false
98
verified
10
10
1
573
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.TwoSumLessThanK.Code.Funs /-! # Specifications of `Aegis.TwoSumLessThanK.two_sum_less_than_k` LeetCode problem `two-sum-less-than-k`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.TwoSumLessThanK def elem (nums : Slice Std.I64) (i : N...
14
the-earliest-moment-when-everyone-become-friends
1,101
Medium
[ "Union Find", "Array", "Sorting" ]
There are n people in a social group labeled from 0 to n - 1. You are given an array logs where logs[i] = [timestampi, xi, yi] indicates that xi and yi will be friends at the time timestampi. Friendship is symmetric. That means if a is friends with b, then b is friends with a. Also, person a is acquainted with a person...
earliestAcq(logs: list_list_int, n: int) -> int
pub fn earliest_acq(logs: &[Vec<i64>], n: i64) -> i64
Aegis.EarliestAcq.earliest_acq
pub fn earliest_acq(logs: &[Vec<i64>], n: i64) -> i64 { let l = logs.len(); // Build the initial order of log indices. let mut order: Vec<i64> = Vec::new(); let mut z: usize = 0; while z < l { order.push(z as i64); z += 1; } // Temporary vector for iterative merge sort. ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [earliest_acq]: type definitions module public import Aeneas @[expose] public section 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 -- [earliest_acq]: function definitions module public import Aeneas public import Aegis.EarliestAcq.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.EarliestAcq.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.EarliestAcq.earliest_acq (Slice.from [(alloc.vec.Vec.from [1#i64, 0#i64, 2#i64] (by scalar_tac) : alloc.vec.Vec Std.I64), (alloc.vec.Vec.from [2#i64,...
[ { "input": "[[[1, 0, 2], [2, 2, 1], [3, 0, 1]], 3]", "output": "2" }, { "input": "[[[8, 1, 2], [9, 1, 3], [10, 2, 3]], 4]", "output": "-1" }, { "input": "[[[10, 1, 2], [1, 0, 1], [8, 1, 0], [5, 2, 1]], 3]", "output": "5" }, { "input": "[[[10, 1, 2], [11, 3, 4], [12, 1, 3], [1...
89
false
89
verified
10
10
1
6,708
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.EarliestAcq.Code.Funs /-! # Specifications of `Aegis.EarliestAcq.earliest_acq` LeetCode problem `the-earliest-moment-when-everyone-become-friends`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.EarliestAcq abbrev Row : Type := all...
13
path-with-maximum-minimum-value
1,102
Medium
[ "Depth-First Search", "Breadth-First Search", "Union Find", "Array", "Binary Search", "Matrix", "Heap (Priority Queue)" ]
Given an m x n integer matrix grid, return the maximum score of a path starting at (0, 0) and ending at (m - 1, n - 1) moving in the 4 cardinal directions. The score of a path is the minimum value in that path. For example, the score of the path 8 → 4 → 5 → 9 is 4.   Example 1: Input: grid = [[5,4,5],[1,2,6],[7,4,6...
maximumMinimumPath(grid: list_list_int) -> int
pub fn maximum_minimum_path(grid: &[Vec<i64>]) -> i64
Aegis.MaximumMinimumPath.maximum_minimum_path
pub fn maximum_minimum_path(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 lo: i64 = 0; let mut hi: i64 = 1_000_000_000; while lo < hi { let mid: i64 = lo + (hi - lo + 1) / 2; ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [maximum_minimum_path]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [maximum_minimum_path]: function definitions module public import Aeneas public import Aegis.MaximumMinimumPath.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand fal...
import Aegis.MaximumMinimumPath.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.MaximumMinimumPath.maximum_minimum_path (Slice.from [(alloc.vec.Vec.from [5#i64, 4#i64, 5#i64] (by scalar_tac) : alloc.vec.Vec Std.I64), (allo...
[ { "input": "[[[5, 4, 5], [1, 2, 6], [7, 4, 6]]]", "output": "4" }, { "input": "[[[1, 2, 3], [6, 5, 4], [7, 8, 9]]]", "output": "1" }, { "input": "[[[1000000000, 1000000000, 1000000000], [1000000000, 1000000000, 1000000000], [1000000000, 1000000000, 1000000000]]]", "output": "10000000...
72
false
72
verified
10
10
1
4,120
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MaximumMinimumPath.Code.Funs /-! # Specifications of `Aegis.MaximumMinimumPath.maximum_minimum_path` LeetCode problem `path-with-maximum-minimum-value`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.MaximumMinimumPath open Aegis.M...
16
distribute-candies-to-people
1,103
Easy
[ "Math", "Simulation" ]
We distribute some number of candies, to a row of n = num_people people in the following way: We then give 1 candy to the first person, 2 candies to the second person, and so on until we give n candies to the last person. Then, we go back to the start of the row, giving n + 1 candies to the first person, n + 2 candies ...
distributeCandies(candies: int, num_people: int) -> list_int
pub fn distribute_candies(candies: i64, num_people: i64) -> Vec<i64>
Aegis.DistributeCandies.distribute_candies
pub fn distribute_candies(candies: i64, num_people: i64) -> Vec<i64> { let n = num_people as usize; let mut ans: Vec<i64> = Vec::new(); let mut i = 0; while i < n { ans.push(0); i += 1; } let mut remaining = candies; let mut give = 1i64; let mut idx = 0usize; while...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [distribute_candies]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option li...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [distribute_candies]: function definitions module public import Aeneas public import Aegis.DistributeCandies.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false ...
import Aegis.DistributeCandies.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.DistributeCandies.distribute_candies 1#i64 1#i64) ((alloc.vec.Vec.from [1#i64] (by scalar_tac) : alloc.vec.Vec Std.I64)))}") #eval (s!"CASE 1 {...
[ { "input": "[1, 1]", "output": "[1]" }, { "input": "[1000, 1]", "output": "[1000]" }, { "input": "[100, 1]", "output": "[100]" }, { "input": "[500, 1]", "output": "[500]" }, { "input": "[15, 1]", "output": "[15]" }, { "input": "[200, 1]", "output":...
79
false
79
verified
10
10
1
1,130
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.DistributeCandies.Code.Funs /-! # Specifications of `Aegis.DistributeCandies.distribute_candies` LeetCode problem `distribute-candies-to-people`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.DistributeCandies def tri (k : ℕ) : ℕ ...
13
path-in-zigzag-labelled-binary-tree
1,104
Medium
[ "Tree", "Math", "Binary Tree" ]
In an infinite binary tree where every node has two children, the nodes are labelled in row order. In the odd numbered rows (ie., the first, third, fifth,...), the labelling is left to right, while in the even numbered rows (second, fourth, sixth,...), the labelling is right to left. Given the label of a node in this ...
pathInZigZagTree(label: int) -> list_int
pub fn path_in_zig_zag_tree(label: i64) -> Vec<i64>
Aegis.PathInZigZagTree.path_in_zig_zag_tree
pub fn path_in_zig_zag_tree(label: i64) -> Vec<i64> { let mut ans: Vec<i64> = Vec::new(); let mut cur: i64 = label; while cur > 0 { ans.push(cur); if cur == 1 { break; } let temp: i64 = cur / 2; let mut level: i64 = 0; let mut pow: i64 = 1; ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [path_in_zig_zag_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 -- [path_in_zig_zag_tree]: function definitions module public import Aeneas public import Aegis.PathInZigZagTree.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false...
import Aegis.PathInZigZagTree.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.PathInZigZagTree.path_in_zig_zag_tree 1#i64) ((alloc.vec.Vec.from [1#i64] (by scalar_tac) : alloc.vec.Vec Std.I64)))}") #eval (s!"CASE 1 {(Resul...
[ { "input": "[1]", "output": "[1]" }, { "input": "[3]", "output": "[1, 3]" }, { "input": "[2]", "output": "[1, 2]" }, { "input": "[4]", "output": "[1, 3, 4]" }, { "input": "[6]", "output": "[1, 2, 6]" }, { "input": "[7]", "output": "[1, 2, 7]" }, ...
78
false
78
verified
10
10
1
2,753
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.PathInZigZagTree.Code.Funs /-! # Specifications of `Aegis.PathInZigZagTree.path_in_zig_zag_tree` LeetCode problem `path-in-zigzag-labelled-binary-tree`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.PathInZigZagTree def elem? (r : all...
12
corporate-flight-bookings
1,109
Medium
[ "Array", "Prefix Sum" ]
There are n flights that are labeled from 1 to n. You are given an array of flight bookings bookings, where bookings[i] = [firsti, lasti, seatsi] represents a booking for flights firsti through lasti (inclusive) with seatsi seats reserved for each flight in the range. Return an array answer of length n, where answer[i]...
corpFlightBookings(bookings: list_list_int, n: int) -> list_int
pub fn corp_flight_bookings(bookings: &[Vec<i64>], n: i64) -> Vec<i64>
Aegis.CorpFlightBookings.corp_flight_bookings
pub fn corp_flight_bookings(bookings: &[Vec<i64>], n: i64) -> Vec<i64> { let mut diff: Vec<i64> = Vec::new(); let mut k: i64 = 0; while k <= n { diff.push(0); k += 1; } let m = bookings.len(); let mut i: usize = 0; while i < m { let booking = &bookings[i]; le...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [corp_flight_bookings]: type definitions module public import Aeneas @[expose] public section 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 -- [corp_flight_bookings]: function definitions module public import Aeneas public import Aegis.CorpFlightBookings.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand fal...
import Aegis.CorpFlightBookings.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.CorpFlightBookings.corp_flight_bookings (Slice.from [(alloc.vec.Vec.from [1#i64, 2#i64, 10#i64] (by scalar_tac) : alloc.vec.Vec Std.I64), (all...
[ { "input": "[[[1, 2, 10], [2, 2, 15]], 2]", "output": "[10, 25]" }, { "input": "[[[1, 2, 1], [1, 2, 1], [1, 2, 1]], 2]", "output": "[3, 3]" }, { "input": "[[[1, 1, 5], [1, 2, 7], [1, 3, 9]], 3]", "output": "[21, 16, 9]" }, { "input": "[[[1, 1, 5], [2, 2, 7], [3, 3, 9]], 3]", ...
105
false
105
verified
10
10
1
1,362
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.CorpFlightBookings.Code.Funs /-! # Specifications of `Aegis.CorpFlightBookings.corp_flight_bookings` LeetCode problem `corporate-flight-bookings`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.CorpFlightBookings def rows (bookings...
12
number-of-days-in-a-month
1,118
Easy
[ "Math" ]
Given a year year and a month month, return the number of days of that month.   Example 1: Input: year = 1992, month = 7 Output: 31 Example 2: Input: year = 2000, month = 2 Output: 29 Example 3: Input: year = 1900, month = 2 Output: 28   Constraints: 1583 <= year <= 2100 1 <= month <= 12
numberOfDays(year: int, month: int) -> int
pub fn number_of_days(year: i64, month: i64) -> i64
Aegis.NumberOfDays.number_of_days
pub fn number_of_days(year: i64, month: i64) -> i64 { if month == 2 { if year % 400 == 0 || (year % 4 == 0 && year % 100 != 0) { 29 } else { 28 } } else if month == 4 || month == 6 || month == 9 || month == 11 { 30 } else { 31 } }
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [number_of_days]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [number_of_days]: function definitions module public import Aeneas public import Aegis.NumberOfDays.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.NumberOfDays.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.NumberOfDays.number_of_days 2023#i64 11#i64) (30#i64))}") #eval (s!"CASE 1 {(Result.reducesTo (Aegis.NumberOfDays.number_of_days 1583#i64 8#i64) (31...
[ { "input": "[2023, 11]", "output": "30" }, { "input": "[1583, 8]", "output": "31" }, { "input": "[1583, 1]", "output": "31" }, { "input": "[1583, 12]", "output": "31" }, { "input": "[2020, 4]", "output": "30" }, { "input": "[1992, 7]", "output": "3...
33
false
33
verified
10
10
1
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.NumberOfDays.Code.Funs /-! # Specifications of `Aegis.NumberOfDays.number_of_days` LeetCode problem `number-of-days-in-a-month`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.NumberOfDays open Aegis.NumberOfDays def IsLeapYear (year ...
12
divide-array-into-increasing-sequences
1,121
Hard
[ "Array", "Counting" ]
Given an integer array nums sorted in non-decreasing order and an integer k, return true if this array can be divided into one or more disjoint increasing subsequences of length at least k, or false otherwise.   Example 1: Input: nums = [1,2,2,3,3,4,4], k = 3 Output: true Explanation: The array can be divided into two...
canDivideIntoSubsequences(nums: list_int, k: int) -> bool
pub fn can_divide_into_subsequences(nums: &[i64], k: i64) -> bool
Aegis.CanDivideIntoSubsequences.can_divide_into_subsequences
pub fn can_divide_into_subsequences(nums: &[i64], k: i64) -> bool { let n = nums.len(); if n == 0 { return true; } // The array can be split as required iff max frequency * k <= n, // i.e. every value occurs at most floor(n / k) times. let limit: i64 = (n as i64) / k; let mut cur_f...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [can_divide_into_subsequences]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [can_divide_into_subsequences]: function definitions module public import Aeneas public import Aegis.CanDivideIntoSubsequences.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter....
import Aegis.CanDivideIntoSubsequences.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.CanDivideIntoSubsequences.can_divide_into_subsequences (Slice.from [5#i64, 6#i64, 6#i64, 7#i64, 8#i64] (by scalar_tac) : Slice Std.I64)...
[ { "input": "[[5, 6, 6, 7, 8], 3]", "output": "false" }, { "input": "[[1, 2, 3, 4, 5], 1]", "output": "true" }, { "input": "[[1, 1, 1, 2, 2, 3], 2]", "output": "true" }, { "input": "[[1, 2, 2, 3, 3, 4, 4], 3]", "output": "true" }, { "input": "[[1, 1, 1, 2, 2, 2, 3,...
103
false
103
verified
10
10
2
15,705
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.CanDivideIntoSubsequences.Code.Funs /-! # Specifications of `Aegis.CanDivideIntoSubsequences.can_divide_into_subsequences` LeetCode problem `divide-array-into-increasing-sequences`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.CanDivi...
9
lowest-common-ancestor-of-deepest-leaves
1,123
Medium
[ "Tree", "Depth-First Search", "Breadth-First Search", "Hash Table", "Binary Tree" ]
Given the root of a binary tree, return the lowest common ancestor of its deepest leaves. Recall that: The node of a binary tree is a leaf if and only if it has no children The depth of the root of the tree is 0. if the depth of a node is d, the depth of each of its children is d + 1. The lowest common ancestor of a s...
lcaDeepestLeaves(root: tree) -> tree
pub fn lca_deepest_leaves(root: &Tree) -> Tree
Aegis.LcaDeepestLeaves.lca_deepest_leaves
fn tree_depth(t: &Tree) -> i64 { match t { Tree::Null => -1, Tree::Node(_, left, right) => { let dl = tree_depth(&**left); let dr = tree_depth(&**right); if dl > dr { dl + 1 } else { dr + 1 } } } ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [lca_deepest_leaves]: type definitions module public import Aeneas @[expose] public section 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 -- [lca_deepest_leaves]: function definitions module public import Aeneas public import Aegis.LcaDeepestLeaves.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.LcaDeepestLeaves.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 deriving instance DecidableEq for Aegis.LcaDeepestLeaves.Tree #eval (s!"CASE 0 {(match (Aegis.LcaDeepestLeaves.lca_deepest_leaves ((.Node 1#i64 (.Null) (.Null)) : Aegis.LcaDeepestLeaves....
[ { "input": "[[1]]", "output": "[1]" }, { "input": "[[2, 1, 3]]", "output": "[2, 1, 3]" }, { "input": "[[1, 2, 3, 4, 5]]", "output": "[2, 4, 5]" }, { "input": "[[1, 2, 3, 4, 5, 6, 7]]", "output": "[1, 2, 3, 4, 5, 6, 7]" }, { "input": "[[20, 8, 22, 4, 12, 10, 14]]",...
11
false
11
verified
10
10
1
2,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.LcaDeepestLeaves.Code.Funs /-! # Specifications of `Aegis.LcaDeepestLeaves.lca_deepest_leaves` LeetCode problem `lowest-common-ancestor-of-deepest-leaves`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.LcaDeepestLeaves open Aegis.LcaD...
11
longest-well-performing-interval
1,124
Medium
[ "Stack", "Array", "Hash Table", "Prefix Sum", "Monotonic Stack" ]
We are given hours, a list of the number of hours worked per day for a given employee. A day is considered to be a tiring day if and only if the number of hours worked is (strictly) greater than 8. A well-performing interval is an interval of days for which the number of tiring days is strictly larger than the number o...
longestWPI(hours: list_int) -> int
pub fn longest_wpi(hours: &[i64]) -> i64
Aegis.LongestWpi.longest_wpi
pub fn longest_wpi(hours: &[i64]) -> i64 { let n: usize = hours.len(); let mut pref: Vec<i64> = Vec::new(); let mut sum: i64 = 0; pref.push(sum); let mut i: usize = 0; while i < n { if hours[i] > 8 { sum += 1; } else { sum -= 1; } pref.pu...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [longest_wpi]: type definitions module public import Aeneas @[expose] public section 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 -- [longest_wpi]: function definitions module public import Aeneas public import Aegis.LongestWpi.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.LongestWpi.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.LongestWpi.longest_wpi (Slice.from [6#i64, 6#i64, 6#i64] (by scalar_tac) : Slice Std.I64)) (0#i64))}") #eval (s!"CASE 1 {(Result.reducesTo (Aegis.Long...
[ { "input": "[[6, 6, 6]]", "output": "0" }, { "input": "[[8, 9, 9, 10]]", "output": "4" }, { "input": "[[16, 16, 16, 16]]", "output": "4" }, { "input": "[[10, 10, 10, 10]]", "output": "4" }, { "input": "[[8, 9, 9, 2, 5]]", "output": "3" }, { "input": "[...
99
false
99
verified
10
10
1
5,441
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.LongestWpi.Code.Funs /-! # Specifications of `Aegis.LongestWpi.longest_wpi` LeetCode problem `longest-well-performing-interval`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.LongestWpi set_option autoImplicit false namespace AegisSpec.Longest...
14
number-of-equivalent-domino-pairs
1,128
Easy
[ "Array", "Hash Table", "Counting" ]
Given a list of dominoes, dominoes[i] = [a, b] is equivalent to dominoes[j] = [c, d] if and only if either (a == c and b == d), or (a == d and b == c) - that is, one domino can be rotated to be equal to another domino. Return the number of pairs (i, j) for which 0 <= i < j < dominoes.length, and dominoes[i] is equivale...
numEquivDominoPairs(dominoes: list_list_int) -> int
pub fn num_equiv_domino_pairs(dominoes: &[Vec<i64>]) -> i64
Aegis.NumEquivDominoPairs.num_equiv_domino_pairs
pub fn num_equiv_domino_pairs(dominoes: &[Vec<i64>]) -> i64 { let n = dominoes.len(); if n == 0 { return 0; } let mut table_size: usize = 1; while table_size < n * 2 { table_size *= 2; } let mut used: Vec<bool> = Vec::new(); let mut key_lo: Vec<i64> = Vec::new(); le...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [num_equiv_domino_pairs]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_optio...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [num_equiv_domino_pairs]: function definitions module public import Aeneas public import Aegis.NumEquivDominoPairs.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand ...
import Aegis.NumEquivDominoPairs.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.NumEquivDominoPairs.num_equiv_domino_pairs (Slice.from [(alloc.vec.Vec.from [1#i64, 2#i64] (by scalar_tac) : alloc.vec.Vec Std.I64), (alloc.v...
[ { "input": "[[[1, 2], [2, 1], [3, 4], [5, 6]]]", "output": "1" }, { "input": "[[[1, 2], [2, 3], [3, 4], [4, 5]]]", "output": "0" }, { "input": "[[[1, 1], [2, 2], [1, 2], [2, 1]]]", "output": "1" }, { "input": "[[[1, 1], [1, 1], [1, 1], [1, 1]]]", "output": "6" }, { ...
89
false
89
verified
10
10
1
6,060
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.NumEquivDominoPairs.Code.Funs /-! # Specifications of `Aegis.NumEquivDominoPairs.num_equiv_domino_pairs` LeetCode problem `number-of-equivalent-domino-pairs`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.NumEquivDominoPairs open Aegi...
8
shortest-path-with-alternating-colors
1,129
Medium
[ "Breadth-First Search", "Graph" ]
You are given an integer n, the number of nodes in a directed graph where the nodes are labeled from 0 to n - 1. Each edge is red or blue in this graph, and there could be self-edges and parallel edges. You are given two arrays redEdges and blueEdges where: redEdges[i] = [ai, bi] indicates that there is a directed red...
shortestAlternatingPaths(n: int, redEdges: list_list_int, blueEdges: list_list_int) -> list_int
pub fn shortest_alternating_paths(n: i64, redEdges: &[Vec<i64>], blueEdges: &[Vec<i64>]) -> Vec<i64>
Aegis.ShortestAlternatingPaths.shortest_alternating_paths
pub fn shortest_alternating_paths(n: i64, redEdges: &[Vec<i64>], blueEdges: &[Vec<i64>]) -> Vec<i64> { let n_usize = n as usize; let total_states = n_usize * 2; let mut dist: Vec<i64> = Vec::new(); let mut i: usize = 0; while i < total_states { dist.push(-1); i += 1; } let ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [shortest_alternating_paths]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_o...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [shortest_alternating_paths]: function definitions module public import Aeneas public import Aegis.ShortestAlternatingPaths.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.has...
import Aegis.ShortestAlternatingPaths.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.ShortestAlternatingPaths.shortest_alternating_paths 2#i64 (Slice.from [(alloc.vec.Vec.from [0#i64, 1#i64] (by scalar_tac) : alloc.vec.Ve...
[ { "input": "[2, [[0, 1]], [[1, 0]]]", "output": "[0, 1]" }, { "input": "[2, [[0, 0]], [[0, 0]]]", "output": "[0, -1]" }, { "input": "[2, [[0, 0]], [[1, 1]]]", "output": "[0, -1]" }, { "input": "[3, [[0, 1]], [[2, 1]]]", "output": "[0, 1, -1]" }, { "input": "[3, []...
97
false
97
verified
10
10
1
4,578
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.ShortestAlternatingPaths.Code.Funs /-! # Specifications of `Aegis.ShortestAlternatingPaths.shortest_alternating_paths` LeetCode problem `shortest-path-with-alternating-colors`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.ShortestAlternatingPa...
12
minimum-cost-tree-from-leaf-values
1,130
Medium
[ "Stack", "Greedy", "Array", "Dynamic Programming", "Monotonic Stack" ]
Given an array arr of positive integers, consider all binary trees such that: Each node has either 0 or 2 children; The values of arr correspond to the values of each leaf in an in-order traversal of the tree. The value of each non-leaf node is equal to the product of the largest leaf value in its left and right subtr...
mctFromLeafValues(arr: list_int) -> int
pub fn mct_from_leaf_values(arr: &[i64]) -> i64
Aegis.MctFromLeafValues.mct_from_leaf_values
pub fn mct_from_leaf_values(arr: &[i64]) -> i64 { let n = arr.len(); if n <= 1 { return 0; } let size = n * n; let mut dp: Vec<i64> = Vec::new(); let mut t = 0; while t < size { dp.push(0); t += 1; } let mut len = 2; while len <= n { let mut i = ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [mct_from_leaf_values]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [mct_from_leaf_values]: function definitions module public import Aeneas public import Aegis.MctFromLeafValues.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand fals...
import Aegis.MctFromLeafValues.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.MctFromLeafValues.mct_from_leaf_values (Slice.from [4#i64, 11#i64] (by scalar_tac) : Slice Std.I64)) (44#i64))}") #eval (s!"CASE 1 {(Result.red...
[ { "input": "[[4, 11]]", "output": "44" }, { "input": "[[3, 2, 1]]", "output": "8" }, { "input": "[[6, 2, 4]]", "output": "32" }, { "input": "[[1, 2, 3, 4]]", "output": "20" }, { "input": "[[7, 12, 8, 10]]", "output": "284" }, { "input": "[[2, 3, 1, 4]]...
108
false
108
verified
10
10
1
3,831
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MctFromLeafValues.Code.Funs /-! # Specifications of `Aegis.MctFromLeafValues.mct_from_leaf_values` LeetCode problem `minimum-cost-tree-from-leaf-values`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.MctFromLeafValues open Aegis.MctFr...
14
maximum-of-absolute-value-expression
1,131
Medium
[ "Array", "Math" ]
Given two arrays of integers with equal lengths, return the maximum value of:\r \r |arr1[i] - arr1[j]| + |arr2[i] - arr2[j]| + |i - j|\r \r where the maximum is taken over all 0 <= i, j < arr1.length.\r   Example 1: Input: arr1 = [1,2,3,4], arr2 = [-1,4,5,6] Output: 13 Example 2: Input: arr1 = [1,-2,-5,0,10], arr2 ...
maxAbsValExpr(arr1: list_int, arr2: list_int) -> int
pub fn max_abs_val_expr(arr1: &[i64], arr2: &[i64]) -> i64
Aegis.MaxAbsValExpr.max_abs_val_expr
pub fn max_abs_val_expr(arr1: &[i64], arr2: &[i64]) -> i64 { let n = arr1.len(); let mut best: i64 = 0; let mut si = 0; while si < 2 { let s: i64 = if si == 0 { 1 } else { -1 }; let mut ti = 0; while ti < 2 { let t: i64 = if ti == 0 { 1 } else { -1 }; l...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [max_abs_val_expr]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option lint...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [max_abs_val_expr]: function definitions module public import Aeneas public import Aegis.MaxAbsValExpr.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.MaxAbsValExpr.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.MaxAbsValExpr.max_abs_val_expr (Slice.from [(-1000000)#i64, 1000000#i64] (by scalar_tac) : Slice Std.I64) (Slice.from [1000000#i64, (-1000000)#i64]...
[ { "input": "[[-1000000, 1000000], [1000000, -1000000]]", "output": "4000001" }, { "input": "[[1000000, -1000000], [-1000000, 1000000]]", "output": "4000001" }, { "input": "[[1, 3, 5, 7], [2, 4, 6, 8]]", "output": "15" }, { "input": "[[0, 0, 0, 0], [0, 0, 0, 0]]", "output"...
94
false
94
verified
10
10
1
1,591
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MaxAbsValExpr.Code.Funs /-! # Specifications of `Aegis.MaxAbsValExpr.max_abs_val_expr` LeetCode problem `maximum-of-absolute-value-expression`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result set_option autoImplicit false namespace AegisSpec.MaxAbsValE...
11
armstrong-number
1,134
Easy
[ "Math" ]
Given an integer n, return true if and only if it is an Armstrong number. The k-digit number n is an Armstrong number if and only if the kth power of each digit sums to n.   Example 1: Input: n = 153 Output: true Explanation: 153 is a 3-digit number, and 153 = 13 + 53 + 33. Example 2: Input: n = 123 Output: false Ex...
isArmstrong(n: int) -> bool
pub fn is_armstrong(n: i64) -> bool
Aegis.IsArmstrong.is_armstrong
pub fn is_armstrong(n: i64) -> bool { let mut digits: i64 = 0; let mut temp: i64 = n; while temp > 0 { digits += 1; temp /= 10; } let mut remaining: i64 = n; let mut total: i64 = 0; while remaining > 0 { let digit: i64 = remaining % 10; let mut power: i64 =...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [is_armstrong]: type definitions module public import Aeneas @[expose] public section 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_armstrong]: function definitions module public import Aeneas public import Aegis.IsArmstrong.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.IsArmstrong.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.IsArmstrong.is_armstrong 1741725#i64) (true))}") #eval (s!"CASE 1 {(Result.reducesTo (Aegis.IsArmstrong.is_armstrong 24678050#i64) (true))}") #eval (...
[ { "input": "[1741725]", "output": "true" }, { "input": "[24678050]", "output": "true" }, { "input": "[9926315]", "output": "true" }, { "input": "[93084]", "output": "true" }, { "input": "[548834]", "output": "true" }, { "input": "[4210818]", "outpu...
56
false
56
verified
10
10
1
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.IsArmstrong.Code.Funs /-! # Specifications of `Aegis.IsArmstrong.is_armstrong` LeetCode problem `armstrong-number`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result set_option autoImplicit false namespace AegisSpec.IsArmstrong def IsArmstrong (m : Na...
6
connecting-cities-with-minimum-cost
1,135
Medium
[ "Union Find", "Graph", "Minimum Spanning Tree", "Heap (Priority Queue)" ]
There are n cities labeled from 1 to n. You are given the integer n and an array connections where connections[i] = [xi, yi, costi] indicates that the cost of connecting city xi and city yi (bidirectional connection) is costi. Return the minimum cost to connect all the n cities such that there is at least one path betw...
minimumCost(n: int, connections: list_list_int) -> int
pub fn minimum_cost(n: i64, connections: &[Vec<i64>]) -> i64
Aegis.MinimumCost.minimum_cost
pub fn minimum_cost(n: i64, connections: &[Vec<i64>]) -> i64 { if n <= 1 { return 0; } let m = connections.len(); let mut xs: Vec<i64> = Vec::new(); let mut ys: Vec<i64> = Vec::new(); let mut cs: Vec<i64> = Vec::new(); let mut i = 0usize; while i < m { xs.push(connecti...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [minimum_cost]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter.s...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [minimum_cost]: function definitions module public import Aeneas public import Aegis.MinimumCost.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option l...
import Aegis.MinimumCost.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.MinimumCost.minimum_cost 3#i64 (Slice.from [(alloc.vec.Vec.from [1#i64, 2#i64, 5#i64] (by scalar_tac) : alloc.vec.Vec Std.I64)] (by scalar_tac) : Sli...
[ { "input": "[3, [[1, 2, 5]]]", "output": "-1" }, { "input": "[4, [[1, 2, 3], [3, 4, 4]]]", "output": "-1" }, { "input": "[3, [[1, 2, 5], [1, 3, 6], [2, 3, 1]]]", "output": "6" }, { "input": "[4, [[1, 2, 10], [1, 3, 30], [2, 3, 5]]]", "output": "-1" }, { "input": "...
79
false
79
verified
10
10
1
6,243
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MinimumCost.Code.Funs /-! # Specifications of `Aegis.MinimumCost.minimum_cost` LeetCode problem `connecting-cities-with-minimum-cost`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.MinimumCost open Aegis.MinimumCost def connA (connec...
15
parallel-courses
1,136
Medium
[ "Graph", "Topological Sort" ]
You are given an integer n, which indicates that there are n courses labeled from 1 to n. You are also given an array relations where relations[i] = [prevCoursei, nextCoursei], representing a prerequisite relationship between course prevCoursei and course nextCoursei: course prevCoursei has to be taken before course ne...
minimumSemesters(n: int, relations: list_list_int) -> int
pub fn minimum_semesters(n: i64, relations: &[Vec<i64>]) -> i64
Aegis.MinimumSemesters.minimum_semesters
pub fn minimum_semesters(n: i64, relations: &[Vec<i64>]) -> i64 { let nu: usize = n as usize; let mut indeg: Vec<i64> = Vec::new(); let mut head: Vec<i64> = Vec::new(); let mut i: usize = 0; while i <= nu { indeg.push(0); head.push(-1); i += 1; } let mut to: Vec<i6...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [minimum_semesters]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option lin...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [minimum_semesters]: function definitions module public import Aeneas public import Aegis.MinimumSemesters.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.MinimumSemesters.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.MinimumSemesters.minimum_semesters 3#i64 (Slice.from [] (by scalar_tac) : Slice (alloc.vec.Vec Std.I64))) (1#i64))}") #eval (s!"CASE 1 {(Result....
[ { "input": "[3, []]", "output": "1" }, { "input": "[1, []]", "output": "1" }, { "input": "[2, [[1, 2]]]", "output": "2" }, { "input": "[2, [[2, 1]]]", "output": "2" }, { "input": "[3, [[1, 3], [2, 3]]]", "output": "2" }, { "input": "[4, [[1, 2], [3, 4]...
77
false
77
verified
10
10
1
2,583
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MinimumSemesters.Code.Funs /-! # Specifications of `Aegis.MinimumSemesters.minimum_semesters` LeetCode problem `parallel-courses`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.MinimumSemesters def vecVals (v : alloc.vec.Vec Std.I64) ...
14
n-th-tribonacci-number
1,137
Easy
[ "Memoization", "Math", "Dynamic Programming" ]
The Tribonacci sequence Tn is defined as follows:  T0 = 0, T1 = 1, T2 = 1, and Tn+3 = Tn + Tn+1 + Tn+2 for n >= 0. Given n, return the value of Tn.   Example 1: Input: n = 4 Output: 4 Explanation: T_3 = 0 + 1 + 1 = 2 T_4 = 1 + 1 + 2 = 4 Example 2: Input: n = 25 Output: 1389537   Constraints: 0 <= n <= 37 The answe...
tribonacci(n: int) -> int
pub fn tribonacci(n: i64) -> i64
Aegis.Tribonacci.tribonacci
fn trib_helper(k: i64, a: i64, b: i64, c: i64) -> i64 { if k == 0 { a } else { trib_helper(k - 1, b, c, a + b + c) } } pub fn tribonacci(n: i64) -> i64 { trib_helper(n, 0, 1, 1) }
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [tribonacci]: type definitions module public import Aeneas @[expose] public section 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 -- [tribonacci]: function definitions module public import Aeneas public import Aegis.Tribonacci.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option lint...
import Aegis.Tribonacci.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.Tribonacci.tribonacci 0#i64) (0#i64))}") #eval (s!"CASE 1 {(Result.reducesTo (Aegis.Tribonacci.tribonacci 3#i64) (2#i64))}") #eval (s!"CASE 2 {(Result...
[ { "input": "[0]", "output": "0" }, { "input": "[3]", "output": "2" }, { "input": "[4]", "output": "4" }, { "input": "[37]", "output": "2082876103" }, { "input": "[2]", "output": "1" }, { "input": "[1]", "output": "1" }, { "input": "[25]", ...
18
false
18
verified
10
10
2
1,874
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.Tribonacci.Code.Funs /-! # Specifications of `Aegis.Tribonacci.tribonacci` LeetCode problem `n-th-tribonacci-number`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.Tribonacci def trib : ℕ → ℤ | 0 => 0 | 1 => 1 | 2 => 1...
8
largest-1-bordered-square
1,139
Medium
[ "Array", "Dynamic Programming", "Matrix" ]
Given a 2D grid of 0s and 1s, return the number of elements in the largest square subgrid that has all 1s on its border, or 0 if such a subgrid doesn't exist in the grid.\r \r  \r Example 1:\r \r \r Input: grid = [[1,1,1],[1,0,1],[1,1,1]]\r Output: 9\r \r \r Example 2:\r \r \r Input: grid = [[1,1,0,0]]\r Output: 1\r \r...
largest1BorderedSquare(grid: list_list_int) -> int
pub fn largest1_bordered_square(grid: &[Vec<i64>]) -> i64
Aegis.Largest1BorderedSquare.largest1_bordered_square
pub fn largest1_bordered_square(grid: &[Vec<i64>]) -> i64 { let n = grid.len(); if n == 0 { return 0; } let m = grid[0].len(); if m == 0 { return 0; } let mut h: Vec<Vec<i64>> = Vec::new(); let mut i = 0; while i < n { let mut row: Vec<i64> = Vec::new(); ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [largest1_bordered_square]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_opt...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [largest1_bordered_square]: function definitions module public import Aeneas public import Aegis.Largest1BorderedSquare.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCom...
import Aegis.Largest1BorderedSquare.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.Largest1BorderedSquare.largest1_bordered_square (Slice.from [(alloc.vec.Vec.from [1#i64] (by scalar_tac) : alloc.vec.Vec Std.I64)] (by sca...
[ { "input": "[[[1]]]", "output": "1" }, { "input": "[[[1, 0], [0, 1]]]", "output": "1" }, { "input": "[[[1, 1, 0, 0]]]", "output": "1" }, { "input": "[[[1, 1], [1, 1]]]", "output": "4" }, { "input": "[[[1, 1, 1], [1, 0, 1], [1, 1, 1]]]", "output": "9" }, { ...
64
false
64
verified
10
10
2
5,427
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.Largest1BorderedSquare.Code.Funs /-! # Specifications of `Aegis.Largest1BorderedSquare.largest1_bordered_square` LeetCode problem `largest-1-bordered-square`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.Largest1BorderedSquare op...
12
stone-game-ii
1,140
Medium
[ "Array", "Math", "Dynamic Programming", "Game Theory", "Prefix Sum" ]
Alice and Bob continue their games with piles of stones. There are a number of piles arranged in a row, and each pile has a positive integer number of stones piles[i]. The objective of the game is to end with the most stones. Alice and Bob take turns, with Alice starting first. On each player's turn, that player can ta...
stoneGameII(piles: list_int) -> int
pub fn stone_game_ii(piles: &[i64]) -> i64
Aegis.StoneGameIi.stone_game_ii
pub fn stone_game_ii(piles: &[i64]) -> i64 { let n = piles.len(); // suffix[i] = sum of piles[i..n] let mut suffix: Vec<i64> = Vec::new(); let mut i = 0; while i <= n { suffix.push(0); i += 1; } let mut i = n; while i > 0 { i -= 1; suffix[i] = suffix[i +...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [stone_game_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 linter....
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [stone_game_ii]: function definitions module public import Aeneas public import Aegis.StoneGameIi.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.StoneGameIi.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.StoneGameIi.stone_game_ii (Slice.from [10#i64] (by scalar_tac) : Slice Std.I64)) (10#i64))}") #eval (s!"CASE 1 {(Result.reducesTo (Aegis.StoneGameIi....
[ { "input": "[[10]]", "output": "10" }, { "input": "[[1, 2, 3]]", "output": "3" }, { "input": "[[100, 100, 100, 100]]", "output": "200" }, { "input": "[[3, 6, 9, 12]]", "output": "15" }, { "input": "[[1, 100, 100, 1]]", "output": "101" }, { "input": "[[...
96
false
96
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.StoneGameIi.Code.Funs /-! # Specifications of `Aegis.StoneGameIi.stone_game_ii` LeetCode problem `stone-game-ii`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.StoneGameIi namespace AegisSpec.StoneGameIi def pvals (piles : Slice Std.I64)...
15
longest-common-subsequence
1,143
Medium
[ "String", "Dynamic Programming" ]
Given two strings text1 and text2, return the length of their longest common subsequence. If there is no common subsequence, return 0. A subsequence of a string is a new string generated from the original string with some characters (can be none) deleted without changing the relative order of the remaining characters. ...
longestCommonSubsequence(text1: str, text2: str) -> int
pub fn longest_common_subsequence(text1: &[u8], text2: &[u8]) -> i64
Aegis.LongestCommonSubsequence.longest_common_subsequence
pub fn longest_common_subsequence(text1: &[u8], text2: &[u8]) -> i64 { let n = text1.len(); let m = text2.len(); let mut dp: Vec<i64> = Vec::new(); let mut k = 0; while k <= m { dp.push(0); k += 1; } let mut i = 1; while i <= n { let mut diag = 0; let mu...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [longest_common_subsequence]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_o...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [longest_common_subsequence]: function definitions module public import Aeneas public import Aegis.LongestCommonSubsequence.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.has...
import Aegis.LongestCommonSubsequence.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.LongestCommonSubsequence.longest_common_subsequence (Slice.from [97#u8] (by scalar_tac) : Slice Std.U8) (Slice.from [98#u8] (by scalar_t...
[ { "input": "[\"a\", \"b\"]", "output": "0" }, { "input": "[\"xyz\", \"zyx\"]", "output": "1" }, { "input": "[\"ezupkr\", \"ubmrapg\"]", "output": "2" }, { "input": "[\"abcde\", \"ace\"]", "output": "3" }, { "input": "[\"abc\", \"def\"]", "output": "0" }, {...
146
false
146
verified
10
10
1
1,002
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.LongestCommonSubsequence.Code.Funs /-! # Specifications of `Aegis.LongestCommonSubsequence.longest_common_subsequence` LeetCode problem `longest-common-subsequence`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.LongestCommonSubseque...
14
decrease-elements-to-make-array-zigzag
1,144
Medium
[ "Greedy", "Array" ]
Given an array nums of integers, a move consists of choosing any element and decreasing it by 1. An array A is a zigzag array if either: Every even-indexed element is greater than adjacent elements, ie. A[0] > A[1] < A[2] > A[3] < A[4] > ... OR, every odd-indexed element is greater than adjacent elements, ie. A[0] < A...
movesToMakeZigzag(nums: list_int) -> int
pub fn moves_to_make_zigzag(nums: &[i64]) -> i64
Aegis.MovesToMakeZigzag.moves_to_make_zigzag
pub fn moves_to_make_zigzag(nums: &[i64]) -> i64 { let n = nums.len(); let mut cost_even: i64 = 0; let mut i: usize = 0; while i < n { let mut min_neighbor: i64 = 1_000_000_000; if i > 0 { let v = nums[i - 1]; if v < min_neighbor { min_neighbor =...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [moves_to_make_zigzag]: type definitions module public import Aeneas @[expose] public section 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 -- [moves_to_make_zigzag]: function definitions module public import Aeneas public import Aegis.MovesToMakeZigzag.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand fals...
import Aegis.MovesToMakeZigzag.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.MovesToMakeZigzag.moves_to_make_zigzag (Slice.from [1#i64] (by scalar_tac) : Slice Std.I64)) (0#i64))}") #eval (s!"CASE 1 {(Result.reducesTo (A...
[ { "input": "[[1]]", "output": "0" }, { "input": "[[1, 2]]", "output": "0" }, { "input": "[[1, 1, 1]]", "output": "1" }, { "input": "[[1, 2, 3]]", "output": "2" }, { "input": "[[4, 3, 2, 1]]", "output": "2" }, { "input": "[[9, 6, 1, 6, 2]]", "output...
148
false
148
verified
10
10
1
3,463
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MovesToMakeZigzag.Code.Funs /-! # Specifications of `Aegis.MovesToMakeZigzag.moves_to_make_zigzag` LeetCode problem `decrease-elements-to-make-array-zigzag`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.MovesToMakeZigzag namespace AegisSpe...
13
binary-tree-coloring-game
1,145
Medium
[ "Tree", "Depth-First Search", "Binary Tree" ]
Two players play a turn based game on a binary tree. We are given the root of this binary tree, and the number of nodes n in the tree. n is odd, and each node has a distinct value from 1 to n. Initially, the first player names a value x with 1 <= x <= n, and the second player names a value y with 1 <= y <= n and y != x...
btreeGameWinningMove(root: tree, n: int, x: int) -> bool
pub fn btree_game_winning_move(root: &Tree, n: i64, x: i64) -> bool
Aegis.BtreeGameWinningMove.btree_game_winning_move
fn size(t: &Tree) -> i64 { match t { Tree::Null => 0, Tree::Node(_, l, r) => 1 + size(l) + size(r), } } fn left_size_at(t: &Tree, x: i64) -> i64 { match t { Tree::Null => -1, Tree::Node(v, l, r) => { if *v == x { size(l) } else { ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [btree_game_winning_move]: type definitions module public import Aeneas @[expose] public 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 -- [btree_game_winning_move]: function definitions module public import Aeneas public import Aegis.BtreeGameWinningMove.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashComman...
import Aegis.BtreeGameWinningMove.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.BtreeGameWinningMove.btree_game_winning_move ((.Node 1#i64 (.Node 2#i64 (.Null) (.Null)) (.Node 3#i64 (.Null) (.Null))) : Aegis.BtreeGameWin...
[ { "input": "[[1, 2, 3], 3, 1]", "output": "false" }, { "input": "[[1, 2, 3, 4, 5], 5, 2]", "output": "false" }, { "input": "[[1, 2, 3, 4, 5, 6], 6, 4]", "output": "true" }, { "input": "[[1, 2, 3, 4, 5, 6, 7], 7, 5]", "output": "true" }, { "input": "[[4, 2, 7, 1, 3...
14
false
14
verified
10
10
1
4,327
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.BtreeGameWinningMove.Code.Funs /-! # Specifications of `Aegis.BtreeGameWinningMove.btree_game_winning_move` LeetCode problem `binary-tree-coloring-game`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.BtreeGameWinningMove namespace AegisSpec.Bt...
9
longest-chunked-palindrome-decomposition
1,147
Hard
[ "Greedy", "Two Pointers", "String", "Dynamic Programming", "Hash Function", "Rolling Hash" ]
You are given a string text. You should split it to k substrings (subtext1, subtext2, ..., subtextk) such that: subtexti is a non-empty string. The concatenation of all the substrings is equal to text (i.e., subtext1 + subtext2 + ... + subtextk == text). subtexti == subtextk - i + 1 for all valid values of i (i.e., 1 ...
longestDecomposition(text: str) -> int
pub fn longest_decomposition(text: &[u8]) -> i64
Aegis.LongestDecomposition.longest_decomposition
pub fn longest_decomposition(text: &[u8]) -> i64 { let n = text.len(); let mut left: usize = 0; let mut right: usize = n; let mut ans: i64 = 0; while left < right { let rem = right - left; let max_len = rem / 2; let mut split: usize = 0; let mut l: usize = 1; ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [longest_decomposition]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [longest_decomposition]: function definitions module public import Aeneas public import Aegis.LongestDecomposition.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand ...
import Aegis.LongestDecomposition.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.LongestDecomposition.longest_decomposition (Slice.from [97#u8, 98#u8, 99#u8, 97#u8, 98#u8, 99#u8] (by scalar_tac) : Slice Std.U8)) (2#i64))}...
[ { "input": "[\"abcabc\"]", "output": "2" }, { "input": "[\"abcabcabc\"]", "output": "3" }, { "input": "[\"level\"]", "output": "5" }, { "input": "[\"zyxzyxzyx\"]", "output": "3" }, { "input": "[\"madam\"]", "output": "5" }, { "input": "[\"aaaaa\"]", ...
181
false
181
verified
10
10
1
4,766
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.LongestDecomposition.Code.Funs /-! # Specifications of `Aegis.LongestDecomposition.longest_decomposition` LeetCode problem `longest-chunked-palindrome-decomposition`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.LongestDecomposition...
16
check-if-a-number-is-majority-element-in-a-sorted-array
1,150
Easy
[ "Array", "Binary Search" ]
Given an integer array nums sorted in non-decreasing order and an integer target, return true if target is a majority element, or false otherwise. A majority element in an array nums is an element that appears more than nums.length / 2 times in the array.   Example 1: Input: nums = [2,4,5,5,5,5,5,6,6], target = 5 Outp...
isMajorityElement(nums: list_int, target: int) -> bool
pub fn is_majority_element(nums: &[i64], target: i64) -> bool
Aegis.IsMajorityElement.is_majority_element
pub fn is_majority_element(nums: &[i64], target: i64) -> bool { let n = nums.len(); let mut count: usize = 0; let mut i: usize = 0; while i < n { if nums[i] == target { count += 1; } i += 1; } count > n / 2 }
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [is_majority_element]: type definitions module public import Aeneas @[expose] public section 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 -- [is_majority_element]: function definitions module public import Aeneas public import Aegis.IsMajorityElement.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false...
import Aegis.IsMajorityElement.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.IsMajorityElement.is_majority_element (Slice.from [10#i64, 100#i64, 101#i64, 101#i64] (by scalar_tac) : Slice Std.I64) 101#i64) (false))}") #ev...
[ { "input": "[[10, 100, 101, 101], 101]", "output": "false" }, { "input": "[[1, 2, 3, 4, 5], 3]", "output": "false" }, { "input": "[[1, 2, 2, 2, 2, 3, 3], 2]", "output": "true" }, { "input": "[[1, 1, 1, 1, 2, 2, 2, 2, 2], 1]", "output": "false" }, { "input": "[[2, ...
20
false
20
verified
10
10
1
393
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.IsMajorityElement.Code.Funs /-! # Specifications of `Aegis.IsMajorityElement.is_majority_element` LeetCode problem `check-if-a-number-is-majority-element-in-a-sorted-array`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.IsMajorityEle...
10
minimum-swaps-to-group-all-1s-together
1,151
Medium
[ "Array", "Sliding Window" ]
Given a binary array data, return the minimum number of swaps required to group all 1’s present in the array together in any place in the array.   Example 1: Input: data = [1,0,1,0,1] Output: 1 Explanation: There are 3 ways to group all 1's together: [1,1,1,0,0] using 1 swap. [0,1,1,1,0] using 2 swaps. [0,0,1,1,1] usi...
minSwaps(data: list_int) -> int
pub fn min_swaps(data: &[i64]) -> i64
Aegis.MinSwaps.min_swaps
pub fn min_swaps(data: &[i64]) -> i64 { let n = data.len(); let mut total_ones: usize = 0; let mut i: usize = 0; while i < n { if data[i] == 1 { total_ones += 1; } i += 1; } if total_ones <= 1 { return 0; } let k = total_ones; let mut c...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [min_swaps]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter.styl...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [min_swaps]: function definitions module public import Aeneas public import Aegis.MinSwaps.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter....
import Aegis.MinSwaps.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.MinSwaps.min_swaps (Slice.from [1#i64] (by scalar_tac) : Slice Std.I64)) (0#i64))}") #eval (s!"CASE 1 {(Result.reducesTo (Aegis.MinSwaps.min_swaps (Slic...
[ { "input": "[[1]]", "output": "0" }, { "input": "[[0]]", "output": "0" }, { "input": "[[0, 0, 0, 1, 0]]", "output": "0" }, { "input": "[[1, 0, 1, 0, 1]]", "output": "1" }, { "input": "[[1, 1, 1, 1, 1]]", "output": "0" }, { "input": "[[0, 0, 0, 0, 0]]",...
117
false
117
verified
10
10
1
1,448
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MinSwaps.Code.Funs /-! # Specifications of `Aegis.MinSwaps.min_swaps` LeetCode problem `minimum-swaps-to-group-all-1s-together`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.MinSwaps namespace AegisSpec.MinSwaps def IsBitList (l : List ...
12
day-of-the-year
1,154
Easy
[ "Math", "String" ]
Given a string date representing a Gregorian calendar date formatted as YYYY-MM-DD, return the day number of the year.   Example 1: Input: date = "2019-01-09" Output: 9 Explanation: Given date is the 9th day of the year in 2019. Example 2: Input: date = "2019-02-10" Output: 41   Constraints: date.length == 10 date...
dayOfYear(date: str) -> int
pub fn day_of_year(date: &[u8]) -> i64
Aegis.DayOfYear.day_of_year
fn ascii_digit(b: u8) -> i64 { if b == 48 { return 0; } if b == 49 { return 1; } if b == 50 { return 2; } if b == 51 { return 3; } if b == 52 { return 4; } if b == 53 { return 5; } if b == 54 { return 6; } ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [day_of_year]: type definitions module public import Aeneas @[expose] public section 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 -- [day_of_year]: function definitions module public import Aeneas public import Aegis.DayOfYear.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option lint...
import Aegis.DayOfYear.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.DayOfYear.day_of_year (Slice.from [50#u8, 48#u8, 49#u8, 55#u8, 45#u8, 48#u8, 51#u8, 45#u8, 48#u8, 49#u8] (by scalar_tac) : Slice Std.U8)) (60#i64))}") ...
[ { "input": "[\"2017-03-01\"]", "output": "60" }, { "input": "[\"2019-01-09\"]", "output": "9" }, { "input": "[\"1900-02-28\"]", "output": "59" }, { "input": "[\"2000-03-01\"]", "output": "61" }, { "input": "[\"2018-08-20\"]", "output": "232" }, { "inpu...
119
false
119
verified
10
10
3
17,708
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.DayOfYear.Code.Funs /-! # Specifications of `Aegis.DayOfYear.day_of_year` LeetCode problem `day-of-the-year`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.DayOfYear namespace AegisSpec.DayOfYear def byteAt (date : Slice U8) (i : ℕ) : ℕ ...
15
number-of-dice-rolls-with-target-sum
1,155
Medium
[ "Dynamic Programming" ]
You have n dice, and each dice has k faces numbered from 1 to k. Given three integers n, k, and target, return the number of possible ways (out of the kn total ways) to roll the dice, so the sum of the face-up numbers equals target. Since the answer may be too large, return it modulo 109 + 7.   Example 1: Input: n = 1...
numRollsToTarget(n: int, k: int, target: int) -> int
pub fn num_rolls_to_target(n: i64, k: i64, target: i64) -> i64
Aegis.NumRollsToTarget.num_rolls_to_target
pub fn num_rolls_to_target(n: i64, k: i64, target: i64) -> i64 { let md: i64 = 1_000_000_007; if target < n { return 0; } if target > n * k { return 0; } let t: usize = target as usize; let n_us: usize = n as usize; let k_us: usize = k as usize; let mut dp: Vec<i64...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [num_rolls_to_target]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option l...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [num_rolls_to_target]: function definitions module public import Aeneas public import Aegis.NumRollsToTarget.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false ...
import Aegis.NumRollsToTarget.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.NumRollsToTarget.num_rolls_to_target 15#i64 10#i64 100#i64) (794915145#i64))}") #eval (s!"CASE 1 {(Result.reducesTo (Aegis.NumRollsToTarget.num_...
[ { "input": "[15, 10, 100]", "output": "794915145" }, { "input": "[4, 6, 12]", "output": "125" }, { "input": "[30, 30, 500]", "output": "222616187" }, { "input": "[2, 6, 7]", "output": "6" }, { "input": "[10, 5, 30]", "output": "856945" }, { "input": "[...
108
false
108
verified
10
10
1
1,940
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.NumRollsToTarget.Code.Funs /-! # Specifications of `Aegis.NumRollsToTarget.num_rolls_to_target` LeetCode problem `number-of-dice-rolls-with-target-sum`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.NumRollsToTarget abbrev I64 : T...
13
swap-for-longest-repeated-character-substring
1,156
Medium
[ "Hash Table", "String", "Sliding Window" ]
You are given a string text. You can swap two of the characters in the text. Return the length of the longest substring with repeated characters.   Example 1: Input: text = "ababa" Output: 3 Explanation: We can swap the first 'b' with the last 'a', or the last 'b' with the first 'a'. Then, the longest repeated charact...
maxRepOpt1(text: str) -> int
pub fn max_rep_opt1(text: &[u8]) -> i64
Aegis.MaxRepOpt1.max_rep_opt1
pub fn max_rep_opt1(text: &[u8]) -> i64 { let n: usize = text.len(); if n == 0 { return 0; } let mut counts: Vec<i64> = Vec::new(); let mut k: usize = 0; while k < 26 { counts.push(0); k += 1; } let mut p: usize = 0; while p < n { let idx: usize = (t...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [max_rep_opt1]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter.s...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [max_rep_opt1]: function definitions module public import Aeneas public import Aegis.MaxRepOpt1.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option li...
import Aegis.MaxRepOpt1.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.MaxRepOpt1.max_rep_opt1 (Slice.from [97#u8, 98#u8, 97#u8, 98#u8, 97#u8, 98#u8, 97#u8, 98#u8, 97#u8, 98#u8] (by scalar_tac) : Slice Std.U8)) (3#i64))}"...
[ { "input": "[\"ababababab\"]", "output": "3" }, { "input": "[\"abababababababab\"]", "output": "3" }, { "input": "[\"ababa\"]", "output": "3" }, { "input": "[\"aaaaa\"]", "output": "5" }, { "input": "[\"zzzzzzzzzz\"]", "output": "10" }, { "input": "[\"...
56
false
56
verified
10
10
1
6,414
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MaxRepOpt1.Code.Funs /-! # Specifications of `Aegis.MaxRepOpt1.max_rep_opt1` LeetCode problem `swap-for-longest-repeated-character-substring`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.MaxRepOpt1 def bytes (text : Slice U8) : ...
13
maximum-level-sum-of-a-binary-tree
1,161
Medium
[ "Tree", "Depth-First Search", "Breadth-First Search", "Binary Tree" ]
Given the root of a binary tree, the level of its root is 1, the level of its children is 2, and so on. Return the smallest level x such that the sum of all the values of nodes at level x is maximal.   Example 1: Input: root = [1,7,0,7,-8,null,null] Output: 2 Explanation: Level 1 sum = 1. Level 2 sum = 7 + 0 = 7. Le...
maxLevelSum(root: tree) -> int
pub fn max_level_sum(root: &Tree) -> i64
Aegis.MaxLevelSum.max_level_sum
pub fn max_level_sum(root: &Tree) -> i64 { let h = tree_height(root); if h == 0 { return 0; } let mut sums: Vec<i64> = Vec::new(); let mut i: usize = 0; while i < h { sums.push(0); i += 1; } let sums = fill_level_sums(root, 1, sums); let mut best_sum: i64 =...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [max_level_sum]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter....
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [max_level_sum]: function definitions module public import Aeneas public import Aegis.MaxLevelSum.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.MaxLevelSum.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.MaxLevelSum.max_level_sum ((.Node 5#i64 (.Null) (.Null)) : Aegis.MaxLevelSum.Tree)) (1#i64))}") #eval (s!"CASE 1 {(Result.reducesTo (Aegis.MaxLevelSu...
[ { "input": "[[5]]", "output": "1" }, { "input": "[[1]]", "output": "1" }, { "input": "[[5, 2, -3]]", "output": "1" }, { "input": "[[1, 2, 3, 4, 5, 6, 7]]", "output": "3" }, { "input": "[[1, -1, 2, -2, 3, -3, 4]]", "output": "3" }, { "input": "[[-10, -2...
38
false
38
verified
10
10
1
10,466
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MaxLevelSum.Code.Funs /-! # Specifications of `Aegis.MaxLevelSum.max_level_sum` LeetCode problem `maximum-level-sum-of-a-binary-tree`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.MaxLevelSum open Aegis.MaxLevelSum def nodeCou...
11
as-far-from-land-as-possible
1,162
Medium
[ "Breadth-First Search", "Array", "Dynamic Programming", "Matrix" ]
Given an n x n grid containing only values 0 and 1, where 0 represents water and 1 represents land, find a water cell such that its distance to the nearest land cell is maximized, and return the distance. If no land or water exists in the grid, return -1. The distance used in this problem is the Manhattan distance: the...
maxDistance(grid: list_list_int) -> int
pub fn max_distance(grid: &[Vec<i64>]) -> i64
Aegis.MaxDistance.max_distance
pub fn max_distance(grid: &[Vec<i64>]) -> i64 { let n = grid.len(); if n == 0 { return -1; } let mut visited: Vec<bool> = Vec::new(); let mut queue: Vec<i64> = Vec::new(); let mut land_count: i64 = 0; let mut water_count: i64 = 0; let mut i: usize = 0; while i < n { ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [max_distance]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter.s...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [max_distance]: function definitions module public import Aeneas public import Aegis.MaxDistance.Code.Types @[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.MaxDistance.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.MaxDistance.max_distance (Slice.from [(alloc.vec.Vec.from [1#i64, 1#i64, 1#i64] (by scalar_tac) : alloc.vec.Vec Std.I64), (alloc.vec.Vec.from [1#i64,...
[ { "input": "[[[1, 1, 1], [1, 1, 1], [1, 1, 1]]]", "output": "-1" }, { "input": "[[[1, 0, 0], [0, 0, 0], [0, 0, 0]]]", "output": "4" }, { "input": "[[[0, 0, 0], [0, 0, 0], [0, 0, 0]]]", "output": "-1" }, { "input": "[[[1, 0, 1], [0, 0, 0], [1, 0, 1]]]", "output": "2" }, ...
62
false
62
verified
10
10
1
3,900
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MaxDistance.Code.Funs /-! # Specifications of `Aegis.MaxDistance.max_distance` LeetCode problem `as-far-from-land-as-possible`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.MaxDistance abbrev Grid := Aeneas.Std.Slice (Aeneas.Std.allo...
11
minimum-cost-to-connect-sticks
1,167
Medium
[ "Greedy", "Array", "Heap (Priority Queue)" ]
You have some number of sticks with positive integer lengths. These lengths are given as an array sticks, where sticks[i] is the length of the ith stick. You can connect any two sticks of lengths x and y into one stick by paying a cost of x + y. You must connect all the sticks until there is only one stick remaining. R...
connectSticks(sticks: list_int) -> int
pub fn connect_sticks(sticks: &[i64]) -> i64
Aegis.ConnectSticks.connect_sticks
pub fn connect_sticks(sticks: &[i64]) -> i64 { let n = sticks.len(); if n <= 1 { return 0; } let mut heap: Vec<i64> = Vec::new(); let mut k: usize = 0; while k < n { heap.push(sticks[k]); k += 1; } // Build a min-heap in place. let mut start: usize = n / 2; ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [connect_sticks]: type definitions module public import Aeneas @[expose] public section 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 -- [connect_sticks]: function definitions module public import Aeneas public import Aegis.ConnectSticks.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.ConnectSticks.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.ConnectSticks.connect_sticks (Slice.from [5#i64] (by scalar_tac) : Slice Std.I64)) (0#i64))}") #eval (s!"CASE 1 {(Result.reducesTo (Aegis.ConnectSt...
[ { "input": "[[5]]", "output": "0" }, { "input": "[[1]]", "output": "0" }, { "input": "[[1, 2147483647]]", "output": "2147483648" }, { "input": "[[100, 200, 300]]", "output": "900" }, { "input": "[[2, 4, 3]]", "output": "14" }, { "input": "[[1, 8, 3, 5]...
84
false
84
verified
10
10
1
11,701
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.ConnectSticks.Code.Funs /-! # Specifications of `Aegis.ConnectSticks.connect_sticks` LeetCode problem `minimum-cost-to-connect-sticks`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.ConnectSticks namespace AegisSpec.ConnectSticks def contents ...
13
optimize-water-distribution-in-a-village
1,168
Hard
[ "Union Find", "Graph", "Minimum Spanning Tree", "Heap (Priority Queue)" ]
There are n houses in a village. We want to supply water for all the houses by building wells and laying pipes. For each house i, we can either build a well inside it directly with cost wells[i - 1] (note the -1 due to 0-indexing), or pipe in water from another well to it. The costs to lay pipes between houses are give...
minCostToSupplyWater(n: int, wells: list_int, pipes: list_list_int) -> int
pub fn min_cost_to_supply_water(n: i64, wells: &[i64], pipes: &[Vec<i64>]) -> i64
Aegis.MinCostToSupplyWater.min_cost_to_supply_water
pub fn min_cost_to_supply_water(n: i64, wells: &[i64], pipes: &[Vec<i64>]) -> i64 { let base: i64 = 100000; let base2: i64 = base * base; let mut edges: Vec<i64> = Vec::new(); let mut max_cost: i64 = 0; let mut i: i64 = 1; while i <= n { let cost = wells[(i - 1) as usize]; let ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [min_cost_to_supply_water]: type definitions module public import Aeneas @[expose] public 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_cost_to_supply_water]: function definitions module public import Aeneas public import Aegis.MinCostToSupplyWater.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashComma...
import Aegis.MinCostToSupplyWater.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.MinCostToSupplyWater.min_cost_to_supply_water 2#i64 (Slice.from [1#i64, 1#i64] (by scalar_tac) : Slice Std.I64) (Slice.from [(alloc.vec.Vec....
[ { "input": "[2, [1, 1], [[1, 2, 1], [1, 2, 2]]]", "output": "2" }, { "input": "[3, [1, 2, 2], [[1, 2, 1], [2, 3, 1]]]", "output": "3" }, { "input": "[3, [10, 20, 30], [[1, 2, 15], [2, 3, 25], [1, 3, 30]]]", "output": "50" }, { "input": "[4, [4, 3, 2, 1], [[1, 2, 3], [3, 4, 2]...
74
false
74
verified
10
10
1
7,032
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MinCostToSupplyWater.Code.Funs /-! # Specifications of `Aegis.MinCostToSupplyWater.min_cost_to_supply_water` LeetCode problem `optimize-water-distribution-in-a-village`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.MinCostToSupplyWate...
14
invalid-transactions
1,169
Medium
[ "Array", "Hash Table", "String", "Sorting" ]
A transaction is possibly invalid if: the amount exceeds $1000, or; if it occurs within (and including) 60 minutes of another transaction with the same name in a different city. You are given an array of strings transaction where transactions[i] consists of comma-separated values representing the name, time (in minut...
invalidTransactions(transactions: list_str) -> list_str
pub fn invalid_transactions(transactions: &[Vec<u8>]) -> Vec<Vec<u8>>
Aegis.InvalidTransactions.invalid_transactions
pub fn invalid_transactions(transactions: &[Vec<u8>]) -> Vec<Vec<u8>> { let n = transactions.len(); let mut out: Vec<Vec<u8>> = Vec::new(); let mut i: usize = 0; while i < n { let len_i = transactions[i].len(); let mut c1: usize = 0; while c1 < len_i && transactions[i][c1] != b...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [invalid_transactions]: type definitions module public import Aeneas @[expose] public section 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 -- [invalid_transactions]: function definitions module public import Aeneas public import Aegis.InvalidTransactions.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand fa...
import Aegis.InvalidTransactions.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(match (Aegis.InvalidTransactions.invalid_transactions (Slice.from [(alloc.vec.Vec.from [97#u8, 108#u8, 105#u8, 99#u8, 101#u8, 44#u8, 50#u8, 48#u8, 44#u8, 56#u8, 48#u...
[ { "input": "[[\"alice,20,800,mtv\", \"alice,50,1200,mtv\"]]", "output": "[\"alice,50,1200,mtv\"]" }, { "input": "[[\"alice,20,800,mtv\", \"alice,50,100,mtv\", \"alice,61,100,mtv\"]]", "output": "[]" }, { "input": "[[\"alice,20,800,mtv\", \"bob,50,1200,mtv\"]]", "output": "[\"bob,50,1...
78
true
78
verified
10
10
1
6,977
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.InvalidTransactions.Code.Funs /-! # Specifications of `Aegis.InvalidTransactions.invalid_transactions` LeetCode problem `invalid-transactions`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.InvalidTransactions abbrev Byte : Type := Ae...
7
prime-arrangements
1,175
Easy
[ "Math" ]
Return the number of permutations of 1 to n so that prime numbers are at prime indices (1-indexed.) (Recall that an integer is prime if and only if it is greater than 1, and cannot be written as a product of two positive integers both smaller than it.) Since the answer may be large, return the answer modulo 10^9 + 7.  ...
numPrimeArrangements(n: int) -> int
pub fn num_prime_arrangements(n: i64) -> i64
Aegis.NumPrimeArrangements.num_prime_arrangements
pub fn num_prime_arrangements(n: i64) -> i64 { let mut prime_count: i64 = 0; let mut i: i64 = 2; while i <= n { let mut is_prime: bool = true; let mut d: i64 = 2; while d * d <= i { if i % d == 0 { is_prime = false; break; } ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [num_prime_arrangements]: type definitions module public import Aeneas @[expose] public 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_prime_arrangements]: function definitions module public import Aeneas public import Aegis.NumPrimeArrangements.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand...
import Aegis.NumPrimeArrangements.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.NumPrimeArrangements.num_prime_arrangements 30#i64) (13697484#i64))}") #eval (s!"CASE 1 {(Result.reducesTo (Aegis.NumPrimeArrangements.num_p...
[ { "input": "[30]", "output": "13697484" }, { "input": "[99]", "output": "75763854" }, { "input": "[75]", "output": "918450925" }, { "input": "[20]", "output": "344376809" }, { "input": "[2]", "output": "1" }, { "input": "[19]", "output": "445364737...
27
false
27
verified
10
10
1
844
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.NumPrimeArrangements.Code.Funs /-! # Specifications of `Aegis.NumPrimeArrangements.num_prime_arrangements` LeetCode problem `prime-arrangements`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.NumPrimeArrangements def M : Int := 100000...
11
diet-plan-performance
1,176
Easy
[ "Array", "Sliding Window" ]
A dieter consumes calories[i] calories on the i-th day.  Given an integer k, for every consecutive sequence of k days (calories[i], calories[i+1], ..., calories[i+k-1] for all 0 <= i <= n-k), they look at T, the total calories consumed during that sequence of k days (calories[i] + calories[i+1] + ... + calories[i+k-1])...
dietPlanPerformance(calories: list_int, k: int, lower: int, upper: int) -> int
pub fn diet_plan_performance(calories: &[i64], k: i64, lower: i64, upper: i64) -> i64
Aegis.DietPlanPerformance.diet_plan_performance
pub fn diet_plan_performance(calories: &[i64], k: i64, lower: i64, upper: i64) -> i64 { let n = calories.len(); let kk = k as usize; let mut sum: i64 = 0; let mut i: usize = 0; while i < kk { sum += calories[i]; i += 1; } let mut points: i64 = 0; if sum < lower { ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [diet_plan_performance]: type definitions module public import Aeneas @[expose] public section 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 -- [diet_plan_performance]: function definitions module public import Aeneas public import Aegis.DietPlanPerformance.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand f...
import Aegis.DietPlanPerformance.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.DietPlanPerformance.diet_plan_performance (Slice.from [3#i64, 2#i64] (by scalar_tac) : Slice Std.I64) 2#i64 0#i64 1#i64) (1#i64))}") #eval (s...
[ { "input": "[[3, 2], 2, 0, 1]", "output": "1" }, { "input": "[[6, 5, 0, 0], 2, 1, 5]", "output": "0" }, { "input": "[[5000, 5000, 5000, 5000, 5000], 5, 20000, 25000]", "output": "0" }, { "input": "[[1, 2, 3, 4, 5], 1, 3, 3]", "output": "0" }, { "input": "[[10000, ...
90
false
90
verified
10
10
1
630
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.DietPlanPerformance.Code.Funs /-! # Specifications of `Aegis.DietPlanPerformance.diet_plan_performance` LeetCode problem `diet-plan-performance`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.DietPlanPerformance namespace AegisSpec.DietPlanPerf...
14
can-make-palindrome-from-substring
1,177
Medium
[ "Bit Manipulation", "Array", "Hash Table", "String", "Prefix Sum" ]
You are given a string s and array queries where queries[i] = [lefti, righti, ki]. We may rearrange the substring s[lefti...righti] for each query and then choose up to ki of them to replace with any lowercase English letter. If the substring is possible to be a palindrome string after the operations above, the result ...
canMakePaliQueries(s: str, queries: list_list_int) -> list_bool
pub fn can_make_pali_queries(s: &[u8], queries: &[Vec<i64>]) -> Vec<bool>
Aegis.CanMakePaliQueries.can_make_pali_queries
pub fn can_make_pali_queries(s: &[u8], queries: &[Vec<i64>]) -> Vec<bool> { let n = s.len(); let mut pref: Vec<Vec<i64>> = Vec::new(); let mut initial: Vec<i64> = Vec::new(); let mut c = 0usize; while c < 26 { initial.push(0i64); c += 1; } pref.push(initial); let mut i ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [can_make_pali_queries]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [can_make_pali_queries]: function definitions module public import Aeneas public import Aegis.CanMakePaliQueries.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand fa...
import Aegis.CanMakePaliQueries.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.CanMakePaliQueries.can_make_pali_queries (Slice.from [97#u8, 98#u8, 99#u8, 100#u8] (by scalar_tac) : Slice Std.U8) (Slice.from [(alloc.vec.Vec...
[ { "input": "[\"abcd\", [[0, 2, 1], [1, 3, 1]]]", "output": "[true, true]" }, { "input": "[\"aaaa\", [[0, 3, 0], [1, 2, 0]]]", "output": "[true, true]" }, { "input": "[\"aabbc\", [[0, 4, 2], [1, 3, 1]]]", "output": "[true, true]" }, { "input": "[\"aabbc\", [[0, 4, 1], [1, 3, 0...
93
false
93
verified
10
10
1
2,777
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.CanMakePaliQueries.Code.Funs /-! # Specifications of `Aegis.CanMakePaliQueries.can_make_pali_queries` LeetCode problem `can-make-palindrome-from-substring`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.CanMakePaliQueries open Aeg...
10
number-of-valid-words-for-each-puzzle
1,178
Hard
[ "Bit Manipulation", "Trie", "Array", "Hash Table", "String" ]
With respect to a given puzzle string, a word is valid if both the following conditions are satisfied: word contains the first letter of puzzle. For each letter in word, that letter is in puzzle. For example, if the puzzle is "abcdefg", then valid words are "faced", "cabbage", and "baggage", while invalid words are ...
findNumOfValidWords(words: list_str, puzzles: list_str) -> list_int
pub fn find_num_of_valid_words(words: &[Vec<u8>], puzzles: &[Vec<u8>]) -> Vec<i64>
Aegis.FindNumOfValidWords.find_num_of_valid_words
fn sort_i64s(v: Vec<i64>) -> Vec<i64> { let n = v.len(); if n <= 1 { return v; } let mut src = v; let mut dst: Vec<i64> = Vec::new(); let mut z: usize = 0; while z < n { dst.push(0); z += 1; } let mut width: usize = 1; while width < n { let mut l...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [find_num_of_valid_words]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_opti...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [find_num_of_valid_words]: function definitions module public import Aeneas public import Aegis.FindNumOfValidWords.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand...
import Aegis.FindNumOfValidWords.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.FindNumOfValidWords.find_num_of_valid_words (Slice.from [(alloc.vec.Vec.from [97#u8, 98#u8, 99#u8, 100#u8, 101#u8, 102#u8, 103#u8] (by scalar...
[ { "input": "[[\"abcdefg\"], [\"abcdefg\"]]", "output": "[1]" }, { "input": "[[\"hello\", \"world\"], [\"ehlol\", \"dlrow\"]]", "output": "[1, 1]" }, { "input": "[[\"zzzz\", \"zzz\", \"zz\", \"z\"], [\"zabcdefghijklmnopqrstuvwxy\"]]", "output": "[4]" }, { "input": "[[\"abcdefg...
68
false
68
verified
10
10
1
19,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.FindNumOfValidWords.Code.Funs /-! # Specifications of `Aegis.FindNumOfValidWords.find_num_of_valid_words` LeetCode problem `number-of-valid-words-for-each-puzzle`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.FindNumOfValidWords ...
17
count-substrings-with-only-one-distinct-letter
1,180
Easy
[ "Math", "String" ]
Given a string s, return the number of substrings that have only one distinct letter.   Example 1: Input: s = "aaaba" Output: 8 Explanation: The substrings with one distinct letter are "aaa", "aa", "a", "b". "aaa" occurs 1 time. "aa" occurs 2 times. "a" occurs 4 times. "b" occurs 1 time. So the answer is 1 + 2 + 4 + 1...
countLetters(s: str) -> int
pub fn count_letters(s: &[u8]) -> i64
Aegis.CountLetters.count_letters
pub fn count_letters(s: &[u8]) -> i64 { let n = s.len(); let mut total: i64 = 0; let mut i: usize = 0; while i < n { let c = s[i]; let mut j: usize = i + 1; while j < n && s[j] == c { j += 1; } let len: i64 = (j - i) as i64; total += len * (...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [count_letters]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter....
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [count_letters]: function definitions module public import Aeneas public import Aegis.CountLetters.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.CountLetters.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.CountLetters.count_letters (Slice.from [97#u8, 97#u8, 98#u8, 98#u8, 99#u8, 99#u8] (by scalar_tac) : Slice Std.U8)) (9#i64))}") #eval (s!"CASE 1 {(Re...
[ { "input": "[\"aabbcc\"]", "output": "9" }, { "input": "[\"bbccdd\"]", "output": "9" }, { "input": "[\"zzzzz\"]", "output": "15" }, { "input": "[\"aaaba\"]", "output": "8" }, { "input": "[\"abcdabcdabcd\"]", "output": "12" }, { "input": "[\"ababab\"]",...
57
false
57
verified
10
10
1
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.CountLetters.Code.Funs /-! # Specifications of `Aegis.CountLetters.count_letters` LeetCode problem `count-substrings-with-only-one-distinct-letter`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.CountLetters def IsLowerByte (b : U8) :...
12
before-and-after-puzzle
1,181
Medium
[ "Array", "Hash Table", "String", "Sorting" ]
Given a list of phrases, generate a list of Before and After puzzles. A phrase is a string that consists of lowercase English letters and spaces only. No space appears in the start or the end of a phrase. There are no consecutive spaces in a phrase. Before and After puzzles are phrases that are formed by merging two ph...
beforeAndAfterPuzzles(phrases: list_str) -> list_str
pub fn before_and_after_puzzles(phrases: &[Vec<u8>]) -> Vec<Vec<u8>>
Aegis.BeforeAndAfterPuzzles.before_and_after_puzzles
fn bytes_eq(a: &Vec<u8>, b: &Vec<u8>) -> bool { if a.len() != b.len() { return false; } let mut i = 0; while i < a.len() { if a[i] != b[i] { return false; } i += 1; } true } fn bytes_less(a: &Vec<u8>, b: &Vec<u8>) -> bool { let mut i = 0; whil...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [before_and_after_puzzles]: type definitions module public import Aeneas @[expose] public 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 -- [before_and_after_puzzles]: function definitions module public import Aeneas public import Aegis.BeforeAndAfterPuzzles.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashComm...
import Aegis.BeforeAndAfterPuzzles.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.BeforeAndAfterPuzzles.before_and_after_puzzles (Slice.from [(alloc.vec.Vec.from [119#u8, 114#u8, 105#u8, 116#u8, 105#u8, 110#u8, 103#u8, 32...
[ { "input": "[[\"writing code\", \"code rocks\"]]", "output": "[\"writing code rocks\"]" }, { "input": "[[\"a\", \"b\", \"a\"]]", "output": "[\"a\"]" }, { "input": "[[\"the quick brown fox\", \"fox jumps over\", \"over the lazy dog\", \"dog chased the\", \"the quick brown fox jumps\"]]", ...
66
false
66
verified
10
10
1
7,235
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.BeforeAndAfterPuzzles.Code.Funs /-! # Specifications of `Aegis.BeforeAndAfterPuzzles.before_and_after_puzzles` LeetCode problem `before-and-after-puzzle`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.BeforeAndAfterPuzzles open Aegis....
14
shortest-distance-to-target-color
1,182
Medium
[ "Array", "Binary Search", "Dynamic Programming" ]
You are given an array colors, in which there are three colors: 1, 2 and 3. You are also given some queries. Each query consists of two integers i and c, return the shortest distance between the given index i and the target color c. If there is no solution return -1.   Example 1: Input: colors = [1,1,2,1,3,2,2,3,3], q...
shortestDistanceColor(colors: list_int, queries: list_list_int) -> list_int
pub fn shortest_distance_color(colors: &[i64], queries: &[Vec<i64>]) -> Vec<i64>
Aegis.ShortestDistanceColor.shortest_distance_color
pub fn shortest_distance_color(colors: &[i64], queries: &[Vec<i64>]) -> Vec<i64> { let n: usize = colors.len(); let mut dist: Vec<i64> = Vec::new(); let total: usize = n * 3; let mut t: usize = 0; while t < total { dist.push(-1); t += 1; } let mut ci: usize = 0; while c...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [shortest_distance_color]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_opti...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [shortest_distance_color]: function definitions module public import Aeneas public import Aegis.ShortestDistanceColor.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashComma...
import Aegis.ShortestDistanceColor.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.ShortestDistanceColor.shortest_distance_color (Slice.from [1#i64, 2#i64] (by scalar_tac) : Slice Std.I64) (Slice.from [(alloc.vec.Vec.from ...
[ { "input": "[[1, 2], [[0, 3]]]", "output": "[-1]" }, { "input": "[[3, 3, 3, 3, 3], [[0, 1], [1, 2], [2, 3]]]", "output": "[-1, -1, 0]" }, { "input": "[[1, 1, 1, 1, 1], [[2, 2], [3, 3], [4, 1]]]", "output": "[-1, -1, 0]" }, { "input": "[[1, 1, 1, 1, 1], [[0, 1], [1, 2], [2, 3]...
89
false
89
verified
10
10
1
2,921
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.ShortestDistanceColor.Code.Funs /-! # Specifications of `Aegis.ShortestDistanceColor.shortest_distance_color` LeetCode problem `shortest-distance-to-target-color`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.ShortestDistanceColor op...
10
maximum-number-of-ones
1,183
Hard
[ "Greedy", "Math", "Sorting", "Heap (Priority Queue)" ]
Consider a matrix M with dimensions width * height, such that every cell has value 0 or 1, and any square sub-matrix of M of size sideLength * sideLength has at most maxOnes ones. Return the maximum possible number of ones that the matrix M can have.   Example 1: Input: width = 3, height = 3, sideLength = 2, maxOnes =...
maximumNumberOfOnes(width: int, height: int, sideLength: int, maxOnes: int) -> int
pub fn maximum_number_of_ones(width: i64, height: i64, sideLength: i64, maxOnes: i64) -> i64
Aegis.MaximumNumberOfOnes.maximum_number_of_ones
pub fn maximum_number_of_ones(width: i64, height: i64, sideLength: i64, maxOnes: i64) -> i64 { let s: usize = sideLength as usize; let mut counts: Vec<i64> = Vec::new(); let mut i: usize = 0; while i < s { let row_count: i64 = (height - (i as i64) + sideLength - 1) / sideLength; let mu...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [maximum_number_of_ones]: type definitions module public import Aeneas @[expose] public 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 -- [maximum_number_of_ones]: function definitions module public import Aeneas public import Aegis.MaximumNumberOfOnes.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand ...
import Aegis.MaximumNumberOfOnes.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.MaximumNumberOfOnes.maximum_number_of_ones 4#i64 4#i64 3#i64 2#i64) (6#i64))}") #eval (s!"CASE 1 {(Result.reducesTo (Aegis.MaximumNumberOfOne...
[ { "input": "[4, 4, 3, 2]", "output": "6" }, { "input": "[6, 6, 3, 3]", "output": "12" }, { "input": "[10, 10, 5, 6]", "output": "24" }, { "input": "[5, 5, 3, 3]", "output": "12" }, { "input": "[4, 4, 2, 3]", "output": "12" }, { "input": "[3, 3, 2, 1]",...
110
false
110
verified
10
10
1
2,527
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MaximumNumberOfOnes.Code.Funs /-! # Specifications of `Aegis.MaximumNumberOfOnes.maximum_number_of_ones` LeetCode problem `maximum-number-of-ones`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.MaximumNumberOfOnes namespace AegisSpec.Maximu...
15
distance-between-bus-stops
1,184
Easy
[ "Array" ]
A bus has n stops numbered from 0 to n - 1 that form a circle. We know the distance between all pairs of neighboring stops where distance[i] is the distance between the stops number i and (i + 1) % n.\r \r The bus goes along both directions i.e. clockwise and counterclockwise.\r \r Return the shortest distance between ...
distanceBetweenBusStops(distance: list_int, start: int, destination: int) -> int
pub fn distance_between_bus_stops(distance: &[i64], start: i64, destination: i64) -> i64
Aegis.DistanceBetweenBusStops.distance_between_bus_stops
pub fn distance_between_bus_stops(distance: &[i64], start: i64, destination: i64) -> i64 { let n = distance.len(); let s = start as usize; let d = destination as usize; let mut total: i64 = 0; let mut i = 0; while i < n { total += distance[i]; i += 1; } let mut lo = s; ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [distance_between_bus_stops]: type definitions module public import Aeneas @[expose] public 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 -- [distance_between_bus_stops]: function definitions module public import Aeneas public import Aegis.DistanceBetweenBusStops.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hash...
import Aegis.DistanceBetweenBusStops.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.DistanceBetweenBusStops.distance_between_bus_stops (Slice.from [4#i64, 3#i64, 2#i64] (by scalar_tac) : Slice Std.I64) 0#i64 2#i64) (2#i64...
[ { "input": "[[4, 3, 2], 0, 2]", "output": "2" }, { "input": "[[1, 2, 3, 4], 0, 2]", "output": "3" }, { "input": "[[1, 2, 3, 4], 0, 1]", "output": "1" }, { "input": "[[1, 2, 3, 4], 0, 3]", "output": "4" }, { "input": "[[3, 4, 5, 1, 2], 2, 1]", "output": "4" }...
68
false
68
verified
10
10
1
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.DistanceBetweenBusStops.Code.Funs /-! # Specifications of `Aegis.DistanceBetweenBusStops.distance_between_bus_stops` LeetCode problem `distance-between-bus-stops`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.DistanceBetweenBusStops ...
11
maximum-subarray-sum-with-one-deletion
1,186
Medium
[ "Array", "Dynamic Programming" ]
Given an array of integers, return the maximum sum for a non-empty subarray (contiguous elements) with at most one element deletion. In other words, you want to choose a subarray and optionally delete one element from it so that there is still at least one element left and the sum of the remaining elements is maximum p...
maximumSum(arr: list_int) -> int
pub fn maximum_sum(arr: &[i64]) -> i64
Aegis.MaximumSum.maximum_sum
pub fn maximum_sum(arr: &[i64]) -> i64 { let n = arr.len(); if n == 0 { return 0; } let neg_inf: i64 = -1000000000000000000; // Maximum sum of a non-empty subarray ending at the current position // without using the deletion. let mut keep: i64 = arr[0]; // Maximum sum of a non...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [maximum_sum]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter.st...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [maximum_sum]: function definitions module public import Aeneas public import Aegis.MaximumSum.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option lin...
import Aegis.MaximumSum.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.MaximumSum.maximum_sum (Slice.from [(-10000)#i64] (by scalar_tac) : Slice Std.I64)) ((-10000)#i64))}") #eval (s!"CASE 1 {(Result.reducesTo (Aegis.Maxi...
[ { "input": "[[-10000]]", "output": "-10000" }, { "input": "[[1]]", "output": "1" }, { "input": "[[-10000, 10000]]", "output": "10000" }, { "input": "[[5, -1, 5]]", "output": "10" }, { "input": "[[1, -2, 0, 3]]", "output": "4" }, { "input": "[[-1, -1, -...
139
false
139
verified
10
10
1
2,396
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MaximumSum.Code.Funs /-! # Specifications of `Aegis.MaximumSum.maximum_sum` LeetCode problem `maximum-subarray-sum-with-one-deletion`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.MaximumSum def vals (arr : Slice Std.I64) : List Int ...
14
make-array-strictly-increasing
1,187
Hard
[ "Array", "Binary Search", "Dynamic Programming", "Sorting" ]
Given two integer arrays arr1 and arr2, return the minimum number of operations (possibly zero) needed to make arr1 strictly increasing. In one operation, you can choose two indices 0 <= i < arr1.length and 0 <= j < arr2.length and do the assignment arr1[i] = arr2[j]. If there is no way to make arr1 strictly increasing...
makeArrayIncreasing(arr1: list_int, arr2: list_int) -> int
pub fn make_array_increasing(arr1: &[i64], arr2: &[i64]) -> i64
Aegis.MakeArrayIncreasing.make_array_increasing
pub fn make_array_increasing(arr1: &[i64], arr2: &[i64]) -> i64 { let n = arr1.len(); let m0 = arr2.len(); let mut sorted: Vec<i64> = Vec::new(); let mut idx: usize = 0; while idx < m0 { sorted.push(arr2[idx]); idx += 1; } let mut pos: usize = 1; while pos < sorted.len(...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [make_array_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_option...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [make_array_increasing]: function definitions module public import Aeneas public import Aegis.MakeArrayIncreasing.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand f...
import Aegis.MakeArrayIncreasing.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.MakeArrayIncreasing.make_array_increasing (Slice.from [1#i64] (by scalar_tac) : Slice Std.I64) (Slice.from [2#i64] (by scalar_tac) : Slice St...
[ { "input": "[[1], [2]]", "output": "0" }, { "input": "[[1, 2000], [1000]]", "output": "0" }, { "input": "[[10, 11, 12], [5, 6, 7]]", "output": "0" }, { "input": "[[1, 1, 1], [2, 2, 2]]", "output": "-1" }, { "input": "[[1, 2, 3], [1, 2, 3]]", "output": "0" },...
145
false
145
verified
10
10
1
10,369
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MakeArrayIncreasing.Code.Funs /-! # Specifications of `Aegis.MakeArrayIncreasing.make_array_increasing` LeetCode problem `make-array-strictly-increasing`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.MakeArrayIncreasing def vals (s :...
11
maximum-number-of-balloons
1,189
Easy
[ "Hash Table", "String", "Counting" ]
Given a string text, you want to use the characters of text to form as many instances of the word "balloon" as possible. You can use each character in text at most once. Return the maximum number of instances that can be formed.   Example 1: Input: text = "nlaebolko" Output: 1 Example 2: Input: text = "loonbalxbal...
maxNumberOfBalloons(text: str) -> int
pub fn max_number_of_balloons(text: &[u8]) -> i64
Aegis.MaxNumberOfBalloons.max_number_of_balloons
pub fn max_number_of_balloons(text: &[u8]) -> i64 { let mut count_b: i64 = 0; let mut count_a: i64 = 0; let mut count_l: i64 = 0; let mut count_o: i64 = 0; let mut count_n: i64 = 0; let mut i: usize = 0; while i < text.len() { let c = text[i]; if c == b'b' { coun...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [max_number_of_balloons]: type definitions module public import Aeneas @[expose] public 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 -- [max_number_of_balloons]: function definitions module public import Aeneas public import Aegis.MaxNumberOfBalloons.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand ...
import Aegis.MaxNumberOfBalloons.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.MaxNumberOfBalloons.max_number_of_balloons (Slice.from [] (by scalar_tac) : Slice Std.U8)) (0#i64))}") #eval (s!"CASE 1 {(Result.reducesTo (A...
[ { "input": "[\"\"]", "output": "0" }, { "input": "[\"bbaalllooonn\"]", "output": "1" }, { "input": "[\"ppooaallbboonn\"]", "output": "1" }, { "input": "[\"leetcode\"]", "output": "0" }, { "input": "[\"balloonballoonballoonballoonballoon\"]", "output": "5" },...
117
false
117
verified
10
10
1
680
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MaxNumberOfBalloons.Code.Funs /-! # Specifications of `Aegis.MaxNumberOfBalloons.max_number_of_balloons` LeetCode problem `maximum-number-of-balloons`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.MaxNumberOfBalloons open Aegis.M...
12
k-concatenation-maximum-sum
1,191
Medium
[ "Array", "Dynamic Programming" ]
Given an integer array arr and an integer k, modify the array by repeating it k times. For example, if arr = [1, 2] and k = 3 then the modified array will be [1, 2, 1, 2, 1, 2]. Return the maximum sub-array sum in the modified array. Note that the length of the sub-array can be 0 and its sum in that case is 0. As the a...
kConcatenationMaxSum(arr: list_int, k: int) -> int
pub fn k_concatenation_max_sum(arr: &[i64], k: i64) -> i64
Aegis.KConcatenationMaxSum.k_concatenation_max_sum
pub fn k_concatenation_max_sum(arr: &[i64], k: i64) -> i64 { const MOD: i64 = 1_000_000_007; let n = arr.len(); let mut total: i64 = 0; let mut i: usize = 0; while i < n { total += arr[i]; i += 1; } let mut prefix: i64 = 0; let mut running: i64 = 0; i = 0; whil...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [k_concatenation_max_sum]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_opti...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [k_concatenation_max_sum]: function definitions module public import Aeneas public import Aegis.KConcatenationMaxSum.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashComman...
import Aegis.KConcatenationMaxSum.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.KConcatenationMaxSum.k_concatenation_max_sum (Slice.from [1#i64] (by scalar_tac) : Slice Std.I64) 1#i64) (1#i64))}") #eval (s!"CASE 1 {(Resu...
[ { "input": "[[1], 1]", "output": "1" }, { "input": "[[-1], 1]", "output": "0" }, { "input": "[[5], 1]", "output": "5" }, { "input": "[[5], 10]", "output": "50" }, { "input": "[[-5], 1]", "output": "0" }, { "input": "[[10000, -10000], 2]", "output":...
106
false
106
verified
10
10
1
4,564
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.KConcatenationMaxSum.Code.Funs /-! # Specifications of `Aegis.KConcatenationMaxSum.k_concatenation_max_sum` LeetCode problem `k-concatenation-maximum-sum`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.KConcatenationMaxSum open Ae...
10
how-many-apples-can-you-put-into-the-basket
1,196
Easy
[ "Greedy", "Array", "Sorting" ]
You have some apples and a basket that can carry up to 5000 units of weight. Given an integer array weight where weight[i] is the weight of the ith apple, return the maximum number of apples you can put in the basket.   Example 1: Input: weight = [100,200,150,1000] Output: 4 Explanation: All 4 apples can be carried by...
maxNumberOfApples(weight: list_int) -> int
pub fn max_number_of_apples(weight: &[i64]) -> i64
Aegis.MaxNumberOfApples.max_number_of_apples
pub fn max_number_of_apples(weight: &[i64]) -> i64 { let n = weight.len(); let mut arr: Vec<i64> = Vec::new(); let mut i = 0usize; while i < n { arr.push(weight[i]); i += 1; } let mut a = 1usize; while a < n { let key = arr[a]; let mut b = a; while b...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [max_number_of_apples]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [max_number_of_apples]: function definitions module public import Aeneas public import Aegis.MaxNumberOfApples.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand fals...
import Aegis.MaxNumberOfApples.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.MaxNumberOfApples.max_number_of_apples (Slice.from [100#i64, 200#i64, 150#i64, 1000#i64] (by scalar_tac) : Slice Std.I64)) (4#i64))}") #eval (s...
[ { "input": "[[100, 200, 150, 1000]]", "output": "4" }, { "input": "[[1000, 1000, 1000, 1000, 1000]]", "output": "5" }, { "input": "[[1, 2, 3, 4, 5]]", "output": "5" }, { "input": "[[900, 950, 800, 1000, 700, 800]]", "output": "5" }, { "input": "[[1000, 1000, 1000,...
59
false
59
verified
10
10
1
820
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MaxNumberOfApples.Code.Funs /-! # Specifications of `Aegis.MaxNumberOfApples.max_number_of_apples` LeetCode problem `how-many-apples-can-you-put-into-the-basket`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.MaxNumberOfApples ope...
12
minimum-knight-moves
1,197
Medium
[ "Breadth-First Search" ]
In an infinite chess board with coordinates from -infinity to +infinity, you have a knight at square [0, 0]. A knight has 8 possible moves it can make, as illustrated below. Each move is two squares in a cardinal direction, then one square in an orthogonal direction. Return the minimum number of steps needed to move t...
minKnightMoves(x: int, y: int) -> int
pub fn min_knight_moves(x: i64, y: i64) -> i64
Aegis.MinKnightMoves.min_knight_moves
pub fn min_knight_moves(x: i64, y: i64) -> i64 { let mut a: i64 = x; let mut b: i64 = y; if a < 0 { a = -a; } if b < 0 { b = -b; } if a < b { let tmp: i64 = a; a = b; b = tmp; } if a == 1 && b == 0 { return 3; } if a == 2 && ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [min_knight_moves]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option lint...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [min_knight_moves]: function definitions module public import Aeneas public import Aegis.MinKnightMoves.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.MinKnightMoves.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.MinKnightMoves.min_knight_moves (-3)#i64 2#i64) (3#i64))}") #eval (s!"CASE 1 {(Result.reducesTo (Aegis.MinKnightMoves.min_knight_moves 300#i64 0#i...
[ { "input": "[-3, 2]", "output": "3" }, { "input": "[300, 0]", "output": "150" }, { "input": "[-3, -2]", "output": "3" }, { "input": "[-200, 150]", "output": "118" }, { "input": "[-300, 0]", "output": "150" }, { "input": "[100, 100]", "output": "68"...
121
false
121
verified
10
10
1
9,396
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MinKnightMoves.Code.Funs /-! # Specifications of `Aegis.MinKnightMoves.min_knight_moves` LeetCode problem `minimum-knight-moves`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.MinKnightMoves namespace AegisSpec.MinKnightMoves def IsKnigh...
14
find-smallest-common-element-in-all-rows
1,198
Medium
[ "Array", "Hash Table", "Binary Search", "Counting", "Matrix" ]
Given an m x n matrix mat where every row is sorted in strictly increasing order, return the smallest common element in all rows. If there is no common element, return -1.   Example 1: Input: mat = [[1,2,3,4,5],[2,4,5,8,10],[3,5,7,9,11],[1,3,5,7,9]] Output: 5 Example 2: Input: mat = [[1,2,3],[2,3,4],[2,3,5]] Output:...
smallestCommonElement(mat: list_list_int) -> int
pub fn smallest_common_element(mat: &[Vec<i64>]) -> i64
Aegis.SmallestCommonElement.smallest_common_element
pub fn smallest_common_element(mat: &[Vec<i64>]) -> i64 { if mat.len() == 0 { return -1; } let mut candidates: Vec<i64> = Vec::new(); let mut j: usize = 0; while j < mat[0].len() { candidates.push(mat[0][j]); j += 1; } if candidates.len() == 0 { return -1; ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [smallest_common_element]: type definitions module public import Aeneas @[expose] public 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 -- [smallest_common_element]: function definitions module public import Aeneas public import Aegis.SmallestCommonElement.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashComma...
import Aegis.SmallestCommonElement.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.SmallestCommonElement.smallest_common_element (Slice.from [(alloc.vec.Vec.from [1#i64, 2#i64, 3#i64] (by scalar_tac) : alloc.vec.Vec Std.I6...
[ { "input": "[[[1, 2, 3], [4, 5, 6], [7, 8, 9]]]", "output": "-1" }, { "input": "[[[1, 2, 3], [2, 3, 4], [2, 3, 5]]]", "output": "2" }, { "input": "[[[1], [2], [3], [4], [5], [6], [7], [8], [9], [10]]]", "output": "-1" }, { "input": "[[[1, 2, 3], [1, 4, 7], [1, 8, 13], [1, 10,...
90
false
90
verified
10
10
1
1,168
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.SmallestCommonElement.Code.Funs /-! # Specifications of `Aegis.SmallestCommonElement.smallest_common_element` LeetCode problem `find-smallest-common-element-in-all-rows`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.SmallestCommonEl...
8
minimum-time-to-build-blocks
1,199
Hard
[ "Greedy", "Array", "Math", "Heap (Priority Queue)" ]
You are given a list of blocks, where blocks[i] = t means that the i-th block needs t units of time to be built. A block can only be built by exactly one worker. A worker can either split into two workers (number of workers increases by one) or build a block then go home. Both decisions cost some time. The time cost of...
minBuildTime(blocks: list_int, split: int) -> int
pub fn min_build_time(blocks: &[i64], split: i64) -> i64
Aegis.MinBuildTime.min_build_time
pub fn min_build_time(blocks: &[i64], split: i64) -> i64 { let n0 = blocks.len(); if n0 == 0 { return 0; } let mut v: Vec<i64> = Vec::new(); let mut idx: usize = 0; while idx < n0 { v.push(blocks[idx]); idx += 1; } while v.len() > 1 { let n = v.len(); ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [min_build_time]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [min_build_time]: function definitions module public import Aeneas public import Aegis.MinBuildTime.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.MinBuildTime.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.MinBuildTime.min_build_time (Slice.from [1#i64] (by scalar_tac) : Slice Std.I64) 1#i64) (1#i64))}") #eval (s!"CASE 1 {(Result.reducesTo (Aegis.MinBu...
[ { "input": "[[1], 1]", "output": "1" }, { "input": "[[100000], 100000]", "output": "100000" }, { "input": "[[1, 2], 5]", "output": "7" }, { "input": "[[1, 2], 5]", "output": "7" }, { "input": "[[10, 20, 30], 10]", "output": "40" }, { "input": "[[1, 2, ...
100
false
100
verified
10
10
1
10,423
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MinBuildTime.Code.Funs /-! # Specifications of `Aegis.MinBuildTime.min_build_time` LeetCode problem `minimum-time-to-build-blocks`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.MinBuildTime namespace AegisSpec.MinBuildTime def content (...
15
minimum-absolute-difference
1,200
Easy
[ "Array", "Sorting" ]
Given an array of distinct integers arr, find all pairs of elements with the minimum absolute difference of any two elements. Return a list of pairs in ascending order(with respect to pairs), each pair [a, b] follows a, b are from arr a < b b - a equals to the minimum absolute difference of any two elements in arr   ...
minimumAbsDifference(arr: list_int) -> list_list_int
pub fn minimum_abs_difference(arr: &[i64]) -> Vec<Vec<i64>>
Aegis.MinimumAbsDifference.minimum_abs_difference
fn min2(a: usize, b: usize) -> usize { if a < b { a } else { b } } pub fn minimum_abs_difference(arr: &[i64]) -> Vec<Vec<i64>> { let n = arr.len(); let mut a: Vec<i64> = Vec::new(); let mut idx: usize = 0; while idx < n { a.push(arr[idx]); idx += 1; } ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [minimum_abs_difference]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_optio...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [minimum_abs_difference]: function definitions module public import Aeneas public import Aegis.MinimumAbsDifference.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand...
import Aegis.MinimumAbsDifference.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.MinimumAbsDifference.minimum_abs_difference (Slice.from [1#i64, 2#i64] (by scalar_tac) : Slice Std.I64)) ((alloc.vec.Vec.from [(alloc.vec.Ve...
[ { "input": "[[1, 2]]", "output": "[[1, 2]]" }, { "input": "[[-1, 2, 1, -4]]", "output": "[[1, 2]]" }, { "input": "[[5, 1, 4, 1, 3]]", "output": "[[1, 1]]" }, { "input": "[[100000, -100000, 0]]", "output": "[[-100000, 0], [0, 100000]]" }, { "input": "[[1, 3, 6, 10,...
101
false
101
verified
10
10
1
2,932
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MinimumAbsDifference.Code.Funs /-! # Specifications of `Aegis.MinimumAbsDifference.minimum_abs_difference` LeetCode problem `minimum-absolute-difference`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.MinimumAbsDifference def arrI...
14
ugly-number-iii
1,201
Medium
[ "Math", "Binary Search", "Combinatorics", "Number Theory" ]
An ugly number is a positive integer that is divisible by a, b, or c. Given four integers n, a, b, and c, return the nth ugly number.   Example 1: Input: n = 3, a = 2, b = 3, c = 5 Output: 4 Explanation: The ugly numbers are 2, 3, 4, 5, 6, 8, 9, 10... The 3rd is 4. Example 2: Input: n = 4, a = 2, b = 3, c = 4 Output...
nthUglyNumber(n: int, a: int, b: int, c: int) -> int
pub fn nth_ugly_number(n: i64, a: i64, b: i64, c: i64) -> i64
Aegis.NthUglyNumber.nth_ugly_number
pub fn nth_ugly_number(n: i64, a: i64, b: i64, c: i64) -> i64 { let cap: i64 = 2_000_000_001; let ab = lcm_capped(a, b, cap); let ac = lcm_capped(a, c, cap); let bc = lcm_capped(b, c, cap); let abc = lcm_capped(ab, c, cap); let mut lo: i64 = 1; let mut hi: i64 = 2_000_000_000; while l...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [nth_ugly_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 linte...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [nth_ugly_number]: function definitions module public import Aeneas public import Aegis.NthUglyNumber.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.NthUglyNumber.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.NthUglyNumber.nth_ugly_number 4#i64 2#i64 3#i64 4#i64) (6#i64))}") #eval (s!"CASE 1 {(Result.reducesTo (Aegis.NthUglyNumber.nth_ugly_number 1#i64 1...
[ { "input": "[4, 2, 3, 4]", "output": "6" }, { "input": "[1, 1000000000, 1000000000, 1000000000]", "output": "1000000000" }, { "input": "[1, 2, 3, 5]", "output": "2" }, { "input": "[3, 2, 3, 5]", "output": "4" }, { "input": "[10, 2, 7, 13]", "output": "16" },...
133
false
133
verified
10
10
1
2,816
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.NthUglyNumber.Code.Funs /-! # Specifications of `Aegis.NthUglyNumber.nth_ugly_number` LeetCode problem `ugly-number-iii`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.NthUglyNumber def IsUgly (a b c x : ℤ) : Prop := 0 < x ∧ (x % a ...
10
unique-number-of-occurrences
1,207
Easy
[ "Array", "Hash Table" ]
Given an array of integers arr, return true if the number of occurrences of each value in the array is unique or false otherwise.   Example 1: Input: arr = [1,2,2,1,1,3] Output: true Explanation: The value 1 has 3 occurrences, 2 has 2 and 3 has 1. No two values have the same number of occurrences. Example 2: Input: a...
uniqueOccurrences(arr: list_int) -> bool
pub fn unique_occurrences(arr: &[i64]) -> bool
Aegis.UniqueOccurrences.unique_occurrences
pub fn unique_occurrences(arr: &[i64]) -> bool { let n = arr.len(); let mut counts: Vec<i64> = Vec::new(); let mut i: usize = 0; while i < n { let value = arr[i]; let mut appeared_before: bool = false; let mut k: usize = 0; while k < i { if arr[k] == value {...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [unique_occurrences]: type definitions module public import Aeneas @[expose] public section 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 -- [unique_occurrences]: function definitions module public import Aeneas public import Aegis.UniqueOccurrences.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false ...
import Aegis.UniqueOccurrences.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.UniqueOccurrences.unique_occurrences (Slice.from [5#i64] (by scalar_tac) : Slice Std.I64)) (true))}") #eval (s!"CASE 1 {(Result.reducesTo (Aegi...
[ { "input": "[[5]]", "output": "true" }, { "input": "[[1]]", "output": "true" }, { "input": "[[1, 2]]", "output": "false" }, { "input": "[[1000, -1000, 0]]", "output": "false" }, { "input": "[[5, 5, 5, 5]]", "output": "true" }, { "input": "[[1000, -1000...
107
false
107
verified
10
10
1
1,033
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.UniqueOccurrences.Code.Funs /-! # Specifications of `Aegis.UniqueOccurrences.unique_occurrences` LeetCode problem `unique-number-of-occurrences`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.UniqueOccurrences namespace AegisSpec.UniqueOccurren...
11
get-equal-substrings-within-budget
1,208
Medium
[ "String", "Binary Search", "Prefix Sum", "Sliding Window" ]
You are given two strings s and t of the same length and an integer maxCost. You want to change s to t. Changing the ith character of s to ith character of t costs |s[i] - t[i]| (i.e., the absolute difference between the ASCII values of the characters). Return the maximum length of a substring of s that can be changed ...
equalSubstring(s: str, t: str, maxCost: int) -> int
pub fn equal_substring(s: &[u8], t: &[u8], maxCost: i64) -> i64
Aegis.EqualSubstring.equal_substring
pub fn equal_substring(s: &[u8], t: &[u8], maxCost: i64) -> i64 { let n = s.len(); let mut left: usize = 0; let mut right: usize = 0; let mut total: i64 = 0; let mut best: i64 = 0; while right < n { let a = s[right] as i64; let b = t[right] as i64; let d = if a >= b { a ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [equal_substring]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linte...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [equal_substring]: function definitions module public import Aeneas public import Aegis.EqualSubstring.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.EqualSubstring.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.EqualSubstring.equal_substring (Slice.from [97#u8] (by scalar_tac) : Slice Std.U8) (Slice.from [98#u8] (by scalar_tac) : Slice Std.U8) 1#i64) (1#i...
[ { "input": "[\"a\", \"b\", 1]", "output": "1" }, { "input": "[\"a\", \"a\", 0]", "output": "1" }, { "input": "[\"krrgw\", \"grkwa\", 3]", "output": "1" }, { "input": "[\"abcd\", \"abce\", 1]", "output": "4" }, { "input": "[\"abcdefgh\", \"efghabcd\", 10]", "ou...
95
false
95
verified
10
10
2
1,602
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.EqualSubstring.Code.Funs /-! # Specifications of `Aegis.EqualSubstring.equal_substring` LeetCode problem `get-equal-substrings-within-budget`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.EqualSubstring open Aegis.EqualSubstring ...
12
minimum-moves-to-reach-target-with-rotations
1,210
Hard
[ "Breadth-First Search", "Array", "Matrix" ]
In an n*n grid, there is a snake that spans 2 cells and starts moving from the top left corner at (0, 0) and (0, 1). The grid has empty cells represented by zeros and blocked cells represented by ones. The snake wants to reach the lower right corner at (n-1, n-2) and (n-1, n-1). In one move the snake can: Move one cel...
minimumMoves(grid: list_list_int) -> int
pub fn minimum_moves(grid: &[Vec<i64>]) -> i64
Aegis.MinimumMoves.minimum_moves
pub fn minimum_moves(grid: &[Vec<i64>]) -> i64 { let n = grid.len(); if n == 0 { return -1; } let total = n * n * 2; let mut dist: Vec<i64> = Vec::new(); let mut i = 0usize; while i < total { dist.push(-1); i += 1; } let start_state = 0usize; let target_...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [minimum_moves]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter....
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [minimum_moves]: function definitions module public import Aeneas public import Aegis.MinimumMoves.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option...
import Aegis.MinimumMoves.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.MinimumMoves.minimum_moves (Slice.from [(alloc.vec.Vec.from [0#i64, 0#i64, 1#i64] (by scalar_tac) : alloc.vec.Vec Std.I64), (alloc.vec.Vec.from [0#i...
[ { "input": "[[[0, 0, 1], [0, 1, 0], [0, 0, 0]]]", "output": "-1" }, { "input": "[[[0, 1, 1], [0, 0, 0], [0, 0, 0]]]", "output": "3" }, { "input": "[[[0, 0, 0], [0, 0, 0], [0, 0, 0]]]", "output": "3" }, { "input": "[[[0, 0, 0, 0, 0, 1], [1, 1, 0, 0, 1, 0], [0, 0, 0, 0, 1, 1], ...
64
false
64
verified
10
10
1
3,853
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MinimumMoves.Code.Funs /-! # Specifications of `Aegis.MinimumMoves.minimum_moves` LeetCode problem `minimum-moves-to-reach-target-with-rotations`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.MinimumMoves def rowCells (v : alloc.vec....
11
intersection-of-three-sorted-arrays
1,213
Easy
[ "Array", "Hash Table", "Binary Search", "Counting" ]
Given three integer arrays arr1, arr2 and arr3 sorted in strictly increasing order, return a sorted array of only the integers that appeared in all three arrays.   Example 1: Input: arr1 = [1,2,3,4,5], arr2 = [1,2,5,7,9], arr3 = [1,3,4,5,8] Output: [1,5] Explanation: Only 1 and 5 appeared in the three arrays. Example...
arraysIntersection(arr1: list_int, arr2: list_int, arr3: list_int) -> list_int
pub fn arrays_intersection(arr1: &[i64], arr2: &[i64], arr3: &[i64]) -> Vec<i64>
Aegis.ArraysIntersection.arrays_intersection
pub fn arrays_intersection(arr1: &[i64], arr2: &[i64], arr3: &[i64]) -> Vec<i64> { let mut i: usize = 0; let mut j: usize = 0; let mut k: usize = 0; let mut result: Vec<i64> = Vec::new(); while i < arr1.len() && j < arr2.len() && k < arr3.len() { let x = arr1[i]; let y = arr2[j]; ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [arrays_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 l...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [arrays_intersection]: function definitions module public import Aeneas public import Aegis.ArraysIntersection.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand fals...
import Aegis.ArraysIntersection.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.ArraysIntersection.arrays_intersection (Slice.from [1#i64, 2#i64, 3#i64] (by scalar_tac) : Slice Std.I64) (Slice.from [4#i64, 5#i64, 6#i64] (b...
[ { "input": "[[1, 2, 3], [4, 5, 6], [7, 8, 9]]", "output": "[]" }, { "input": "[[5, 10, 15], [5, 10, 20], [10, 15, 25]]", "output": "[10]" }, { "input": "[[100, 200, 300], [100, 200, 300], [100, 200, 300]]", "output": "[100, 200, 300]" }, { "input": "[[10, 20, 30, 40], [15, 25...
84
false
84
verified
10
10
1
759
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.ArraysIntersection.Code.Funs /-! # Specifications of `Aegis.ArraysIntersection.arrays_intersection` LeetCode problem `intersection-of-three-sorted-arrays`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.ArraysIntersection namespace AegisSpec.Arr...
13
stepping-numbers
1,215
Medium
[ "Breadth-First Search", "Math", "Backtracking" ]
A stepping number is an integer such that all of its adjacent digits have an absolute difference of exactly 1. For example, 321 is a stepping number while 421 is not. Given two integers low and high, return a sorted list of all the stepping numbers in the inclusive range [low, high].   Example 1: Input: low = 0, hig...
countSteppingNumbers(low: int, high: int) -> list_int
pub fn count_stepping_numbers(low: i64, high: i64) -> Vec<i64>
Aegis.CountSteppingNumbers.count_stepping_numbers
pub fn count_stepping_numbers(low: i64, high: i64) -> Vec<i64> { let mut all: Vec<i64> = Vec::new(); // 0 is a stepping number and must not be expanded, since that could // create leading-zero duplicates. all.push(0); // All one-digit positive numbers are stepping numbers. let mut d: i64 = 1; ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [count_stepping_numbers]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_optio...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [count_stepping_numbers]: function definitions module public import Aeneas public import Aegis.CountSteppingNumbers.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand...
import Aegis.CountSteppingNumbers.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.CountSteppingNumbers.count_stepping_numbers 999999998#i64 1000000000#i64) ((alloc.vec.Vec.from [] (by scalar_tac) : alloc.vec.Vec Std.I64)))...
[ { "input": "[999999998, 1000000000]", "output": "[]" }, { "input": "[1000000000, 1000000000]", "output": "[]" }, { "input": "[222222, 222223]", "output": "[]" }, { "input": "[999999, 1000001]", "output": "[]" }, { "input": "[22222, 22223]", "output": "[]" },...
84
false
84
verified
10
10
1
2,632
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.CountSteppingNumbers.Code.Funs /-! # Specifications of `Aegis.CountSteppingNumbers.count_stepping_numbers` LeetCode problem `stepping-numbers`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.CountSteppingNumbers namespace AegisSpec.CountStep...
10
minimum-cost-to-move-chips-to-the-same-position
1,217
Easy
[ "Greedy", "Array", "Math" ]
We have n chips, where the position of the ith chip is position[i]. We need to move all the chips to the same position. In one step, we can change the position of the ith chip from position[i] to: position[i] + 2 or position[i] - 2 with cost = 0. position[i] + 1 or position[i] - 1 with cost = 1. Return the minimum co...
minCostToMoveChips(position: list_int) -> int
pub fn min_cost_to_move_chips(position: &[i64]) -> i64
Aegis.MinCostToMoveChips.min_cost_to_move_chips
pub fn min_cost_to_move_chips(position: &[i64]) -> i64 { let mut even_count: i64 = 0; let mut odd_count: i64 = 0; let mut i: usize = 0; while i < position.len() { if position[i] % 2 == 0 { even_count += 1; } else { odd_count += 1; } i += 1; } ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [min_cost_to_move_chips]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_optio...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [min_cost_to_move_chips]: function definitions module public import Aeneas public import Aegis.MinCostToMoveChips.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand f...
import Aegis.MinCostToMoveChips.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.MinCostToMoveChips.min_cost_to_move_chips (Slice.from [1#i64] (by scalar_tac) : Slice Std.I64)) (0#i64))}") #eval (s!"CASE 1 {(Result.reducesT...
[ { "input": "[[1]]", "output": "0" }, { "input": "[[1, 1000000000]]", "output": "1" }, { "input": "[[1000000000, 1000000000, 1000000000]]", "output": "0" }, { "input": "[[999999999, 1000000000, 1000000001]]", "output": "1" }, { "input": "[[1, 2, 3]]", "output":...
105
false
105
verified
10
10
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.MinCostToMoveChips.Code.Funs /-! # Specifications of `Aegis.MinCostToMoveChips.min_cost_to_move_chips` LeetCode problem `minimum-cost-to-move-chips-to-the-same-position`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.MinCostToMoveChips...
8
longest-arithmetic-subsequence-of-given-difference
1,218
Medium
[ "Array", "Hash Table", "Dynamic Programming" ]
Given an integer array arr and an integer difference, return the length of the longest subsequence in arr which is an arithmetic sequence such that the difference between adjacent elements in the subsequence equals difference. A subsequence is a sequence that can be derived from arr by deleting some or no elements with...
longestSubsequence(arr: list_int, difference: int) -> int
pub fn longest_subsequence(arr: &[i64], difference: i64) -> i64
Aegis.LongestSubsequence.longest_subsequence
pub fn longest_subsequence(arr: &[i64], difference: i64) -> i64 { let n = arr.len(); if n == 0 { return 0; } // For small inputs, use a position-indexed DP. This avoids allocating // a value-sized table for tiny test cases. if n <= 2000 { let mut dp: Vec<i64> = Vec::new(); ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [longest_subsequence]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option l...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [longest_subsequence]: function definitions module public import Aeneas public import Aegis.LongestSubsequence.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand fals...
import Aegis.LongestSubsequence.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval ae...
[ { "input": "[[1, 2, 3, 4], 1]", "output": "4" }, { "input": "[[1, 3, 5, 7], 1]", "output": "1" }, { "input": "[[1, 4, 7, 10], 3]", "output": "4" }, { "input": "[[1, 1, 1, 1, 1], 0]", "output": "5" }, { "input": "[[5, 4, 3, 2, 1], -1]", "output": "5" }, { ...
154
false
154
verified
10
10
2
29,948
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.LongestSubsequence.Code.Funs /-! # Specifications of `Aegis.LongestSubsequence.longest_subsequence` LeetCode problem `longest-arithmetic-subsequence-of-given-difference`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.LongestSubsequence name...
13
path-with-maximum-gold
1,219
Medium
[ "Array", "Backtracking", "Matrix" ]
In a gold mine grid of size m x n, each cell in this mine has an integer representing the amount of gold in that cell, 0 if it is empty. Return the maximum amount of gold you can collect under the conditions: Every time you are located in a cell you will collect all the gold in that cell. From your position, you can w...
getMaximumGold(grid: list_list_int) -> int
pub fn get_maximum_gold(grid: &[Vec<i64>]) -> i64
Aegis.GetMaximumGold.get_maximum_gold
pub fn get_maximum_gold(grid: &[Vec<i64>]) -> i64 { if grid.len() == 0 { return 0; } if grid[0].len() == 0 { return 0; } let m = grid.len(); let n = grid[0].len(); let total = m * n; let mut gold: Vec<i64> = Vec::new(); let mut i = 0; while i < m { let m...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [get_maximum_gold]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option lint...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [get_maximum_gold]: function definitions module public import Aeneas public import Aegis.GetMaximumGold.Code.Types public import Aegis.GetMaximumGold.Code.FunsExternal @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupName...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [get_maximum_gold]: external functions. -- This is a template file: rename it to "FunsExternal.lean" and fill the holes. module public import Aeneas public import Aegis.GetMaximumGold.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Erro...
import Aegis.GetMaximumGold.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.GetMaximumGold.get_maximum_gold (Slice.from [(alloc.vec.Vec.from [10#i64] (by scalar_tac) : alloc.vec.Vec Std.I64)] (by scalar_tac) : Slice (alloc...
[ { "input": "[[[10]]]", "output": "10" }, { "input": "[[[1]]]", "output": "1" }, { "input": "[[[0, 0], [0, 1]]]", "output": "1" }, { "input": "[[[10, 33], [8, 3]]]", "output": "54" }, { "input": "[[[0, 6, 0], [5, 8, 7], [0, 9, 0]]]", "output": "24" }, { ...
99
false
99
verified
10
10
1
6,746
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.GetMaximumGold.Code.Funs /-! # Specifications of `Aegis.GetMaximumGold.get_maximum_gold` LeetCode problem `path-with-maximum-gold`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.GetMaximumGold def cellVal (grid : Slice (alloc.vec.Vec ...
9