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
find-latest-group-of-size-m
1,562
Medium
[ "Array", "Hash Table", "Binary Search", "Simulation" ]
Given an array arr that represents a permutation of numbers from 1 to n. You have a binary string of size n that initially has all its bits set to zero. At each step i (assuming both the binary string and arr are 1-indexed) from 1 to n, the bit at position arr[i] is set to 1. You are also given an integer m. Find the l...
findLatestStep(arr: list_int, m: int) -> int
pub fn find_latest_step(arr: &[i64], m: i64) -> i64
Aegis.FindLatestStep.find_latest_step
pub fn find_latest_step(arr: &[i64], m: i64) -> i64 { let n = arr.len(); let mut on: Vec<u8> = Vec::new(); let mut length: Vec<i64> = Vec::new(); let mut count: Vec<i64> = Vec::new(); let mut i: usize = 0; while i < n { on.push(0); length.push(0); i += 1; } let...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [find_latest_step]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option lint...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [find_latest_step]: function definitions module public import Aeneas public import Aegis.FindLatestStep.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.FindLatestStep.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.FindLatestStep.find_latest_step (Slice.from [1#i64, 2#i64, 3#i64, 4#i64, 5#i64] (by scalar_tac) : Slice Std.I64) 3#i64) (3#i64))}") #eval (s!"CASE...
[ { "input": "[[1, 2, 3, 4, 5], 3]", "output": "3" }, { "input": "[[1, 3, 5, 2, 4], 1]", "output": "4" }, { "input": "[[2, 1, 3, 5, 4], 1]", "output": "4" }, { "input": "[[3, 5, 1, 2, 4], 1]", "output": "4" }, { "input": "[[5, 4, 3, 2, 1], 1]", "output": "1" }...
106
false
106
verified
10
10
1
6,125
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.FindLatestStep.Code.Funs /-! # Specifications of `Aegis.FindLatestStep.find_latest_step` LeetCode problem `find-latest-group-of-size-m`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.FindLatestStep def lenZ (arr : Slice Std.I64) : ℤ :...
11
stone-game-v
1,563
Hard
[ "Array", "Math", "Dynamic Programming", "Game Theory" ]
There are several stones arranged in a row, and each stone has an associated value which is an integer given in the array stoneValue. In each round of the game, Alice divides the row into two non-empty rows (i.e. left row and right row), then Bob calculates the value of each row which is the sum of the values of all th...
stoneGameV(stoneValue: list_int) -> int
pub fn stone_game_v(stoneValue: &[i64]) -> i64
Aegis.StoneGameV.stone_game_v
pub fn stone_game_v(stoneValue: &[i64]) -> i64 { let n = stoneValue.len(); if n == 0 { return 0; } if n == 1 { return 0; } let mut prefix: Vec<i64> = Vec::new(); prefix.push(0); let mut i: usize = 0; while i < n { let next = prefix[i] + stoneValue[i]; ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [stone_game_v]: type definitions module public import Aeneas @[expose] public section 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 -- [stone_game_v]: function definitions module public import Aeneas public import Aegis.StoneGameV.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.StoneGameV.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.StoneGameV.stone_game_v (Slice.from [4#i64] (by scalar_tac) : Slice Std.I64)) (0#i64))}") #eval (s!"CASE 1 {(Result.reducesTo (Aegis.StoneGameV.stone_...
[ { "input": "[[4]]", "output": "0" }, { "input": "[[1000000, 1000000]]", "output": "1000000" }, { "input": "[[1000000, 1000000]]", "output": "1000000" }, { "input": "[[1, 100, 1]]", "output": "1" }, { "input": "[[1, 2, 3, 4, 5]]", "output": "10" }, { "i...
93
false
93
verified
10
10
2
3,351
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.StoneGameV.Code.Funs /-! # Specifications of `Aegis.StoneGameV.stone_game_v` LeetCode problem `stone-game-v`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.StoneGameV namespace AegisSpec.StoneGameV def vals (s : Slice Std.I64) : List ℤ := s.va...
12
put-boxes-into-the-warehouse-i
1,564
Medium
[ "Greedy", "Array", "Sorting" ]
You are given two arrays of positive integers, boxes and warehouse, representing the heights of some boxes of unit width and the heights of n rooms in a warehouse respectively. The warehouse's rooms are labelled from 0 to n - 1 from left to right where warehouse[i] (0-indexed) is the height of the ith room. Boxes are p...
maxBoxesInWarehouse(boxes: list_int, warehouse: list_int) -> int
pub fn max_boxes_in_warehouse(boxes: &[i64], warehouse: &[i64]) -> i64
Aegis.MaxBoxesInWarehouse.max_boxes_in_warehouse
pub fn max_boxes_in_warehouse(boxes: &[i64], warehouse: &[i64]) -> i64 { let n = warehouse.len(); let m = boxes.len(); if n == 0 || m == 0 { return 0; } let mut sorted_boxes: Vec<i64> = Vec::new(); let mut i = 0; while i < m { sorted_boxes.push(boxes[i]); i += 1; ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [max_boxes_in_warehouse]: type definitions module public import Aeneas @[expose] public 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_boxes_in_warehouse]: function definitions module public import Aeneas public import Aegis.MaxBoxesInWarehouse.Code.Types public import Aegis.MaxBoxesInWarehouse.Code.FunsExternal @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_optio...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [max_boxes_in_warehouse]: external functions. -- This is a template file: rename it to "FunsExternal.lean" and fill the holes. module public import Aeneas public import Aegis.MaxBoxesInWarehouse.Code.Types @[expose] public section open Aeneas Aeneas.Std Result Contr...
import Aegis.MaxBoxesInWarehouse.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.MaxBoxesInWarehouse.max_boxes_in_warehouse (Slice.from [1#i64, 1000000000#i64] (by scalar_tac) : Slice Std.I64) (Slice.from [1000000000#i64, ...
[ { "input": "[[1, 1000000000], [1000000000, 1]]", "output": "2" }, { "input": "[[100, 200, 300], [150, 250, 350]]", "output": "1" }, { "input": "[[1, 2, 3], [1, 2, 3, 4]]", "output": "1" }, { "input": "[[1, 1, 1, 1], [10, 10, 10, 10]]", "output": "4" }, { "input": ...
107
false
107
verified
10
10
1
4,047
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MaxBoxesInWarehouse.Code.Funs /-! # Specifications of `Aegis.MaxBoxesInWarehouse.max_boxes_in_warehouse` LeetCode problem `put-boxes-into-the-warehouse-i`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.MaxBoxesInWarehouse namespace AegisSpec.Ma...
18
detect-pattern-of-length-m-repeated-k-or-more-times
1,566
Easy
[ "Array", "Enumeration" ]
Given an array of positive integers arr, find a pattern of length m that is repeated k or more times. A pattern is a subarray (consecutive sub-sequence) that consists of one or more values, repeated multiple times consecutively without overlapping. A pattern is defined by its length and the number of repetitions. Retur...
containsPattern(arr: list_int, m: int, k: int) -> bool
pub fn contains_pattern(arr: &[i64], m: i64, k: i64) -> bool
Aegis.ContainsPattern.contains_pattern
pub fn contains_pattern(arr: &[i64], m: i64, k: i64) -> bool { let n: usize = arr.len(); let mu: usize = m as usize; // Number of consecutive matches of arr[i] == arr[i - m] needed // before we have seen the pattern repeated k times. let target: i64 = m * (k - 1); let mut cnt: i64 = 0; let ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [contains_pattern]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option lint...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [contains_pattern]: function definitions module public import Aeneas public import Aegis.ContainsPattern.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.ContainsPattern.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.ContainsPattern.contains_pattern (Slice.from [1#i64, 1#i64, 1#i64, 1#i64] (by scalar_tac) : Slice Std.I64) 1#i64 4#i64) (true))}") #eval (s!"CASE...
[ { "input": "[[1, 1, 1, 1], 1, 4]", "output": "true" }, { "input": "[[1, 1, 1, 1, 1], 1, 5]", "output": "true" }, { "input": "[[1, 2, 4, 4, 4, 4], 1, 3]", "output": "true" }, { "input": "[[2, 2, 2, 2, 2, 2], 2, 2]", "output": "true" }, { "input": "[[1, 1, 1, 1, 1, ...
128
false
128
verified
10
10
1
3,241
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.ContainsPattern.Code.Funs /-! # Specifications of `Aegis.ContainsPattern.contains_pattern` LeetCode problem `detect-pattern-of-length-m-repeated-k-or-more-times`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.ContainsPattern namespace AegisSpec...
12
maximum-length-of-subarray-with-positive-product
1,567
Medium
[ "Greedy", "Array", "Dynamic Programming" ]
Given an array of integers nums, find the maximum length of a subarray where the product of all its elements is positive. A subarray of an array is a consecutive sequence of zero or more values taken out of that array. Return the maximum length of a subarray with positive product.   Example 1: Input: nums = [1,-2,-3,4...
getMaxLen(nums: list_int) -> int
pub fn get_max_len(nums: &[i64]) -> i64
Aegis.GetMaxLen.get_max_len
pub fn get_max_len(nums: &[i64]) -> i64 { let n: usize = nums.len(); let mut best: i64 = 0; let mut pos: i64 = 0; let mut neg: i64 = 0; let mut i: usize = 0; while i < n { let x: i64 = nums[i]; if x == 0 { pos = 0; neg = 0; } else if x > 0 { ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [get_max_len]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter.st...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [get_max_len]: function definitions module public import Aeneas public import Aegis.GetMaxLen.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.GetMaxLen.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.GetMaxLen.get_max_len (Slice.from [(-1)#i64] (by scalar_tac) : Slice Std.I64)) (0#i64))}") #eval (s!"CASE 1 {(Result.reducesTo (Aegis.GetMaxLen.get_max...
[ { "input": "[[-1]]", "output": "0" }, { "input": "[[1]]", "output": "1" }, { "input": "[[0]]", "output": "0" }, { "input": "[[-1, -1, -1, -1]]", "output": "4" }, { "input": "[[0, 0, 0, 0]]", "output": "0" }, { "input": "[[1000000000, -1000000000, 10000...
122
false
122
verified
10
10
1
876
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.GetMaxLen.Code.Funs /-! # Specifications of `Aegis.GetMaxLen.get_max_len` LeetCode problem `maximum-length-of-subarray-with-positive-product`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.GetMaxLen def entry (nums : Slice Std.I64...
9
minimum-number-of-days-to-disconnect-island
1,568
Hard
[ "Depth-First Search", "Breadth-First Search", "Array", "Matrix", "Strongly Connected Component" ]
You are given an m x n binary grid grid where 1 represents land and 0 represents water. An island is a maximal 4-directionally (horizontal or vertical) connected group of 1's. The grid is said to be connected if we have exactly one island, otherwise is said disconnected. In one day, we are allowed to change any single ...
minDays(grid: list_list_int) -> int
pub fn min_days(grid: &[Vec<i64>]) -> i64
Aegis.MinDays.min_days
pub fn min_days(grid: &[Vec<i64>]) -> i64 { let m = grid.len(); if m == 0 { return 0; } let n = grid[0].len(); if n == 0 { return 0; } if !connected(grid, -1, -1) { return 0; } let mut ans: i64 = 2; let mut i = 0usize; while i < m && ans == 2 { ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [min_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.style...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [min_days]: function definitions module public import Aeneas public import Aegis.MinDays.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.un...
import Aegis.MinDays.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.MinDays.min_days (Slice.from [(alloc.vec.Vec.from [1#i64, 1#i64] (by scalar_tac) : alloc.vec.Vec Std.I64)] (by scalar_tac) : Slice (alloc.vec.Vec Std.I64...
[ { "input": "[[[1, 1]]]", "output": "2" }, { "input": "[[[1, 1, 1], [1, 1, 1], [1, 1, 1]]]", "output": "2" }, { "input": "[[[0, 0, 0], [0, 0, 0], [0, 0, 0]]]", "output": "0" }, { "input": "[[[1, 1, 0], [0, 0, 0], [0, 0, 1]]]", "output": "0" }, { "input": "[[[1, 0, ...
73
false
73
verified
10
10
2
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.MinDays.Code.Funs /-! # Specifications of `Aegis.MinDays.min_days` LeetCode problem `minimum-number-of-days-to-disconnect-island`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result Aegis.MinDays namespace AegisSpec.MinDays def rowVals (grid : Slice (allo...
14
matrix-diagonal-sum
1,572
Easy
[ "Array", "Matrix" ]
Given a square matrix mat, return the sum of the matrix diagonals. Only include the sum of all the elements on the primary diagonal and all the elements on the secondary diagonal that are not part of the primary diagonal.   Example 1: Input: mat = [[1,2,3],   [4,5,6],   [7,8,9]] Output: 25 Exp...
diagonalSum(mat: list_list_int) -> int
pub fn diagonal_sum(mat: &[Vec<i64>]) -> i64
Aegis.DiagonalSum.diagonal_sum
pub fn diagonal_sum(mat: &[Vec<i64>]) -> i64 { let n = mat.len(); if n == 0 { return 0; } let mut sum: i64 = 0; let mut i: usize = 0; while i < n { sum += mat[i][i]; let j: usize = n - 1 - i; if j != i { sum += mat[i][j]; } i += 1; ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [diagonal_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.s...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [diagonal_sum]: function definitions module public import Aeneas public import Aegis.DiagonalSum.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.DiagonalSum.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.DiagonalSum.diagonal_sum (Slice.from [(alloc.vec.Vec.from [5#i64] (by scalar_tac) : alloc.vec.Vec Std.I64)] (by scalar_tac) : Slice (alloc.vec.Vec St...
[ { "input": "[[[5]]]", "output": "5" }, { "input": "[[[1, 2], [3, 4]]]", "output": "10" }, { "input": "[[[10, 1, 1], [1, 0, 1], [1, 1, 10]]]", "output": "22" }, { "input": "[[[1, 2, 3], [4, 5, 6], [7, 8, 9]]]", "output": "25" }, { "input": "[[[100, 100, 100], [100,...
54
false
54
verified
10
10
1
886
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.DiagonalSum.Code.Funs /-! # Specifications of `Aegis.DiagonalSum.diagonal_sum` LeetCode problem `matrix-diagonal-sum`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.DiagonalSum open scoped BigOperators abbrev Mat := Slice (alloc.vec....
8
number-of-ways-to-split-a-string
1,573
Medium
[ "Math", "String" ]
Given a binary string s, you can split s into 3 non-empty strings s1, s2, and s3 where s1 + s2 + s3 = s. Return the number of ways s can be split such that the number of ones is the same in s1, s2, and s3. Since the answer may be too large, return it modulo 109 + 7.   Example 1: Input: s = "10101" Output: 4 Explanatio...
numWays(s: str) -> int
pub fn num_ways(s: &[u8]) -> i64
Aegis.NumWays.num_ways
pub fn num_ways(s: &[u8]) -> i64 { let modulo: i64 = 1000000007; let n: usize = s.len(); let mut total: i64 = 0; let mut i: usize = 0; while i < n { if s[i] == b'1' { total += 1; } i += 1; } if total == 0 { let m: i64 = n as i64; let ans:...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [num_ways]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter.style...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [num_ways]: function definitions module public import Aeneas public import Aegis.NumWays.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.un...
import Aegis.NumWays.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.NumWays.num_ways (Slice.from [49#u8, 48#u8, 49#u8, 48#u8, 49#u8, 48#u8, 49#u8, 48#u8, 49#u8] (by scalar_tac) : Slice Std.U8)) (0#i64))}") #eval (s!"CASE ...
[ { "input": "[\"101010101\"]", "output": "0" }, { "input": "[\"10101010101\"]", "output": "4" }, { "input": "[\"0000\"]", "output": "3" }, { "input": "[\"0000000\"]", "output": "15" }, { "input": "[\"010101010\"]", "output": "0" }, { "input": "[\"111000...
84
false
84
verified
10
10
1
3,370
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.NumWays.Code.Funs /-! # Specifications of `Aegis.NumWays.num_ways` LeetCode problem `number-of-ways-to-split-a-string`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.NumWays def countOnes (l : List Std.U8) : ℕ := (l.filter fun b =...
9
shortest-subarray-to-be-removed-to-make-array-sorted
1,574
Medium
[ "Stack", "Array", "Two Pointers", "Binary Search", "Monotonic Stack" ]
Given an integer array arr, remove a subarray (can be empty) from arr such that the remaining elements in arr are non-decreasing. Return the length of the shortest subarray to remove. A subarray is a contiguous subsequence of the array.   Example 1: Input: arr = [1,2,3,10,4,2,3,5] Output: 3 Explanation: The shortest s...
findLengthOfShortestSubarray(arr: list_int) -> int
pub fn find_length_of_shortest_subarray(arr: &[i64]) -> i64
Aegis.FindLengthOfShortestSubarray.find_length_of_shortest_subarray
pub fn find_length_of_shortest_subarray(arr: &[i64]) -> i64 { let n = arr.len(); if n <= 1 { return 0; } let mut i: usize = 0; while i + 1 < n && arr[i] <= arr[i + 1] { i += 1; } if i == n - 1 { return 0; } let mut j: usize = n - 1; while j > 0 && arr[j...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [find_length_of_shortest_subarray]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [find_length_of_shortest_subarray]: function definitions module public import Aeneas public import Aegis.FindLengthOfShortestSubarray.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option ...
import Aegis.FindLengthOfShortestSubarray.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.FindLengthOfShortestSubarray.find_length_of_shortest_subarray (Slice.from [1#i64] (by scalar_tac) : Slice Std.I64)) (0#i64))}") #eva...
[ { "input": "[[1]]", "output": "0" }, { "input": "[[1, 2, 3]]", "output": "0" }, { "input": "[[5, 4, 3, 2, 1]]", "output": "4" }, { "input": "[[1, 3, 5, 4, 7]]", "output": "1" }, { "input": "[[1, 1, 1, 1, 1]]", "output": "0" }, { "input": "[[1, 2, 3, 4,...
189
false
189
verified
10
10
1
2,658
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.FindLengthOfShortestSubarray.Code.Funs /-! # Specifications of `Aegis.FindLengthOfShortestSubarray.find_length_of_shortest_subarray` LeetCode problem `shortest-subarray-to-be-removed-to-make-array-sorted`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result nam...
11
count-all-possible-routes
1,575
Hard
[ "Memoization", "Array", "Dynamic Programming" ]
You are given an array of distinct positive integers locations where locations[i] represents the position of city i. You are also given integers start, finish and fuel representing the starting city, ending city, and the initial amount of fuel you have, respectively. At each step, if you are at city i, you can pick any...
countRoutes(locations: list_int, start: int, finish: int, fuel: int) -> int
pub fn count_routes(locations: &[i64], start: i64, finish: i64, fuel: i64) -> i64
Aegis.CountRoutes.count_routes
pub fn count_routes(locations: &[i64], start: i64, finish: i64, fuel: i64) -> i64 { const MOD: i64 = 1000000007; let n = locations.len(); let max_fuel = fuel as usize; let start_idx = start as usize; let finish_idx = finish as usize; // Sorted copy of positions, used only to canonically index ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [count_routes]: type definitions module public import Aeneas @[expose] public section 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 -- [count_routes]: function definitions module public import Aeneas public import Aegis.CountRoutes.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.CountRoutes.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval aegisCase...
[ { "input": "[[4, 3, 1], 1, 0, 6]", "output": "5" }, { "input": "[[5, 2, 1], 0, 2, 3]", "output": "0" }, { "input": "[[1, 2, 3], 0, 2, 3]", "output": "2" }, { "input": "[[10, 20, 30, 40], 0, 3, 50]", "output": "16" }, { "input": "[[1, 10, 100, 1000, 10000], 0, 4, 5...
96
false
96
verified_partial
10
4
2
29,241
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.CountRoutes.Code.Funs /-! # Specifications of `Aegis.CountRoutes.count_routes` LeetCode problem `count-all-possible-routes`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.CountRoutes section def locAt (locs : List Std.I64) (i :...
13
minimum-time-to-make-rope-colorful
1,578
Medium
[ "Greedy", "Array", "String", "Dynamic Programming" ]
Alice has n balloons arranged on a rope. You are given a 0-indexed string colors where colors[i] is the color of the ith balloon. Alice wants the rope to be colorful. She does not want two consecutive balloons to be of the same color, so she asks Bob for help. Bob can remove some balloons from the rope to make it color...
minCost(colors: str, neededTime: list_int) -> int
pub fn min_cost(colors: &[u8], neededTime: &[i64]) -> i64
Aegis.MinCost.min_cost
pub fn min_cost(colors: &[u8], neededTime: &[i64]) -> i64 { let n = colors.len(); if n == 0 { return 0; } let mut ans: i64 = 0; let mut i: usize = 0; while i < n { let c = colors[i]; let mut run_sum: i64 = neededTime[i]; let mut run_max: i64 = neededTime[i]; ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [min_cost]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter.style...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [min_cost]: function definitions module public import Aeneas public import Aegis.MinCost.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.un...
import Aegis.MinCost.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.MinCost.min_cost (Slice.from [97#u8] (by scalar_tac) : Slice Std.U8) (Slice.from [5#i64] (by scalar_tac) : Slice Std.I64)) (0#i64))}") #eval (s!"CASE 1 {...
[ { "input": "[\"a\", [5]]", "output": "0" }, { "input": "[\"a\", [1]]", "output": "0" }, { "input": "[\"abc\", [1, 2, 3]]", "output": "0" }, { "input": "[\"zzzz\", [1, 1, 1, 1]]", "output": "3" }, { "input": "[\"aaaa\", [10, 5, 4, 2]]", "output": "11" }, { ...
91
false
91
verified
10
10
1
760
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MinCost.Code.Funs /-! # Specifications of `Aegis.MinCost.min_cost` LeetCode problem `minimum-time-to-make-rope-colorful`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.MinCost def colorAt (colors : List Std.U8) (i : ℕ) : ℕ := (col...
11
remove-max-number-of-edges-to-keep-graph-fully-traversable
1,579
Hard
[ "Union Find", "Graph" ]
Alice and Bob have an undirected graph of n nodes and three types of edges: Type 1: Can be traversed by Alice only. Type 2: Can be traversed by Bob only. Type 3: Can be traversed by both Alice and Bob. Given an array edges where edges[i] = [typei, ui, vi] represents a bidirectional edge of type typei between nodes ui...
maxNumEdgesToRemove(n: int, edges: list_list_int) -> int
pub fn max_num_edges_to_remove(n: i64, edges: &[Vec<i64>]) -> i64
Aegis.MaxNumEdgesToRemove.max_num_edges_to_remove
fn make_parent(n: i64) -> Vec<i64> { let mut parent: Vec<i64> = Vec::new(); let mut i: i64 = 0; while i <= n { parent.push(i); i += 1; } parent } fn make_rank(n: i64) -> Vec<i64> { let mut rank: Vec<i64> = Vec::new(); let mut i: i64 = 0; while i <= n { rank.push(...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [max_num_edges_to_remove]: type definitions module public import Aeneas @[expose] public 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 -- [max_num_edges_to_remove]: function definitions module public import Aeneas public import Aegis.MaxNumEdgesToRemove.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand...
import Aegis.MaxNumEdgesToRemove.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.MaxNumEdgesToRemove.max_num_edges_to_remove 3#i64 (Slice.from [(alloc.vec.Vec.from [1#i64, 1#i64, 2#i64] (by scalar_tac) : alloc.vec.Vec Std....
[ { "input": "[3, [[1, 1, 2], [2, 1, 2], [3, 2, 3]]]", "output": "0" }, { "input": "[4, [[3, 2, 3], [1, 1, 2], [2, 3, 4]]]", "output": "-1" }, { "input": "[3, [[3, 1, 2], [1, 1, 3], [2, 2, 3]]]", "output": "0" }, { "input": "[4, [[3, 1, 2], [3, 2, 3], [1, 1, 4], [2, 1, 4]]]", ...
65
false
65
verified
10
10
1
6,749
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MaxNumEdgesToRemove.Code.Funs /-! # Specifications of `Aegis.MaxNumEdgesToRemove.max_num_edges_to_remove` LeetCode problem `remove-max-number-of-edges-to-keep-graph-fully-traversable`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.MaxNumEdgesTo...
15
put-boxes-into-the-warehouse-ii
1,580
Medium
[ "Greedy", "Array", "Sorting" ]
You are given two arrays of positive integers, boxes and warehouse, representing the heights of some boxes of unit width and the heights of n rooms in a warehouse respectively. The warehouse's rooms are labeled from 0 to n - 1 from left to right where warehouse[i] (0-indexed) is the height of the ith room. Boxes are pu...
maxBoxesInWarehouse(boxes: list_int, warehouse: list_int) -> int
pub fn max_boxes_in_warehouse(boxes: &[i64], warehouse: &[i64]) -> i64
Aegis.MaxBoxesInWarehouse.max_boxes_in_warehouse
fn sort_i64(mut v: Vec<i64>) -> Vec<i64> { let n = v.len(); if n <= 1 { return v; } let mut tmp: Vec<i64> = Vec::new(); let mut t: usize = 0; while t < n { tmp.push(0); t += 1; } let mut width: usize = 1; while width < n { let mut left: usize = 0; ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [max_boxes_in_warehouse]: type definitions module public import Aeneas @[expose] public 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_boxes_in_warehouse]: function definitions module public import Aeneas public import Aegis.MaxBoxesInWarehouse.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand ...
import Aegis.MaxBoxesInWarehouse.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.MaxBoxesInWarehouse.max_boxes_in_warehouse (Slice.from [4#i64, 5#i64, 6#i64] (by scalar_tac) : Slice Std.I64) (Slice.from [1#i64, 2#i64, 3#i6...
[ { "input": "[[4, 5, 6], [1, 2, 3]]", "output": "0" }, { "input": "[[1, 2, 3], [1, 2, 3]]", "output": "3" }, { "input": "[[10, 20, 30], [30, 20, 10]]", "output": "3" }, { "input": "[[1, 1, 1, 1], [5, 5, 5, 5]]", "output": "4" }, { "input": "[[1, 1, 1, 1], [1, 1, 1,...
136
false
136
verified
10
10
1
7,601
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MaxBoxesInWarehouse.Code.Funs /-! # Specifications of `Aegis.MaxBoxesInWarehouse.max_boxes_in_warehouse` LeetCode problem `put-boxes-into-the-warehouse-ii`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.MaxBoxesInWarehouse namespace AegisSp...
17
special-positions-in-a-binary-matrix
1,582
Easy
[ "Array", "Matrix" ]
Given an m x n binary matrix mat, return the number of special positions in mat. A position (i, j) is called special if mat[i][j] == 1 and all other elements in row i and column j are 0 (rows and columns are 0-indexed).   Example 1: Input: mat = [[1,0,0],[0,0,1],[1,0,0]] Output: 1 Explanation: (1, 2) is a special pos...
numSpecial(mat: list_list_int) -> int
pub fn num_special(mat: &[Vec<i64>]) -> i64
Aegis.NumSpecial.num_special
pub fn num_special(mat: &[Vec<i64>]) -> i64 { let m = mat.len(); if m == 0 { return 0; } let n = mat[0].len(); let mut row_counts: Vec<i64> = Vec::new(); let mut i: usize = 0; while i < m { row_counts.push(0); i = i + 1; } let mut col_counts: Vec<i64> = Vec...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [num_special]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter.st...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [num_special]: function definitions module public import Aeneas public import Aegis.NumSpecial.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.NumSpecial.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.NumSpecial.num_special (Slice.from [(alloc.vec.Vec.from [1#i64, 0#i64] (by scalar_tac) : alloc.vec.Vec Std.I64), (alloc.vec.Vec.from [0#i64, 1#i64] (b...
[ { "input": "[[[1, 0], [0, 1]]]", "output": "2" }, { "input": "[[[1, 0, 0], [0, 0, 1], [1, 0, 0]]]", "output": "1" }, { "input": "[[[0, 0, 0], [0, 0, 0], [0, 0, 0]]]", "output": "0" }, { "input": "[[[1, 0, 0], [0, 1, 0], [0, 0, 1]]]", "output": "3" }, { "input": "[...
70
false
70
verified
10
10
1
1,152
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.NumSpecial.Code.Funs /-! # Specifications of `Aegis.NumSpecial.num_special` LeetCode problem `special-positions-in-a-binary-matrix`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.NumSpecial abbrev Mat : Type := Slice (alloc.vec.Vec I6...
10
count-unhappy-friends
1,583
Medium
[ "Array", "Simulation" ]
You are given a list of preferences for n friends, where n is always even. For each person i, preferences[i] contains a list of friends sorted in the order of preference. In other words, a friend earlier in the list is more preferred than a friend later in the list. Friends in each list are denoted by integers from 0 t...
unhappyFriends(n: int, preferences: list_list_int, pairs: list_list_int) -> int
pub fn unhappy_friends(n: i64, preferences: &[Vec<i64>], pairs: &[Vec<i64>]) -> i64
Aegis.UnhappyFriends.unhappy_friends
pub fn unhappy_friends(n: i64, preferences: &[Vec<i64>], pairs: &[Vec<i64>]) -> i64 { let nn = n as usize; let mut partner: Vec<i64> = Vec::new(); let mut i = 0usize; while i < nn { partner.push(-1); i += 1; } let mut p = 0usize; while p < pairs.len() { let a = pair...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [unhappy_friends]: type definitions module public import Aeneas @[expose] public section 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 -- [unhappy_friends]: function definitions module public import Aeneas public import Aegis.UnhappyFriends.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.UnhappyFriends.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.UnhappyFriends.unhappy_friends 2#i64 (Slice.from [(alloc.vec.Vec.from [1#i64] (by scalar_tac) : alloc.vec.Vec Std.I64), (alloc.vec.Vec.from [0#i64...
[ { "input": "[2, [[1], [0]], [[1, 0]]]", "output": "0" }, { "input": "[4, [[1, 3, 2], [2, 3, 0], [1, 3, 0], [0, 2, 1]], [[1, 3], [0, 2]]]", "output": "4" }, { "input": "[4, [[1, 2, 3], [3, 2, 0], [3, 1, 0], [1, 2, 0]], [[0, 1], [2, 3]]]", "output": "2" }, { "input": "[6, [[1, ...
37
false
37
verified
10
10
1
6,379
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.UnhappyFriends.Code.Funs /-! # Specifications of `Aegis.UnhappyFriends.unhappy_friends` LeetCode problem `count-unhappy-friends`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.UnhappyFriends def NRange (n : I64) : Prop := n.val % 2 ...
12
min-cost-to-connect-all-points
1,584
Medium
[ "Union Find", "Graph", "Array", "Minimum Spanning Tree" ]
You are given an array points representing integer coordinates of some points on a 2D-plane, where points[i] = [xi, yi]. The cost of connecting two points [xi, yi] and [xj, yj] is the manhattan distance between them: |xi - xj| + |yi - yj|, where |val| denotes the absolute value of val. Return the minimum cost to make a...
minCostConnectPoints(points: list_list_int) -> int
pub fn min_cost_connect_points(points: &[Vec<i64>]) -> i64
Aegis.MinCostConnectPoints.min_cost_connect_points
fn abs_i64(x: i64) -> i64 { if x < 0 { -x } else { x } } fn manhattan(points: &[Vec<i64>], i: usize, j: usize) -> i64 { let dx: i64 = points[i][0] - points[j][0]; let dy: i64 = points[i][1] - points[j][1]; abs_i64(dx) + abs_i64(dy) } // Select the unused vertex with the smalles...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [min_cost_connect_points]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_opti...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [min_cost_connect_points]: function definitions module public import Aeneas public import Aegis.MinCostConnectPoints.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashComman...
import Aegis.MinCostConnectPoints.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.MinCostConnectPoints.min_cost_connect_points (Slice.from [(alloc.vec.Vec.from [(-1000000)#i64, (-1000000)#i64] (by scalar_tac) : alloc.vec.V...
[ { "input": "[[[-1000000, -1000000], [1000000, 1000000]]]", "output": "4000000" }, { "input": "[[[-1000000, 1000000], [1000000, -1000000], [0, 0]]]", "output": "4000000" }, { "input": "[[[3, 12], [-2, 5], [-4, 1]]]", "output": "18" }, { "input": "[[[1000000, -1000000], [-10000...
104
false
104
verified
10
10
4
41,492
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MinCostConnectPoints.Code.Funs /-! # Specifications of `Aegis.MinCostConnectPoints.min_cost_connect_points` LeetCode problem `min-cost-to-connect-all-points`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.MinCostConnectPoints open Aeg...
17
sum-of-all-odd-length-subarrays
1,588
Easy
[ "Array", "Math", "Prefix Sum" ]
Given an array of positive integers arr, return the sum of all possible odd-length subarrays of arr. A subarray is a contiguous subsequence of the array.   Example 1: Input: arr = [1,4,2,5,3] Output: 58 Explanation: The odd-length subarrays of arr and their sums are: [1] = 1 [4] = 4 [2] = 2 [5] = 5 [3] = 3 [1,4,2] = 7...
sumOddLengthSubarrays(arr: list_int) -> int
pub fn sum_odd_length_subarrays(arr: &[i64]) -> i64
Aegis.SumOddLengthSubarrays.sum_odd_length_subarrays
pub fn sum_odd_length_subarrays(arr: &[i64]) -> i64 { let n: usize = arr.len(); let mut total: i64 = 0; let mut i: usize = 0; while i < n { let mut j: usize = i; let mut current_sum: i64 = 0; while j < n { current_sum += arr[j]; let length: usize = j - i...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [sum_odd_length_subarrays]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_opt...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [sum_odd_length_subarrays]: function definitions module public import Aeneas public import Aegis.SumOddLengthSubarrays.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashComm...
import Aegis.SumOddLengthSubarrays.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.SumOddLengthSubarrays.sum_odd_length_subarrays (Slice.from [5#i64] (by scalar_tac) : Slice Std.I64)) (5#i64))}") #eval (s!"CASE 1 {(Result....
[ { "input": "[[5]]", "output": "5" }, { "input": "[[1]]", "output": "1" }, { "input": "[[7]]", "output": "7" }, { "input": "[[1, 2]]", "output": "3" }, { "input": "[[10, 11, 12]]", "output": "66" }, { "input": "[[100, 200, 300]]", "output": "1200" ...
104
false
104
verified
10
10
1
547
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.SumOddLengthSubarrays.Code.Funs /-! # Specifications of `Aegis.SumOddLengthSubarrays.sum_odd_length_subarrays` LeetCode problem `sum-of-all-odd-length-subarrays`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.SumOddLengthSubarrays ...
11
make-sum-divisible-by-p
1,590
Medium
[ "Array", "Hash Table", "Prefix Sum" ]
Given an array of positive integers nums, remove the smallest subarray (possibly empty) such that the sum of the remaining elements is divisible by p. It is not allowed to remove the whole array. Return the length of the smallest subarray that you need to remove, or -1 if it's impossible. A subarray is defined as a con...
minSubarray(nums: list_int, p: int) -> int
pub fn min_subarray(nums: &[i64], p: i64) -> i64
Aegis.MinSubarray.min_subarray
pub fn min_subarray(nums: &[i64], p: i64) -> i64 { let n = nums.len(); let mut pref: Vec<i64> = Vec::new(); pref.push(0); let mut i = 0; while i < n { let cur = pref[i]; let val = nums[i] % p; let next = (cur + val) % p; pref.push(next); i += 1; } l...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [min_subarray]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter.s...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [min_subarray]: function definitions module public import Aeneas public import Aegis.MinSubarray.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.MinSubarray.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.MinSubarray.min_subarray (Slice.from [1000000000#i64] (by scalar_tac) : Slice Std.I64) 1000000000#i64) (0#i64))}") #eval (s!"CASE 1 {(Result.reducesT...
[ { "input": "[[1000000000], 1000000000]", "output": "0" }, { "input": "[[1], 1]", "output": "0" }, { "input": "[[10, 11, 12], 6]", "output": "2" }, { "input": "[[1, 2, 3], 3]", "output": "0" }, { "input": "[[1000000000, 1000000000, 1000000000], 3000000000]", "o...
76
false
76
verified
10
10
1
9,811
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MinSubarray.Code.Funs /-! # Specifications of `Aegis.MinSubarray.min_subarray` LeetCode problem `make-sum-divisible-by-p`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.MinSubarray def vals (nums : Slice I64) : List ℤ := nums.val.map ...
10
strange-printer-ii
1,591
Hard
[ "Graph", "Topological Sort", "Array", "Matrix" ]
There is a strange printer with the following two special requirements: On each turn, the printer will print a solid rectangular pattern of a single color on the grid. This will cover up the existing colors in the rectangle. Once the printer has used a color for the above operation, the same color cannot be used again...
isPrintable(targetGrid: list_list_int) -> bool
pub fn is_printable(targetGrid: &[Vec<i64>]) -> bool
Aegis.IsPrintable.is_printable
pub fn is_printable(targetGrid: &[Vec<i64>]) -> bool { let m = targetGrid.len(); if m == 0 { return true; } let n = targetGrid[0].len(); if n == 0 { return true; } let mut max_color: i64 = 0; let mut i = 0; while i < m { let row = &targetGrid[i]; let ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [is_printable]: type definitions module public import Aeneas @[expose] public section 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_printable]: function definitions module public import Aeneas public import Aegis.IsPrintable.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.IsPrintable.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.IsPrintable.is_printable (Slice.from [(alloc.vec.Vec.from [1#i64, 1#i64] (by scalar_tac) : alloc.vec.Vec Std.I64), (alloc.vec.Vec.from [1#i64, 1#i64]...
[ { "input": "[[[1, 1], [1, 1], [2, 2], [2, 2]]]", "output": "true" }, { "input": "[[[1, 2, 3], [4, 5, 6], [7, 8, 9]]]", "output": "true" }, { "input": "[[[1, 1, 1], [1, 1, 1], [1, 1, 1]]]", "output": "true" }, { "input": "[[[1, 2, 1], [2, 1, 2], [1, 2, 1]]]", "output": "fa...
65
false
65
verified
10
10
1
11,865
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.IsPrintable.Code.Funs /-! # Specifications of `Aegis.IsPrintable.is_printable` LeetCode problem `strange-printer-ii`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.IsPrintable namespace AegisSpec.IsPrintable abbrev Grid : Type := Slice (...
12
split-a-string-into-the-max-number-of-unique-substrings
1,593
Medium
[ "Hash Table", "String", "Backtracking" ]
Given a string s, return the maximum number of unique substrings that the given string can be split into. You can split string s into any list of non-empty substrings, where the concatenation of the substrings forms the original string. However, you must split the substrings such that all of them are unique. A substrin...
maxUniqueSplit(s: str) -> int
pub fn max_unique_split(s: &[u8]) -> i64
Aegis.MaxUniqueSplit.max_unique_split
fn substring_used( starts: &[usize], ends: &[usize], used_len: usize, s: &[u8], start: usize, end: usize, ) -> bool { let len = end - start; let mut i = 0usize; while i < used_len { let s2 = starts[i]; let e2 = ends[i]; if e2 - s2 == len { let mut ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [max_unique_split]: type definitions module public import Aeneas @[expose] public section 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_unique_split]: function definitions module public import Aeneas public import Aegis.MaxUniqueSplit.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.MaxUniqueSplit.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.MaxUniqueSplit.max_unique_split (Slice.from [97#u8, 97#u8, 97#u8, 97#u8, 98#u8, 98#u8, 98#u8, 98#u8] (by scalar_tac) : Slice Std.U8)) (5#i64))}") ...
[ { "input": "[\"aaaabbbb\"]", "output": "5" }, { "input": "[\"abcdefghijklmnopqrstuvwxyz\"]", "output": "26" }, { "input": "[\"abac\"]", "output": "3" }, { "input": "[\"abcdef\"]", "output": "6" }, { "input": "[\"aaaaaaaab\"]", "output": "4" }, { "input...
102
false
102
verified
10
10
1
14,694
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MaxUniqueSplit.Code.Funs /-! # Specifications of `Aegis.MaxUniqueSplit.max_unique_split` LeetCode problem `split-a-string-into-the-max-number-of-unique-substrings`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.MaxUniqueSplit def ...
12
maximum-non-negative-product-in-a-matrix
1,594
Medium
[ "Array", "Dynamic Programming", "Matrix" ]
You are given a m x n matrix grid. Initially, you are located at the top-left corner (0, 0), and in each step, you can only move right or down in the matrix. Among all possible paths starting from the top-left corner (0, 0) and ending in the bottom-right corner (m - 1, n - 1), find the path with the maximum non-negativ...
maxProductPath(grid: list_list_int) -> int
pub fn max_product_path(grid: &[Vec<i64>]) -> i64
Aegis.MaxProductPath.max_product_path
pub fn max_product_path(grid: &[Vec<i64>]) -> i64 { let m = grid.len(); let n = grid[0].len(); let mut max_dp: Vec<Vec<i64>> = Vec::new(); let mut min_dp: Vec<Vec<i64>> = Vec::new(); let mut i = 0; while i < m { let mut row_max: Vec<i64> = Vec::new(); let mut row_min: Vec<i64> ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [max_product_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 lint...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [max_product_path]: function definitions module public import Aeneas public import Aegis.MaxProductPath.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.MaxProductPath.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.MaxProductPath.max_product_path (Slice.from [(alloc.vec.Vec.from [(-1)#i64, 0#i64] (by scalar_tac) : alloc.vec.Vec Std.I64), (alloc.vec.Vec.from [...
[ { "input": "[[[-1, 0], [-8, -2]]]", "output": "0" }, { "input": "[[[-1, 0], [-2, -1]]]", "output": "0" }, { "input": "[[[-4, 3], [-3, -4]]]", "output": "48" }, { "input": "[[[0, 0], [0, 0]]]", "output": "0" }, { "input": "[[[-1, 2], [-3, 4]]]", "output": "12" ...
111
false
111
verified
10
10
1
2,382
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MaxProductPath.Code.Funs /-! # Specifications of `Aegis.MaxProductPath.max_product_path` LeetCode problem `maximum-non-negative-product-in-a-matrix`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.MaxProductPath def gridCells (grid...
7
minimum-cost-to-connect-two-groups-of-points
1,595
Hard
[ "Bit Manipulation", "Array", "Dynamic Programming", "Bitmask", "Matrix" ]
You are given two groups of points where the first group has size1 points, the second group has size2 points, and size1 >= size2. The cost of the connection between any two points are given in an size1 x size2 matrix where cost[i][j] is the cost of connecting point i of the first group and point j of the second group. ...
connectTwoGroups(cost: list_list_int) -> int
pub fn connect_two_groups(cost: &[Vec<i64>]) -> i64
Aegis.ConnectTwoGroups.connect_two_groups
pub fn connect_two_groups(cost: &[Vec<i64>]) -> i64 { let n: usize = cost.len(); let m: usize = cost[0].len(); let full: usize = 1usize << m; let inf: i64 = 1000000000; let mut dp: Vec<i64> = Vec::new(); let mut s: usize = 0; while s < full { dp.push(inf); s += 1; } ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [connect_two_groups]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option li...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [connect_two_groups]: function definitions module public import Aeneas public import Aegis.ConnectTwoGroups.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.ConnectTwoGroups.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.ConnectTwoGroups.connect_two_groups (Slice.from [(alloc.vec.Vec.from [15#i64, 96#i64] (by scalar_tac) : alloc.vec.Vec Std.I64), (alloc.vec.Vec.f...
[ { "input": "[[[15, 96], [36, 2]]]", "output": "17" }, { "input": "[[[10, 20], [30, 40], [50, 60]]]", "output": "100" }, { "input": "[[[5, 5, 5], [5, 5, 5]]]", "output": "15" }, { "input": "[[[1, 3, 5], [4, 1, 1], [1, 5, 3]]]", "output": "4" }, { "input": "[[[1, 2]...
8
false
8
verified
8
8
1
8,247
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.ConnectTwoGroups.Code.Funs /-! # Specifications of `Aegis.ConnectTwoGroups.connect_two_groups` LeetCode problem `minimum-cost-to-connect-two-groups-of-points`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.ConnectTwoGroups namespace AegisSpec.C...
13
maximum-profit-of-operating-a-centennial-wheel
1,599
Medium
[ "Array", "Simulation" ]
You are the operator of a Centennial Wheel that has four gondolas, and each gondola has room for up to four people. You have the ability to rotate the gondolas counterclockwise, which costs you runningCost dollars. You are given an array customers of length n where customers[i] is the number of new customers arriving j...
minOperationsMaxProfit(customers: list_int, boardingCost: int, runningCost: int) -> int
pub fn min_operations_max_profit(customers: &[i64], boardingCost: i64, runningCost: i64) -> i64
Aegis.MinOperationsMaxProfit.min_operations_max_profit
pub fn min_operations_max_profit(customers: &[i64], boardingCost: i64, runningCost: i64) -> i64 { let n: usize = customers.len(); let mut i: usize = 0; let mut waiting: i64 = 0; let mut profit: i64 = 0; let mut max_profit: i64 = 0; let mut best: i64 = -1; let mut rotations: i64 = 0; whi...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [min_operations_max_profit]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_op...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [min_operations_max_profit]: function definitions module public import Aeneas public import Aegis.MinOperationsMaxProfit.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCo...
import Aegis.MinOperationsMaxProfit.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.MinOperationsMaxProfit.min_operations_max_profit (Slice.from [8#i64, 3#i64] (by scalar_tac) : Slice Std.I64) 5#i64 6#i64) (3#i64))}") #eva...
[ { "input": "[[8, 3], 5, 6]", "output": "3" }, { "input": "[[10, 9, 6], 6, 4]", "output": "7" }, { "input": "[[0, 0, 0, 0], 10, 5]", "output": "-1" }, { "input": "[[0, 0, 0, 0], 10, 1]", "output": "-1" }, { "input": "[[50, 50, 50, 50], 2, 1]", "output": "50" ...
55
false
55
verified
10
10
1
2,806
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MinOperationsMaxProfit.Code.Funs /-! # Specifications of `Aegis.MinOperationsMaxProfit.min_operations_max_profit` LeetCode problem `maximum-profit-of-operating-a-centennial-wheel`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.MinOpera...
13
maximum-number-of-achievable-transfer-requests
1,601
Hard
[ "Bit Manipulation", "Array", "Backtracking", "Enumeration" ]
We have n buildings numbered from 0 to n - 1. Each building has a number of employees. It's transfer season, and some employees want to change the building they reside in. You are given an array requests where requests[i] = [fromi, toi] represents an employee's request to transfer from building fromi to building toi. A...
maximumRequests(n: int, requests: list_list_int) -> int
pub fn maximum_requests(n: i64, requests: &[Vec<i64>]) -> i64
Aegis.MaximumRequests.maximum_requests
pub fn maximum_requests(n: i64, requests: &[Vec<i64>]) -> i64 { let m: usize = requests.len(); let n_usize: usize = n as usize; let m_i64: i64 = m as i64; let mut total: usize = 1; let mut e: usize = 0; while e < m { total = total * 2; e += 1; } let mut balances: Vec<i6...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [maximum_requests]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option lint...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [maximum_requests]: function definitions module public import Aeneas public import Aegis.MaximumRequests.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.MaximumRequests.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.MaximumRequests.maximum_requests 2#i64 (Slice.from [(alloc.vec.Vec.from [0#i64, 0#i64] (by scalar_tac) : alloc.vec.Vec Std.I64), (alloc.vec.Vec.f...
[ { "input": "[2, [[0, 0], [1, 1]]]", "output": "2" }, { "input": "[2, [[0, 1], [1, 0]]]", "output": "2" }, { "input": "[3, [[0, 0], [1, 2], [2, 1]]]", "output": "3" }, { "input": "[4, [[0, 3], [3, 1], [1, 2], [2, 0]]]", "output": "4" }, { "input": "[3, [[0, 1], [1,...
71
false
71
verified
10
10
1
2,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.MaximumRequests.Code.Funs /-! # Specifications of `Aegis.MaximumRequests.maximum_requests` LeetCode problem `maximum-number-of-achievable-transfer-requests`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.MaximumRequests set_option autoImpli...
14
find-valid-matrix-given-row-and-column-sums
1,605
Medium
[ "Greedy", "Array", "Matrix" ]
You are given two arrays rowSum and colSum of non-negative integers where rowSum[i] is the sum of the elements in the ith row and colSum[j] is the sum of the elements of the jth column of a 2D matrix. In other words, you do not know the elements of the matrix, but you do know the sums of each row and column. Find any m...
restoreMatrix(rowSum: list_int, colSum: list_int) -> list_list_int
pub fn restore_matrix(rowSum: &[i64], colSum: &[i64]) -> Vec<Vec<i64>>
Aegis.RestoreMatrix.restore_matrix
pub fn restore_matrix(rowSum: &[i64], colSum: &[i64]) -> Vec<Vec<i64>> { let n = rowSum.len(); let m = colSum.len(); let mut rem_row: Vec<i64> = Vec::new(); let mut i = 0; while i < n { rem_row.push(rowSum[i]); i += 1; } let mut rem_col: Vec<i64> = Vec::new(); let mut j...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [restore_matrix]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [restore_matrix]: function definitions module public import Aeneas public import Aegis.RestoreMatrix.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.RestoreMatrix.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.RestoreMatrix.restore_matrix (Slice.from [10#i64, 15#i64] (by scalar_tac) : Slice Std.I64) (Slice.from [12#i64, 13#i64] (by scalar_tac) : Slice Std...
[ { "input": "[[10, 15], [12, 13]]", "output": "[[10, 0], [2, 13]]" }, { "input": "[[10, 20], [15, 15]]", "output": "[[10, 0], [5, 15]]" }, { "input": "[[0, 0], [0, 0]]", "output": "[[0, 0], [0, 0]]" }, { "input": "[[1, 2], [3, 0]]", "output": "[[1, 0], [2, 0]]" }, { ...
113
false
113
verified
10
10
1
8,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.RestoreMatrix.Code.Funs /-! # Specifications of `Aegis.RestoreMatrix.restore_matrix` LeetCode problem `find-valid-matrix-given-row-and-column-sums`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.RestoreMatrix set_option autoImplic...
12
special-array-with-x-elements-greater-than-or-equal-x
1,608
Easy
[ "Array", "Binary Search", "Sorting" ]
You are given an array nums of non-negative integers. nums is considered special if there exists a number x such that there are exactly x numbers in nums that are greater than or equal to x. Notice that x does not have to be an element in nums. Return x if the array is special, otherwise, return -1. It can be proven th...
specialArray(nums: list_int) -> int
pub fn special_array(nums: &[i64]) -> i64
Aegis.SpecialArray.special_array
pub fn special_array(nums: &[i64]) -> i64 { let n: i64 = nums.len() as i64; let mut x: i64 = 0; while x <= n { let mut count: i64 = 0; let mut i: usize = 0; while i < nums.len() { if nums[i] >= x { count += 1; } i += 1; } ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [special_array]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter....
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [special_array]: function definitions module public import Aeneas public import Aegis.SpecialArray.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.SpecialArray.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.SpecialArray.special_array (Slice.from [1#i64] (by scalar_tac) : Slice Std.I64)) (1#i64))}") #eval (s!"CASE 1 {(Result.reducesTo (Aegis.SpecialArray...
[ { "input": "[[1]]", "output": "1" }, { "input": "[[1000]]", "output": "1" }, { "input": "[[0]]", "output": "-1" }, { "input": "[[0, 0]]", "output": "-1" }, { "input": "[[3, 5]]", "output": "2" }, { "input": "[[1000, 1000, 1000]]", "output": "3" }...
75
false
75
verified
10
10
1
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.SpecialArray.Code.Funs /-! # Specifications of `Aegis.SpecialArray.special_array` LeetCode problem `special-array-with-x-elements-greater-than-or-equal-x`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.SpecialArray (special_array) namespace Ae...
14
even-odd-tree
1,609
Medium
[ "Tree", "Breadth-First Search", "Binary Tree" ]
A binary tree is named Even-Odd if it meets the following conditions: The root of the binary tree is at level index 0, its children are at level index 1, their children are at level index 2, etc. For every even-indexed level, all nodes at the level have odd integer values in strictly increasing order (from left to rig...
isEvenOddTree(root: tree) -> bool
pub fn is_even_odd_tree(root: &Tree) -> bool
Aegis.IsEvenOddTree.is_even_odd_tree
fn check_tree( t: &Tree, level: usize, even_level: bool, prev: &mut Vec<i64>, seen: &mut Vec<bool>, ) -> bool { match t { Tree::Null => true, Tree::Node(vbox, left, right) => { let v = *vbox; while seen.len() <= level { prev.push(0); ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [is_even_odd_tree]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option lint...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [is_even_odd_tree]: function definitions module public import Aeneas public import Aegis.IsEvenOddTree.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.IsEvenOddTree.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.IsEvenOddTree.is_even_odd_tree ((.Node 1#i64 (.Null) (.Null)) : Aegis.IsEvenOddTree.Tree)) (true))}") #eval (s!"CASE 1 {(Result.reducesTo (Aegis.Is...
[ { "input": "[[1]]", "output": "true" }, { "input": "[[1, 2, 3]]", "output": "false" }, { "input": "[[2, 2, 2]]", "output": "false" }, { "input": "[[1, 3, 5, 7, 9]]", "output": "false" }, { "input": "[[5, 4, 2, 3, 3, 7]]", "output": "false" }, { "input"...
47
false
47
verified
10
10
2
10,107
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.IsEvenOddTree.Code.Funs /-! # Specifications of `Aegis.IsEvenOddTree.is_even_odd_tree` LeetCode problem `even-odd-tree`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.IsEvenOddTree open Aegis.IsEvenOddTree def nodeCount : Tree ...
12
minimum-one-bit-operations-to-make-integers-zero
1,611
Hard
[ "Bit Manipulation", "Memoization", "Dynamic Programming" ]
Given an integer n, you must transform it into 0 using the following operations any number of times: Change the rightmost (0th) bit in the binary representation of n. Change the ith bit in the binary representation of n if the (i-1)th bit is set to 1 and the (i-2)th through 0th bits are set to 0. Return the minimum n...
minimumOneBitOperations(n: int) -> int
pub fn minimum_one_bit_operations(n: i64) -> i64
Aegis.MinimumOneBitOperations.minimum_one_bit_operations
pub fn minimum_one_bit_operations(n: i64) -> i64 { let mut x = n; let mut ans: i64 = 0; while x > 0 { ans = ans ^ x; x = x >> 1; } ans }
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [minimum_one_bit_operations]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_o...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [minimum_one_bit_operations]: function definitions module public import Aeneas public import Aegis.MinimumOneBitOperations.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hash...
import Aegis.MinimumOneBitOperations.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.MinimumOneBitOperations.minimum_one_bit_operations 0#i64) (0#i64))}") #eval (s!"CASE 1 {(Result.reducesTo (Aegis.MinimumOneBitOperations....
[ { "input": "[0]", "output": "0" }, { "input": "[8]", "output": "15" }, { "input": "[3]", "output": "2" }, { "input": "[100]", "output": "71" }, { "input": "[15]", "output": "10" }, { "input": "[16]", "output": "31" }, { "input": "[31]", ...
71
false
71
verified
10
10
1
804
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MinimumOneBitOperations.Code.Funs /-! # Specifications of `Aegis.MinimumOneBitOperations.minimum_one_bit_operations` LeetCode problem `minimum-one-bit-operations-to-make-integers-zero`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.M...
10
maximum-nesting-depth-of-the-parentheses
1,614
Easy
[ "Stack", "String" ]
Given a valid parentheses string s, return the nesting depth of s. The nesting depth is the maximum number of nested parentheses.   Example 1: Input: s = "(1+(2*3)+((8)/4))+1" Output: 3 Explanation: Digit 8 is inside of 3 nested parentheses in the string. Example 2: Input: s = "(1)+((2))+(((3)))" Output: 3 Explanati...
maxDepth(s: str) -> int
pub fn max_depth(s: &[u8]) -> i64
Aegis.MaxDepth.max_depth
pub fn max_depth(s: &[u8]) -> i64 { let n = s.len(); let mut depth: i64 = 0; let mut max_d: i64 = 0; let mut i: usize = 0; while i < n { let c = s[i]; if c == b'(' { depth += 1; if depth > max_d { max_d = depth; } } else if...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [max_depth]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter.styl...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [max_depth]: function definitions module public import Aeneas public import Aegis.MaxDepth.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.MaxDepth.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.MaxDepth.max_depth (Slice.from [40#u8, 49#u8, 43#u8, 40#u8, 50#u8, 42#u8, 51#u8, 41#u8, 43#u8, 40#u8, 40#u8, 56#u8, 41#u8, 47#u8, 52#u8, 41#u8, 41#u8, 4...
[ { "input": "[\"(1+(2*3)+((8)/4))+1\"]", "output": "3" }, { "input": "[\"(a+(b*c)+((d/e)+f))\"]", "output": "3" }, { "input": "[\"()()()\"]", "output": "1" }, { "input": "[\"(a+b)+((c*d)+e)\"]", "output": "2" }, { "input": "[\"(1+2)\"]", "output": "1" }, { ...
101
false
101
verified
10
10
1
406
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MaxDepth.Code.Funs /-! # Specifications of `Aegis.MaxDepth.max_depth` LeetCode problem `maximum-nesting-depth-of-the-parentheses`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.MaxDepth def openByte : Nat := 40 def closeByte : Nat :=...
13
count-subtrees-with-max-distance-between-cities
1,617
Hard
[ "Bit Manipulation", "Tree", "Dynamic Programming", "Bitmask", "Enumeration" ]
There are n cities numbered from 1 to n. You are given an array edges of size n-1, where edges[i] = [ui, vi] represents a bidirectional edge between cities ui and vi. There exists a unique path between each pair of cities. In other words, the cities form a tree.\r \r A subtree is a subset of cities where every city is ...
countSubgraphsForEachDiameter(n: int, edges: list_list_int) -> list_int
pub fn count_subgraphs_for_each_diameter(n: i64, edges: &[Vec<i64>]) -> Vec<i64>
Aegis.CountSubgraphsForEachDiameter.count_subgraphs_for_each_diameter
pub fn count_subgraphs_for_each_diameter(n: i64, edges: &[Vec<i64>]) -> Vec<i64> { let n_usize: usize = n as usize; let mut ans: Vec<i64> = Vec::new(); let mut d: i64 = 1; while d < n { ans.push(0); d += 1; } let mut adj: Vec<i64> = Vec::new(); let total_cells: usize = n_us...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [count_subgraphs_for_each_diameter]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables fals...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [count_subgraphs_for_each_diameter]: function definitions module public import Aeneas public import Aegis.CountSubgraphsForEachDiameter.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_optio...
import Aegis.CountSubgraphsForEachDiameter.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.CountSubgraphsForEachDiameter.count_subgraphs_for_each_diameter 2#i64 (Slice.from [(alloc.vec.Vec.from [1#i64, 2#i64] (by scalar_ta...
[ { "input": "[2, [[1, 2]]]", "output": "[1]" }, { "input": "[3, [[1, 2], [2, 3]]]", "output": "[2, 1]" }, { "input": "[4, [[1, 2], [2, 3], [2, 4]]]", "output": "[3, 4, 0]" }, { "input": "[5, [[1, 2], [2, 3], [3, 4], [4, 5]]]", "output": "[4, 3, 2, 1]" }, { "input":...
45
false
45
verified
10
10
1
9,935
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.CountSubgraphsForEachDiameter.Code.Funs /-! # Specifications of `Aegis.CountSubgraphsForEachDiameter.count_subgraphs_for_each_diameter` LeetCode problem `count-subtrees-with-max-distance-between-cities`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result names...
13
number-of-sets-of-k-non-overlapping-line-segments
1,621
Medium
[ "Math", "Dynamic Programming", "Combinatorics" ]
Given n points on a 1-D plane, where the ith point (from 0 to n-1) is at x = i, find the number of ways we can draw exactly k non-overlapping line segments such that each segment covers two or more points. The endpoints of each segment must have integral coordinates. The k line segments do not have to cover all n point...
numberOfSets(n: int, k: int) -> int
pub fn number_of_sets(n: i64, k: i64) -> i64
Aegis.NumberOfSets.number_of_sets
const MOD: i64 = 1_000_000_007; fn pow_mod(mut base: i64, mut exp: i64) -> i64 { let mut result: i64 = 1; while exp > 0 { if exp % 2 == 1 { result = (result * base) % MOD; } base = (base * base) % MOD; exp = exp / 2; } result } pub fn number_of_sets(n: i64, ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [number_of_sets]: type definitions module public import Aeneas @[expose] public section 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_sets]: function definitions module public import Aeneas public import Aegis.NumberOfSets.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.NumberOfSets.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval aegisCas...
[ { "input": "[3, 1]", "output": "3" }, { "input": "[1000, 500]", "output": "70047606" }, { "input": "[30, 7]", "output": "796297179" }, { "input": "[6, 3]", "output": "28" }, { "input": "[8, 4]", "output": "165" }, { "input": "[5, 2]", "output": "15...
58
false
58
verified
10
10
2
4,923
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.NumberOfSets.Code.Funs /-! # Specifications of `Aegis.NumberOfSets.number_of_sets` LeetCode problem `number-of-sets-of-k-non-overlapping-line-segments`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result ControlFlow Error namespace AegisSpec.NumberOfSets abbr...
12
largest-substring-between-two-equal-characters
1,624
Easy
[ "Hash Table", "String" ]
Given a string s, return the length of the longest substring between two equal characters, excluding the two characters. If there is no such substring return -1. A substring is a contiguous sequence of characters within a string.   Example 1: Input: s = "aa" Output: 0 Explanation: The optimal substring here is an empt...
maxLengthBetweenEqualCharacters(s: str) -> int
pub fn max_length_between_equal_characters(s: &[u8]) -> i64
Aegis.MaxLengthBetweenEqualCharacters.max_length_between_equal_characters
pub fn max_length_between_equal_characters(s: &[u8]) -> i64 { let n = s.len(); let mut best: i64 = -1; let mut i: usize = 0; while i < n { let mut j: usize = i + 1; while j < n { if s[i] == s[j] { let between: i64 = (j - i - 1) as i64; if betw...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [max_length_between_equal_characters]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables fa...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [max_length_between_equal_characters]: function definitions module public import Aeneas public import Aegis.MaxLengthBetweenEqualCharacters.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_o...
import Aegis.MaxLengthBetweenEqualCharacters.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.MaxLengthBetweenEqualCharacters.max_length_between_equal_characters (Slice.from [97#u8, 97#u8, 98#u8, 98#u8, 97#u8, 97#u8] (by sc...
[ { "input": "[\"aabbaa\"]", "output": "4" }, { "input": "[\"xyzx\"]", "output": "2" }, { "input": "[\"a\"]", "output": "-1" }, { "input": "[\"aa\"]", "output": "0" }, { "input": "[\"abcda\"]", "output": "3" }, { "input": "[\"abcabc\"]", "output": "2...
74
false
74
verified
10
10
1
669
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MaxLengthBetweenEqualCharacters.Code.Funs /-! # Specifications of `Aegis.MaxLengthBetweenEqualCharacters.max_length_between_equal_characters` LeetCode problem `largest-substring-between-two-equal-characters`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result ...
12
graph-connectivity-with-threshold
1,627
Hard
[ "Union Find", "Array", "Math", "Number Theory" ]
We have n cities labeled from 1 to n. Two different cities with labels x and y are directly connected by a bidirectional road if and only if x and y share a common divisor strictly greater than some threshold. More formally, cities with labels x and y have a road between them if there exists an integer z such that all ...
areConnected(n: int, threshold: int, queries: list_list_int) -> list_bool
pub fn are_connected(n: i64, threshold: i64, queries: &[Vec<i64>]) -> Vec<bool>
Aegis.AreConnected.are_connected
fn find(parent: &mut Vec<i64>, x: i64) -> i64 { let mut cur = x; while parent[cur as usize] != cur { let p = parent[cur as usize]; let gp = parent[p as usize]; parent[cur as usize] = gp; cur = gp; } cur } fn union(parent: &mut Vec<i64>, size: &mut Vec<i64>, a: i64, b: i6...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [are_connected]: type definitions module public import Aeneas @[expose] public section 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 -- [are_connected]: function definitions module public import Aeneas public import Aegis.AreConnected.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.AreConnected.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval aegisCas...
[ { "input": "[100, 99, [[1, 100]]]", "output": "[false]" }, { "input": "[100, 50, [[1, 2], [51, 100], [49, 99]]]", "output": "[false, false, false]" }, { "input": "[6, 2, [[1, 4], [2, 5], [3, 6]]]", "output": "[false, false, true]" }, { "input": "[5000, 1000, [[1000, 2000], [3...
63
false
63
verified_partial
10
3
2
36,424
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.AreConnected.Code.Funs /-! # Specifications of `Aegis.AreConnected.are_connected` LeetCode problem `graph-connectivity-with-threshold`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.AreConnected namespace AegisSpec.AreConnected def Adjacent (t...
16
path-with-minimum-effort
1,631
Medium
[ "Depth-First Search", "Breadth-First Search", "Union Find", "Array", "Binary Search", "Matrix", "Heap (Priority Queue)" ]
You are a hiker preparing for an upcoming hike. You are given heights, a 2D array of size rows x columns, where heights[row][col] represents the height of cell (row, col). You are situated in the top-left cell, (0, 0), and you hope to travel to the bottom-right cell, (rows-1, columns-1) (i.e., 0-indexed). You can move ...
minimumEffortPath(heights: list_list_int) -> int
pub fn minimum_effort_path(heights: &[Vec<i64>]) -> i64
Aegis.MinimumEffortPath.minimum_effort_path
pub fn minimum_effort_path(heights: &[Vec<i64>]) -> i64 { let rows = heights.len(); if rows == 0 { return 0; } let cols = heights[0].len(); if cols == 0 { return 0; } if rows == 1 && cols == 1 { return 0; } let mut lo: i64 = 0; let mut hi: i64 = 1_000_000...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [minimum_effort_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 l...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [minimum_effort_path]: function definitions module public import Aeneas public import Aegis.MinimumEffortPath.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false...
import Aegis.MinimumEffortPath.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.MinimumEffortPath.minimum_effort_path (Slice.from [(alloc.vec.Vec.from [1#i64, 10#i64] (by scalar_tac) : alloc.vec.Vec Std.I64), (alloc.vec.Vec...
[ { "input": "[[[1, 10], [10, 1]]]", "output": "9" }, { "input": "[[[1, 1], [1, 1]]]", "output": "0" }, { "input": "[[[1, 10, 6, 7, 9, 10, 4, 9]]]", "output": "9" }, { "input": "[[[1, 2, 3], [3, 8, 4], [5, 3, 5]]]", "output": "1" }, { "input": "[[[1, 10, 6], [1, 3, ...
69
false
69
verified
10
10
1
7,453
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MinimumEffortPath.Code.Funs /-! # Specifications of `Aegis.MinimumEffortPath.minimum_effort_path` LeetCode problem `path-with-minimum-effort`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.MinimumEffortPath def gridRows (heights : Sli...
14
rank-transform-of-a-matrix
1,632
Hard
[ "Union Find", "Graph", "Topological Sort", "Array", "Matrix", "Sorting" ]
Given an m x n matrix, return a new matrix answer where answer[row][col] is the rank of matrix[row][col]. The rank is an integer that represents how large an element is compared to other elements. It is calculated using the following rules: The rank is an integer starting from 1. If two elements p and q are in the sam...
matrixRankTransform(matrix: list_list_int) -> list_list_int
pub fn matrix_rank_transform(matrix: &[Vec<i64>]) -> Vec<Vec<i64>>
Aegis.MatrixRankTransform.matrix_rank_transform
fn dsu_find(parent: &[usize], x: usize) -> usize { let mut y = x; while parent[y] != y { y = parent[y]; } y } fn dsu_union(parent: &mut Vec<usize>, size: &mut Vec<usize>, a: usize, b: usize) { let ra = dsu_find(&parent[..], a); let rb = dsu_find(&parent[..], b); if ra != rb { ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [matrix_rank_transform]: type definitions module public import Aeneas @[expose] public section 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 -- [matrix_rank_transform]: function definitions module public import Aeneas public import Aegis.MatrixRankTransform.Code.Types public import Aegis.MatrixRankTransform.Code.FunsExternal @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [matrix_rank_transform]: external functions. -- This is a template file: rename it to "FunsExternal.lean" and fill the holes. module public import Aeneas public import Aegis.MatrixRankTransform.Code.Types @[expose] public section open Aeneas Aeneas.Std Result Contro...
import Aegis.MatrixRankTransform.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.MatrixRankTransform.matrix_rank_transform (Slice.from [(alloc.vec.Vec.from [(-1)#i64, (-2)#i64] (by scalar_tac) : alloc.vec.Vec Std.I64), (al...
[ { "input": "[[[-1, -2], [-3, -4]]]", "output": "[[3, 2], [2, 1]]" }, { "input": "[[[1, 2], [3, 4]]]", "output": "[[1, 2], [2, 3]]" }, { "input": "[[[7, 7], [7, 7]]]", "output": "[[1, 1], [1, 1]]" }, { "input": "[[[-1000000000, 1000000000], [1000000000, -1000000000]]]", "o...
96
false
96
verified
10
10
2
14,227
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MatrixRankTransform.Code.Funs /-! # Specifications of `Aegis.MatrixRankTransform.matrix_rank_transform` LeetCode problem `rank-transform-of-a-matrix`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.MatrixRankTransform open Aegis.Ma...
15
sort-array-by-increasing-frequency
1,636
Easy
[ "Array", "Hash Table", "Sorting" ]
Given an array of integers nums, sort the array in increasing order based on the frequency of the values. If multiple values have the same frequency, sort them in decreasing order. Return the sorted array.   Example 1: Input: nums = [1,1,2,2,2,3] Output: [3,1,1,2,2,2] Explanation: '3' has a frequency of 1, '1' has a f...
frequencySort(nums: list_int) -> list_int
pub fn frequency_sort(nums: &[i64]) -> Vec<i64>
Aegis.FrequencySort.frequency_sort
pub fn frequency_sort(nums: &[i64]) -> Vec<i64> { let mut counts: Vec<i64> = Vec::new(); let mut i: usize = 0; while i < 201 { counts.push(0); i += 1; } let n = nums.len(); let mut idx: usize = 0; while idx < n { let value = nums[idx]; let count_index = (valu...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [frequency_sort]: type definitions module public import Aeneas @[expose] public section 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 -- [frequency_sort]: function definitions module public import Aeneas public import Aegis.FrequencySort.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.FrequencySort.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.FrequencySort.frequency_sort (Slice.from [1#i64] (by scalar_tac) : Slice Std.I64)) ((alloc.vec.Vec.from [1#i64] (by scalar_tac) : alloc.vec.Vec Std...
[ { "input": "[[1]]", "output": "[1]" }, { "input": "[[-100, 100]]", "output": "[100, -100]" }, { "input": "[[10, 10, 20, 20, 30]]", "output": "[30, 20, 20, 10, 10]" }, { "input": "[[2, 3, 1, 3, 2]]", "output": "[1, 3, 3, 2, 2]" }, { "input": "[[100, -100, 100, -100...
117
false
117
verified
10
10
1
1,234
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.FrequencySort.Code.Funs /-! # Specifications of `Aegis.FrequencySort.frequency_sort` LeetCode problem `sort-array-by-increasing-frequency`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.FrequencySort def freq (xs : List Std.I64) (...
10
widest-vertical-area-between-two-points-containing-no-points
1,637
Easy
[ "Array", "Sorting" ]
Given n points on a 2D plane where points[i] = [xi, yi], Return the widest vertical area between two points such that no points are inside the area. A vertical area is an area of fixed-width extending infinitely along the y-axis (i.e., infinite height). The widest vertical area is the one with the maximum width. Note t...
maxWidthOfVerticalArea(points: list_list_int) -> int
pub fn max_width_of_vertical_area(points: &[Vec<i64>]) -> i64
Aegis.MaxWidthOfVerticalArea.max_width_of_vertical_area
pub fn max_width_of_vertical_area(points: &[Vec<i64>]) -> i64 { let n = points.len(); let mut xs: Vec<i64> = Vec::new(); let mut i = 0; while i < n { xs.push(points[i][0]); i += 1; } xs.sort(); let mut best = 0; let mut j = 1; while j < n { let width = xs[j...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [max_width_of_vertical_area]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_o...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [max_width_of_vertical_area]: function definitions module public import Aeneas public import Aegis.MaxWidthOfVerticalArea.Code.Types public import Aegis.MaxWidthOfVerticalArea.Code.FunsExternal @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [max_width_of_vertical_area]: external functions. -- This is a template file: rename it to "FunsExternal.lean" and fill the holes. module public import Aeneas public import Aegis.MaxWidthOfVerticalArea.Code.Types @[expose] public section open Aeneas Aeneas.Std Resul...
import Aegis.MaxWidthOfVerticalArea.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.MaxWidthOfVerticalArea.max_width_of_vertical_area (Slice.from [(alloc.vec.Vec.from [0#i64, 0#i64] (by scalar_tac) : alloc.vec.Vec Std.I64)...
[ { "input": "[[[0, 0], [1000000000, 1000000000]]]", "output": "1000000000" }, { "input": "[[[1, 1], [3, 3], [5, 5], [7, 7]]]", "output": "2" }, { "input": "[[[8, 7], [9, 9], [7, 4], [9, 7]]]", "output": "1" }, { "input": "[[[10, 10], [20, 20], [30, 30], [40, 40]]]", "outpu...
104
false
104
verified
10
10
1
606
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MaxWidthOfVerticalArea.Code.Funs /-! # Specifications of `Aegis.MaxWidthOfVerticalArea.max_width_of_vertical_area` LeetCode problem `widest-vertical-area-between-two-points-containing-no-points`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace A...
11
count-substrings-that-differ-by-one-character
1,638
Medium
[ "Hash Table", "String", "Dynamic Programming", "Enumeration" ]
Given two strings s and t, find the number of ways you can choose a non-empty substring of s and replace a single character by a different character such that the resulting substring is a substring of t. In other words, find the number of substrings in s that differ from some substring in t by exactly one character. Fo...
countSubstrings(s: str, t: str) -> int
pub fn count_substrings(s: &[u8], t: &[u8]) -> i64
Aegis.CountSubstrings.count_substrings
pub fn count_substrings(s: &[u8], t: &[u8]) -> i64 { let n = s.len(); let m = t.len(); let mut ans: i64 = 0; let mut i: usize = 0; while i < n { let mut j: usize = 0; while j < m { let mut k: usize = 0; let mut diff: i64 = 0; while i + k < n && j...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [count_substrings]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option lint...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [count_substrings]: function definitions module public import Aeneas public import Aegis.CountSubstrings.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_...
import Aegis.CountSubstrings.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.CountSubstrings.count_substrings (Slice.from [97#u8, 98#u8, 99#u8] (by scalar_tac) : Slice Std.U8) (Slice.from [97#u8, 98#u8, 99#u8, 100#u8] (by ...
[ { "input": "[\"abc\", \"abcd\"]", "output": "9" }, { "input": "[\"abcde\", \"bcdef\"]", "output": "21" }, { "input": "[\"aaaa\", \"bbbb\"]", "output": "16" }, { "input": "[\"xyz\", \"xya\"]", "output": "9" }, { "input": "[\"python\", \"typhon\"]", "output": "4...
156
false
156
verified
10
10
1
1,749
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.CountSubstrings.Code.Funs /-! # Specifications of `Aegis.CountSubstrings.count_substrings` LeetCode problem `count-substrings-that-differ-by-one-character`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.CountSubstrings namespace AegisSpec.Count...
14
check-array-formation-through-concatenation
1,640
Easy
[ "Array", "Hash Table" ]
You are given an array of distinct integers arr and an array of integer arrays pieces, where the integers in pieces are distinct. Your goal is to form arr by concatenating the arrays in pieces in any order. However, you are not allowed to reorder the integers in each array pieces[i]. Return true if it is possible to fo...
canFormArray(arr: list_int, pieces: list_list_int) -> bool
pub fn can_form_array(arr: &[i64], pieces: &[Vec<i64>]) -> bool
Aegis.CanFormArray.can_form_array
pub fn can_form_array(arr: &[i64], pieces: &[Vec<i64>]) -> bool { let n = arr.len(); let num_pieces = pieces.len(); let mut pos: usize = 0; let mut ok: bool = true; let mut active: bool = true; while active && pos < n { // Find the piece that starts with arr[pos]. let mut q: us...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [can_form_array]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [can_form_array]: function definitions module public import Aeneas public import Aegis.CanFormArray.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.CanFormArray.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.CanFormArray.can_form_array (Slice.from [15#i64, 88#i64] (by scalar_tac) : Slice Std.I64) (Slice.from [(alloc.vec.Vec.from [88#i64] (by scalar_tac) ...
[ { "input": "[[15, 88], [[88], [15]]]", "output": "true" }, { "input": "[[49, 18, 16], [[16, 18, 49]]]", "output": "false" }, { "input": "[[91, 4, 64, 78], [[78], [4, 64], [91]]]", "output": "true" }, { "input": "[[10, 20, 30, 40, 50], [[10, 20], [30, 40, 50]]]", "output":...
99
false
99
verified
10
10
2
7,043
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.CanFormArray.Code.Funs /-! # Specifications of `Aegis.CanFormArray.can_form_array` LeetCode problem `check-array-formation-through-concatenation`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.CanFormArray def arrVals (arr : Slice...
10
count-sorted-vowel-strings
1,641
Medium
[ "Math", "Dynamic Programming", "Combinatorics" ]
Given an integer n, return the number of strings of length n that consist only of vowels (a, e, i, o, u) and are lexicographically sorted. A string s is lexicographically sorted if for all valid i, s[i] is the same as or comes before s[i+1] in the alphabet.   Example 1: Input: n = 1 Output: 5 Explanation: The 5 sorted...
countVowelStrings(n: int) -> int
pub fn count_vowel_strings(n: i64) -> i64
Aegis.CountVowelStrings.count_vowel_strings
pub fn count_vowel_strings(n: i64) -> i64 { let mut dp: Vec<i64> = Vec::new(); let mut i: usize = 0; while i < 5 { dp.push(1); i += 1; } let mut length: i64 = 1; while length < n { let mut j: usize = 1; while j < 5 { dp[j] = dp[j] + dp[j - 1]; ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [count_vowel_strings]: type definitions module public import Aeneas @[expose] public section 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 -- [count_vowel_strings]: function definitions module public import Aeneas public import Aegis.CountVowelStrings.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false...
import Aegis.CountVowelStrings.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.CountVowelStrings.count_vowel_strings 3#i64) (35#i64))}") #eval (s!"CASE 1 {(Result.reducesTo (Aegis.CountVowelStrings.count_vowel_strings 4#i6...
[ { "input": "[3]", "output": "35" }, { "input": "[4]", "output": "70" }, { "input": "[33]", "output": "66045" }, { "input": "[2]", "output": "15" }, { "input": "[20]", "output": "10626" }, { "input": "[1]", "output": "5" }, { "input": "[50]"...
24
false
24
verified
10
10
1
894
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.CountVowelStrings.Code.Funs /-! # Specifications of `Aegis.CountVowelStrings.count_vowel_strings` LeetCode problem `count-sorted-vowel-strings`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.CountVowelStrings namespace AegisSpec.CountVowelS...
10
furthest-building-you-can-reach
1,642
Medium
[ "Greedy", "Array", "Heap (Priority Queue)" ]
You are given an integer array heights representing the heights of buildings, some bricks, and some ladders. You start your journey from building 0 and move to the next building by possibly using bricks or ladders. While moving from building i to building i+1 (0-indexed), If the current building's height is greater th...
furthestBuilding(heights: list_int, bricks: int, ladders: int) -> int
pub fn furthest_building(heights: &[i64], bricks: i64, ladders: i64) -> i64
Aegis.FurthestBuilding.furthest_building
pub fn furthest_building(heights: &[i64], bricks: i64, ladders: i64) -> i64 { let n = heights.len(); if n == 0 { return 0; } let mut heap: Vec<i64> = Vec::new(); let mut heap_len: usize = 0; let mut remaining_bricks: i64 = bricks; let mut i: usize = 1; while i < n { let...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [furthest_building]: type definitions module public import Aeneas @[expose] public section 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 -- [furthest_building]: function definitions module public import Aeneas public import Aegis.FurthestBuilding.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.FurthestBuilding.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.FurthestBuilding.furthest_building (Slice.from [1#i64, 1000000#i64] (by scalar_tac) : Slice Std.I64) 999999#i64 0#i64) (1#i64))}") #eval (s!"CAS...
[ { "input": "[[1, 1000000], 999999, 0]", "output": "1" }, { "input": "[[1, 2], 0, 0]", "output": "0" }, { "input": "[[4, 2, 3], 0, 1]", "output": "2" }, { "input": "[[14, 3, 19, 3], 17, 0]", "output": "3" }, { "input": "[[10, 15, 20, 25, 30], 0, 2]", "output": ...
118
false
118
verified
10
10
1
5,870
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.FurthestBuilding.Code.Funs /-! # Specifications of `Aegis.FurthestBuilding.furthest_building` LeetCode problem `furthest-building-you-can-reach`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.FurthestBuilding namespace AegisSpec.FurthestBuildin...
13
get-maximum-in-generated-array
1,646
Easy
[ "Array", "Simulation" ]
You are given an integer n. A 0-indexed integer array nums of length n + 1 is generated in the following way: nums[0] = 0 nums[1] = 1 nums[2 * i] = nums[i] when 2 <= 2 * i <= n nums[2 * i + 1] = nums[i] + nums[i + 1] when 2 <= 2 * i + 1 <= n Return the maximum integer in the array nums​​​.   Example 1: Input: n = 7 ...
getMaximumGenerated(n: int) -> int
pub fn get_maximum_generated(n: i64) -> i64
Aegis.GetMaximumGenerated.get_maximum_generated
pub fn get_maximum_generated(n: i64) -> i64 { if n <= 0 { return 0; } if n == 1 { return 1; } let len: usize = (n + 1) as usize; let mut nums: Vec<i64> = Vec::new(); let mut k: usize = 0; while k < len { nums.push(0); k += 1; } nums[0] = 0; ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [get_maximum_generated]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [get_maximum_generated]: function definitions module public import Aeneas public import Aegis.GetMaximumGenerated.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand f...
import Aegis.GetMaximumGenerated.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.GetMaximumGenerated.get_maximum_generated 0#i64) (0#i64))}") #eval (s!"CASE 1 {(Result.reducesTo (Aegis.GetMaximumGenerated.get_maximum_gener...
[ { "input": "[0]", "output": "0" }, { "input": "[3]", "output": "2" }, { "input": "[100]", "output": "21" }, { "input": "[99]", "output": "21" }, { "input": "[2]", "output": "1" }, { "input": "[20]", "output": "7" }, { "input": "[1]", "o...
31
false
31
verified
10
10
1
2,542
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.GetMaximumGenerated.Code.Funs /-! # Specifications of `Aegis.GetMaximumGenerated.get_maximum_generated` LeetCode problem `get-maximum-in-generated-array`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.GetMaximumGenerated def gen : Nat...
13
minimum-deletions-to-make-character-frequencies-unique
1,647
Medium
[ "Greedy", "Hash Table", "String", "Sorting" ]
A string s is called good if there are no two different characters in s that have the same frequency. Given a string s, return the minimum number of characters you need to delete to make s good. The frequency of a character in a string is the number of times it appears in the string. For example, in the string "aab", t...
minDeletions(s: str) -> int
pub fn min_deletions(s: &[u8]) -> i64
Aegis.MinDeletions.min_deletions
pub fn min_deletions(s: &[u8]) -> i64 { let mut counts: Vec<i64> = Vec::new(); let mut i: usize = 0; while i < 26 { counts.push(0); i += 1; } let mut idx: usize = 0; while idx < s.len() { let b = s[idx]; let mut c: usize = 0; let mut letter: u8 = b'a'; ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [min_deletions]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter....
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [min_deletions]: function definitions module public import Aeneas public import Aegis.MinDeletions.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.MinDeletions.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.MinDeletions.min_deletions (Slice.from [97#u8, 97#u8, 98#u8] (by scalar_tac) : Slice Std.U8)) (0#i64))}") #eval (s!"CASE 1 {(Result.reducesTo (Aegis...
[ { "input": "[\"aab\"]", "output": "0" }, { "input": "[\"aabacabadabaeabafabagabahabaiabajabakabalabamabanabaoabapabaqabarabasabataabuabavabawabaxabayabajabaz\"]", "output": "22" }, { "input": "[\"abcabcabc\"]", "output": "3" }, { "input": "[\"aabbbcccddddeeeeeffffffggggggghhh...
23
false
23
verified
10
10
1
4,177
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MinDeletions.Code.Funs /-! # Specifications of `Aegis.MinDeletions.min_deletions` LeetCode problem `minimum-deletions-to-make-character-frequencies-unique`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.MinDeletions def bytes (s : Sli...
12
sell-diminishing-valued-colored-balls
1,648
Medium
[ "Greedy", "Array", "Math", "Binary Search", "Sorting", "Heap (Priority Queue)" ]
You have an inventory of different colored balls, and there is a customer that wants orders balls of any color. The customer weirdly values the colored balls. Each colored ball's value is the number of balls of that color you currently have in your inventory. For example, if you own 6 yellow balls, the customer would p...
maxProfit(inventory: list_int, orders: int) -> int
pub fn max_profit(inventory: &[i64], orders: i64) -> i64
Aegis.MaxProfit.max_profit
pub fn max_profit(inventory: &[i64], orders: i64) -> i64 { let modv: i64 = 1000000007; let n: usize = inventory.len(); if n == 0 { return 0; } let mut maxv: i64 = 0; let mut i: usize = 0; while i < n { if inventory[i] > maxv { maxv = inventory[i]; } ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [max_profit]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter.sty...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [max_profit]: function definitions module public import Aeneas public import Aegis.MaxProfit.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linte...
import Aegis.MaxProfit.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.MaxProfit.max_profit (Slice.from [7#i64] (by scalar_tac) : Slice Std.I64) 7#i64) (28#i64))}") #eval (s!"CASE 1 {(Result.reducesTo (Aegis.MaxProfit.max_...
[ { "input": "[[7], 7]", "output": "28" }, { "input": "[[1000000000], 1]", "output": "1000000000" }, { "input": "[[1000000000], 1000000000]", "output": "21" }, { "input": "[[100], 10]", "output": "955" }, { "input": "[[3, 5], 6]", "output": "19" }, { "in...
88
false
88
verified
10
10
1
6,557
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MaxProfit.Code.Funs /-! # Specifications of `Aegis.MaxProfit.max_profit` LeetCode problem `sell-diminishing-valued-colored-balls`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.MaxProfit def M : ℤ := 1000000007 def entries (inv...
11
create-sorted-array-through-instructions
1,649
Hard
[ "Binary Indexed Tree", "Segment Tree", "Array", "Binary Search", "Divide and Conquer", "Ordered Set", "Merge Sort" ]
Given an integer array instructions, you are asked to create a sorted array from the elements in instructions. You start with an empty container nums. For each element from left to right in instructions, insert it into nums. The cost of each insertion is the minimum of the following:\r \r \r The number of elements cur...
createSortedArray(instructions: list_int) -> int
pub fn create_sorted_array(instructions: &[i64]) -> i64
Aegis.CreateSortedArray.create_sorted_array
pub fn create_sorted_array(instructions: &[i64]) -> i64 { let n = instructions.len(); if n == 0 { return 0; } let mut vals: Vec<i64> = Vec::new(); let mut idxs: Vec<i64> = Vec::new(); let mut i: usize = 0; while i < n { vals.push(instructions[i]); idxs.push(i as i64)...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [create_sorted_array]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option l...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [create_sorted_array]: function definitions module public import Aeneas public import Aegis.CreateSortedArray.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false...
import Aegis.CreateSortedArray.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval aeg...
[ { "input": "[[1, 5, 6, 2]]", "output": "1" }, { "input": "[[5, 4, 3, 2, 1]]", "output": "0" }, { "input": "[[1, 2, 3, 6, 5, 4]]", "output": "3" }, { "input": "[[1, 3, 3, 3, 2, 4, 2, 1, 2]]", "output": "4" }, { "input": "[[10, 9, 8, 7, 6, 5, 4, 3, 2, 1]]", "out...
113
false
113
verified
10
10
2
34,703
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.CreateSortedArray.Code.Funs /-! # Specifications of `Aegis.CreateSortedArray.create_sorted_array` LeetCode problem `create-sorted-array-through-instructions`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.CreateSortedArray (create_sorted_array) ...
8
defuse-the-bomb
1,652
Easy
[ "Array", "Sliding Window" ]
You have a bomb to defuse, and your time is running out! Your informer will provide you with a circular array code of length of n and a key k. To decrypt the code, you must replace every number. All the numbers are replaced simultaneously. If k > 0, replace the ith number with the sum of the next k numbers. If k < 0, ...
decrypt(code: list_int, k: int) -> list_int
pub fn decrypt(code: &[i64], k: i64) -> Vec<i64>
Aegis.Decrypt.decrypt
pub fn decrypt(code: &[i64], k: i64) -> Vec<i64> { let n = code.len(); let mut out: Vec<i64> = Vec::new(); if n == 0 { return out; } if k == 0 { let mut i: usize = 0; while i < n { out.push(0); i += 1; } return out; } let n_i...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [decrypt]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter.style....
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [decrypt]: function definitions module public import Aeneas public import Aegis.Decrypt.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.unu...
import Aegis.Decrypt.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.Decrypt.decrypt (Slice.from [7#i64, 8#i64, 9#i64] (by scalar_tac) : Slice Std.I64) 1#i64) ((alloc.vec.Vec.from [8#i64, 9#i64, 7#i64] (by scalar_tac) : al...
[ { "input": "[[7, 8, 9], 1]", "output": "[8, 9, 7]" }, { "input": "[[1, 2, 3], -3]", "output": "[6, 6, 6]" }, { "input": "[[15, 20, 25], 0]", "output": "[0, 0, 0]" }, { "input": "[[7, 8, 9, 10], 4]", "output": "[34, 34, 34, 34]" }, { "input": "[[5, 7, 1, 4], 3]", ...
119
false
119
verified
10
10
1
2,415
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.Decrypt.Code.Funs /-! # Specifications of `Aegis.Decrypt.decrypt` LeetCode problem `defuse-the-bomb`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.Decrypt open Aegis.Decrypt (decrypt) def codeElem (code : Slice I64) (i : Nat) ...
7
minimum-deletions-to-make-string-balanced
1,653
Medium
[ "Stack", "String", "Dynamic Programming" ]
You are given a string s consisting only of characters 'a' and 'b'​​​​. You can delete any number of characters in s to make s balanced. s is balanced if there is no pair of indices (i,j) such that i < j and s[i] = 'b' and s[j]= 'a'. Return the minimum number of deletions needed to make s balanced.   Example 1: Input:...
minimumDeletions(s: str) -> int
pub fn minimum_deletions(s: &[u8]) -> i64
Aegis.MinimumDeletions.minimum_deletions
pub fn minimum_deletions(s: &[u8]) -> i64 { let n = s.len(); let mut total_a: i64 = 0; let mut i: usize = 0; while i < n { if s[i] == b'a' { total_a += 1; } i += 1; } let mut best: i64 = total_a; let mut a_remaining: i64 = total_a; let mut b_seen: i6...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [minimum_deletions]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option lin...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [minimum_deletions]: function definitions module public import Aeneas public import Aegis.MinimumDeletions.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false se...
import Aegis.MinimumDeletions.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.MinimumDeletions.minimum_deletions (Slice.from [97#u8, 97#u8, 97#u8, 97#u8, 97#u8, 97#u8, 98#u8, 98#u8, 98#u8, 98#u8] (by scalar_tac) : Slice St...
[ { "input": "[\"aaaaaabbbb\"]", "output": "0" }, { "input": "[\"bbbaaaaa\"]", "output": "3" }, { "input": "[\"bbbaaaaabbbb\"]", "output": "3" }, { "input": "[\"aabbaa\"]", "output": "2" }, { "input": "[\"abababab\"]", "output": "3" }, { "input": "[\"aaa...
190
false
190
verified
10
10
1
1,238
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MinimumDeletions.Code.Funs /-! # Specifications of `Aegis.MinimumDeletions.minimum_deletions` LeetCode problem `minimum-deletions-to-make-string-balanced`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.MinimumDeletions open Aegis....
15
minimum-jumps-to-reach-home
1,654
Medium
[ "Breadth-First Search", "Array", "Dynamic Programming" ]
A certain bug's home is on the x-axis at position x. Help them get there from position 0. The bug jumps according to the following rules: It can jump exactly a positions forward (to the right). It can jump exactly b positions backward (to the left). It cannot jump backward twice in a row. It cannot jump to any forbidd...
minimumJumps(forbidden: list_int, a: int, b: int, x: int) -> int
pub fn minimum_jumps(forbidden: &[i64], a: i64, b: i64, x: i64) -> i64
Aegis.MinimumJumps.minimum_jumps
pub fn minimum_jumps(forbidden: &[i64], a: i64, b: i64, x: i64) -> i64 { if x == 0 { return 0; } let mut maxpos = x; let mut i = 0; while i < forbidden.len() { if forbidden[i] > maxpos { maxpos = forbidden[i]; } i += 1; } let limit_i64 = maxpos +...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [minimum_jumps]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter....
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [minimum_jumps]: function definitions module public import Aeneas public import Aegis.MinimumJumps.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.MinimumJumps.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.MinimumJumps.minimum_jumps (Slice.from [] (by scalar_tac) : Slice Std.I64) 1#i64 1#i64 0#i64) (0#i64))}") #eval (s!"CASE 1 {(Result.reducesTo (Aegis...
[ { "input": "[[], 1, 1, 0]", "output": "0" }, { "input": "[[], 1000, 500, 2000]", "output": "2" }, { "input": "[[2000], 1000, 500, 1500]", "output": "3" }, { "input": "[[5, 6, 7], 1, 1, 10]", "output": "-1" }, { "input": "[[500, 1000, 1500], 100, 50, 2000]", "o...
98
false
98
verified
10
10
1
7,356
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MinimumJumps.Code.Funs /-! # Specifications of `Aegis.MinimumJumps.minimum_jumps` LeetCode problem `minimum-jumps-to-reach-home`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.MinimumJumps set_option autoImplicit false namespace AegisSpec.Mini...
13
distribute-repeating-integers
1,655
Hard
[ "Bit Manipulation", "Array", "Dynamic Programming", "Backtracking", "Bitmask" ]
You are given an array of n integers, nums, where there are at most 50 unique values in the array. You are also given an array of m customer order quantities, quantity, where quantity[i] is the amount of integers the ith customer ordered. Determine if it is possible to distribute nums such that: The ith customer gets ...
canDistribute(nums: list_int, quantity: list_int) -> bool
pub fn can_distribute(nums: &[i64], quantity: &[i64]) -> bool
Aegis.CanDistribute.can_distribute
pub fn can_distribute(nums: &[i64], quantity: &[i64]) -> bool { let m = quantity.len(); let mut total: usize = 1; let mut i: usize = 0; while i < m { total = total * 2; i += 1; } let mut total_quantity: i64 = 0; i = 0; while i < m { total_quantity += quantity[i]...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [can_distribute]: type definitions module public import Aeneas @[expose] public section 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 -- [can_distribute]: function definitions module public import Aeneas public import Aegis.CanDistribute.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.CanDistribute.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.CanDistribute.can_distribute (Slice.from [1#i64, 2#i64, 3#i64, 4#i64] (by scalar_tac) : Slice Std.I64) (Slice.from [2#i64] (by scalar_tac) : Slice ...
[ { "input": "[[1, 2, 3, 4], [2]]", "output": "false" }, { "input": "[[1, 2, 3, 3], [2]]", "output": "true" }, { "input": "[[1, 1, 2, 2], [2, 2]]", "output": "true" }, { "input": "[[1, 1, 1, 1, 1], [5]]", "output": "true" }, { "input": "[[1, 2, 2, 3, 3, 3], [2, 3]]"...
62
false
62
verified
10
10
1
7,403
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.CanDistribute.Code.Funs /-! # Specifications of `Aegis.CanDistribute.can_distribute` LeetCode problem `distribute-repeating-integers`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.CanDistribute (can_distribute) namespace AegisSpec.CanDistribut...
10
determine-if-two-strings-are-close
1,657
Medium
[ "Hash Table", "String", "Counting", "Sorting" ]
Two strings are considered close if you can attain one from the other using the following operations: Operation 1: Swap any two existing characters. For example, abcde -> aecdb Operation 2: Transform every occurrence of one existing character into another existing character, and do the same with the other charact...
closeStrings(word1: str, word2: str) -> bool
pub fn close_strings(word1: &[u8], word2: &[u8]) -> bool
Aegis.CloseStrings.close_strings
pub fn close_strings(word1: &[u8], word2: &[u8]) -> bool { let mut ok: bool = word1.len() == word2.len(); let mut c1: Vec<i64> = Vec::new(); let mut c2: Vec<i64> = Vec::new(); let mut k: usize = 0; while k < 26 { c1.push(0); c2.push(0); k += 1; } let mut i: usize =...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [close_strings]: type definitions module public import Aeneas @[expose] public section 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 -- [close_strings]: function definitions module public import Aeneas public import Aegis.CloseStrings.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.CloseStrings.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.CloseStrings.close_strings (Slice.from [108#u8, 101#u8, 101#u8, 116#u8, 99#u8, 111#u8, 100#u8, 101#u8] (by scalar_tac) : Slice Std.U8) (Slice.from [...
[ { "input": "[\"leetcode\", \"coeddlet\"]", "output": "false" }, { "input": "[\"aaa\", \"bbb\"]", "output": "false" }, { "input": "[\"aaabbbbccdddd\", \"bbbbaacdddd\"]", "output": "false" }, { "input": "[\"abcdefghijklmnopqrstuvwxyz\", \"zyxwvutsrqponmlkjihgfedcba\"]", "ou...
106
false
106
verified
10
10
3
5,998
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.CloseStrings.Code.Funs /-! # Specifications of `Aegis.CloseStrings.close_strings` LeetCode problem `determine-if-two-strings-are-close`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.CloseStrings namespace AegisSpec.CloseStrings def IsLower (b...
14
minimum-operations-to-reduce-x-to-zero
1,658
Medium
[ "Array", "Hash Table", "Binary Search", "Prefix Sum", "Sliding Window" ]
You are given an integer array nums and an integer x. In one operation, you can either remove the leftmost or the rightmost element from the array nums and subtract its value from x. Note that this modifies the array for future operations. Return the minimum number of operations to reduce x to exactly 0 if it is possib...
minOperations(nums: list_int, x: int) -> int
pub fn min_operations(nums: &[i64], x: i64) -> i64
Aegis.MinOperations.min_operations
pub fn min_operations(nums: &[i64], x: i64) -> i64 { let n = nums.len(); let mut total: i64 = 0; let mut i: usize = 0; while i < n { total += nums[i]; i += 1; } let target = total - x; if target < 0 { return -1; } if target == 0 { return n as i64; ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [min_operations]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [min_operations]: function definitions module public import Aeneas public import Aegis.MinOperations.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_opti...
import Aegis.MinOperations.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.MinOperations.min_operations (Slice.from [1#i64, 2#i64, 3#i64, 4#i64, 5#i64] (by scalar_tac) : Slice Std.I64) 15#i64) (5#i64))}") #eval (s!"CASE 1 ...
[ { "input": "[[1, 2, 3, 4, 5], 15]", "output": "5" }, { "input": "[[1, 1, 4, 2, 3], 5]", "output": "2" }, { "input": "[[10, 20, 30, 40, 50], 100]", "output": "3" }, { "input": "[[10000, 10000, 10000, 10000, 10000], 30000]", "output": "3" }, { "input": "[[1, 1, 1, 1...
107
false
107
verified
10
10
1
1,985
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MinOperations.Code.Funs /-! # Specifications of `Aegis.MinOperations.min_operations` LeetCode problem `minimum-operations-to-reduce-x-to-zero`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.MinOperations def elems (nums : Slice I64) :...
15
check-if-two-string-arrays-are-equivalent
1,662
Easy
[ "Array", "String" ]
Given two string arrays word1 and word2, return true if the two arrays represent the same string, and false otherwise. A string is represented by an array if the array elements concatenated in order forms the string.   Example 1: Input: word1 = ["ab", "c"], word2 = ["a", "bc"] Output: true Explanation: word1 represent...
arrayStringsAreEqual(word1: list_str, word2: list_str) -> bool
pub fn array_strings_are_equal(word1: &[Vec<u8>], word2: &[Vec<u8>]) -> bool
Aegis.ArrayStringsAreEqual.array_strings_are_equal
pub fn array_strings_are_equal(word1: &[Vec<u8>], word2: &[Vec<u8>]) -> bool { let mut s1: Vec<u8> = Vec::new(); let mut i: usize = 0; while i < word1.len() { let word = &word1[i]; let mut j: usize = 0; while j < word.len() { s1.push(word[j]); j += 1; ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [array_strings_are_equal]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_opti...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [array_strings_are_equal]: function definitions module public import Aeneas public import Aegis.ArrayStringsAreEqual.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashComman...
import Aegis.ArrayStringsAreEqual.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.ArrayStringsAreEqual.array_strings_are_equal (Slice.from [(alloc.vec.Vec.from [120#u8] (by scalar_tac) : alloc.vec.Vec Std.U8)] (by scalar_t...
[ { "input": "[[\"x\"], [\"y\"]]", "output": "false" }, { "input": "[[\"different\"], [\"string\"]]", "output": "false" }, { "input": "[[\"a\"], [\"a\"]]", "output": "true" }, { "input": "[[\"hello\"], [\"hello\"]]", "output": "true" }, { "input": "[[\"z\"], [\"z\"]...
105
false
105
verified
10
10
1
770
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.ArrayStringsAreEqual.Code.Funs /-! # Specifications of `Aegis.ArrayStringsAreEqual.array_strings_are_equal` LeetCode problem `check-if-two-string-arrays-are-equivalent`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.ArrayStringsAreEq...
11
ways-to-make-a-fair-array
1,664
Medium
[ "Array", "Prefix Sum" ]
You are given an integer array nums. You can choose exactly one index (0-indexed) and remove the element. Notice that the index of the elements may change after the removal. For example, if nums = [6,1,7,4,1]: Choosing to remove index 1 results in nums = [6,7,4,1]. Choosing to remove index 2 results in nums = [6,1,4,1...
waysToMakeFair(nums: list_int) -> int
pub fn ways_to_make_fair(nums: &[i64]) -> i64
Aegis.WaysToMakeFair.ways_to_make_fair
pub fn ways_to_make_fair(nums: &[i64]) -> i64 { let n = nums.len(); let mut total_even: i64 = 0; let mut total_odd: i64 = 0; let mut i: usize = 0; while i < n { if i % 2 == 0 { total_even += nums[i]; } else { total_odd += nums[i]; } i += 1; ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [ways_to_make_fair]: type definitions module public import Aeneas @[expose] public section 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 -- [ways_to_make_fair]: function definitions module public import Aeneas public import Aegis.WaysToMakeFair.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.WaysToMakeFair.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.WaysToMakeFair.ways_to_make_fair (Slice.from [1#i64] (by scalar_tac) : Slice Std.I64)) (1#i64))}") #eval (s!"CASE 1 {(Result.reducesTo (Aegis.Ways...
[ { "input": "[[1]]", "output": "1" }, { "input": "[[10000]]", "output": "1" }, { "input": "[[42]]", "output": "1" }, { "input": "[[1, 2]]", "output": "0" }, { "input": "[[1, 2, 3]]", "output": "0" }, { "input": "[[1, 1, 1]]", "output": "3" }, { ...
100
false
100
verified
10
10
1
1,868
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.WaysToMakeFair.Code.Funs /-! # Specifications of `Aegis.WaysToMakeFair.ways_to_make_fair` LeetCode problem `ways-to-make-a-fair-array`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.WaysToMakeFair namespace AegisSpec.WaysToMakeFair def v...
10
minimum-initial-energy-to-finish-tasks
1,665
Hard
[ "Greedy", "Array", "Sorting" ]
You are given an array tasks where tasks[i] = [actuali, minimumi]: actuali is the actual amount of energy you spend to finish the ith task. minimumi is the minimum amount of energy you require to begin the ith task. For example, if the task is [10, 12] and your current energy is 11, you cannot start this task. Howeve...
minimumEffort(tasks: list_list_int) -> int
pub fn minimum_effort(tasks: &[Vec<i64>]) -> i64
Aegis.MinimumEffort.minimum_effort
pub fn minimum_effort(tasks: &[Vec<i64>]) -> i64 { let n: usize = tasks.len(); // Flatten tasks into [actual0, minimum0, actual1, minimum1, ...] let mut v: Vec<i64> = Vec::new(); let mut i: usize = 0; while i < n { v.push(tasks[i][0]); v.push(tasks[i][1]); i += 1; } ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [minimum_effort]: type definitions module public import Aeneas @[expose] public section 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_effort]: function definitions module public import Aeneas public import Aegis.MinimumEffort.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.MinimumEffort.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.MinimumEffort.minimum_effort (Slice.from [(alloc.vec.Vec.from [10#i64, 15#i64] (by scalar_tac) : alloc.vec.Vec Std.I64), (alloc.vec.Vec.from [20#i6...
[ { "input": "[[[10, 15], [20, 25], [30, 35]]]", "output": "65" }, { "input": "[[[10, 15], [5, 10], [3, 7]]]", "output": "22" }, { "input": "[[[10, 10], [15, 15], [5, 5]]]", "output": "30" }, { "input": "[[[5, 10], [1, 2], [3, 4]]]", "output": "10" }, { "input": "[[...
104
false
104
verified
10
10
1
7,426
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MinimumEffort.Code.Funs /-! # Specifications of `Aegis.MinimumEffort.minimum_effort` LeetCode problem `minimum-initial-energy-to-finish-tasks`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.MinimumEffort (minimum_effort) namespace AegisSpec.Mi...
11
maximum-repeating-substring
1,668
Easy
[ "String", "Dynamic Programming", "String Matching" ]
For a string sequence, a string word is k-repeating if word concatenated k times is a substring of sequence. The word's maximum k-repeating value is the highest value k where word is k-repeating in sequence. If word is not a substring of sequence, word's maximum k-repeating value is 0. Given strings sequence and word, ...
maxRepeating(sequence: str, word: str) -> int
pub fn max_repeating(sequence: &[u8], word: &[u8]) -> i64
Aegis.MaxRepeating.max_repeating
fn contains(haystack: &[u8], needle: &[u8]) -> bool { let n = haystack.len(); let m = needle.len(); if m == 0 { return true; } if m > n { return false; } let mut i: usize = 0; while i + m <= n { let mut j: usize = 0; let mut matched: bool = true; ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [max_repeating]: type definitions module public import Aeneas @[expose] public section 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_repeating]: function definitions module public import Aeneas public import Aegis.MaxRepeating.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.MaxRepeating.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.MaxRepeating.max_repeating (Slice.from [97#u8, 98#u8, 97#u8, 98#u8, 99#u8] (by scalar_tac) : Slice Std.U8) (Slice.from [97#u8, 99#u8] (by scalar_tac...
[ { "input": "[\"ababc\", \"ac\"]", "output": "0" }, { "input": "[\"banana\", \"ana\"]", "output": "1" }, { "input": "[\"abcabcabc\", \"abc\"]", "output": "3" }, { "input": "[\"aaaa\", \"aa\"]", "output": "2" }, { "input": "[\"abc\", \"d\"]", "output": "0" }, ...
154
false
154
verified
10
10
1
1,920
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MaxRepeating.Code.Funs /-! # Specifications of `Aegis.MaxRepeating.max_repeating` LeetCode problem `maximum-repeating-substring`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.MaxRepeating def byteAt (l : List Std.U8) (i : Nat) : Nat ...
12
merge-in-between-linked-lists
1,669
Medium
[ "Linked List" ]
You are given two linked lists: list1 and list2 of sizes n and m respectively. Remove list1's nodes from the ath node to the bth node, and put list2 in their place. The blue edges and nodes in the following figure indicate the result: Build the result list and return its head.   Example 1: Input: list1 = [10,1,13,6,...
mergeInBetween(list1: linkedlist, a: int, b: int, list2: linkedlist) -> linkedlist
pub fn merge_in_between(list1: &List, a: i64, b: i64, list2: &List) -> List
Aegis.MergeInBetween.merge_in_between
pub fn merge_in_between(list1: &List, a: i64, b: i64, list2: &List) -> List { let vals1 = list_to_vec(list1); let vals2 = list_to_vec(list2); let mut result: Vec<i64> = Vec::new(); let a_usize = a as usize; let b_usize = b as usize; let mut i: usize = 0; while i < a_usize { result...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [merge_in_between]: type definitions module public import Aeneas @[expose] public section 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 -- [merge_in_between]: function definitions module public import Aeneas public import Aegis.MergeInBetween.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.MergeInBetween.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 deriving instance DecidableEq for Aegis.MergeInBetween.List #eval (s!"CASE 0 {(match (Aegis.MergeInBetween.merge_in_between ((.Cons 1#i64 (.Cons 2#i64 (.Cons 3#i64 (.Cons 4#i64 (.Cons 5#i6...
[ { "input": "[[1, 2, 3, 4, 5], 1, 2, [10, 20]]", "output": "[1, 10, 20, 4, 5]" }, { "input": "[[1, 2, 3, 4, 5], 1, 2, [9, 8]]", "output": "[1, 9, 8, 4, 5]" }, { "input": "[[1, 2, 3, 4, 5], 1, 2, [10, 20, 30]]", "output": "[1, 10, 20, 30, 4, 5]" }, { "input": "[[1, 3, 5, 7, 9, ...
97
false
97
verified
10
10
1
4,206
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MergeInBetween.Code.Funs /-! # Specifications of `Aegis.MergeInBetween.merge_in_between` LeetCode problem `merge-in-between-linked-lists`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.MergeInBetween def len : Aegis.MergeInBetween...
2
minimum-number-of-removals-to-make-mountain-array
1,671
Hard
[ "Greedy", "Array", "Binary Search", "Dynamic Programming" ]
You may recall that an array arr is a mountain array if and only if: arr.length >= 3 There exists some index i (0-indexed) with 0 < i < arr.length - 1 such that: arr[0] < arr[1] < ... < arr[i - 1] < arr[i] arr[i] > arr[i + 1] > ... > arr[arr.length - 1] Given an integer array nums​​​, return the minimum number of...
minimumMountainRemovals(nums: list_int) -> int
pub fn minimum_mountain_removals(nums: &[i64]) -> i64
Aegis.MinimumMountainRemovals.minimum_mountain_removals
pub fn minimum_mountain_removals(nums: &[i64]) -> i64 { let n = nums.len(); if n < 3 { return 0; } let mut left: Vec<i64> = Vec::new(); let mut i = 0; while i < n { left.push(1); i += 1; } i = 0; while i < n { let mut j = 0; while j < i { ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [minimum_mountain_removals]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_op...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [minimum_mountain_removals]: function definitions module public import Aeneas public import Aegis.MinimumMountainRemovals.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashC...
import Aegis.MinimumMountainRemovals.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.MinimumMountainRemovals.minimum_mountain_removals (Slice.from [1#i64, 3#i64, 1#i64] (by scalar_tac) : Slice Std.I64)) (0#i64))}") #eval (...
[ { "input": "[[1, 3, 1]]", "output": "0" }, { "input": "[[1, 2, 3, 1]]", "output": "0" }, { "input": "[[1, 2, 3, 4, 5, 3, 1]]", "output": "0" }, { "input": "[[1, 2, 3, 4, 5, 3, 2, 1]]", "output": "0" }, { "input": "[[4, 3, 2, 1, 1, 2, 3, 1]]", "output": "4" }...
107
false
107
verified
10
10
1
1,330
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MinimumMountainRemovals.Code.Funs /-! # Specifications of `Aegis.MinimumMountainRemovals.minimum_mountain_removals` LeetCode problem `minimum-number-of-removals-to-make-mountain-array`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.MinimumMoun...
11
richest-customer-wealth
1,672
Easy
[ "Array", "Matrix" ]
You are given an m x n integer grid accounts where accounts[i][j] is the amount of money the i​​​​​​​​​​​th​​​​ customer has in the j​​​​​​​​​​​th​​​​ bank. Return the wealth that the richest customer has. A customer's wealth is the amount of money they have in all their bank accounts. The richest customer is the custo...
maximumWealth(accounts: list_list_int) -> int
pub fn maximum_wealth(accounts: &[Vec<i64>]) -> i64
Aegis.MaximumWealth.maximum_wealth
pub fn maximum_wealth(accounts: &[Vec<i64>]) -> i64 { let m = accounts.len(); let mut best: i64 = 0; let mut i: usize = 0; while i < m { let row = &accounts[i]; let n = row.len(); let mut sum: i64 = 0; let mut j: usize = 0; while j < n { sum += row[j];...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [maximum_wealth]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [maximum_wealth]: function definitions module public import Aeneas public import Aegis.MaximumWealth.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.MaximumWealth.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.MaximumWealth.maximum_wealth (Slice.from [(alloc.vec.Vec.from [100#i64] (by scalar_tac) : alloc.vec.Vec Std.I64), (alloc.vec.Vec.from [100#i64] (by...
[ { "input": "[[[100], [100], [100]]]", "output": "100" }, { "input": "[[[1], [2], [3]]]", "output": "3" }, { "input": "[[[1], [2], [3], [4], [5]]]", "output": "5" }, { "input": "[[[100, 100], [50, 50, 50, 50]]]", "output": "200" }, { "input": "[[[5, 5, 5], [15], [1...
85
false
85
verified
10
10
1
165
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MaximumWealth.Code.Funs /-! # Specifications of `Aegis.MaximumWealth.maximum_wealth` LeetCode problem `richest-customer-wealth`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.MaximumWealth def rowWealth (row : alloc.vec.Vec Std.I6...
13
find-the-most-competitive-subsequence
1,673
Medium
[ "Stack", "Greedy", "Array", "Monotonic Stack" ]
Given an integer array nums and a positive integer k, return the most competitive subsequence of nums of size k. An array's subsequence is a resulting sequence obtained by erasing some (possibly zero) elements from the array. We define that a subsequence a is more competitive than a subsequence b (of the same length) i...
mostCompetitive(nums: list_int, k: int) -> list_int
pub fn most_competitive(nums: &[i64], k: i64) -> Vec<i64>
Aegis.MostCompetitive.most_competitive
pub fn most_competitive(nums: &[i64], k: i64) -> Vec<i64> { let n: usize = nums.len(); let kk: usize = k as usize; let mut stack: Vec<i64> = Vec::new(); let mut i: usize = 0; while i < n { while stack.len() > 0 && stack[stack.len() - 1] > nums[i] && stack.len() + (n ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [most_competitive]: type definitions module public import Aeneas @[expose] public section 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 -- [most_competitive]: function definitions module public import Aeneas public import Aegis.MostCompetitive.Code.Types public import Aegis.MostCompetitive.Code.FunsExternal @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNa...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [most_competitive]: external functions. -- This is a template file: rename it to "FunsExternal.lean" and fill the holes. module public import Aeneas public import Aegis.MostCompetitive.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Err...
import Aegis.MostCompetitive.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.MostCompetitive.most_competitive (Slice.from [3#i64, 5#i64, 2#i64, 6#i64] (by scalar_tac) : Slice Std.I64) 2#i64) ((alloc.vec.Vec.from [2#i64, 6#...
[ { "input": "[[3, 5, 2, 6], 2]", "output": "[2, 6]" }, { "input": "[[5, 2, 6, 3, 4, 1], 2]", "output": "[2, 1]" }, { "input": "[[1, 1, 1, 1, 1, 1, 1], 2]", "output": "[1, 1]" }, { "input": "[[1, 3, 1, 3, 1, 3, 1], 2]", "output": "[1, 1]" }, { "input": "[[1, 5, 4, 3...
106
false
106
verified
10
10
1
6,961
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MostCompetitive.Code.Funs /-! # Specifications of `Aegis.MostCompetitive.most_competitive` LeetCode problem `find-the-most-competitive-subsequence`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.MostCompetitive def Subseq (r s : List ...
13
minimum-moves-to-make-array-complementary
1,674
Medium
[ "Array", "Hash Table", "Prefix Sum" ]
You are given an integer array nums of even length n and an integer limit. In one move, you can replace any integer from nums with another integer between 1 and limit, inclusive. The array nums is complementary if for all indices i (0-indexed), nums[i] + nums[n - 1 - i] equals the same number. For example, the array [1...
minMoves(nums: list_int, limit: int) -> int
pub fn min_moves(nums: &[i64], limit: i64) -> i64
Aegis.MinMoves.min_moves
pub fn min_moves(nums: &[i64], limit: i64) -> i64 { let n = nums.len(); let half = n / 2; let mut events: Vec<i64> = Vec::new(); let mut sums: Vec<i64> = Vec::new(); let mut i: usize = 0; while i < half { let a = nums[i]; let b = nums[n - 1 - i]; sums.push(a + b); ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [min_moves]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter.styl...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [min_moves]: function definitions module public import Aeneas public import Aegis.MinMoves.Code.Types public import Aegis.MinMoves.Code.FunsExternal @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_opt...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [min_moves]: external functions. -- This is a template file: rename it to "FunsExternal.lean" and fill the holes. module public import Aeneas public import Aegis.MinMoves.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option ...
import Aegis.MinMoves.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := 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": "[[3, 3, 3, 3], 5]", "output": "0" }, { "input": "[[1, 1, 1, 1], 10]", "output": "0" }, { "input": "[[5, 3, 5, 3], 10]", "output": "0" }, { "input": "[[1, 5, 5, 1], 5]", "output": "2" }, { "input": "[[1, 2, 2, 1], 2]", "output": "2" }, { "in...
112
false
112
verified
10
10
2
17,007
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MinMoves.Code.Funs /-! # Specifications of `Aegis.MinMoves.min_moves` LeetCode problem `minimum-moves-to-make-array-complementary`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.MinMoves def vals (nums : Slice Std.I64) : List Int := n...
12
minimize-deviation-in-array
1,675
Hard
[ "Greedy", "Array", "Ordered Set", "Heap (Priority Queue)" ]
You are given an array nums of n positive integers. You can perform two types of operations on any element of the array any number of times: If the element is even, divide it by 2. For example, if the array is [1,2,3,4], then you can do this operation on the last element, and the array will be [1,2,3,2]. If the e...
minimumDeviation(nums: list_int) -> int
pub fn minimum_deviation(nums: &[i64]) -> i64
Aegis.MinimumDeviation.minimum_deviation
pub fn minimum_deviation(nums: &[i64]) -> i64 { let n = nums.len(); if n == 0 { return 0; } let mut heap: Vec<i64> = Vec::new(); let mut min_v: i64 = 1000000000000000000; let mut i: usize = 0; while i < n { let mut val = nums[i]; if val % 2 != 0 { val = ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [minimum_deviation]: type definitions module public import Aeneas @[expose] public section 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_deviation]: function definitions module public import Aeneas public import Aegis.MinimumDeviation.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.MinimumDeviation.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.MinimumDeviation.minimum_deviation (Slice.from [1#i64, 1000000000#i64] (by scalar_tac) : Slice Std.I64)) (1953123#i64))}") #eval (s!"CASE 1 {(Re...
[ { "input": "[[1, 1000000000]]", "output": "1953123" }, { "input": "[[2, 10, 8]]", "output": "3" }, { "input": "[[1000000000, 1, 1000000000]]", "output": "1953123" }, { "input": "[[10, 10, 10]]", "output": "0" }, { "input": "[[3, 9, 6, 12]]", "output": "3" },...
105
false
105
verified
10
10
1
5,686
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MinimumDeviation.Code.Funs /-! # Specifications of `Aegis.MinimumDeviation.minimum_deviation` LeetCode problem `minimize-deviation-in-array`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.MinimumDeviation namespace AegisSpec.MinimumDeviation d...
14
max-number-of-k-sum-pairs
1,679
Medium
[ "Array", "Hash Table", "Two Pointers", "Sorting" ]
You are given an integer array nums and an integer k. In one operation, you can pick two numbers from the array whose sum equals k and remove them from the array. Return the maximum number of operations you can perform on the array.   Example 1: Input: nums = [1,2,3,4], k = 5 Output: 2 Explanation: Starting with nums ...
maxOperations(nums: list_int, k: int) -> int
pub fn max_operations(nums: &[i64], k: i64) -> i64
Aegis.MaxOperations.max_operations
pub fn max_operations(nums: &[i64], k: i64) -> i64 { let sorted = merge_sort(nums); let n = sorted.len(); let mut left: usize = 0; let mut right: usize = n; let mut count: i64 = 0; while left + 1 < right { let sum = sorted[left] + sorted[right - 1]; if sum == k { co...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [max_operations]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [max_operations]: function definitions module public import Aeneas public import Aegis.MaxOperations.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_opti...
import Aegis.MaxOperations.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.MaxOperations.max_operations (Slice.from [1000000000#i64] (by scalar_tac) : Slice Std.I64) 1000000000#i64) (0#i64))}") #eval (s!"CASE 1 {(Result.re...
[ { "input": "[[1000000000], 1000000000]", "output": "0" }, { "input": "[[1, 2, 3, 4], 5]", "output": "2" }, { "input": "[[3, 1, 3, 4, 3], 6]", "output": "1" }, { "input": "[[1, 3, 5, 7, 9], 10]", "output": "2" }, { "input": "[[5, 5, 5, 5, 5], 10]", "output": "2...
68
false
68
verified
10
10
1
4,837
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MaxOperations.Code.Funs /-! # Specifications of `Aegis.MaxOperations.max_operations` LeetCode problem `max-number-of-k-sum-pairs`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.MaxOperations def len (nums : Slice Std.I64) : ℕ := nums....
15
concatenation-of-consecutive-binary-numbers
1,680
Medium
[ "Bit Manipulation", "Math", "Simulation" ]
Given an integer n, return the decimal value of the binary string formed by concatenating the binary representations of 1 to n in order, modulo 109 + 7.   Example 1: Input: n = 1 Output: 1 Explanation: "1" in binary corresponds to the decimal value 1. Example 2: Input: n = 3 Output: 27 Explanation: In binary, 1, 2,...
concatenatedBinary(n: int) -> int
pub fn concatenated_binary(n: i64) -> i64
Aegis.ConcatenatedBinary.concatenated_binary
pub fn concatenated_binary(n: i64) -> i64 { let modulus: i64 = 1000000007; let mut ans: i64 = 0; let mut i: i64 = 1; let mut next_power: i64 = 2; let mut base: i64 = 2; while i <= n { if i >= next_power { next_power *= 2; base *= 2; } ans = (ans ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [concatenated_binary]: type definitions module public import Aeneas @[expose] public section 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 -- [concatenated_binary]: function definitions module public import Aeneas public import Aegis.ConcatenatedBinary.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand fals...
import Aegis.ConcatenatedBinary.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.ConcatenatedBinary.concatenated_binary 3#i64) (27#i64))}") #eval (s!"CASE 1 {(Result.reducesTo (Aegis.ConcatenatedBinary.concatenated_binary 1...
[ { "input": "[3]", "output": "27" }, { "input": "[100000]", "output": "757631812" }, { "input": "[100]", "output": "310828084" }, { "input": "[12]", "output": "505379714" }, { "input": "[10000]", "output": "356435599" }, { "input": "[20]", "output":...
28
false
28
verified
10
10
1
1,522
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.ConcatenatedBinary.Code.Funs /-! # Specifications of `Aegis.ConcatenatedBinary.concatenated_binary` LeetCode problem `concatenation-of-consecutive-binary-numbers`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.ConcatenatedBinary d...
3
longest-palindromic-subsequence-ii
1,682
Medium
[ "String", "Dynamic Programming" ]
A subsequence of a string s is considered a good palindromic subsequence if: It is a subsequence of s. It is a palindrome (has the same value if reversed). It has an even length. No two consecutive characters are equal, except the two middle ones. For example, if s = "abcabcabb", then "abba" is considered a good pali...
longestPalindromeSubseq(s: str) -> int
pub fn longest_palindrome_subseq(s: &[u8]) -> i64
Aegis.LongestPalindromeSubseq.longest_palindrome_subseq
pub fn longest_palindrome_subseq(s: &[u8]) -> i64 { let n = s.len(); if n < 2 { return 0; } let alpha: usize = 26; let total = n * n * alpha; let mut dp: Vec<i64> = Vec::new(); let mut i: usize = 0; while i < total { dp.push(0); i += 1; } let mut l: usiz...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [longest_palindrome_subseq]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_op...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [longest_palindrome_subseq]: function definitions module public import Aeneas public import Aegis.LongestPalindromeSubseq.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashC...
import Aegis.LongestPalindromeSubseq.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.LongestPalindromeSubseq.longest_palindrome_subseq (Slice.from [112#u8, 113#u8, 114#u8, 115#u8, 112#u8, 113#u8, 114#u8, 115#u8, 112#u8, 11...
[ { "input": "[\"pqrspqrspqr\"]", "output": "4" }, { "input": "[\"aabbaa\"]", "output": "4" }, { "input": "[\"abcdcba\"]", "output": "6" }, { "input": "[\"noonappa\"]", "output": "4" }, { "input": "[\"abcdedcba\"]", "output": "8" }, { "input": "[\"ababab...
121
false
121
verified
10
10
1
12,097
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.LongestPalindromeSubseq.Code.Funs /-! # Specifications of `Aegis.LongestPalindromeSubseq.longest_palindrome_subseq` LeetCode problem `longest-palindromic-subsequence-ii`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.LongestPalindromeS...
14
count-the-number-of-consistent-strings
1,684
Easy
[ "Bit Manipulation", "Array", "Hash Table", "String", "Counting" ]
You are given a string allowed consisting of distinct characters and an array of strings words. A string is consistent if all characters in the string appear in the string allowed. Return the number of consistent strings in the array words.   Example 1: Input: allowed = "ab", words = ["ad","bd","aaab","baa","badab"] O...
countConsistentStrings(allowed: str, words: list_str) -> int
pub fn count_consistent_strings(allowed: &[u8], words: &[Vec<u8>]) -> i64
Aegis.CountConsistentStrings.count_consistent_strings
pub fn count_consistent_strings(allowed: &[u8], words: &[Vec<u8>]) -> i64 { let mut count: i64 = 0; let mut wi: usize = 0; while wi < words.len() { let word = &words[wi]; let mut ok: bool = true; let mut ci: usize = 0; while ci < word.len() { let c: u8 = word[ci...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [count_consistent_strings]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_opt...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [count_consistent_strings]: function definitions module public import Aeneas public import Aegis.CountConsistentStrings.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCom...
import Aegis.CountConsistentStrings.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.CountConsistentStrings.count_consistent_strings (Slice.from [103#u8, 104#u8] (by scalar_tac) : Slice Std.U8) (Slice.from [(alloc.vec.Vec.f...
[ { "input": "[\"gh\", [\"g\", \"h\", \"gh\"]]", "output": "3" }, { "input": "[\"ab\", [\"ad\", \"bd\", \"aaab\", \"baa\", \"badab\"]]", "output": "2" }, { "input": "[\"xyz\", [\"xzy\", \"zyx\", \"zyzx\", \"xxxyyyzzz\", \"xzyxzyxzy\"]]", "output": "5" }, { "input": "[\"abcdef\"...
66
false
66
verified
10
10
1
1,183
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.CountConsistentStrings.Code.Funs /-! # Specifications of `Aegis.CountConsistentStrings.count_consistent_strings` LeetCode problem `count-the-number-of-consistent-strings`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.CountConsistentStrings ...
9
sum-of-absolute-differences-in-a-sorted-array
1,685
Medium
[ "Array", "Math", "Prefix Sum" ]
You are given an integer array nums sorted in non-decreasing order. Build and return an integer array result with the same length as nums such that result[i] is equal to the summation of absolute differences between nums[i] and all the other elements in the array. In other words, result[i] is equal to sum(|nums[i]-nums...
getSumAbsoluteDifferences(nums: list_int) -> list_int
pub fn get_sum_absolute_differences(nums: &[i64]) -> Vec<i64>
Aegis.GetSumAbsoluteDifferences.get_sum_absolute_differences
pub fn get_sum_absolute_differences(nums: &[i64]) -> Vec<i64> { let n = nums.len(); let mut total: i64 = 0; let mut n_i64: i64 = 0; let mut k: usize = 0; while k < n { total = total + nums[k]; n_i64 = n_i64 + 1; k = k + 1; } let mut result: Vec<i64> = Vec::new(); ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [get_sum_absolute_differences]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [get_sum_absolute_differences]: function definitions module public import Aeneas public import Aegis.GetSumAbsoluteDifferences.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter....
import Aegis.GetSumAbsoluteDifferences.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.GetSumAbsoluteDifferences.get_sum_absolute_differences (Slice.from [2#i64, 3#i64, 5#i64] (by scalar_tac) : Slice Std.I64)) ((alloc.vec....
[ { "input": "[[2, 3, 5]]", "output": "[4, 3, 5]" }, { "input": "[[1, 1, 1, 1]]", "output": "[0, 0, 0, 0]" }, { "input": "[[1, 1, 1, 1, 1]]", "output": "[0, 0, 0, 0, 0]" }, { "input": "[[100, 200, 300, 400, 500]]", "output": "[1000, 700, 600, 700, 1000]" }, { "input...
69
false
69
verified
10
10
1
1,156
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.GetSumAbsoluteDifferences.Code.Funs /-! # Specifications of `Aegis.GetSumAbsoluteDifferences.get_sum_absolute_differences` LeetCode problem `sum-of-absolute-differences-in-a-sorted-array`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.GetSumAbso...
13
stone-game-vi
1,686
Medium
[ "Greedy", "Array", "Math", "Game Theory", "Sorting", "Heap (Priority Queue)" ]
Alice and Bob take turns playing a game, with Alice starting first. There are n stones in a pile. On each player's turn, they can remove a stone from the pile and receive points based on the stone's value. Alice and Bob may value the stones differently. You are given two integer arrays of length n, aliceValues and bobV...
stoneGameVI(aliceValues: list_int, bobValues: list_int) -> int
pub fn stone_game_vi(aliceValues: &[i64], bobValues: &[i64]) -> i64
Aegis.StoneGameVi.stone_game_vi
pub fn stone_game_vi(alice_values: &[i64], bob_values: &[i64]) -> i64 { let n = alice_values.len(); let mut diff: i64 = 0; let mut turn: i64 = 0; let mut wanted_sum: i64 = 200; while wanted_sum >= 2 { let mut i: usize = 0; while i < n { if alice_values[i] + bob_values[i]...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [stone_game_vi]: type definitions module public import Aeneas @[expose] public section 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_vi]: function definitions module public import Aeneas public import Aegis.StoneGameVi.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.StoneGameVi.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.StoneGameVi.stone_game_vi (Slice.from [100#i64] (by scalar_tac) : Slice Std.I64) (Slice.from [1#i64] (by scalar_tac) : Slice Std.I64)) (1#i64))}") #e...
[ { "input": "[[100], [1]]", "output": "1" }, { "input": "[[1, 2], [3, 1]]", "output": "0" }, { "input": "[[1, 3], [2, 1]]", "output": "1" }, { "input": "[[10, 20, 30], [30, 20, 10]]", "output": "1" }, { "input": "[[7, 8, 9], [9, 8, 7]]", "output": "1" }, { ...
106
false
106
verified
10
10
1
1,860
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.StoneGameVi.Code.Funs /-! # Specifications of `Aegis.StoneGameVi.stone_game_vi` LeetCode problem `stone-game-vi`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.StoneGameVi local notation "stone_game_vi" => Aegis.StoneGameVi.stone_game...
14
count-of-matches-in-tournament
1,688
Easy
[ "Math", "Simulation" ]
You are given an integer n, the number of teams in a tournament that has strange rules: If the current number of teams is even, each team gets paired with another team. A total of n / 2 matches are played, and n / 2 teams advance to the next round. If the current number of teams is odd, one team randomly advances in t...
numberOfMatches(n: int) -> int
pub fn number_of_matches(n: i64) -> i64
Aegis.NumberOfMatches.number_of_matches
pub fn number_of_matches(n: i64) -> i64 { n - 1 }
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [number_of_matches]: type definitions module public import Aeneas @[expose] public section 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 -- [number_of_matches]: function definitions module public import Aeneas public import Aegis.NumberOfMatches.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.NumberOfMatches.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.NumberOfMatches.number_of_matches 3#i64) (2#i64))}") #eval (s!"CASE 1 {(Result.reducesTo (Aegis.NumberOfMatches.number_of_matches 100#i64) (99#i6...
[ { "input": "[3]", "output": "2" }, { "input": "[100]", "output": "99" }, { "input": "[14]", "output": "13" }, { "input": "[200]", "output": "199" }, { "input": "[17]", "output": "16" }, { "input": "[2]", "output": "1" }, { "input": "[199]",...
60
false
60
verified
10
10
1
307
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.NumberOfMatches.Code.Funs /-! # Specifications of `Aegis.NumberOfMatches.number_of_matches` LeetCode problem `count-of-matches-in-tournament`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.NumberOfMatches /-- The function returns ...
9
partitioning-into-minimum-number-of-deci-binary-numbers
1,689
Medium
[ "Greedy", "String" ]
A decimal number is called deci-binary if each of its digits is either 0 or 1 without any leading zeros. For example, 101 and 1100 are deci-binary, while 112 and 3001 are not. Given a string n that represents a positive decimal integer, return the minimum number of positive deci-binary numbers needed so that they sum u...
minPartitions(n: str) -> int
pub fn min_partitions(n: &[u8]) -> i64
Aegis.MinPartitions.min_partitions
pub fn min_partitions(n: &[u8]) -> i64 { let mut max_digit: u8 = 0; let mut i: usize = 0; while i < n.len() { let d: u8 = n[i] - b'0'; if d > max_digit { max_digit = d; } i += 1; } max_digit as i64 }
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [min_partitions]: type definitions module public import Aeneas @[expose] public section 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_partitions]: function definitions module public import Aeneas public import Aegis.MinPartitions.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.MinPartitions.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.MinPartitions.min_partitions (Slice.from [57#u8, 56#u8, 55#u8, 54#u8, 53#u8, 52#u8, 51#u8, 50#u8, 49#u8, 48#u8] (by scalar_tac) : Slice Std.U8)) (9...
[ { "input": "[\"9876543210\"]", "output": "9" }, { "input": "[\"111\"]", "output": "1" }, { "input": "[\"123456789\"]", "output": "9" }, { "input": "[\"1\"]", "output": "1" }, { "input": "[\"82734\"]", "output": "8" }, { "input": "[\"32\"]", "output...
72
false
72
verified
10
10
1
408
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MinPartitions.Code.Funs /-! # Specifications of `Aegis.MinPartitions.min_partitions` LeetCode problem `partitioning-into-minimum-number-of-deci-binary-numbers`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.MinPartitions def decDigits...
13
stone-game-vii
1,690
Medium
[ "Array", "Math", "Dynamic Programming", "Game Theory" ]
Alice and Bob take turns playing a game, with Alice starting first. There are n stones arranged in a row. On each player's turn, they can remove either the leftmost stone or the rightmost stone from the row and receive points equal to the sum of the remaining stones' values in the row. The winner is the one with the hi...
stoneGameVII(stones: list_int) -> int
pub fn stone_game_vii(stones: &[i64]) -> i64
Aegis.StoneGameVii.stone_game_vii
pub fn stone_game_vii(stones: &[i64]) -> i64 { let n = stones.len(); if n == 0 { return 0; } if n == 1 { return 0; } let mut prefix: Vec<i64> = Vec::new(); prefix.push(0); let mut i: usize = 0; while i < n { let prev = prefix[i]; prefix.push(prev + s...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [stone_game_vii]: type definitions module public import Aeneas @[expose] public section 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_vii]: function definitions module public import Aeneas public import Aegis.StoneGameVii.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.StoneGameVii.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.StoneGameVii.stone_game_vii (Slice.from [1#i64, 2#i64, 3#i64, 4#i64, 5#i64] (by scalar_tac) : Slice Std.I64)) (6#i64))}") #eval (s!"CASE 1 {(Result....
[ { "input": "[[1, 2, 3, 4, 5]]", "output": "6" }, { "input": "[[10, 20, 30, 40, 50]]", "output": "60" }, { "input": "[[5, 3, 1, 4, 2]]", "output": "6" }, { "input": "[[1, 100, 1, 100, 1, 100]]", "output": "300" }, { "input": "[[7, 90, 5, 1, 100, 10, 10, 2]]", "...
109
false
109
verified
10
10
1
3,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.StoneGameVii.Code.Funs /-! # Specifications of `Aegis.StoneGameVii.stone_game_vii` LeetCode problem `stone-game-vii`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.StoneGameVii def vals (l : List Std.I64) : List ℤ := l.map fun x =...
11
maximum-height-by-stacking-cuboids
1,691
Hard
[ "Array", "Dynamic Programming", "Sorting" ]
Given n cuboids where the dimensions of the ith cuboid is cuboids[i] = [widthi, lengthi, heighti] (0-indexed). Choose a subset of cuboids and place them on each other. You can place cuboid i on cuboid j if widthi <= widthj and lengthi <= lengthj and heighti <= heightj. You can rearrange any cuboid's dimensions by rotat...
maxHeight(cuboids: list_list_int) -> int
pub fn max_height(cuboids: &[Vec<i64>]) -> i64
Aegis.MaxHeight.max_height
pub fn max_height(cuboids: &[Vec<i64>]) -> i64 { let n = cuboids.len(); let mut a: Vec<i64> = Vec::new(); let mut b: Vec<i64> = Vec::new(); let mut c: Vec<i64> = Vec::new(); let mut i: usize = 0; while i < n { let row = &cuboids[i]; let mut x = row[0]; let mut y = row[1...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [max_height]: type definitions module public import Aeneas @[expose] public section 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 -- [max_height]: function definitions module public import Aeneas public import Aegis.MaxHeight.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linte...
import Aegis.MaxHeight.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.MaxHeight.max_height (Slice.from [(alloc.vec.Vec.from [38#i64, 25#i64, 45#i64] (by scalar_tac) : alloc.vec.Vec Std.I64), (alloc.vec.Vec.from [76#i64, 3...
[ { "input": "[[[38, 25, 45], [76, 35, 3]]]", "output": "76" }, { "input": "[[[10, 10, 10], [5, 5, 5], [20, 20, 20]]]", "output": "35" }, { "input": "[[[1, 1, 1], [2, 2, 2], [3, 3, 3]]]", "output": "6" }, { "input": "[[[50, 45, 20], [95, 37, 53], [45, 23, 12]]]", "output": ...
108
false
108
verified
10
10
1
8,005
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MaxHeight.Code.Funs /-! # Specifications of `Aegis.MaxHeight.max_height` LeetCode problem `maximum-height-by-stacking-cuboids`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.MaxHeight open Aegis.MaxHeight def rows (cuboids : Slice (a...
13
count-ways-to-distribute-candies
1,692
Hard
[ "Dynamic Programming" ]
There are n unique candies (labeled 1 through n) and k bags. You are asked to distribute all the candies into the bags such that every bag has at least one candy. There can be multiple ways to distribute the candies. Two ways are considered different if the candies in one bag in the first way are not all in the same ba...
waysToDistribute(n: int, k: int) -> int
pub fn ways_to_distribute(n: i64, k: i64) -> i64
Aegis.WaysToDistribute.ways_to_distribute
fn mod_pow(mut base: i64, mut exp: i64, modv: i64) -> i64 { let mut res: i64 = 1; base = base % modv; while exp > 0 { if exp % 2 == 1 { res = (res * base) % modv; } base = (base * base) % modv; exp = exp / 2; } res } pub fn ways_to_distribute(n: i64, k: i...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [ways_to_distribute]: type definitions module public import Aeneas @[expose] public section 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 -- [ways_to_distribute]: function definitions module public import Aeneas public import Aegis.WaysToDistribute.Code.Types public import Aegis.WaysToDistribute.Code.FunsExternal @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.d...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [ways_to_distribute]: external functions. -- This is a template file: rename it to "FunsExternal.lean" and fill the holes. module public import Aeneas public import Aegis.WaysToDistribute.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow ...
import Aegis.WaysToDistribute.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval aegi...
[ { "input": "[1000, 500]", "output": "596728287" }, { "input": "[3, 2]", "output": "3" }, { "input": "[1, 1]", "output": "1" }, { "input": "[5, 1]", "output": "1" }, { "input": "[10, 10]", "output": "1" }, { "input": "[10, 3]", "output": "9330" },...
78
false
78
verified
10
10
2
13,723
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.WaysToDistribute.Code.Funs /-! # Specifications of `Aegis.WaysToDistribute.ways_to_distribute` LeetCode problem `count-ways-to-distribute-candies`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.WaysToDistribute def IsSetPartition ...
4
maximum-erasure-value
1,695
Medium
[ "Array", "Hash Table", "Sliding Window" ]
You are given an array of positive integers nums and want to erase a subarray containing unique elements. The score you get by erasing the subarray is equal to the sum of its elements. Return the maximum score you can get by erasing exactly one subarray. An array b is called to be a subarray of a if it forms a contiguo...
maximumUniqueSubarray(nums: list_int) -> int
pub fn maximum_unique_subarray(nums: &[i64]) -> i64
Aegis.MaximumUniqueSubarray.maximum_unique_subarray
pub fn maximum_unique_subarray(nums: &[i64]) -> i64 { let n = nums.len(); if n == 0 { return 0; } // Small fixed bitset over value / 64. Values are bounded by 10^4, // so 160 i64 words are enough and this avoids a large value-sized Vec. let mut bits: Vec<i64> = Vec::new(); let mut i...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [maximum_unique_subarray]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_opti...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [maximum_unique_subarray]: function definitions module public import Aeneas public import Aegis.MaximumUniqueSubarray.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashComma...
import Aegis.MaximumUniqueSubarray.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval...
[ { "input": "[[1]]", "output": "1" }, { "input": "[[1, 1, 1, 1, 1]]", "output": "1" }, { "input": "[[10000, 9999, 9998, 9997, 9996]]", "output": "49990" }, { "input": "[[1, 2, 3, 4, 5]]", "output": "15" }, { "input": "[[4, 2, 4, 5, 6]]", "output": "17" }, {...
105
false
105
verified
10
10
2
9,539
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MaximumUniqueSubarray.Code.Funs /-! # Specifications of `Aegis.MaximumUniqueSubarray.maximum_unique_subarray` LeetCode problem `maximum-erasure-value`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.MaximumUniqueSubarray def vals (...
8
jump-game-vi
1,696
Medium
[ "Queue", "Array", "Dynamic Programming", "Monotonic Queue", "Heap (Priority Queue)" ]
You are given a 0-indexed integer array nums and an integer k. You are initially standing at index 0. In one move, you can jump at most k steps forward without going outside the boundaries of the array. That is, you can jump from index i to any index in the range [i + 1, min(n - 1, i + k)] inclusive. You want to reach ...
maxResult(nums: list_int, k: int) -> int
pub fn max_result(nums: &[i64], k: i64) -> i64
Aegis.MaxResult.max_result
pub fn max_result(nums: &[i64], k: i64) -> i64 { let n = nums.len(); if n == 0 { return 0; } let mut dp: Vec<i64> = Vec::new(); dp.push(nums[0]); // Monotonic deque of indices, stored as i64. // Elements before `head` are considered removed from the front. let mut q: Vec<i64> =...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [max_result]: type definitions module public import Aeneas @[expose] public section 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 -- [max_result]: function definitions module public import Aeneas public import Aegis.MaxResult.Code.Types public import Aegis.MaxResult.Code.FunsExternal @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [max_result]: external functions. -- This is a template file: rename it to "FunsExternal.lean" and fill the holes. module public import Aeneas public import Aegis.MaxResult.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_optio...
import Aegis.MaxResult.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.MaxResult.max_result (Slice.from [1#i64] (by scalar_tac) : Slice Std.I64) 1#i64) (1#i64))}") #eval (s!"CASE 1 {(Result.reducesTo (Aegis.MaxResult.max_r...
[ { "input": "[[1], 1]", "output": "1" }, { "input": "[[5, -1, 5], 2]", "output": "10" }, { "input": "[[-5, -1, -5], 1]", "output": "-11" }, { "input": "[[-1, -2, -3, -4, -5], 4]", "output": "-6" }, { "input": "[[-10000, -10000, -10000, -10000, -10000], 2]", "ou...
92
false
92
verified
10
10
1
3,401
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MaxResult.Code.Funs /-! # Specifications of `Aegis.MaxResult.max_result` LeetCode problem `jump-game-vi`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.MaxResult def vals (nums : Slice Std.I64) : List Int := nums.val.map (fun x =>...
10
checking-existence-of-edge-length-limited-paths
1,697
Hard
[ "Union Find", "Graph", "Array", "Two Pointers", "Sorting" ]
An undirected graph of n nodes is defined by edgeList, where edgeList[i] = [ui, vi, disi] denotes an edge between nodes ui and vi with distance disi. Note that there may be multiple edges between two nodes. Given an array queries, where queries[j] = [pj, qj, limitj], your task is to determine for each queries[j] whethe...
distanceLimitedPathsExist(n: int, edgeList: list_list_int, queries: list_list_int) -> list_bool
pub fn distance_limited_paths_exist(n: i64, edgeList: &[Vec<i64>], queries: &[Vec<i64>]) -> Vec<bool>
Aegis.DistanceLimitedPathsExist.distance_limited_paths_exist
fn find(parent: &mut Vec<i64>, x: i64) -> i64 { let mut r = x; while parent[r as usize] != r { r = parent[r as usize]; } let mut cur = x; while parent[cur as usize] != r { let nxt = parent[cur as usize]; parent[cur as usize] = r; cur = nxt; } r } pub fn dis...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [distance_limited_paths_exist]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [distance_limited_paths_exist]: function definitions module public import Aeneas public import Aegis.DistanceLimitedPathsExist.Code.Types public import Aegis.DistanceLimitedPathsExist.Code.FunsExternal @[expose] public section open Aeneas Aeneas.Std Result ControlFl...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [distance_limited_paths_exist]: external functions. -- This is a template file: rename it to "FunsExternal.lean" and fill the holes. module public import Aeneas public import Aegis.DistanceLimitedPathsExist.Code.Types @[expose] public section open Aeneas Aeneas.Std ...
import Aegis.DistanceLimitedPathsExist.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.DistanceLimitedPathsExist.distance_limited_paths_exist 2#i64 (Slice.from [(alloc.vec.Vec.from [0#i64, 1#i64, 1#i64] (by scalar_tac) : a...
[ { "input": "[2, [[0, 1, 1]], [[0, 1, 2], [0, 1, 1]]]", "output": "[true, false]" }, { "input": "[3, [[0, 1, 2], [1, 2, 4], [2, 0, 8], [1, 0, 16]], [[0, 1, 2], [0, 2, 5]]]", "output": "[false, true]" }, { "input": "[4, [[0, 1, 5], [1, 2, 10], [2, 3, 15], [3, 0, 20]], [[0, 3, 15], [1, 2, 8...
62
false
62
verified
10
10
1
3,658
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.DistanceLimitedPathsExist.Code.Funs /-! # Specifications of `Aegis.DistanceLimitedPathsExist.distance_limited_paths_exist` LeetCode problem `checking-existence-of-edge-length-limited-paths`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result ControlFlow Error ...
9
number-of-distinct-substrings-in-a-string
1,698
Medium
[ "Trie", "String", "Suffix Array", "Hash Function", "Rolling Hash" ]
Given a string s, return the number of distinct substrings of s. A substring of a string is obtained by deleting any number of characters (possibly zero) from the front of the string and any number (possibly zero) from the back of the string.   Example 1: Input: s = "aabbaba" Output: 21 Explanation: The set of distinc...
countDistinct(s: str) -> int
pub fn count_distinct(s: &[u8]) -> i64
Aegis.CountDistinct.count_distinct
pub fn count_distinct(s: &[u8]) -> i64 { let n = s.len(); if n == 0 { return 0; } let mut children: Vec<Vec<i64>> = Vec::new(); let mut root: Vec<i64> = Vec::new(); let mut k: usize = 0; while k < 26 { root.push(-1); k += 1; } children.push(root); let m...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [count_distinct]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [count_distinct]: function definitions module public import Aeneas public import Aegis.CountDistinct.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_opti...
import Aegis.CountDistinct.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.CountDistinct.count_distinct (Slice.from [97#u8, 97#u8, 97#u8, 97#u8, 98#u8, 98#u8, 98#u8, 98#u8] (by scalar_tac) : Slice Std.U8)) (24#i64))}") #ev...
[ { "input": "[\"aaaabbbb\"]", "output": "24" }, { "input": "[\"abcdefghijklmnopqrstuvwxyz\"]", "output": "351" }, { "input": "[\"abac\"]", "output": "9" }, { "input": "[\"abababab\"]", "output": "15" }, { "input": "[\"aaaaa\"]", "output": "5" }, { "inpu...
84
false
84
verified
10
10
1
4,574
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.CountDistinct.Code.Funs /-! # Specifications of `Aegis.CountDistinct.count_distinct` LeetCode problem `number-of-distinct-substrings-in-a-string`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.CountDistinct namespace AegisSpec.CountDistinct...
8
minimum-adjacent-swaps-for-k-consecutive-ones
1,703
Hard
[ "Greedy", "Array", "Prefix Sum", "Sliding Window" ]
You are given an integer array, nums, and an integer k. nums comprises of only 0's and 1's. In one move, you can choose two adjacent indices and swap their values. Return the minimum number of moves required so that nums has k consecutive 1's.   Example 1: Input: nums = [1,0,0,1,0,1], k = 2 Output: 1 Explanation: In 1...
minMoves(nums: list_int, k: int) -> int
pub fn min_moves(nums: &[i64], k: i64) -> i64
Aegis.MinMoves.min_moves
pub fn min_moves(nums: &[i64], k: i64) -> i64 { let mut positions: Vec<i64> = Vec::new(); let n = nums.len(); let mut idx: usize = 0; while idx < n { if nums[idx] == 1 { positions.push(idx as i64); } idx += 1; } let m = positions.len(); let kk = k as usi...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [min_moves]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter.styl...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [min_moves]: function definitions module public import Aeneas public import Aegis.MinMoves.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.MinMoves.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.MinMoves.min_moves (Slice.from [1#i64, 1#i64, 0#i64, 1#i64] (by scalar_tac) : Slice Std.I64) 2#i64) (0#i64))}") #eval (s!"CASE 1 {(Result.reducesTo (Aeg...
[ { "input": "[[1, 1, 0, 1], 2]", "output": "0" }, { "input": "[[1, 1, 1, 1, 1], 3]", "output": "0" }, { "input": "[[1, 0, 0, 1, 0, 1], 2]", "output": "1" }, { "input": "[[1, 0, 1, 0, 1, 0, 1], 3]", "output": "2" }, { "input": "[[1, 0, 0, 0, 0, 0, 1, 1], 3]", "o...
97
false
97
verified
10
10
1
3,713
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MinMoves.Code.Funs /-! # Specifications of `Aegis.MinMoves.min_moves` LeetCode problem `minimum-adjacent-swaps-for-k-consecutive-ones`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.MinMoves def absSub (a b : ℤ) : ℤ := if a ≤ b then b...
14
determine-if-string-halves-are-alike
1,704
Easy
[ "String", "Counting" ]
You are given a string s of even length. Split this string into two halves of equal lengths, and let a be the first half and b be the second half. Two strings are alike if they have the same number of vowels ('a', 'e', 'i', 'o', 'u', 'A', 'E', 'I', 'O', 'U'). Notice that s contains uppercase and lowercase letters. Retu...
halvesAreAlike(s: str) -> bool
pub fn halves_are_alike(s: &[u8]) -> bool
Aegis.HalvesAreAlike.halves_are_alike
fn is_vowel(c: u8) -> bool { c == b'a' || c == b'e' || c == b'i' || c == b'o' || c == b'u' || c == b'A' || c == b'E' || c == b'I' || c == b'O' || c == b'U' } pub fn halves_are_alike(s: &[u8]) -> bool { let n = s.len(); let half = n / 2...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [halves_are_alike]: type definitions module public import Aeneas @[expose] public section 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 -- [halves_are_alike]: function definitions module public import Aeneas public import Aegis.HalvesAreAlike.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.HalvesAreAlike.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.HalvesAreAlike.halves_are_alike (Slice.from [85#u8, 70#u8, 79#u8] (by scalar_tac) : Slice Std.U8)) (false))}") #eval (s!"CASE 1 {(Result.reducesTo...
[ { "input": "[\"UFO\"]", "output": "false" }, { "input": "[\"aAeEiIoOuU\"]", "output": "true" }, { "input": "[\"Leetcode\"]", "output": "true" }, { "input": "[\"abcdefgihjklmno\"]", "output": "false" }, { "input": "[\"Regal\"]", "output": "true" }, { "i...
175
false
175
verified
10
10
1
581
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.HalvesAreAlike.Code.Funs /-! # Specifications of `Aegis.HalvesAreAlike.halves_are_alike` LeetCode problem `determine-if-string-halves-are-alike`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.HalvesAreAlike def IsVowelByte (x : Std.U8...
8
maximum-number-of-eaten-apples
1,705
Medium
[ "Greedy", "Array", "Heap (Priority Queue)" ]
There is a special kind of apple tree that grows apples every day for n days. On the ith day, the tree grows apples[i] apples that will rot after days[i] days, that is on day i + days[i] the apples will be rotten and cannot be eaten. On some days, the apple tree does not grow any apples, which are denoted by apples[i] ...
eatenApples(apples: list_int, days: list_int) -> int
pub fn eaten_apples(apples: &[i64], days: &[i64]) -> i64
Aegis.EatenApples.eaten_apples
fn push_apple(heap_exp: &mut Vec<i64>, heap_cnt: &mut Vec<i64>, exp: i64, cnt: i64) { heap_exp.push(exp); heap_cnt.push(cnt); let mut i = heap_exp.len() - 1; while i > 0 { let p = (i - 1) / 2; if heap_exp[p] <= heap_exp[i] { break; } let te = heap_exp[p]; ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [eaten_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 linter.s...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [eaten_apples]: function definitions module public import Aeneas public import Aegis.EatenApples.Code.Types public import Aegis.EatenApples.Code.FunsExternal @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace fals...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [eaten_apples]: external functions. -- This is a template file: rename it to "FunsExternal.lean" and fill the holes. module public import Aeneas public import Aegis.EatenApples.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_o...
import Aegis.EatenApples.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.EatenApples.eaten_apples (Slice.from [1#i64, 3#i64, 2#i64] (by scalar_tac) : Slice Std.I64) (Slice.from [3#i64, 5#i64, 2#i64] (by scalar_tac) : Slice...
[ { "input": "[[1, 3, 2], [3, 5, 2]]", "output": "6" }, { "input": "[[2, 1, 10], [2, 10, 1]]", "output": "4" }, { "input": "[[0, 0, 0, 0], [0, 0, 0, 0]]", "output": "0" }, { "input": "[[5, 5, 5, 5, 5], [1, 2, 3, 4, 5]]", "output": "9" }, { "input": "[[5, 5, 5, 5, 5]...
72
false
72
verified
10
10
1
5,129
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.EatenApples.Code.Funs /-! # Specifications of `Aegis.EatenApples.eaten_apples` LeetCode problem `maximum-number-of-eaten-apples`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.EatenApples def getZ (l : List Std.I64) (i : ℤ) : ℤ := i...
16
where-will-the-ball-fall
1,706
Medium
[ "Array", "Matrix", "Simulation" ]
You have a 2-D grid of size m x n representing a box, and you have n balls. The box is open on the top and bottom sides. Each cell in the box has a diagonal board spanning two corners of the cell that can redirect a ball to the right or to the left. A board that redirects the ball to the right spans the top-left corne...
findBall(grid: list_list_int) -> list_int
pub fn find_ball(grid: &[Vec<i64>]) -> Vec<i64>
Aegis.FindBall.find_ball
pub fn find_ball(grid: &[Vec<i64>]) -> Vec<i64> { let m = grid.len(); let n = grid[0].len(); let mut answer: Vec<i64> = Vec::new(); let mut col: usize = 0; while col < n { let mut pos: usize = col; let mut row: usize = 0; let mut stuck: bool = false; while row < m {...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [find_ball]: type definitions module public import Aeneas @[expose] public section 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 -- [find_ball]: function definitions module public import Aeneas public import Aegis.FindBall.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.FindBall.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.FindBall.find_ball (Slice.from [(alloc.vec.Vec.from [(-1)#i64] (by scalar_tac) : alloc.vec.Vec Std.I64)] (by scalar_tac) : Slice (alloc.vec.Vec Std.I64)...
[ { "input": "[[[-1]]]", "output": "[-1]" }, { "input": "[[[1, 1, 1], [1, 1, 1], [1, 1, 1]]]", "output": "[-1, -1, -1]" }, { "input": "[[[-1, -1, -1], [-1, -1, -1], [-1, -1, -1]]]", "output": "[-1, -1, -1]" }, { "input": "[[[1, 1, 1], [1, 1, 1], [-1, -1, -1]]]", "output": "...
65
false
65
verified
10
10
1
1,148
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.FindBall.Code.Funs /-! # Specifications of `Aegis.FindBall.find_ball` LeetCode problem `where-will-the-ball-fall`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result ControlFlow Error namespace AegisSpec.FindBall def entry (l : List Std.I64) (i : ℕ) : Option ...
13
maximum-units-on-a-truck
1,710
Easy
[ "Greedy", "Array", "Sorting" ]
You are assigned to put some amount of boxes onto one truck. You are given a 2D array boxTypes, where boxTypes[i] = [numberOfBoxesi, numberOfUnitsPerBoxi]: numberOfBoxesi is the number of boxes of type i. numberOfUnitsPerBoxi is the number of units in each box of the type i. You are also given an integer truckSize, w...
maximumUnits(boxTypes: list_list_int, truckSize: int) -> int
pub fn maximum_units(boxTypes: &[Vec<i64>], truckSize: i64) -> i64
Aegis.MaximumUnits.maximum_units
pub fn maximum_units(boxTypes: &[Vec<i64>], truckSize: i64) -> i64 { let n = boxTypes.len(); let mut max_unit: i64 = 0; let mut i: usize = 0; while i < n { let row = &boxTypes[i]; let unit = row[1]; if unit > max_unit { max_unit = unit; } i += 1; ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [maximum_units]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter....
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [maximum_units]: function definitions module public import Aeneas public import Aegis.MaximumUnits.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.MaximumUnits.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.MaximumUnits.maximum_units (Slice.from [(alloc.vec.Vec.from [10#i64, 1#i64] (by scalar_tac) : alloc.vec.Vec Std.I64)] (by scalar_tac) : Slice (alloc...
[ { "input": "[[[10, 1]], 10]", "output": "10" }, { "input": "[[[1, 1000], [1000, 1]], 500]", "output": "1499" }, { "input": "[[[1, 999], [999, 1]], 1000]", "output": "1998" }, { "input": "[[[1, 3], [2, 2], [3, 1]], 4]", "output": "8" }, { "input": "[[[2, 1], [4, 4]...
104
false
104
verified
10
10
1
1,535
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MaximumUnits.Code.Funs /-! # Specifications of `Aegis.MaximumUnits.maximum_units` LeetCode problem `maximum-units-on-a-truck`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.MaximumUnits namespace AegisSpec.MaximumUnits abbrev BoxTypes := Slice...
16
count-good-meals
1,711
Medium
[ "Array", "Hash Table" ]
A good meal is a meal that contains exactly two different food items with a sum of deliciousness equal to a power of two. You can pick any two different foods to make a good meal. Given an array of integers deliciousness where deliciousness[i] is the deliciousness of the i​​​​​​th​​​​​​​​ item of food, return the numbe...
countPairs(deliciousness: list_int) -> int
pub fn count_pairs(deliciousness: &[i64]) -> i64
Aegis.CountPairs.count_pairs
pub fn count_pairs(deliciousness: &[i64]) -> i64 { let modulo: i64 = 1000000007; let n = deliciousness.len(); if n < 2 { return 0; } // Copy the input into an owned vector. let mut src: Vec<i64> = Vec::new(); let mut i: usize = 0; while i < n { src.push(deliciousness[i])...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [count_pairs]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter.st...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [count_pairs]: function definitions module public import Aeneas public import Aegis.CountPairs.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option lin...
import Aegis.CountPairs.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval aegisCase ...
[ { "input": "[[1]]", "output": "0" }, { "input": "[[0, 0]]", "output": "0" }, { "input": "[[1048576, 1048576]]", "output": "1" }, { "input": "[[1048576, 1048576]]", "output": "1" }, { "input": "[[1, 1048575]]", "output": "1" }, { "input": "[[13, 100, 13...
101
false
101
verified_partial
10
7
2
30,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.CountPairs.Code.Funs /-! # Specifications of `Aegis.CountPairs.count_pairs` LeetCode problem `count-good-meals`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.CountPairs def IsPowerOfTwo (x : ℤ) : Prop := ∃ k : ℕ, x = 2 ^ k def...
7
ways-to-split-array-into-three-subarrays
1,712
Medium
[ "Array", "Two Pointers", "Binary Search", "Prefix Sum" ]
A split of an integer array is good if: The array is split into three non-empty contiguous subarrays - named left, mid, right respectively from left to right. The sum of the elements in left is less than or equal to the sum of the elements in mid, and the sum of the elements in mid is less than or equal to the sum of ...
waysToSplit(nums: list_int) -> int
pub fn ways_to_split(nums: &[i64]) -> i64
Aegis.WaysToSplit.ways_to_split
pub fn ways_to_split(nums: &[i64]) -> i64 { let n: usize = nums.len(); if n < 3 { return 0; } let mut prefix: Vec<i64> = Vec::new(); prefix.push(0); let mut k: usize = 0; while k < n { let next: i64 = prefix[k] + nums[k]; prefix.push(next); k += 1; } ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [ways_to_split]: type definitions module public import Aeneas @[expose] public section 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 -- [ways_to_split]: function definitions module public import Aeneas public import Aegis.WaysToSplit.Code.Types public import Aegis.WaysToSplit.Code.FunsExternal @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace fal...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [ways_to_split]: external functions. -- This is a template file: rename it to "FunsExternal.lean" and fill the holes. module public import Aeneas public import Aegis.WaysToSplit.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_...
import Aegis.WaysToSplit.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.WaysToSplit.ways_to_split (Slice.from [10000#i64, 10000#i64, 10000#i64] (by scalar_tac) : Slice Std.I64)) (1#i64))}") #eval (s!"CASE 1 {(Result.reduc...
[ { "input": "[[10000, 10000, 10000]]", "output": "1" }, { "input": "[[1, 1, 1]]", "output": "1" }, { "input": "[[3, 2, 1]]", "output": "0" }, { "input": "[[10, 4, -8, 7]]", "output": "0" }, { "input": "[[9, 4, 2, 5, 1]]", "output": "0" }, { "input": "[[...
93
false
93
verified
10
10
1
21,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.WaysToSplit.Code.Funs /-! # Specifications of `Aegis.WaysToSplit.ways_to_split` LeetCode problem `ways-to-split-array-into-three-subarrays`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.WaysToSplit namespace AegisSpec.WaysToSplit def mo...
9
minimum-operations-to-make-a-subsequence
1,713
Hard
[ "Greedy", "Array", "Hash Table", "Binary Search" ]
You are given an array target that consists of distinct integers and another integer array arr that can have duplicates. In one operation, you can insert any integer at any position in arr. For example, if arr = [1,4,1,2], you can add 3 in the middle and make it [1,4,3,1,2]. Note that you can insert the integer at the ...
minOperations(target: list_int, arr: list_int) -> int
pub fn min_operations(target: &[i64], arr: &[i64]) -> i64
Aegis.MinOperations.min_operations
pub fn min_operations(target: &[i64], arr: &[i64]) -> i64 { let n = target.len(); if n == 0 { return 0; } // Build pairs (target value, original target index), stored in two parallel vectors. let mut vals: Vec<i64> = Vec::new(); let mut idxs: Vec<i64> = Vec::new(); let mut i = 0usi...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [min_operations]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [min_operations]: function definitions module public import Aeneas public import Aegis.MinOperations.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_opti...
import Aegis.MinOperations.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.MinOperations.min_operations (Slice.from [1#i64] (by scalar_tac) : Slice Std.I64) (Slice.from [1#i64] (by scalar_tac) : Slice Std.I64)) (0#i64))}")...
[ { "input": "[[1], [1]]", "output": "0" }, { "input": "[[1], [1, 1, 1, 1]]", "output": "0" }, { "input": "[[1, 2, 3], [4, 5, 6]]", "output": "3" }, { "input": "[[1, 2, 3], [3, 2, 1]]", "output": "2" }, { "input": "[[1, 3, 5, 7], [2, 4, 6, 8]]", "output": "4" ...
111
false
111
verified
10
10
1
4,135
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MinOperations.Code.Funs /-! # Specifications of `Aegis.MinOperations.min_operations` LeetCode problem `minimum-operations-to-make-a-subsequence`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Classical namespace AegisSpec.MinOperations def vals (s :...
14
calculate-money-in-leetcode-bank
1,716
Easy
[ "Math" ]
Hercy wants to save money for his first car. He puts money in the Leetcode bank every day. He starts by putting in $1 on Monday, the first day. Every day from Tuesday to Sunday, he will put in $1 more than the day before. On every subsequent Monday, he will put in $1 more than the previous Monday. Given n, return the ...
totalMoney(n: int) -> int
pub fn total_money(n: i64) -> i64
Aegis.TotalMoney.total_money
pub fn total_money(n: i64) -> i64 { let mut total: i64 = 0; let mut day: i64 = 0; while day < n { let week: i64 = day / 7; let weekday: i64 = day % 7; total = total + week + weekday + 1; day = day + 1; } total }
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [total_money]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter.st...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [total_money]: function definitions module public import Aeneas public import Aegis.TotalMoney.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.TotalMoney.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.TotalMoney.total_money 30#i64) (165#i64))}") #eval (s!"CASE 1 {(Result.reducesTo (Aegis.TotalMoney.total_money 4#i64) (10#i64))}") #eval (s!"CASE 2 {(...
[ { "input": "[30]", "output": "165" }, { "input": "[4]", "output": "10" }, { "input": "[20]", "output": "96" }, { "input": "[1]", "output": "1" }, { "input": "[1000]", "output": "74926" }, { "input": "[7]", "output": "28" }, { "input": "[10]...
50
false
50
verified
10
10
1
404
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.TotalMoney.Code.Funs /-! # Specifications of `Aegis.TotalMoney.total_money` LeetCode problem `calculate-money-in-leetcode-bank`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.TotalMoney def i64OfInt (x : ℤ) : Aeneas.Std.I64 := ⟨BitVec...
9
maximum-score-from-removing-substrings
1,717
Medium
[ "Stack", "Greedy", "String" ]
You are given a string s and two integers x and y. You can perform two types of operations any number of times. Remove substring "ab" and gain x points. For example, when removing "ab" from "cabxbae" it becomes "cxbae". Remove substring "ba" and gain y points. For example, when removing "ba" from "cabxbae" it b...
maximumGain(s: str, x: int, y: int) -> int
pub fn maximum_gain(s: &[u8], x: i64, y: i64) -> i64
Aegis.MaximumGain.maximum_gain
pub fn maximum_gain(s: &[u8], x: i64, y: i64) -> i64 { let n = s.len(); let mut score: i64 = 0; let mut stack: Vec<u8> = Vec::new(); if x >= y { let mut i: usize = 0; while i < n { let c: u8 = s[i]; if c == b'b' && stack.len() > 0 && stack[stack.len() - 1] == b'a...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [maximum_gain]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter.s...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [maximum_gain]: function definitions module public import Aeneas public import Aegis.MaximumGain.Code.Types public import Aegis.MaximumGain.Code.FunsExternal @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace fals...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [maximum_gain]: external functions. -- This is a template file: rename it to "FunsExternal.lean" and fill the holes. module public import Aeneas public import Aegis.MaximumGain.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_o...
import Aegis.MaximumGain.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.MaximumGain.maximum_gain (Slice.from [97#u8, 98#u8, 97#u8, 98#u8, 97#u8, 98#u8, 97#u8, 98#u8, 97#u8, 98#u8, 97#u8, 98#u8, 97#u8, 98#u8, 97#u8, 98#u8,...
[ { "input": "[\"ababababababababababababababababababababab\", 1, 1]", "output": "21" }, { "input": "[\"abbaabba\", 7, 8]", "output": "31" }, { "input": "[\"abababab\", 10, 10]", "output": "40" }, { "input": "[\"ababab\", 10, 10]", "output": "30" }, { "input": "[\"b...
154
false
154
verified
10
10
1
5,514
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MaximumGain.Code.Funs /-! # Specifications of `Aegis.MaximumGain.maximum_gain` LeetCode problem `maximum-score-from-removing-substrings`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.MaximumGain namespace AegisSpec.MaximumGain def isAb (c : U...
15
construct-the-lexicographically-largest-valid-sequence
1,718
Medium
[ "Array", "Backtracking" ]
Given an integer n, find a sequence with elements in the range [1, n] that satisfies all of the following: The integer 1 occurs once in the sequence. Each integer between 2 and n occurs twice in the sequence. For every integer i between 2 and n, the distance between the two occurrences of i is exactly i. The distance...
constructDistancedSequence(n: int) -> list_int
pub fn construct_distanced_sequence(n: i64) -> Vec<i64>
Aegis.ConstructDistancedSequence.construct_distanced_sequence
pub fn construct_distanced_sequence(n: i64) -> Vec<i64> { let m = (2 * n - 1) as usize; let n_usize = n as usize; let mut seq: Vec<i64> = Vec::new(); let mut i = 0; while i < m { seq.push(0); i += 1; } let mut used: Vec<bool> = Vec::new(); let mut j = 0; while j <= ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [construct_distanced_sequence]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [construct_distanced_sequence]: function definitions module public import Aeneas public import Aegis.ConstructDistancedSequence.Code.Types public import Aegis.ConstructDistancedSequence.Code.FunsExternal @[expose] public section open Aeneas Aeneas.Std Result Control...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [construct_distanced_sequence]: external functions. -- This is a template file: rename it to "FunsExternal.lean" and fill the holes. module public import Aeneas public import Aegis.ConstructDistancedSequence.Code.Types @[expose] public section open Aeneas Aeneas.Std...
import Aegis.ConstructDistancedSequence.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.ConstructDistancedSequence.construct_distanced_sequence 1#i64) ((alloc.vec.Vec.from [1#i64] (by scalar_tac) : alloc.vec.Vec Std.I64)))...
[ { "input": "[1]", "output": "[1]" }, { "input": "[2]", "output": "[2, 1, 2]" }, { "input": "[3]", "output": "[3, 1, 2, 3, 2]" }, { "input": "[4]", "output": "[4, 2, 3, 2, 4, 3, 1]" }, { "input": "[5]", "output": "[5, 3, 1, 4, 3, 5, 2, 4, 2]" }, { "inpu...
18
false
18
verified
10
10
1
15,861
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.ConstructDistancedSequence.Code.Funs /-! # Specifications of `Aegis.ConstructDistancedSequence.construct_distanced_sequence` LeetCode problem `construct-the-lexicographically-largest-valid-sequence`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespa...
12
number-of-ways-to-reconstruct-a-tree
1,719
Hard
[ "Tree", "Graph" ]
You are given an array pairs, where pairs[i] = [xi, yi], and: There are no duplicates. xi < yi Let ways be the number of rooted trees that satisfy the following conditions: The tree consists of nodes whose values appeared in pairs. A pair [xi, yi] exists in pairs if and only if xi is an ancestor of yi or yi is an an...
checkWays(pairs: list_list_int) -> int
pub fn check_ways(pairs: &[Vec<i64>]) -> i64
Aegis.CheckWays.check_ways
pub fn check_ways(pairs: &[Vec<i64>]) -> i64 { let max_val: usize = 501; let mut idx_of: Vec<i64> = Vec::new(); let mut t: usize = 0; while t < max_val { idx_of.push(-1i64); t += 1; } let mut n: usize = 0; let mut i: usize = 0; while i < pairs.len() { let a = pa...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [check_ways]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter.sty...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [check_ways]: function definitions module public import Aeneas public import Aegis.CheckWays.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linte...
import Aegis.CheckWays.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval aegisCase "...
[ { "input": "[[[1, 2], [3, 4]]]", "output": "0" }, { "input": "[[[1, 2], [2, 3]]]", "output": "1" }, { "input": "[[[1, 3], [2, 3], [4, 5]]]", "output": "0" }, { "input": "[[[1, 2], [2, 3], [1, 3]]]", "output": "2" }, { "input": "[[[1, 3], [2, 3], [3, 4], [4, 5]]]",...
80
false
80
verified
10
10
4
61,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.CheckWays.Code.Funs /-! # Specifications of `Aegis.CheckWays.check_ways` LeetCode problem `number-of-ways-to-reconstruct-a-tree`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.CheckWays (check_ways) namespace AegisSpec.CheckWays def toPairs (p...
11
decode-xored-array
1,720
Easy
[ "Bit Manipulation", "Array" ]
There is a hidden integer array arr that consists of n non-negative integers. It was encoded into another integer array encoded of length n - 1, such that encoded[i] = arr[i] XOR arr[i + 1]. For example, if arr = [1,0,2,1], then encoded = [1,2,3]. You are given the encoded array. You are also given an integer first, th...
decode(encoded: list_int, first: int) -> list_int
pub fn decode(encoded: &[i64], first: i64) -> Vec<i64>
Aegis.Decode.decode
pub fn decode(encoded: &[i64], first: i64) -> Vec<i64> { let n = encoded.len(); let mut arr: Vec<i64> = Vec::new(); arr.push(first); let mut i: usize = 0; while i < n { let prev = arr[i]; arr.push(prev ^ encoded[i]); i += 1; } arr }
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [decode]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter.style.w...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [decode]: function definitions module public import Aeneas public import Aegis.Decode.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unuse...
import Aegis.Decode.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.Decode.decode (Slice.from [3#i64, 1#i64] (by scalar_tac) : Slice Std.I64) 5#i64) ((alloc.vec.Vec.from [5#i64, 6#i64, 7#i64] (by scalar_tac) : alloc.vec.Ve...
[ { "input": "[[3, 1], 5]", "output": "[5, 6, 7]" }, { "input": "[[3, 1], 2]", "output": "[2, 1, 0]" }, { "input": "[[10, 5, 15], 0]", "output": "[0, 10, 15, 0]" }, { "input": "[[0, 0, 0], 7]", "output": "[7, 7, 7, 7]" }, { "input": "[[9, 5, 6], 0]", "output": "...
97
false
97
verified
10
10
1
103
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.Decode.Code.Funs /-! # Specifications of `Aegis.Decode.decode` LeetCode problem `decode-xored-array`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.Decode namespace AegisSpec.Decode def xorInt (a b : Int) : Int := ((BitVec.ofInt 64 a) ^...
13
swapping-nodes-in-a-linked-list
1,721
Medium
[ "Linked List", "Two Pointers" ]
You are given the head of a linked list, and an integer k. Return the head of the linked list after swapping the values of the kth node from the beginning and the kth node from the end (the list is 1-indexed).   Example 1: Input: head = [1,2,3,4,5], k = 2 Output: [1,4,3,2,5] Example 2: Input: head = [7,9,6,6,7,8,3,...
swapNodes(head: linkedlist, k: int) -> linkedlist
pub fn swap_nodes(head: &List, k: i64) -> List
Aegis.SwapNodes.swap_nodes
fn list_length(l: &List) -> usize { match l { List::Nil => 0, List::Cons(_, next) => 1 + list_length(next), } } // Structural recursion over the list: `l` strictly shrinks on each call, // `counter` just tracks the original position. `target` is a valid index. fn value_at(l: &List, counter: usi...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [swap_nodes]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter.sty...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [swap_nodes]: function definitions module public import Aeneas public import Aegis.SwapNodes.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linte...
import Aegis.SwapNodes.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 deriving instance DecidableEq for Aegis.SwapNodes.List #eval (s!"CASE 0 {(match (Aegis.SwapNodes.swap_nodes ((.Cons 1#i64 (.Nil)) : Aegis.SwapNodes.List) 1#i64).match with | .ok r => decide (r ...
[ { "input": "[[1], 1]", "output": "[1]" }, { "input": "[[42], 1]", "output": "[42]" }, { "input": "[[5], 1]", "output": "[5]" }, { "input": "[[1, 2], 1]", "output": "[2, 1]" }, { "input": "[[100, 90], 1]", "output": "[90, 100]" }, { "input": "[[1, 2, 3]...
102
false
102
verified
10
10
2
15,824
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.SwapNodes.Code.Funs /-! # Specifications of `Aegis.SwapNodes.swap_nodes` LeetCode problem `swapping-nodes-in-a-linked-list`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.SwapNodes def vals : Aegis.SwapNodes.List → List Std.I64 | Ae...
14
minimize-hamming-distance-after-swap-operations
1,722
Medium
[ "Depth-First Search", "Union Find", "Array" ]
You are given two integer arrays, source and target, both of length n. You are also given an array allowedSwaps where each allowedSwaps[i] = [ai, bi] indicates that you are allowed to swap the elements at index ai and index bi (0-indexed) of array source. Note that you can swap elements at a specific pair of indices mu...
minimumHammingDistance(source: list_int, target: list_int, allowedSwaps: list_list_int) -> int
pub fn minimum_hamming_distance(source: &[i64], target: &[i64], allowedSwaps: &[Vec<i64>]) -> i64
Aegis.MinimumHammingDistance.minimum_hamming_distance
fn find(parent: &mut Vec<i64>, mut x: i64) -> i64 { while parent[x as usize] != x { let p = parent[x as usize]; let gp = parent[p as usize]; parent[x as usize] = gp; x = gp; } x } fn union(parent: &mut Vec<i64>, rank: &mut Vec<i64>, a: i64, b: i64) { let ra = find(parent...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [minimum_hamming_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_opt...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [minimum_hamming_distance]: function definitions module public import Aeneas public import Aegis.MinimumHammingDistance.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCom...
import Aegis.MinimumHammingDistance.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.MinimumHammingDistance.minimum_hamming_distance (Slice.from [1#i64, 2#i64, 3#i64, 4#i64] (by scalar_tac) : Slice Std.I64) (Slice.from [1#i...
[ { "input": "[[1, 2, 3, 4], [1, 3, 2, 4], []]", "output": "2" }, { "input": "[[10, 20, 30], [30, 20, 10], [[0, 2]]]", "output": "0" }, { "input": "[[4, 5, 6], [6, 4, 5], [[0, 1], [1, 2]]]", "output": "0" }, { "input": "[[4, 3, 2, 1], [1, 2, 3, 4], [[0, 2], [1, 3]]]", "outp...
83
false
83
verified
10
10
1
7,687
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MinimumHammingDistance.Code.Funs /-! # Specifications of `Aegis.MinimumHammingDistance.minimum_hamming_distance` LeetCode problem `minimize-hamming-distance-after-swap-operations`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.MinimumH...
12
find-minimum-time-to-finish-all-jobs
1,723
Hard
[ "Bit Manipulation", "Array", "Dynamic Programming", "Backtracking", "Bitmask" ]
You are given an integer array jobs, where jobs[i] is the amount of time it takes to complete the ith job. There are k workers that you can assign jobs to. Each job should be assigned to exactly one worker. The working time of a worker is the sum of the time it takes to complete all jobs assigned to them. Your goal is ...
minimumTimeRequired(jobs: list_int, k: int) -> int
pub fn minimum_time_required(jobs: &[i64], k: i64) -> i64
Aegis.MinimumTimeRequired.minimum_time_required
pub fn minimum_time_required(jobs: &[i64], k: i64) -> i64 { let n = jobs.len(); if n == 0 || k <= 0 { return 0; } let mut kk = k as usize; if kk > n { kk = n; } let mut a: Vec<i64> = Vec::new(); let mut i = 0usize; while i < n { a.push(jobs[i]); i +=...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [minimum_time_required]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [minimum_time_required]: function definitions module public import Aeneas public import Aegis.MinimumTimeRequired.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand f...
import Aegis.MinimumTimeRequired.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval a...
[ { "input": "[[3, 2, 3], 3]", "output": "3" }, { "input": "[[1, 2, 4, 7, 8], 2]", "output": "11" }, { "input": "[[6, 5, 4, 3, 2, 1], 6]", "output": "6" }, { "input": "[[10, 20, 30, 40, 50, 60], 3]", "output": "70" }, { "input": "[[5, 5, 3, 2, 4, 1], 3]", "outpu...
111
false
111
verified
10
10
2
25,296
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MinimumTimeRequired.Code.Funs /-! # Specifications of `Aegis.MinimumTimeRequired.minimum_time_required` LeetCode problem `find-minimum-time-to-finish-all-jobs`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.MinimumTimeRequired def j...
10
number-of-rectangles-that-can-form-the-largest-square
1,725
Easy
[ "Array" ]
You are given an array rectangles where rectangles[i] = [li, wi] represents the ith rectangle of length li and width wi.\r \r You can cut the ith rectangle to form a square with a side length of k if both k <= li and k <= wi. For example, if you have a rectangle [4,6], you can cut it to get a square with a side length ...
countGoodRectangles(rectangles: list_list_int) -> int
pub fn count_good_rectangles(rectangles: &[Vec<i64>]) -> i64
Aegis.CountGoodRectangles.count_good_rectangles
pub fn count_good_rectangles(rectangles: &[Vec<i64>]) -> i64 { let n = rectangles.len(); let mut max_len: i64 = 0; let mut count: i64 = 0; let mut i: usize = 0; while i < n { let row = &rectangles[i]; let length = row[0]; let width = row[1]; let side = if length < wi...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [count_good_rectangles]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [count_good_rectangles]: function definitions module public import Aeneas public import Aegis.CountGoodRectangles.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand f...
import Aegis.CountGoodRectangles.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.CountGoodRectangles.count_good_rectangles (Slice.from [(alloc.vec.Vec.from [1000000000#i64, 1000000000#i64] (by scalar_tac) : alloc.vec.Vec S...
[ { "input": "[[[1000000000, 1000000000], [999999999, 999999999], [1, 1]]]", "output": "1" }, { "input": "[[[1, 2], [2, 1], [3, 4], [4, 3]]]", "output": "2" }, { "input": "[[[2, 3], [3, 7], [4, 3], [3, 7]]]", "output": "3" }, { "input": "[[[5, 8], [3, 9], [5, 12], [16, 5]]]", ...
83
false
83
verified
10
10
1
471
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.CountGoodRectangles.Code.Funs /-! # Specifications of `Aegis.CountGoodRectangles.count_good_rectangles` LeetCode problem `number-of-rectangles-that-can-form-the-largest-square`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.CountGood...
8
tuple-with-same-product
1,726
Medium
[ "Array", "Hash Table", "Counting" ]
Given an array nums of distinct positive integers, return the number of tuples (a, b, c, d) such that a * b = c * d where a, b, c, and d are elements of nums, and a != b != c != d.   Example 1: Input: nums = [2,3,4,6] Output: 8 Explanation: There are 8 valid tuples: (2,6,3,4) , (2,6,4,3) , (6,2,3,4) , (6,2,4,3) (3,4,2...
tupleSameProduct(nums: list_int) -> int
pub fn tuple_same_product(nums: &[i64]) -> i64
Aegis.TupleSameProduct.tuple_same_product
pub fn tuple_same_product(nums: &[i64]) -> i64 { let n = nums.len(); let mut products: Vec<i64> = Vec::new(); let mut i = 0; while i < n { let mut j = i + 1; while j < n { products.push(nums[i] * nums[j]); j += 1; } i += 1; } products.sor...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [tuple_same_product]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option li...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [tuple_same_product]: function definitions module public import Aeneas public import Aegis.TupleSameProduct.Code.Types public import Aegis.TupleSameProduct.Code.FunsExternal @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.d...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [tuple_same_product]: external functions. -- This is a template file: rename it to "FunsExternal.lean" and fill the holes. module public import Aeneas public import Aegis.TupleSameProduct.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow ...
import Aegis.TupleSameProduct.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.TupleSameProduct.tuple_same_product (Slice.from [7#i64, 8#i64, 14#i64, 21#i64] (by scalar_tac) : Slice Std.I64)) (0#i64))}") #eval (s!"CASE 1 {(...
[ { "input": "[[7, 8, 14, 21]]", "output": "0" }, { "input": "[[2, 3, 4, 6]]", "output": "8" }, { "input": "[[1, 10, 100, 1000]]", "output": "8" }, { "input": "[[10, 20, 30, 60]]", "output": "8" }, { "input": "[[7, 8, 9, 14, 21]]", "output": "0" }, { "in...
105
false
105
verified
10
10
1
2,278
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.TupleSameProduct.Code.Funs /-! # Specifications of `Aegis.TupleSameProduct.tuple_same_product` LeetCode problem `tuple-with-same-product`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.TupleSameProduct open Aegis.TupleSameProduct def...
12
largest-submatrix-with-rearrangements
1,727
Medium
[ "Greedy", "Array", "Matrix", "Sorting" ]
You are given a binary matrix matrix of size m x n, and you are allowed to rearrange the columns of the matrix in any order. Return the area of the largest submatrix within matrix where every element of the submatrix is 1 after reordering the columns optimally.   Example 1: Input: matrix = [[0,0,1],[1,1,1],[1,0,1]] O...
largestSubmatrix(matrix: list_list_int) -> int
pub fn largest_submatrix(matrix: &[Vec<i64>]) -> i64
Aegis.LargestSubmatrix.largest_submatrix
pub fn largest_submatrix(matrix: &[Vec<i64>]) -> i64 { let m = matrix.len(); if m == 0 { return 0; } let n = matrix[0].len(); if n == 0 { return 0; } let mut heights: Vec<i64> = Vec::new(); let mut j: usize = 0; while j < n { heights.push(0); j += 1;...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [largest_submatrix]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option lin...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [largest_submatrix]: function definitions module public import Aeneas public import Aegis.LargestSubmatrix.Code.Types public import Aegis.LargestSubmatrix.Code.FunsExternal @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.du...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [largest_submatrix]: external functions. -- This is a template file: rename it to "FunsExternal.lean" and fill the holes. module public import Aeneas public import Aegis.LargestSubmatrix.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow E...
import Aegis.LargestSubmatrix.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.LargestSubmatrix.largest_submatrix (Slice.from [(alloc.vec.Vec.from [0#i64, 1#i64] (by scalar_tac) : alloc.vec.Vec Std.I64), (alloc.vec.Vec.from...
[ { "input": "[[[0, 1], [1, 0]]]", "output": "1" }, { "input": "[[[1, 0, 1, 0, 1]]]", "output": "3" }, { "input": "[[[1, 1, 0], [1, 0, 1]]]", "output": "2" }, { "input": "[[[0, 0, 1], [1, 1, 1], [1, 0, 1]]]", "output": "4" }, { "input": "[[[0, 0, 0], [0, 0, 0], [0, ...
83
false
83
verified
10
10
1
5,631
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.LargestSubmatrix.Code.Funs /-! # Specifications of `Aegis.LargestSubmatrix.largest_submatrix` LeetCode problem `largest-submatrix-with-rearrangements`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Classical open Aegis.LargestSubmatrix namespace Aegi...
15
find-the-highest-altitude
1,732
Easy
[ "Array", "Prefix Sum" ]
There is a biker going on a road trip. The road trip consists of n + 1 points at different altitudes. The biker starts his trip on point 0 with altitude equal 0. You are given an integer array gain of length n where gain[i] is the net gain in altitude between points i​​​​​​ and i + 1 for all (0 <= i < n). Return the hi...
largestAltitude(gain: list_int) -> int
pub fn largest_altitude(gain: &[i64]) -> i64
Aegis.LargestAltitude.largest_altitude
pub fn largest_altitude(gain: &[i64]) -> i64 { let n = gain.len(); let mut altitude: i64 = 0; let mut best: i64 = 0; let mut i: usize = 0; while i < n { altitude = altitude + gain[i]; if altitude > best { best = altitude; } i = i + 1; } best }
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [largest_altitude]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option lint...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [largest_altitude]: function definitions module public import Aeneas public import Aegis.LargestAltitude.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.LargestAltitude.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.LargestAltitude.largest_altitude (Slice.from [(-1)#i64, (-2)#i64, (-3)#i64, (-4)#i64] (by scalar_tac) : Slice Std.I64)) (0#i64))}") #eval (s!"CAS...
[ { "input": "[[-1, -2, -3, -4]]", "output": "0" }, { "input": "[[5, 5, 5, 5]]", "output": "20" }, { "input": "[[100, -100, 100, -100]]", "output": "100" }, { "input": "[[0, 0, 0, 0]]", "output": "0" }, { "input": "[[-10, -20, -30, -40, -50]]", "output": "0" }...
110
false
110
verified
10
10
1
129
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.LargestAltitude.Code.Funs /-! # Specifications of `Aegis.LargestAltitude.largest_altitude` LeetCode problem `find-the-highest-altitude`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.LargestAltitude def prefixAlt (gain : Slice Std.I64...
9
minimum-number-of-people-to-teach
1,733
Medium
[ "Greedy", "Array", "Hash Table" ]
On a social network consisting of m users and some friendships between users, two users can communicate with each other if they know a common language. You are given an integer n, an array languages, and an array friendships where: There are n languages numbered 1 through n, languages[i] is the set of languages the i​...
minimumTeachings(n: int, languages: list_list_int, friendships: list_list_int) -> int
pub fn minimum_teachings(n: i64, languages: &[Vec<i64>], friendships: &[Vec<i64>]) -> i64
Aegis.MinimumTeachings.minimum_teachings
pub fn minimum_teachings(n: i64, languages: &[Vec<i64>], friendships: &[Vec<i64>]) -> i64 { let m = languages.len(); let mut need: Vec<bool> = Vec::new(); let mut idx: usize = 0; while idx < m { need.push(false); idx += 1; } let mut f: usize = 0; while f < friendships.len()...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [minimum_teachings]: type definitions module public import Aeneas @[expose] public section 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_teachings]: function definitions module public import Aeneas public import Aegis.MinimumTeachings.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.MinimumTeachings.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.MinimumTeachings.minimum_teachings 2#i64 (Slice.from [(alloc.vec.Vec.from [1#i64, 2#i64] (by scalar_tac) : alloc.vec.Vec Std.I64), (alloc.vec.Ve...
[ { "input": "[2, [[1, 2], [1, 2]], [[1, 2]]]", "output": "0" }, { "input": "[2, [[1], [2], [1, 2]], [[1, 2], [1, 3], [2, 3]]]", "output": "1" }, { "input": "[5, [[1, 2, 3, 4, 5]], [[1, 1], [1, 1], [1, 1]]]", "output": "0" }, { "input": "[4, [[1], [2], [3], [4]], [[1, 2], [2, 3...
73
false
73
verified
10
10
1
3,257
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MinimumTeachings.Code.Funs /-! # Specifications of `Aegis.MinimumTeachings.minimum_teachings` LeetCode problem `minimum-number-of-people-to-teach`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.MinimumTeachings namespace AegisSpec.MinimumTeachi...
13
decode-xored-permutation
1,734
Medium
[ "Bit Manipulation", "Array" ]
There is an integer array perm that is a permutation of the first n positive integers, where n is always odd. It was encoded into another integer array encoded of length n - 1, such that encoded[i] = perm[i] XOR perm[i + 1]. For example, if perm = [1,3,2], then encoded = [2,1]. Given the encoded array, return the origi...
decode(encoded: list_int) -> list_int
pub fn decode(encoded: &[i64]) -> Vec<i64>
Aegis.Decode.decode
pub fn decode(encoded: &[i64]) -> Vec<i64> { let n: usize = encoded.len() + 1; let mut xor_all: i64 = 0; let mut i: usize = 1; while i <= n { xor_all = xor_all ^ (i as i64); i += 1; } let mut xor_odd: i64 = 0; let mut j: usize = 1; while j < encoded.len() { xor_...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [decode]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter.style.w...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [decode]: function definitions module public import Aeneas public import Aegis.Decode.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unuse...
import Aegis.Decode.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.Decode.decode (Slice.from [3#i64, 1#i64] (by scalar_tac) : Slice Std.I64)) ((alloc.vec.Vec.from [1#i64, 2#i64, 3#i64] (by scalar_tac) : alloc.vec.Vec Std....
[ { "input": "[[3, 1]]", "output": "[1, 2, 3]" }, { "input": "[[1, 5, 7]]", "output": "[1, 0, 5, 2]" }, { "input": "[[2, 3, 2]]", "output": "[7, 5, 6, 4]" }, { "input": "[[7, 3, 5]]", "output": "[7, 0, 3, 6]" }, { "input": "[[6, 5, 4, 6]]", "output": "[2, 4, 1, ...
110
false
110
verified
10
10
1
2,400
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.Decode.Code.Funs /-! # Specifications of `Aegis.Decode.decode` LeetCode problem `decode-xored-permutation`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.Decode def xorInt (a b : Int) : Int := (BitVec.ofInt 64 a ^^^ BitVec.ofInt 6...
12
change-minimum-characters-to-satisfy-one-of-three-conditions
1,737
Medium
[ "Hash Table", "String", "Counting", "Prefix Sum" ]
You are given two strings a and b that consist of lowercase letters. In one operation, you can change any character in a or b to any lowercase letter. Your goal is to satisfy one of the following three conditions: Every letter in a is strictly less than every letter in b in the alphabet. Every letter in b is strictly ...
minCharacters(a: str, b: str) -> int
pub fn min_characters(a: &[u8], b: &[u8]) -> i64
Aegis.MinCharacters.min_characters
pub fn min_characters(a: &[u8], b: &[u8]) -> i64 { let mut ca: Vec<i64> = Vec::new(); let mut cb: Vec<i64> = Vec::new(); let mut i: usize = 0; while i < 26 { ca.push(0); cb.push(0); i += 1; } let mut len_a: i64 = 0; i = 0; while i < a.len() { let idx: us...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [min_characters]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [min_characters]: function definitions module public import Aeneas public import Aegis.MinCharacters.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.MinCharacters.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.MinCharacters.min_characters (Slice.from [97#u8, 98#u8, 99#u8] (by scalar_tac) : Slice Std.U8) (Slice.from [98#u8, 99#u8, 100#u8] (by scalar_tac) :...
[ { "input": "[\"abc\", \"bcd\"]", "output": "2" }, { "input": "[\"aba\", \"caa\"]", "output": "2" }, { "input": "[\"xyzz\", \"zzzz\"]", "output": "2" }, { "input": "[\"abcd\", \"dcba\"]", "output": "4" }, { "input": "[\"aaaabbbb\", \"ccccdddd\"]", "output": "0"...
128
false
128
verified
10
10
1
10,919
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MinCharacters.Code.Funs /-! # Specifications of `Aegis.MinCharacters.min_characters` LeetCode problem `change-minimum-characters-to-satisfy-one-of-three-conditions`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.MinCharacters def IsLo...
13
find-kth-largest-xor-coordinate-value
1,738
Medium
[ "Bit Manipulation", "Array", "Divide and Conquer", "Matrix", "Prefix Sum", "Quickselect", "Sorting", "Heap (Priority Queue)" ]
You are given a 2D matrix of size m x n, consisting of non-negative integers. You are also given an integer k. The value of coordinate (a, b) of the matrix is the XOR of all matrix[i][j] where 0 <= i <= a < m and 0 <= j <= b < n (0-indexed). Find the kth largest value (1-indexed) of all the coordinates of matrix.   Exa...
kthLargestValue(matrix: list_list_int, k: int) -> int
pub fn kth_largest_value(matrix: &[Vec<i64>], k: i64) -> i64
Aegis.KthLargestValue.kth_largest_value
pub fn kth_largest_value(matrix: &[Vec<i64>], k: i64) -> i64 { let m = matrix.len(); if m == 0 { return 0; } let n = matrix[0].len(); let mut vals: Vec<i64> = Vec::new(); let mut max_val: i64 = 0; let mut prev: Vec<i64> = Vec::new(); let mut i: usize = 0; while i < m { ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [kth_largest_value]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option lin...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [kth_largest_value]: function definitions module public import Aeneas public import Aegis.KthLargestValue.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.KthLargestValue.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.KthLargestValue.kth_largest_value (Slice.from [(alloc.vec.Vec.from [10#i64, 20#i64] (by scalar_tac) : alloc.vec.Vec Std.I64), (alloc.vec.Vec.from...
[ { "input": "[[[10, 20], [30, 40]], 1]", "output": "40" }, { "input": "[[[0, 0], [0, 0]], 1]", "output": "0" }, { "input": "[[[5, 2], [1, 6]], 1]", "output": "7" }, { "input": "[[[5, 2], [1, 6]], 3]", "output": "4" }, { "input": "[[[5, 2], [1, 6]], 2]", "output...
87
false
87
verified
10
10
1
10,901
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.KthLargestValue.Code.Funs /-! # Specifications of `Aegis.KthLargestValue.kth_largest_value` LeetCode problem `find-kth-largest-xor-coordinate-value`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result ControlFlow Error open Aegis.KthLargestValue namespace ...
15