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
check-if-all-the-integers-in-a-range-are-covered
1,893
Easy
[ "Array", "Hash Table", "Prefix Sum" ]
You are given a 2D integer array ranges and two integers left and right. Each ranges[i] = [starti, endi] represents an inclusive interval between starti and endi. Return true if each integer in the inclusive range [left, right] is covered by at least one interval in ranges. Return false otherwise. An integer x is cover...
isCovered(ranges: list_list_int, left: int, right: int) -> bool
pub fn is_covered(ranges: &[Vec<i64>], left: i64, right: i64) -> bool
Aegis.IsCovered.is_covered
pub fn is_covered(ranges: &[Vec<i64>], left: i64, right: i64) -> bool { let mut x = left; while x <= right { let mut covered = false; let mut i = 0; while i < ranges.len() { let row = &ranges[i]; if row[0] <= x && x <= row[1] { covered = true; ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [is_covered]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter.sty...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [is_covered]: function definitions module public import Aeneas public import Aegis.IsCovered.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.IsCovered.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.IsCovered.is_covered (Slice.from [(alloc.vec.Vec.from [1#i64, 50#i64] (by scalar_tac) : alloc.vec.Vec Std.I64)] (by scalar_tac) : Slice (alloc.vec.Vec ...
[ { "input": "[[[1, 50]], 1, 50]", "output": "true" }, { "input": "[[[1, 50]], 1, 50]", "output": "true" }, { "input": "[[[5, 7], [1, 3]], 1, 7]", "output": "false" }, { "input": "[[[5, 10], [15, 20]], 10, 15]", "output": "false" }, { "input": "[[[10, 20], [21, 30]]...
105
false
105
verified
10
10
1
521
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.IsCovered.Code.Funs /-! # Specifications of `Aegis.IsCovered.is_covered` LeetCode problem `check-if-all-the-integers-in-a-range-are-covered`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.IsCovered namespace AegisSpec.IsCovered def rowIn...
11
find-the-student-that-will-replace-the-chalk
1,894
Medium
[ "Array", "Binary Search", "Prefix Sum", "Simulation" ]
There are n students in a class numbered from 0 to n - 1. The teacher will give each student a problem starting with the student number 0, then the student number 1, and so on until the teacher reaches the student number n - 1. After that, the teacher will restart the process, starting with the student number 0 again. ...
chalkReplacer(chalk: list_int, k: int) -> int
pub fn chalk_replacer(chalk: &[i64], k: i64) -> i64
Aegis.ChalkReplacer.chalk_replacer
pub fn chalk_replacer(chalk: &[i64], k: i64) -> i64 { let n = chalk.len(); let mut total: i64 = 0; let mut i: usize = 0; while i < n { total += chalk[i]; i += 1; } let mut remaining: i64 = k % total; i = 0; let mut answer: i64 = 0; while i < n { if remainin...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [chalk_replacer]: type definitions module public import Aeneas @[expose] public section 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 -- [chalk_replacer]: function definitions module public import Aeneas public import Aegis.ChalkReplacer.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.ChalkReplacer.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.ChalkReplacer.chalk_replacer (Slice.from [1#i64] (by scalar_tac) : Slice Std.I64) 1000000000#i64) (0#i64))}") #eval (s!"CASE 1 {(Result.reducesTo (...
[ { "input": "[[1], 1000000000]", "output": "0" }, { "input": "[[100000], 1000000000]", "output": "0" }, { "input": "[[10, 10, 10], 100]", "output": "1" }, { "input": "[[5, 1, 5], 22]", "output": "0" }, { "input": "[[5, 1, 5], 1000000000]", "output": "2" }, ...
92
false
92
verified
10
10
1
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.ChalkReplacer.Code.Funs /-! # Specifications of `Aegis.ChalkReplacer.chalk_replacer` LeetCode problem `find-the-student-that-will-replace-the-chalk`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.ChalkReplacer def n (chalk : Slice I64...
12
largest-magic-square
1,895
Medium
[ "Array", "Matrix", "Prefix Sum" ]
A k x k magic square is a k x k grid filled with integers such that every row sum, every column sum, and both diagonal sums are all equal. The integers in the magic square do not have to be distinct. Every 1 x 1 grid is trivially a magic square. Given an m x n integer grid, return the size (i.e., the side length k) of ...
largestMagicSquare(grid: list_list_int) -> int
pub fn largest_magic_square(grid: &[Vec<i64>]) -> i64
Aegis.LargestMagicSquare.largest_magic_square
pub fn largest_magic_square(grid: &[Vec<i64>]) -> i64 { let m = grid.len(); if m == 0 { return 0; } let n = grid[0].len(); if n == 0 { return 0; } let mut max_k = m; if n < max_k { max_k = n; } let mut result: i64 = 1; let mut found = false; let...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [largest_magic_square]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [largest_magic_square]: function definitions module public import Aeneas public import Aegis.LargestMagicSquare.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand fal...
import Aegis.LargestMagicSquare.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.LargestMagicSquare.largest_magic_square (Slice.from [(alloc.vec.Vec.from [8#i64] (by scalar_tac) : alloc.vec.Vec Std.I64)] (by scalar_tac) : S...
[ { "input": "[[[8]]]", "output": "1" }, { "input": "[[[10, 20], [15, 25]]]", "output": "1" }, { "input": "[[[1, 2], [3, 4]]]", "output": "1" }, { "input": "[[[16, 23, 17], [78, 32, 21], [17, 26, 79]]]", "output": "1" }, { "input": "[[[16, 23, 17], [78, 32, 21], [17...
80
false
80
verified
10
10
2
5,352
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.LargestMagicSquare.Code.Funs /-! # Specifications of `Aegis.LargestMagicSquare.largest_magic_square` LeetCode problem `largest-magic-square`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.LargestMagicSquare namespace AegisSpec.LargestMagicS...
15
maximum-number-of-removable-characters
1,898
Medium
[ "Array", "Two Pointers", "String", "Binary Search" ]
You are given two strings s and p where p is a subsequence of s. You are also given a distinct 0-indexed integer array removable containing a subset of indices of s (s is also 0-indexed). You want to choose an integer k (0 <= k <= removable.length) such that, after removing k characters from s using the first k indices...
maximumRemovals(s: str, p: str, removable: list_int) -> int
pub fn maximum_removals(s: &[u8], p: &[u8], removable: &[i64]) -> i64
Aegis.MaximumRemovals.maximum_removals
pub fn maximum_removals(s: &[u8], p: &[u8], removable: &[i64]) -> i64 { let mut lo: usize = 0; let mut hi: usize = removable.len(); while lo < hi { let mid: usize = lo + (hi - lo + 1) / 2; if can_remove(s, p, removable, mid) { lo = mid; } else { hi = mid - 1;...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [maximum_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_option lint...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [maximum_removals]: function definitions module public import Aeneas public import Aegis.MaximumRemovals.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.MaximumRemovals.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.MaximumRemovals.maximum_removals (Slice.from [97#u8, 98#u8, 99#u8, 97#u8, 99#u8, 98#u8] (by scalar_tac) : Slice Std.U8) (Slice.from [97#u8, 98#u8...
[ { "input": "[\"abcacb\", \"ab\", [3, 1, 0]]", "output": "2" }, { "input": "[\"xyz\", \"xyz\", [0, 1, 2]]", "output": "0" }, { "input": "[\"banana\", \"ban\", [0, 2, 4]]", "output": "0" }, { "input": "[\"deeddeede\", \"dee\", [5, 3, 4, 6]]", "output": "4" }, { "inp...
82
false
82
verified
10
10
1
2,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.MaximumRemovals.Code.Funs /-! # Specifications of `Aegis.MaximumRemovals.maximum_removals` LeetCode problem `maximum-number-of-removable-characters`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.MaximumRemovals def IsLowerAscii (b : ...
9
merge-triplets-to-form-target-triplet
1,899
Medium
[ "Greedy", "Array" ]
A triplet is an array of three integers. You are given a 2D integer array triplets, where triplets[i] = [ai, bi, ci] describes the ith triplet. You are also given an integer array target = [x, y, z] that describes the triplet you want to obtain. To obtain target, you may apply the following operation on triplets any nu...
mergeTriplets(triplets: list_list_int, target: list_int) -> bool
pub fn merge_triplets(triplets: &[Vec<i64>], target: &[i64]) -> bool
Aegis.MergeTriplets.merge_triplets
pub fn merge_triplets(triplets: &[Vec<i64>], target: &[i64]) -> bool { let mut best0: i64 = 0; let mut best1: i64 = 0; let mut best2: i64 = 0; let n = triplets.len(); let mut i = 0; while i < n { let row = &triplets[i]; let a = row[0]; let b = row[1]; let c = row...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [merge_triplets]: type definitions module public import Aeneas @[expose] public section 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 -- [merge_triplets]: function definitions module public import Aeneas public import Aegis.MergeTriplets.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.MergeTriplets.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.MergeTriplets.merge_triplets (Slice.from [(alloc.vec.Vec.from [1000#i64, 1000#i64, 1000#i64] (by scalar_tac) : alloc.vec.Vec Std.I64)] (by scalar_t...
[ { "input": "[[[1000, 1000, 1000]], [1000, 1000, 1000]]", "output": "true" }, { "input": "[[[1, 2, 3], [4, 5, 6]], [1, 2, 3]]", "output": "true" }, { "input": "[[[3, 4, 5], [4, 5, 6]], [3, 2, 5]]", "output": "false" }, { "input": "[[[2, 5, 3], [1, 8, 4], [1, 7, 5]], [2, 7, 5]]...
119
false
119
verified
10
10
1
1,076
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MergeTriplets.Code.Funs /-! # Specifications of `Aegis.MergeTriplets.merge_triplets` LeetCode problem `merge-triplets-to-form-target-triplet`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.MergeTriplets def nth (l : List Int) (j : Nat...
9
find-a-peak-element-ii
1,901
Medium
[ "Array", "Binary Search", "Matrix" ]
A peak element in a 2D grid is an element that is strictly greater than all of its adjacent neighbors to the left, right, top, and bottom. Given a 0-indexed m x n matrix mat where no two adjacent cells are equal, find any peak element mat[i][j] and return the length 2 array [i,j]. You may assume that the entire matrix ...
findPeakGrid(mat: list_list_int) -> list_int
pub fn find_peak_grid(mat: &[Vec<i64>]) -> Vec<i64>
Aegis.FindPeakGrid.find_peak_grid
pub fn find_peak_grid(mat: &[Vec<i64>]) -> Vec<i64> { let m = mat.len(); let n = mat[0].len(); let mut lo: usize = 0; let mut hi: usize = m - 1; while lo < hi { let mid: usize = (lo + hi) / 2; let row = &mat[mid]; let mut max_col: usize = 0; let mut j: usize = 1; ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [find_peak_grid]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [find_peak_grid]: function definitions module public import Aeneas public import Aegis.FindPeakGrid.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.FindPeakGrid.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.FindPeakGrid.find_peak_grid (Slice.from [(alloc.vec.Vec.from [1#i64] (by scalar_tac) : alloc.vec.Vec Std.I64)] (by scalar_tac) : Slice (alloc.vec.Ve...
[ { "input": "[[[1]]]", "output": "[0, 0]" }, { "input": "[[[1, 4], [3, 2]]]", "output": "[0, 1]" }, { "input": "[[[10, 20, 15], [21, 30, 14], [7, 16, 32]]]", "output": "[1, 1]" }, { "input": "[[[1, 2, 3], [6, 5, 4], [7, 8, 9]]]", "output": "[2, 2]" }, { "input": "[...
85
false
85
verified
10
10
1
25,049
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.FindPeakGrid.Code.Funs /-! # Specifications of `Aegis.FindPeakGrid.find_peak_grid` LeetCode problem `find-a-peak-element-ii`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.FindPeakGrid (find_peak_grid) set_option autoImplicit false namespace Ae...
2
the-number-of-full-rounds-you-have-played
1,904
Medium
[ "Math", "String" ]
You are participating in an online chess tournament. There is a chess round that starts every 15 minutes. The first round of the day starts at 00:00, and after every 15 minutes, a new round starts. For example, the second round starts at 00:15, the fourth round starts at 00:45, and the seventh round starts at 01:30. ...
numberOfRounds(loginTime: str, logoutTime: str) -> int
pub fn number_of_rounds(loginTime: &[u8], logoutTime: &[u8]) -> i64
Aegis.NumberOfRounds.number_of_rounds
fn parse_minutes(t: &[u8]) -> i64 { let h0: i64 = t[0] as i64 - 48; let h1: i64 = t[1] as i64 - 48; let m0: i64 = t[3] as i64 - 48; let m1: i64 = t[4] as i64 - 48; let hh: i64 = h0 * 10 + h1; let mm: i64 = m0 * 10 + m1; hh * 60 + mm } pub fn number_of_rounds(loginTime: &[u8], logoutTime: ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [number_of_rounds]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option lint...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [number_of_rounds]: function definitions module public import Aeneas public import Aegis.NumberOfRounds.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.NumberOfRounds.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.NumberOfRounds.number_of_rounds (Slice.from [49#u8, 49#u8, 58#u8, 53#u8, 57#u8] (by scalar_tac) : Slice Std.U8) (Slice.from [49#u8, 50#u8, 58#u8, ...
[ { "input": "[\"11:59\", \"12:01\"]", "output": "0" }, { "input": "[\"14:30\", \"15:30\"]", "output": "4" }, { "input": "[\"00:01\", \"00:14\"]", "output": "0" }, { "input": "[\"14:20\", \"15:50\"]", "output": "5" }, { "input": "[\"00:00\", \"23:59\"]", "output...
168
false
168
verified
10
10
1
1,844
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.NumberOfRounds.Code.Funs /-! # Specifications of `Aegis.NumberOfRounds.number_of_rounds` LeetCode problem `the-number-of-full-rounds-you-have-played`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.NumberOfRounds namespace AegisSpec.NumberOf...
14
count-sub-islands
1,905
Medium
[ "Depth-First Search", "Breadth-First Search", "Union Find", "Array", "Matrix" ]
You are given two m x n binary matrices grid1 and grid2 containing only 0's (representing water) and 1's (representing land). An island is a group of 1's connected 4-directionally (horizontal or vertical). Any cells outside of the grid are considered water cells. An island in grid2 is considered a sub-island if there i...
countSubIslands(grid1: list_list_int, grid2: list_list_int) -> int
pub fn count_sub_islands(grid1: &[Vec<i64>], grid2: &[Vec<i64>]) -> i64
Aegis.CountSubIslands.count_sub_islands
pub fn count_sub_islands(grid1: &[Vec<i64>], grid2: &[Vec<i64>]) -> i64 { let m = grid1.len(); if m == 0 { return 0; } let n = grid1[0].len(); if n == 0 { return 0; } let mut visited: Vec<Vec<bool>> = Vec::new(); let mut i: usize = 0; while i < m { let mut ro...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [count_sub_islands]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option lin...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [count_sub_islands]: function definitions module public import Aeneas public import Aegis.CountSubIslands.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.CountSubIslands.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.CountSubIslands.count_sub_islands (Slice.from [(alloc.vec.Vec.from [0#i64, 0#i64, 0#i64] (by scalar_tac) : alloc.vec.Vec Std.I64), (alloc.vec.Vec...
[ { "input": "[[[0, 0, 0], [0, 0, 0]], [[0, 0, 0], [0, 0, 0]]]", "output": "0" }, { "input": "[[[1, 1, 1], [0, 0, 0], [0, 0, 0]], [[1, 1, 1], [0, 0, 0], [0, 0, 0]]]", "output": "1" }, { "input": "[[[1, 0, 1], [0, 1, 0], [1, 0, 1]], [[0, 0, 0], [0, 1, 0], [0, 0, 0]]]", "output": "1" }...
67
false
67
verified
10
10
1
5,035
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.CountSubIslands.Code.Funs /-! # Specifications of `Aegis.CountSubIslands.count_sub_islands` LeetCode problem `count-sub-islands`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.CountSubIslands namespace AegisSpec.CountSubIslands def cell (g : S...
7
minimum-absolute-difference-queries
1,906
Medium
[ "Array", "Hash Table" ]
The minimum absolute difference of an array a is defined as the minimum value of |a[i] - a[j]|, where 0 <= i < j < a.length and a[i] != a[j]. If all elements of a are the same, the minimum absolute difference is -1. For example, the minimum absolute difference of the array [5,2,3,7,2] is |2 - 3| = 1. Note that it is n...
minDifference(nums: list_int, queries: list_list_int) -> list_int
pub fn min_difference(nums: &[i64], queries: &[Vec<i64>]) -> Vec<i64>
Aegis.MinDifference.min_difference
pub fn min_difference(nums: &[i64], queries: &[Vec<i64>]) -> Vec<i64> { let n = nums.len(); let mut positions: Vec<Vec<i64>> = Vec::new(); let mut v: usize = 0; while v <= 100 { let mut row: Vec<i64> = Vec::new(); let mut i: usize = 0; while i < n { if nums[i] == v a...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [min_difference]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [min_difference]: function definitions module public import Aeneas public import Aegis.MinDifference.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.MinDifference.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.MinDifference.min_difference (Slice.from [5#i64, 5#i64, 5#i64, 5#i64] (by scalar_tac) : Slice Std.I64) (Slice.from [(alloc.vec.Vec.from [0#i64, 3#i...
[ { "input": "[[5, 5, 5, 5], [[0, 3], [1, 2]]]", "output": "[-1, -1]" }, { "input": "[[1, 1, 1, 1, 1], [[0, 4], [1, 3]]]", "output": "[-1, -1]" }, { "input": "[[1, 2, 3, 4, 5], [[0, 4], [1, 3], [2, 2]]]", "output": "[1, 1, -1]" }, { "input": "[[100, 1, 100, 1, 100], [[0, 4], [1...
90
false
90
verified
10
10
1
8,991
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MinDifference.Code.Funs /-! # Specifications of `Aegis.MinDifference.min_difference` LeetCode problem `minimum-absolute-difference-queries`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.MinDifference namespace AegisSpec.MinDifference de...
8
game-of-nim
1,908
Medium
[ "Bit Manipulation", "Brainteaser", "Array", "Math", "Dynamic Programming", "Game Theory" ]
Alice and Bob take turns playing a game with Alice starting first. In this game, there are n piles of stones. On each player's turn, the player should remove any positive number of stones from a non-empty pile of his or her choice. The first player who cannot make a move loses, and the other player wins. Given an integ...
nimGame(piles: list_int) -> bool
pub fn nim_game(piles: &[i64]) -> bool
Aegis.NimGame.nim_game
pub fn nim_game(piles: &[i64]) -> bool { let mut xor_sum: i64 = 0; let mut i: usize = 0; while i < piles.len() { xor_sum = xor_sum ^ piles[i]; i = i + 1; } xor_sum != 0 }
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [nim_game]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter.style...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [nim_game]: function definitions module public import Aeneas public import Aegis.NimGame.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.NimGame.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.NimGame.nim_game (Slice.from [1#i64] (by scalar_tac) : Slice Std.I64)) (true))}") #eval (s!"CASE 1 {(Result.reducesTo (Aegis.NimGame.nim_game (Slice.from...
[ { "input": "[[1]]", "output": "true" }, { "input": "[[1, 1]]", "output": "false" }, { "input": "[[5, 3, 1]]", "output": "true" }, { "input": "[[1, 2, 3]]", "output": "false" }, { "input": "[[2, 2, 2]]", "output": "true" }, { "input": "[[7, 7, 7]]", ...
79
false
79
verified
10
10
1
175
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.NimGame.Code.Funs /-! # Specifications of `Aegis.NimGame.nim_game` LeetCode problem `game-of-nim`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.NimGame abbrev I64Slice := Aeneas.Std.Slice Aeneas.Std.I64 def xorInt (a b : Int) ...
7
remove-one-element-to-make-the-array-strictly-increasing
1,909
Easy
[ "Array" ]
Given a 0-indexed integer array nums, return true if it can be made strictly increasing after removing exactly one element, or false otherwise. If the array is already strictly increasing, return true. The array nums is strictly increasing if nums[i - 1] < nums[i] for each index (1 <= i < nums.length).   Example 1: In...
canBeIncreasing(nums: list_int) -> bool
pub fn can_be_increasing(nums: &[i64]) -> bool
Aegis.CanBeIncreasing.can_be_increasing
pub fn can_be_increasing(nums: &[i64]) -> bool { let n = nums.len(); // An array of length 0 or 1 is trivially strictly increasing. if n <= 1 { return true; } let mut i: usize = 1; let mut prev: i64 = nums[0]; let mut used: bool = false; // whether we already "removed" one element ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [can_be_increasing]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option lin...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [can_be_increasing]: function definitions module public import Aeneas public import Aegis.CanBeIncreasing.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.CanBeIncreasing.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.CanBeIncreasing.can_be_increasing (Slice.from [1#i64, 1#i64, 1#i64] (by scalar_tac) : Slice Std.I64)) (false))}") #eval (s!"CASE 1 {(Result.reduc...
[ { "input": "[[1, 1, 1]]", "output": "false" }, { "input": "[[100, 20, 30]]", "output": "true" }, { "input": "[[3, 2, 1]]", "output": "false" }, { "input": "[[1, 2, 3]]", "output": "true" }, { "input": "[[1, 2, 2, 3]]", "output": "true" }, { "input": "[...
179
false
179
verified
10
10
2
16,080
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.CanBeIncreasing.Code.Funs /-! # Specifications of `Aegis.CanBeIncreasing.can_be_increasing` LeetCode problem `remove-one-element-to-make-the-array-strictly-increasing`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.CanBeIncreasing ...
9
maximum-alternating-subsequence-sum
1,911
Medium
[ "Array", "Dynamic Programming" ]
The alternating sum of a 0-indexed array is defined as the sum of the elements at even indices minus the sum of the elements at odd indices.\r \r \r For example, the alternating sum of [4,2,5,3] is (4 + 5) - (2 + 3) = 4.\r \r \r Given an array nums, return the maximum alternating sum of any subsequence of nums (after ...
maxAlternatingSum(nums: list_int) -> int
pub fn max_alternating_sum(nums: &[i64]) -> i64
Aegis.MaxAlternatingSum.max_alternating_sum
pub fn max_alternating_sum(nums: &[i64]) -> i64 { let n = nums.len(); if n == 0 { return 0; } let mut ans = nums[0]; let mut i: usize = 1; while i < n { let diff = nums[i] - nums[i - 1]; if diff > 0 { ans += diff; } i += 1; } ans }
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [max_alternating_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 l...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [max_alternating_sum]: function definitions module public import Aeneas public import Aegis.MaxAlternatingSum.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false...
import Aegis.MaxAlternatingSum.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.MaxAlternatingSum.max_alternating_sum (Slice.from [1#i64] (by scalar_tac) : Slice Std.I64)) (1#i64))}") #eval (s!"CASE 1 {(Result.reducesTo (Ae...
[ { "input": "[[1]]", "output": "1" }, { "input": "[[100]]", "output": "100" }, { "input": "[[4, 2, 5, 3]]", "output": "7" }, { "input": "[[5, 6, 7, 8]]", "output": "8" }, { "input": "[[100000, 99999, 99998, 99997, 99996]]", "output": "100000" }, { "inpu...
96
false
96
verified
10
10
1
1,283
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MaxAlternatingSum.Code.Funs /-! # Specifications of `Aegis.MaxAlternatingSum.max_alternating_sum` LeetCode problem `maximum-alternating-subsequence-sum`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.MaxAlternatingSum def vals (nu...
14
maximum-product-difference-between-two-pairs
1,913
Easy
[ "Array", "Sorting" ]
The product difference between two pairs (a, b) and (c, d) is defined as (a * b) - (c * d).\r \r \r For example, the product difference between (5, 6) and (2, 7) is (5 * 6) - (2 * 7) = 16.\r \r \r Given an integer array nums, choose four distinct indices w, x, y, and z such that the product difference between pairs (n...
maxProductDifference(nums: list_int) -> int
pub fn max_product_difference(nums: &[i64]) -> i64
Aegis.MaxProductDifference.max_product_difference
pub fn max_product_difference(nums: &[i64]) -> i64 { let mut max1 = nums[0]; let mut max2 = nums[1]; if max2 > max1 { let tmp = max1; max1 = max2; max2 = tmp; } let mut min1 = nums[0]; let mut min2 = nums[1]; if min2 < min1 { let tmp = min1; min1 = ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [max_product_difference]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_optio...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [max_product_difference]: function definitions module public import Aeneas public import Aegis.MaxProductDifference.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand...
import Aegis.MaxProductDifference.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.MaxProductDifference.max_product_difference (Slice.from [1#i64, 2#i64, 3#i64, 4#i64] (by scalar_tac) : Slice Std.I64)) (10#i64))}") #eval (s...
[ { "input": "[[1, 2, 3, 4]]", "output": "10" }, { "input": "[[10000, 1, 10000, 1]]", "output": "99999999" }, { "input": "[[10000, 9999, 1, 2]]", "output": "99989998" }, { "input": "[[5, 6, 2, 7, 4]]", "output": "34" }, { "input": "[[9, 5, 8, 3, 7]]", "output": ...
98
false
98
verified
10
10
1
1,407
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MaxProductDifference.Code.Funs /-! # Specifications of `Aegis.MaxProductDifference.max_product_difference` LeetCode problem `maximum-product-difference-between-two-pairs`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.MaxProductDiffere...
11
cyclically-rotating-a-grid
1,914
Medium
[ "Array", "Matrix", "Simulation" ]
You are given an m x n integer matrix grid​​​, where m and n are both even integers, and an integer k.\r \r The matrix is composed of several layers, which is shown in the below image, where each color is its own layer:\r \r \r \r A cyclic rotation of the matrix is done by cyclically rotating each layer in the matrix. ...
rotateGrid(grid: list_list_int, k: int) -> list_list_int
pub fn rotate_grid(grid: &[Vec<i64>], k: i64) -> Vec<Vec<i64>>
Aegis.RotateGrid.rotate_grid
pub fn rotate_grid(grid: &[Vec<i64>], k: i64) -> Vec<Vec<i64>> { let m = grid.len(); if m == 0 { return Vec::new(); } let n = grid[0].len(); let mut out: Vec<Vec<i64>> = Vec::new(); let mut i0: usize = 0; while i0 < m { let mut row: Vec<i64> = Vec::new(); let mut j0:...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [rotate_grid]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter.st...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [rotate_grid]: function definitions module public import Aeneas public import Aegis.RotateGrid.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.RotateGrid.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.RotateGrid.rotate_grid (Slice.from [(alloc.vec.Vec.from [40#i64, 10#i64] (by scalar_tac) : alloc.vec.Vec Std.I64), (alloc.vec.Vec.from [30#i64, 20#i64...
[ { "input": "[[[40, 10], [30, 20]], 1]", "output": "[[10, 20], [40, 30]]" }, { "input": "[[[1, 2], [3, 4], [5, 6], [7, 8]], 1]", "output": "[[2, 4], [1, 6], [3, 8], [5, 7]]" }, { "input": "[[[1, 2], [3, 4], [5, 6], [7, 8]], 5]", "output": "[[7, 5], [8, 3], [6, 1], [4, 2]]" }, { ...
57
false
57
verified
10
10
1
9,343
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.RotateGrid.Code.Funs /-! # Specifications of `Aegis.RotateGrid.rotate_grid` LeetCode problem `cyclically-rotating-a-grid`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.RotateGrid namespace AegisSpec.RotateGrid def nrows (grid : Slice (alloc.v...
11
build-array-from-permutation
1,920
Easy
[ "Array", "Simulation" ]
Given a zero-based permutation nums (0-indexed), build an array ans of the same length where ans[i] = nums[nums[i]] for each 0 <= i < nums.length and return it. A zero-based permutation nums is an array of distinct integers from 0 to nums.length - 1 (inclusive).   Example 1: Input: nums = [0,2,1,5,3,4] Output: [0,1,2,...
buildArray(nums: list_int) -> list_int
pub fn build_array(nums: &[i64]) -> Vec<i64>
Aegis.BuildArray.build_array
pub fn build_array(nums: &[i64]) -> Vec<i64> { let n = nums.len(); let mut ans: Vec<i64> = Vec::new(); let mut i: usize = 0; while i < n { let idx = nums[i] as usize; ans.push(nums[idx]); i = i + 1; } ans }
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [build_array]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter.st...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [build_array]: function definitions module public import Aeneas public import Aegis.BuildArray.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.BuildArray.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.BuildArray.build_array (Slice.from [1#i64, 0#i64] (by scalar_tac) : Slice Std.I64)) ((alloc.vec.Vec.from [0#i64, 1#i64] (by scalar_tac) : alloc.vec.Ve...
[ { "input": "[[1, 0]]", "output": "[0, 1]" }, { "input": "[[2, 0, 1]]", "output": "[1, 2, 0]" }, { "input": "[[3, 2, 1, 0]]", "output": "[0, 1, 2, 3]" }, { "input": "[[1, 0, 3, 2]]", "output": "[0, 1, 2, 3]" }, { "input": "[[0, 1, 2, 3]]", "output": "[0, 1, 2, ...
81
false
81
verified
10
10
1
89
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.BuildArray.Code.Funs /-! # Specifications of `Aegis.BuildArray.build_array` LeetCode problem `build-array-from-permutation`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.BuildArray def countOcc (l : List I64) (v : Int) : Nat := ...
10
eliminate-maximum-number-of-monsters
1,921
Medium
[ "Greedy", "Array", "Sorting" ]
You are playing a video game where you are defending your city from a group of n monsters. You are given a 0-indexed integer array dist of size n, where dist[i] is the initial distance in kilometers of the ith monster from the city. The monsters walk toward the city at a constant speed. The speed of each monster is giv...
eliminateMaximum(dist: list_int, speed: list_int) -> int
pub fn eliminate_maximum(dist: &[i64], speed: &[i64]) -> i64
Aegis.EliminateMaximum.eliminate_maximum
pub fn eliminate_maximum(dist: &[i64], speed: &[i64]) -> i64 { let n = dist.len(); // Find the maximum arrival time so we can size a counting array. let mut max_time: usize = 0; let mut i: usize = 0; while i < n { let d = dist[i]; let s = speed[i]; let t_i64 = (d + s - 1) / ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [eliminate_maximum]: type definitions module public import Aeneas @[expose] public section 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 -- [eliminate_maximum]: function definitions module public import Aeneas public import Aegis.EliminateMaximum.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.EliminateMaximum.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.EliminateMaximum.eliminate_maximum (Slice.from [1#i64] (by scalar_tac) : Slice Std.I64) (Slice.from [1#i64] (by scalar_tac) : Slice Std.I64)) (1...
[ { "input": "[[1], [1]]", "output": "1" }, { "input": "[[6, 7, 8], [2, 2, 2]]", "output": "3" }, { "input": "[[1, 2, 3], [3, 2, 1]]", "output": "1" }, { "input": "[[100, 200, 300], [1, 1, 1]]", "output": "3" }, { "input": "[[7, 14, 21], [1, 2, 3]]", "output": "...
127
false
127
verified
10
10
2
8,302
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.EliminateMaximum.Code.Funs import Mathlib.Data.Real.Basic /-! # Specifications of `Aegis.EliminateMaximum.eliminate_maximum` LeetCode problem `eliminate-maximum-number-of-monsters`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.EliminateMaximum ...
12
count-good-numbers
1,922
Medium
[ "Recursion", "Math" ]
A digit string is good if the digits (0-indexed) at even indices are even and the digits at odd indices are prime (2, 3, 5, or 7). For example, "2582" is good because the digits (2 and 8) at even positions are even and the digits (5 and 2) at odd positions are prime. However, "3245" is not good because 3 is at an even...
countGoodNumbers(n: int) -> int
pub fn count_good_numbers(n: i64) -> i64
Aegis.CountGoodNumbers.count_good_numbers
pub fn count_good_numbers(n: i64) -> i64 { const MOD: i64 = 1_000_000_007; fn pow_mod(mut base: i64, mut exp: i64, modulus: i64) -> i64 { let mut result: i64 = 1; base %= modulus; while exp > 0 { if exp % 2 == 1 { result = (result * base) % modulus; ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [count_good_numbers]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option li...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [count_good_numbers]: function definitions module public import Aeneas public import Aegis.CountGoodNumbers.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.CountGoodNumbers.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.CountGoodNumbers.count_good_numbers 1#i64) (5#i64))}") #eval (s!"CASE 1 {(Result.reducesTo (Aegis.CountGoodNumbers.count_good_numbers 4#i64) (40...
[ { "input": "[1]", "output": "5" }, { "input": "[4]", "output": "400" }, { "input": "[50]", "output": "564908303" }, { "input": "[500]", "output": "315782032" }, { "input": "[15]", "output": "399999958" }, { "input": "[200]", "output": "864605215" ...
29
false
29
verified
10
10
1
468
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.CountGoodNumbers.Code.Funs /-! # Specifications of `Aegis.CountGoodNumbers.count_good_numbers` LeetCode problem `count-good-numbers`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.CountGoodNumbers def imod (m a : ℤ) : ℤ := Int.emod a ...
12
longest-common-subpath
1,923
Hard
[ "Array", "Binary Search", "Suffix Array", "Hash Function", "Rolling Hash" ]
There is a country of n cities numbered from 0 to n - 1. In this country, there is a road connecting every pair of cities. There are m friends numbered from 0 to m - 1 who are traveling through the country. Each one of them will take a path consisting of some cities. Each path is represented by an integer array that co...
longestCommonSubpath(n: int, paths: list_list_int) -> int
pub fn longest_common_subpath(n: i64, paths: &[Vec<i64>]) -> i64
Aegis.LongestCommonSubpath.longest_common_subpath
pub fn longest_common_subpath(n: i64, paths: &[Vec<i64>]) -> i64 { let m = paths.len(); if m == 0 { return 0; } let mut min_len: i64 = paths[0].len() as i64; let mut i: usize = 1; while i < m { let l = paths[i].len() as i64; if l < min_len { min_len = l; ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [longest_common_subpath]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_optio...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [longest_common_subpath]: function definitions module public import Aeneas public import Aegis.LongestCommonSubpath.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand...
import Aegis.LongestCommonSubpath.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.LongestCommonSubpath.longest_common_subpath 1#i64 (Slice.from [(alloc.vec.Vec.from [0#i64] (by scalar_tac) : alloc.vec.Vec Std.I64), (alloc....
[ { "input": "[1, [[0], [0], [0]]]", "output": "1" }, { "input": "[3, [[0], [1], [2]]]", "output": "0" }, { "input": "[10, [[0, 1, 2], [1, 2, 3], [2, 3, 4]]]", "output": "1" }, { "input": "[5, [[0, 1, 2, 3, 4], [4, 3, 2, 1, 0]]]", "output": "1" }, { "input": "[10, [...
55
false
55
verified
10
10
1
26,271
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.LongestCommonSubpath.Code.Funs /-! # Specifications of `Aegis.LongestCommonSubpath.longest_common_subpath` LeetCode problem `longest-common-subpath`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.LongestCommonSubpath namespace AegisSpec.Longest...
14
count-square-sum-triples
1,925
Easy
[ "Math", "Enumeration" ]
A square triple (a,b,c) is a triple where a, b, and c are integers and a2 + b2 = c2. Given an integer n, return the number of square triples such that 1 <= a, b, c <= n.   Example 1: Input: n = 5 Output: 2 Explanation: The square triples are (3,4,5) and (4,3,5). Example 2: Input: n = 10 Output: 4 Explanation: The sq...
countTriples(n: int) -> int
pub fn count_triples(n: i64) -> i64
Aegis.CountTriples.count_triples
pub fn count_triples(n: i64) -> i64 { let mut count: i64 = 0; let mut a: i64 = 1; while a <= n { let mut b: i64 = 1; while b <= n { let target = a * a + b * b; let mut c: i64 = 1; while c <= n && c * c < target { c += 1; } ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [count_triples]: type definitions module public import Aeneas @[expose] public section 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_triples]: function definitions module public import Aeneas public import Aegis.CountTriples.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.CountTriples.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.CountTriples.count_triples 250#i64) (330#i64))}") #eval (s!"CASE 1 {(Result.reducesTo (Aegis.CountTriples.count_triples 5#i64) (2#i64))}") #eval (s!...
[ { "input": "[250]", "output": "330" }, { "input": "[5]", "output": "2" }, { "input": "[15]", "output": "8" }, { "input": "[200]", "output": "254" }, { "input": "[20]", "output": "12" }, { "input": "[100]", "output": "104" }, { "input": "[50...
23
false
23
verified
10
10
1
1,871
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.CountTriples.Code.Funs /-! # Specifications of `Aegis.CountTriples.count_triples` LeetCode problem `count-square-sum-triples`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.CountTriples def tripleSet (n : ℕ) : Finset (ℕ × ℕ × ℕ) :...
15
sum-game
1,927
Medium
[ "Greedy", "Math", "String", "Game Theory" ]
Alice and Bob take turns playing a game, with Alice starting first. You are given a string num of even length consisting of digits and '?' characters. On each turn, a player will do the following if there is still at least one '?' in num: Choose an index i where num[i] == '?'. Replace num[i] with any digit between '0'...
sumGame(num: str) -> bool
pub fn sum_game(num: &[u8]) -> bool
Aegis.SumGame.sum_game
pub fn sum_game(num: &[u8]) -> bool { let n = num.len(); let half = n / 2; let mut sum1: i64 = 0; let mut sum2: i64 = 0; let mut q1: i64 = 0; let mut q2: i64 = 0; let mut i: usize = 0; while i < half { let c = num[i]; if c == b'?' { q1 += 1; } else {...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [sum_game]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter.style...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [sum_game]: function definitions module public import Aeneas public import Aegis.SumGame.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.SumGame.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.SumGame.sum_game (Slice.from [49#u8, 63#u8, 63#u8, 63#u8, 50#u8, 63#u8, 63#u8, 63#u8] (by scalar_tac) : Slice Std.U8)) (true))}") #eval (s!"CASE 1 {(Resu...
[ { "input": "[\"1???2???\"]", "output": "true" }, { "input": "[\"9?8?7?6?\"]", "output": "true" }, { "input": "[\"????2222\"]", "output": "true" }, { "input": "[\"98765432\"]", "output": "true" }, { "input": "[\"???45678\"]", "output": "true" }, { "inpu...
168
false
168
verified
10
10
1
5,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.SumGame.Code.Funs /-! # Specifications of `Aegis.SumGame.sum_game` LeetCode problem `sum-game`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.SumGame def digitVal (c : U8) : Int := if 48 ≤ c.val ∧ c.val ≤ 57 then (c.val : Int) - 48 ...
2
minimum-cost-to-reach-destination-in-time
1,928
Hard
[ "Graph", "Array", "Dynamic Programming" ]
There is a country of n cities numbered from 0 to n - 1 where all the cities are connected by bi-directional roads. The roads are represented as a 2D integer array edges where edges[i] = [xi, yi, timei] denotes a road between cities xi and yi that takes timei minutes to travel. There may be multiple roads of differing ...
minCost(maxTime: int, edges: list_list_int, passingFees: list_int) -> int
pub fn min_cost(maxTime: i64, edges: &[Vec<i64>], passingFees: &[i64]) -> i64
Aegis.MinCost.min_cost
pub fn min_cost(maxTime: i64, edges: &[Vec<i64>], passingFees: &[i64]) -> i64 { let n = passingFees.len(); let tmax = maxTime as usize; let inf: i64 = 1_000_000_000; let mut dp: Vec<Vec<i64>> = Vec::new(); let mut i = 0; while i < n { let mut row: Vec<i64> = Vec::new(); let mut ...
-- 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 1#i64 (Slice.from [(alloc.vec.Vec.from [0#i64, 1#i64, 1#i64] (by scalar_tac) : alloc.vec.Vec Std.I64)] (by scalar_tac) : Slice (alloc.ve...
[ { "input": "[1, [[0, 1, 1]], [1, 1]]", "output": "2" }, { "input": "[15, [[0, 1, 10], [1, 2, 10], [0, 2, 1]], [3, 1, 2]]", "output": "5" }, { "input": "[10, [[0, 1, 5], [1, 2, 5], [0, 2, 10]], [3, 2, 1]]", "output": "4" }, { "input": "[5, [[0, 1, 5], [1, 2, 5], [0, 2, 10]], [...
98
false
98
verified
10
10
1
6,965
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": 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-cost-to-reach-destination-in-time`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.MinCost def edgeAt (edges : Slice (alloc.vec.Vec Std.I64)) ...
10
concatenation-of-array
1,929
Easy
[ "Array", "Simulation" ]
Given an integer array nums of length n, you want to create an array ans of length 2n where ans[i] == nums[i] and ans[i + n] == nums[i] for 0 <= i < n (0-indexed). Specifically, ans is the concatenation of two nums arrays. Return the array ans.   Example 1: Input: nums = [1,2,1] Output: [1,2,1,1,2,1] Explanation: The ...
getConcatenation(nums: list_int) -> list_int
pub fn get_concatenation(nums: &[i64]) -> Vec<i64>
Aegis.GetConcatenation.get_concatenation
pub fn get_concatenation(nums: &[i64]) -> Vec<i64> { let n = nums.len(); let mut ans: Vec<i64> = Vec::new(); let mut i: usize = 0; while i < n { ans.push(nums[i]); i += 1; } let mut j: usize = 0; while j < n { ans.push(nums[j]); j += 1; } ans }
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [get_concatenation]: type definitions module public import Aeneas @[expose] public section 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 -- [get_concatenation]: function definitions module public import Aeneas public import Aegis.GetConcatenation.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.GetConcatenation.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.GetConcatenation.get_concatenation (Slice.from [5#i64] (by scalar_tac) : Slice Std.I64)) ((alloc.vec.Vec.from [5#i64, 5#i64] (by scalar_tac) : a...
[ { "input": "[[5]]", "output": "[5, 5]" }, { "input": "[[10]]", "output": "[10, 10]" }, { "input": "[[999, 1000]]", "output": "[999, 1000, 999, 1000]" }, { "input": "[[5, 6, 7]]", "output": "[5, 6, 7, 5, 6, 7]" }, { "input": "[[1, 2, 1]]", "output": "[1, 2, 1, ...
71
false
71
verified
10
10
1
124
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.GetConcatenation.Code.Funs /-! # Specifications of `Aegis.GetConcatenation.get_concatenation` LeetCode problem `concatenation-of-array`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.GetConcatenation def countValue (l : List Std.I...
8
unique-length-3-palindromic-subsequences
1,930
Medium
[ "Bit Manipulation", "Hash Table", "String", "Prefix Sum" ]
Given a string s, return the number of unique palindromes of length three that are a subsequence of s. Note that even if there are multiple ways to obtain the same subsequence, it is still only counted once. A palindrome is a string that reads the same forwards and backwards. A subsequence of a string is a new string g...
countPalindromicSubsequence(s: str) -> int
pub fn count_palindromic_subsequence(s: &[u8]) -> i64
Aegis.CountPalindromicSubsequence.count_palindromic_subsequence
pub fn count_palindromic_subsequence(s: &[u8]) -> i64 { let n = s.len(); let mut ans: i64 = 0; let mut a: usize = 0; while a < 26 { let target: u8 = b'a' + (a as u8); // First occurrence: assign at most once (guarded by sentinel n). let mut first: usize = n; let mut i: ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [count_palindromic_subsequence]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false se...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [count_palindromic_subsequence]: function definitions module public import Aeneas public import Aegis.CountPalindromicSubsequence.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option lint...
import Aegis.CountPalindromicSubsequence.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.CountPalindromicSubsequence.count_palindromic_subsequence (Slice.from [97#u8, 98#u8, 99#u8, 98#u8, 97#u8] (by scalar_tac) : Slice Std...
[ { "input": "[\"abcba\"]", "output": "3" }, { "input": "[\"madam\"]", "output": "3" }, { "input": "[\"abcdedcba\"]", "output": "10" }, { "input": "[\"aaaaa\"]", "output": "1" }, { "input": "[\"adc\"]", "output": "0" }, { "input": "[\"abcabcabc\"]", ...
75
false
75
verified
10
10
3
24,917
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.CountPalindromicSubsequence.Code.Funs /-! # Specifications of `Aegis.CountPalindromicSubsequence.count_palindromic_subsequence` LeetCode problem `unique-length-3-palindromic-subsequences`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec....
11
painting-a-grid-with-three-different-colors
1,931
Hard
[ "Dynamic Programming" ]
You are given two integers m and n. Consider an m x n grid where each cell is initially white. You can paint each cell red, green, or blue. All cells must be painted. Return the number of ways to color the grid with no two adjacent cells having the same color. Since the answer can be very large, return it modulo 109 + ...
colorTheGrid(m: int, n: int) -> int
pub fn color_the_grid(m: i64, n: i64) -> i64
Aegis.ColorTheGrid.color_the_grid
const MOD: i64 = 1_000_000_007; pub fn color_the_grid(m: i64, n: i64) -> i64 { let m_us = m as usize; // There are 3^m possible color sequences for one column. let mut total_codes: i64 = 1; let mut i: i64 = 0; while i < m { total_codes *= 3; i += 1; } // Generate all verti...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [color_the_grid]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [color_the_grid]: function definitions module public import Aeneas public import Aegis.ColorTheGrid.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.ColorTheGrid.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.ColorTheGrid.color_the_grid 2#i64 4#i64) (162#i64))}") #eval (s!"CASE 1 {(Result.reducesTo (Aegis.ColorTheGrid.color_the_grid 4#i64 3#i64) (1122#i64...
[ { "input": "[2, 4]", "output": "162" }, { "input": "[4, 3]", "output": "1122" }, { "input": "[5, 1]", "output": "48" }, { "input": "[1, 2]", "output": "6" }, { "input": "[5, 5]", "output": "580986" }, { "input": "[3, 4]", "output": "1122" }, { ...
61
false
61
verified
10
10
1
4,055
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.ColorTheGrid.Code.Funs /-! # Specifications of `Aegis.ColorTheGrid.color_the_grid` LeetCode problem `painting-a-grid-with-three-different-colors`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aeneas.Std.Result namespace AegisSpec.ColorTheGrid ...
7
check-if-string-is-decomposable-into-value-equal-substrings
1,933
Easy
[ "String" ]
A value-equal string is a string where all characters are the same. For example, "1111" and "33" are value-equal strings. In contrast, "123" is not a value-equal string. Given a digit string s, decompose the string into some number of consecutive value-equal substrings where exactly one substring has a length of 2 an...
isDecomposable(s: str) -> bool
pub fn is_decomposable(s: &[u8]) -> bool
Aegis.IsDecomposable.is_decomposable
pub fn is_decomposable(s: &[u8]) -> bool { let n = s.len(); let mut have_two: bool = false; let mut ok: bool = true; let mut i: usize = 0; while i < n { let mut j: usize = i + 1; while j < n && s[j] == s[i] { j += 1; } let run_len: usize = j - i; ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [is_decomposable]: type definitions module public import Aeneas @[expose] public section 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 -- [is_decomposable]: function definitions module public import Aeneas public import Aegis.IsDecomposable.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.IsDecomposable.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.IsDecomposable.is_decomposable (Slice.from [55#u8, 55#u8, 55#u8, 55#u8, 55#u8, 55#u8, 55#u8, 55#u8, 55#u8, 55#u8, 55#u8, 55#u8, 55#u8, 55#u8, 55#u...
[ { "input": "[\"7777777777777777\"]", "output": "false" }, { "input": "[\"666666666666666\"]", "output": "false" }, { "input": "[\"111111\"]", "output": "false" }, { "input": "[\"999999999999999999\"]", "output": "false" }, { "input": "[\"55555555555555\"]", "o...
14
false
14
verified
10
10
2
3,409
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.IsDecomposable.Code.Funs /-! # Specifications of `Aegis.IsDecomposable.is_decomposable` LeetCode problem `check-if-string-is-decomposable-into-value-equal-substrings`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.IsDecomposable d...
12
add-minimum-number-of-rungs
1,936
Medium
[ "Greedy", "Array" ]
You are given a strictly increasing integer array rungs that represents the height of rungs on a ladder. You are currently on the floor at height 0, and you want to reach the last rung. You are also given an integer dist. You can only climb to the next highest rung if the distance between where you are currently at (th...
addRungs(rungs: list_int, dist: int) -> int
pub fn add_rungs(rungs: &[i64], dist: i64) -> i64
Aegis.AddRungs.add_rungs
pub fn add_rungs(rungs: &[i64], dist: i64) -> i64 { let mut ans: i64 = 0; let mut prev: i64 = 0; let mut i: usize = 0; while i < rungs.len() { let cur: i64 = rungs[i]; let gap: i64 = cur - prev; if gap > dist { ans = ans + (gap - 1) / dist; } prev =...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [add_rungs]: type definitions module public import Aeneas @[expose] public section 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 -- [add_rungs]: function definitions module public import Aeneas public import Aegis.AddRungs.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.AddRungs.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.AddRungs.add_rungs (Slice.from [10#i64] (by scalar_tac) : Slice Std.I64) 10#i64) (0#i64))}") #eval (s!"CASE 1 {(Result.reducesTo (Aegis.AddRungs.add_run...
[ { "input": "[[10], 10]", "output": "0" }, { "input": "[[1000000000], 1]", "output": "999999999" }, { "input": "[[5], 10]", "output": "0" }, { "input": "[[1000000000], 500000000]", "output": "1" }, { "input": "[[1000000000], 100000000]", "output": "9" }, { ...
102
false
102
verified
10
10
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.AddRungs.Code.Funs /-! # Specifications of `Aegis.AddRungs.add_rungs` LeetCode problem `add-minimum-number-of-rungs`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.AddRungs open Aegis.AddRungs (add_rungs) def vals (rungs : Slice Std....
12
maximum-number-of-points-with-cost
1,937
Medium
[ "Array", "Dynamic Programming", "Matrix" ]
You are given an m x n integer matrix points (0-indexed). Starting with 0 points, you want to maximize the number of points you can get from the matrix. To gain points, you must pick one cell in each row. Picking the cell at coordinates (r, c) will add points[r][c] to your score. However, you will lose points if you pi...
maxPoints(points: list_list_int) -> int
pub fn max_points(points: &[Vec<i64>]) -> i64
Aegis.MaxPoints.max_points
pub fn max_points(points: &[Vec<i64>]) -> i64 { let m = points.len(); if m == 0 { return 0; } let n = points[0].len(); if n == 0 { return 0; } let mut prev: Vec<i64> = Vec::new(); let mut j = 0; while j < n { prev.push(points[0][j]); j = j + 1; }...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [max_points]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter.sty...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [max_points]: function definitions module public import Aeneas public import Aegis.MaxPoints.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.MaxPoints.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.MaxPoints.max_points (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": "[[[5, 10], [10, 5]]]", "output": "19" }, { "input": "[[[5, 2], [1, 2]]]", "output": "6" }, { "input": "[[[1, 5], [2, 3], [4, 2]]]", "output": "11" }, { "input": "[[[1, 2, 3], [1, 5, 1], [3, 1, 1]]]", "output":...
91
false
91
verified
10
10
1
3,761
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MaxPoints.Code.Funs /-! # Specifications of `Aegis.MaxPoints.max_points` LeetCode problem `maximum-number-of-points-with-cost`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.MaxPoints def entries (points : Slice (alloc.vec.Vec Std...
10
longest-common-subsequence-between-sorted-arrays
1,940
Medium
[ "Array", "Hash Table", "Counting" ]
Given an array of integer arrays arrays where each arrays[i] is sorted in strictly increasing order, return an integer array representing the longest common subsequence among all the arrays. A subsequence is a sequence that can be derived from another sequence by deleting some elements (possibly none) without changing ...
longestCommonSubsequence(arrays: list_list_int) -> list_int
pub fn longest_common_subsequence(arrays: &[Vec<i64>]) -> Vec<i64>
Aegis.LongestCommonSubsequence.longest_common_subsequence
pub fn longest_common_subsequence(arrays: &[Vec<i64>]) -> Vec<i64> { let mut ans: Vec<i64> = Vec::new(); if arrays.len() == 0 { return ans; } let first = &arrays[0]; let mut j: usize = 0; while j < first.len() { let val = first[j]; let mut in_all: bool = true; le...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [longest_common_subsequence]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_o...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [longest_common_subsequence]: function definitions module public import Aeneas public import Aegis.LongestCommonSubsequence.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.has...
import Aegis.LongestCommonSubsequence.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.LongestCommonSubsequence.longest_common_subsequence (Slice.from [(alloc.vec.Vec.from [1#i64] (by scalar_tac) : alloc.vec.Vec Std.I64), (...
[ { "input": "[[[1], [1], [1], [1]]]", "output": "[1]" }, { "input": "[[[1, 2, 3, 4, 5], [6, 7, 8]]]", "output": "[]" }, { "input": "[[[1, 2, 3, 4, 5], [6, 7, 8]]]", "output": "[]" }, { "input": "[[[1, 3, 4], [1, 4, 7, 9]]]", "output": "[1, 4]" }, { "input": "[[[1, ...
96
false
96
verified
10
10
1
2,667
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.LongestCommonSubsequence.Code.Funs /-! # Specifications of `Aegis.LongestCommonSubsequence.longest_common_subsequence` LeetCode problem `longest-common-subsequence-between-sorted-arrays`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec...
12
check-if-all-characters-have-equal-number-of-occurrences
1,941
Easy
[ "Hash Table", "String", "Counting" ]
Given a string s, return true if s is a good string, or false otherwise. A string s is good if all the characters that appear in s have the same number of occurrences (i.e., the same frequency).   Example 1: Input: s = "abacbc" Output: true Explanation: The characters that appear in s are 'a', 'b', and 'c'. All charac...
areOccurrencesEqual(s: str) -> bool
pub fn are_occurrences_equal(s: &[u8]) -> bool
Aegis.AreOccurrencesEqual.are_occurrences_equal
pub fn are_occurrences_equal(s: &[u8]) -> bool { // Count occurrences per byte value (256 slots, no underflow risk). let mut counts: Vec<i64> = Vec::new(); let mut i: usize = 0; while i < 256 { counts.push(0); i += 1; } let mut j: usize = 0; while j < s.len() { let i...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [are_occurrences_equal]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [are_occurrences_equal]: function definitions module public import Aeneas public import Aegis.AreOccurrencesEqual.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand f...
import Aegis.AreOccurrencesEqual.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.AreOccurrencesEqual.are_occurrences_equal (Slice.from [97#u8, 97#u8, 98#u8, 98#u8, 99#u8, 99#u8, 99#u8] (by scalar_tac) : Slice Std.U8)) (fal...
[ { "input": "[\"aabbccc\"]", "output": "false" }, { "input": "[\"abacbc\"]", "output": "true" }, { "input": "[\"abcabcabc\"]", "output": "true" }, { "input": "[\"qqqq\"]", "output": "true" }, { "input": "[\"aabbcc\"]", "output": "true" }, { "input": "[\...
91
false
91
verified
10
10
2
8,589
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.AreOccurrencesEqual.Code.Funs /-! # Specifications of `Aegis.AreOccurrencesEqual.are_occurrences_equal` LeetCode problem `check-if-all-characters-have-equal-number-of-occurrences`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.AreOccurrencesEq...
7
describe-the-painting
1,943
Medium
[ "Array", "Hash Table", "Prefix Sum", "Sorting" ]
There is a long and thin painting that can be represented by a number line. The painting was painted with multiple overlapping segments where each segment was painted with a unique color. You are given a 2D integer array segments, where segments[i] = [starti, endi, colori] represents the half-closed segment [starti, en...
splitPainting(segments: list_list_int) -> list_list_int
pub fn split_painting(segments: &[Vec<i64>]) -> Vec<Vec<i64>>
Aegis.SplitPainting.split_painting
fn radix_pass(src: &[i64], dst: &mut Vec<i64>, shift: usize) { let n: usize = src.len(); let mut count: Vec<i64> = Vec::new(); let mut b: usize = 0; while b < 512 { count.push(0); b += 1; } let mut i: usize = 0; while i < n { let key: i64 = src[i]; let pos: ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [split_painting]: type definitions module public import Aeneas @[expose] public section 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 -- [split_painting]: function definitions module public import Aeneas public import Aegis.SplitPainting.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.SplitPainting.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval aegisCa...
[ { "input": "[[[1, 100000, 1000000000]]]", "output": "[[1, 100000, 1000000000]]" }, { "input": "[[[1, 4, 5], [4, 7, 7], [1, 7, 9]]]", "output": "[[1, 4, 14], [4, 7, 16]]" }, { "input": "[[[1, 100000, 1000000], [50000, 100000, 900000], [1, 50000, 800000]]]", "output": "[[1, 50000, 1800...
98
true
98
verified
10
10
4
52,218
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.SplitPainting.Code.Funs /-! # Specifications of `Aegis.SplitPainting.split_painting` LeetCode problem `describe-the-painting`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.SplitPainting structure Seg where s : ℤ e : ℤ ...
15
number-of-visible-people-in-a-queue
1,944
Hard
[ "Stack", "Array", "Monotonic Stack" ]
There are n people standing in a queue, and they numbered from 0 to n - 1 in left to right order. You are given an array heights of distinct integers where heights[i] represents the height of the ith person. A person can see another person to their right in the queue if everybody in between is shorter than both of them...
canSeePersonsCount(heights: list_int) -> list_int
pub fn can_see_persons_count(heights: &[i64]) -> Vec<i64>
Aegis.CanSeePersonsCount.can_see_persons_count
pub fn can_see_persons_count(heights: &[i64]) -> Vec<i64> { let n = heights.len(); let mut ans: Vec<i64> = Vec::new(); let mut k = 0; while k < n { ans.push(0); k += 1; } let mut stack: Vec<i64> = Vec::new(); let mut i = n; while i > 0 { i -= 1; let h =...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [can_see_persons_count]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [can_see_persons_count]: function definitions module public import Aeneas public import Aegis.CanSeePersonsCount.Code.Types public import Aegis.CanSeePersonsCount.Code.FunsExternal @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option l...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [can_see_persons_count]: external functions. -- This is a template file: rename it to "FunsExternal.lean" and fill the holes. module public import Aeneas public import Aegis.CanSeePersonsCount.Code.Types @[expose] public section open Aeneas Aeneas.Std Result Control...
import Aegis.CanSeePersonsCount.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.CanSeePersonsCount.can_see_persons_count (Slice.from [1#i64] (by scalar_tac) : Slice Std.I64)) ((alloc.vec.Vec.from [0#i64] (by scalar_tac) : ...
[ { "input": "[[1]]", "output": "[0]" }, { "input": "[[100000]]", "output": "[0]" }, { "input": "[[3, 1, 2]]", "output": "[2, 1, 0]" }, { "input": "[[5, 1, 2, 3, 10]]", "output": "[4, 1, 1, 1, 0]" }, { "input": "[[5, 4, 3, 2, 1]]", "output": "[1, 1, 1, 1, 0]" ...
123
false
123
verified
10
10
1
1,540
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.CanSeePersonsCount.Code.Funs /-! # Specifications of `Aegis.CanSeePersonsCount.can_see_persons_count` LeetCode problem `number-of-visible-people-in-a-queue`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.CanSeePersonsCount open Cl...
10
sum-of-digits-of-string-after-convert
1,945
Easy
[ "String", "Simulation" ]
You are given a string s consisting of lowercase English letters, and an integer k. Your task is to convert the string into an integer by a special process, and then transform it by summing its digits repeatedly k times. More specifically, perform the following steps: Convert s into an integer by replacing each letter...
getLucky(s: str, k: int) -> int
pub fn get_lucky(s: &[u8], k: i64) -> i64
Aegis.GetLucky.get_lucky
pub fn get_lucky(s: &[u8], k: i64) -> i64 { let mut sum: i64 = 0; let mut i: usize = 0; while i < s.len() { let val: i64 = (s[i] - b'a') as i64 + 1; sum = sum + (val / 10) + (val % 10); i = i + 1; } let mut step: i64 = 1; while step < k { let mut x: i64 = sum; ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [get_lucky]: type definitions module public import Aeneas @[expose] public section 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 -- [get_lucky]: function definitions module public import Aeneas public import Aegis.GetLucky.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.GetLucky.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.GetLucky.get_lucky (Slice.from [122#u8, 122#u8, 122#u8, 122#u8] (by scalar_tac) : Slice Std.U8) 1#i64) (32#i64))}") #eval (s!"CASE 1 {(Result.reducesTo ...
[ { "input": "[\"zzzz\", 1]", "output": "32" }, { "input": "[\"zzz\", 10]", "output": "6" }, { "input": "[\"programming\", 1]", "output": "68" }, { "input": "[\"abz\", 5]", "output": "2" }, { "input": "[\"a\", 1]", "output": "1" }, { "input": "[\"aaa\", ...
93
false
93
verified
10
10
1
926
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.GetLucky.Code.Funs /-! # Specifications of `Aegis.GetLucky.get_lucky` LeetCode problem `sum-of-digits-of-string-after-convert`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.GetLucky open Aegis.GetLucky (get_lucky) def digitSum (n : ...
9
maximum-compatibility-score-sum
1,947
Medium
[ "Bit Manipulation", "Array", "Dynamic Programming", "Backtracking", "Bitmask" ]
There is a survey that consists of n questions where each question's answer is either 0 (no) or 1 (yes). The survey was given to m students numbered from 0 to m - 1 and m mentors numbered from 0 to m - 1. The answers of the students are represented by a 2D integer array students where students[i] is an integer array th...
maxCompatibilitySum(students: list_list_int, mentors: list_list_int) -> int
pub fn max_compatibility_sum(students: &[Vec<i64>], mentors: &[Vec<i64>]) -> i64
Aegis.MaxCompatibilitySum.max_compatibility_sum
pub fn max_compatibility_sum(students: &[Vec<i64>], mentors: &[Vec<i64>]) -> i64 { let m = students.len(); if m == 0 { return 0; } let n = students[0].len(); if n == 0 { return 0; } let mut score: Vec<i64> = Vec::new(); let mut i = 0; while i < m { let mut j...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [max_compatibility_sum]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [max_compatibility_sum]: function definitions module public import Aeneas public import Aegis.MaxCompatibilitySum.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand f...
import Aegis.MaxCompatibilitySum.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.MaxCompatibilitySum.max_compatibility_sum (Slice.from [(alloc.vec.Vec.from [1#i64, 1#i64] (by scalar_tac) : alloc.vec.Vec Std.I64), (alloc.ve...
[ { "input": "[[[1, 1], [0, 0]], [[0, 0], [1, 1]]]", "output": "4" }, { "input": "[[[1, 0], [0, 1]], [[1, 0], [0, 1]]]", "output": "4" }, { "input": "[[[1, 0], [0, 1]], [[0, 1], [1, 0]]]", "output": "4" }, { "input": "[[[1, 1, 1], [0, 0, 0]], [[1, 1, 1], [0, 0, 0]]]", "outp...
68
false
68
verified
10
10
1
2,565
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MaxCompatibilitySum.Code.Funs /-! # Specifications of `Aegis.MaxCompatibilitySum.max_compatibility_sum` LeetCode problem `maximum-compatibility-score-sum`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.MaxCompatibilitySum def toRows (...
14
maximum-of-minimum-values-in-all-subarrays
1,950
Medium
[ "Stack", "Array", "Monotonic Stack" ]
You are given an integer array nums of size n. You are asked to solve n queries for each integer i in the range 0 <= i < n. To solve the ith query: Find the minimum value in each possible subarray of size i + 1 of the array nums. Find the maximum of those minimum values. This maximum is the answer to the query. Retur...
findMaximums(nums: list_int) -> list_int
pub fn find_maximums(nums: &[i64]) -> Vec<i64>
Aegis.FindMaximums.find_maximums
pub fn find_maximums(nums: &[i64]) -> Vec<i64> { let n = nums.len(); if n == 0 { return Vec::new(); } // left[i] = index of the previous element strictly smaller than nums[i], or -1. let mut left: Vec<i64> = Vec::new(); let mut stack: Vec<i64> = Vec::new(); let mut i: usize = 0; ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [find_maximums]: type definitions module public import Aeneas @[expose] public section 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 -- [find_maximums]: function definitions module public import Aeneas public import Aegis.FindMaximums.Code.Types public import Aegis.FindMaximums.Code.FunsExternal @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace f...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [find_maximums]: external functions. -- This is a template file: rename it to "FunsExternal.lean" and fill the holes. module public import Aeneas public import Aegis.FindMaximums.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set...
import Aegis.FindMaximums.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.FindMaximums.find_maximums (Slice.from [1#i64] (by scalar_tac) : Slice Std.I64)) ((alloc.vec.Vec.from [1#i64] (by scalar_tac) : alloc.vec.Vec Std.I6...
[ { "input": "[[1]]", "output": "[1]" }, { "input": "[[10, 20, 50, 10]]", "output": "[50, 20, 10, 10]" }, { "input": "[[100, 100, 100, 100]]", "output": "[100, 100, 100, 100]" }, { "input": "[[0, 1, 2, 4]]", "output": "[4, 2, 1, 0]" }, { "input": "[[1000000000, 0, 1...
140
false
140
verified
10
10
1
4,639
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.FindMaximums.Code.Funs /-! # Specifications of `Aegis.FindMaximums.find_maximums` LeetCode problem `maximum-of-minimum-values-in-all-subarrays`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.FindMaximums namespace AegisSpec.FindMaximums ...
13
three-divisors
1,952
Easy
[ "Math", "Enumeration", "Number Theory" ]
Given an integer n, return true if n has exactly three positive divisors. Otherwise, return false. An integer m is a divisor of n if there exists an integer k such that n = k * m.   Example 1: Input: n = 2 Output: false Explantion: 2 has only two divisors: 1 and 2. Example 2: Input: n = 4 Output: true Explantion: 4 ...
isThree(n: int) -> bool
pub fn is_three(n: i64) -> bool
Aegis.IsThree.is_three
pub fn is_three(n: i64) -> bool { if n < 1 { return false; } let mut count: i64 = 0; let mut d: i64 = 1; while d <= n { if n % d == 0 { count += 1; } d += 1; } count == 3 }
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [is_three]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter.style...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [is_three]: function definitions module public import Aeneas public import Aegis.IsThree.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.IsThree.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.IsThree.is_three 625#i64) (false))}") #eval (s!"CASE 1 {(Result.reducesTo (Aegis.IsThree.is_three 3#i64) (false))}") #eval (s!"CASE 2 {(Result.reducesTo ...
[ { "input": "[625]", "output": "false" }, { "input": "[3]", "output": "false" }, { "input": "[576]", "output": "false" }, { "input": "[729]", "output": "false" }, { "input": "[144]", "output": "false" }, { "input": "[49]", "output": "true" }, { ...
144
false
144
verified
10
10
1
519
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.IsThree.Code.Funs /-! # Specifications of `Aegis.IsThree.is_three` LeetCode problem `three-divisors`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.IsThree (is_three) namespace AegisSpec.IsThree def PosDiv (n d : Int) : Prop := 1 ≤ d ∧ d ≤ n...
6
maximum-number-of-weeks-for-which-you-can-work
1,953
Medium
[ "Greedy", "Array" ]
There are n projects numbered from 0 to n - 1. You are given an integer array milestones where each milestones[i] denotes the number of milestones the ith project has. You can work on the projects following these two rules: Every week, you will finish exactly one milestone of one project. You must work every week. You...
numberOfWeeks(milestones: list_int) -> int
pub fn number_of_weeks(milestones: &[i64]) -> i64
Aegis.NumberOfWeeks.number_of_weeks
pub fn number_of_weeks(milestones: &[i64]) -> i64 { let n = milestones.len(); let mut total: i64 = 0; let mut max_val: i64 = 0; let mut i: usize = 0; while i < n { let v = milestones[i]; total += v; if v > max_val { max_val = v; } i += 1; } ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [number_of_weeks]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linte...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [number_of_weeks]: function definitions module public import Aeneas public import Aegis.NumberOfWeeks.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_opt...
import Aegis.NumberOfWeeks.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.NumberOfWeeks.number_of_weeks (Slice.from [1#i64] (by scalar_tac) : Slice Std.I64)) (1#i64))}") #eval (s!"CASE 1 {(Result.reducesTo (Aegis.NumberOf...
[ { "input": "[[1]]", "output": "1" }, { "input": "[[1, 1000000000]]", "output": "3" }, { "input": "[[3, 3, 3]]", "output": "9" }, { "input": "[[10, 5, 1]]", "output": "13" }, { "input": "[[1000000000, 1, 1]]", "output": "5" }, { "input": "[[1, 2, 3]]", ...
80
false
80
verified
10
10
1
543
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.NumberOfWeeks.Code.Funs /-! # Specifications of `Aegis.NumberOfWeeks.number_of_weeks` LeetCode problem `maximum-number-of-weeks-for-which-you-can-work`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.NumberOfWeeks def contents (s : Sli...
15
minimum-garden-perimeter-to-collect-enough-apples
1,954
Medium
[ "Math", "Binary Search" ]
In a garden represented as an infinite 2D grid, there is an apple tree planted at every integer coordinate. The apple tree planted at an integer coordinate (i, j) has |i| + |j| apples growing on it. You will buy an axis-aligned square plot of land that is centered at (0, 0). Given an integer neededApples, return the mi...
minimumPerimeter(neededApples: int) -> int
pub fn minimum_perimeter(neededApples: i64) -> i64
Aegis.MinimumPerimeter.minimum_perimeter
pub fn minimum_perimeter(neededApples: i64) -> i64 { let mut low: i64 = 0; let mut high: i64 = 1000000; while low < high { let mid: i64 = (low + high) / 2; let apples: i64 = 2 * mid * (mid + 1) * (2 * mid + 1); if apples >= neededApples { high = mid; } else { ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [minimum_perimeter]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option lin...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [minimum_perimeter]: function definitions module public import Aeneas public import Aegis.MinimumPerimeter.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.MinimumPerimeter.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.MinimumPerimeter.minimum_perimeter 10000000000#i64) (10856#i64))}") #eval (s!"CASE 1 {(Result.reducesTo (Aegis.MinimumPerimeter.minimum_perimete...
[ { "input": "[10000000000]", "output": "10856" }, { "input": "[10]", "output": "8" }, { "input": "[50]", "output": "16" }, { "input": "[1000000]", "output": "504" }, { "input": "[13]", "output": "16" }, { "input": "[1000000000]", "output": "5040" ...
66
false
66
verified
10
10
1
2,153
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MinimumPerimeter.Code.Funs /-! # Specifications of `Aegis.MinimumPerimeter.minimum_perimeter` LeetCode problem `minimum-garden-perimeter-to-collect-enough-apples`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.MinimumPerimeter def app...
10
count-number-of-special-subsequences
1,955
Hard
[ "Array", "Dynamic Programming" ]
A sequence is special if it consists of a positive number of 0s, followed by a positive number of 1s, then a positive number of 2s. For example, [0,1,2] and [0,0,1,1,1,2] are special. In contrast, [2,1,0], [1], and [0,1,2,0] are not special. Given an array nums (consisting of only integers 0, 1, and 2), return the nu...
countSpecialSubsequences(nums: list_int) -> int
pub fn count_special_subsequences(nums: &[i64]) -> i64
Aegis.CountSpecialSubsequences.count_special_subsequences
pub fn count_special_subsequences(nums: &[i64]) -> i64 { const MOD: i64 = 1_000_000_007; let mut dp0: i64 = 0; let mut dp1: i64 = 0; let mut dp2: i64 = 0; let mut i: usize = 0; while i < nums.len() { let x = nums[i]; if x == 0 { dp0 = (2 * dp0 + 1) % MOD; } ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [count_special_subsequences]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_o...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [count_special_subsequences]: function definitions module public import Aeneas public import Aegis.CountSpecialSubsequences.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.has...
import Aegis.CountSpecialSubsequences.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.CountSpecialSubsequences.count_special_subsequences (Slice.from [0#i64, 1#i64, 2#i64] (by scalar_tac) : Slice Std.I64)) (1#i64))}") #eva...
[ { "input": "[[0, 1, 2]]", "output": "1" }, { "input": "[[1, 2, 0]]", "output": "0" }, { "input": "[[2, 2, 0, 0]]", "output": "0" }, { "input": "[[0, 1, 2, 2]]", "output": "3" }, { "input": "[[0, 0, 1, 1, 2]]", "output": "9" }, { "input": "[[0, 1, 2, 2,...
128
false
128
verified
10
10
1
906
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.CountSpecialSubsequences.Code.Funs /-! # Specifications of `Aegis.CountSpecialSubsequences.count_special_subsequences` LeetCode problem `count-number-of-special-subsequences`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.CountSpecialSubsequen...
11
minimum-time-for-k-virus-variants-to-spread
1,956
Hard
[ "Geometry", "Array", "Math", "Binary Search", "Enumeration" ]
There are n unique virus variants in an infinite 2D grid. You are given a 2D array points, where points[i] = [xi, yi] represents a virus originating at (xi, yi) on day 0. Note that it is possible for multiple virus variants to originate at the same point. Every day, each cell infected with a virus variant will spread t...
minDayskVariants(points: list_list_int, k: int) -> int
pub fn min_daysk_variants(points: &[Vec<i64>], k: i64) -> i64
Aegis.MinDayskVariants.min_daysk_variants
fn can_spread( points: &[Vec<i64>], k: i64, minx: i64, maxx: i64, miny: i64, maxy: i64, days: i64, ) -> bool { let n = points.len(); let mut found = false; let mut cx = minx; while cx <= maxx { let mut cy = miny; while cy <= maxy { let mut count: i...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [min_daysk_variants]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option li...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [min_daysk_variants]: function definitions module public import Aeneas public import Aegis.MinDayskVariants.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.MinDayskVariants.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.MinDayskVariants.min_daysk_variants (Slice.from [(alloc.vec.Vec.from [1#i64, 1#i64] (by scalar_tac) : alloc.vec.Vec Std.I64), (alloc.vec.Vec.fro...
[ { "input": "[[[1, 1], [6, 1]], 2]", "output": "3" }, { "input": "[[[3, 3], [1, 2], [9, 2]], 3]", "output": "4" }, { "input": "[[[10, 10], [1, 1], [5, 5]], 2]", "output": "4" }, { "input": "[[[3, 3], [1, 2], [9, 2]], 2]", "output": "2" }, { "input": "[[[1, 1], [1, ...
212
false
212
verified
10
10
2
7,344
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MinDayskVariants.Code.Funs /-! # Specifications of `Aegis.MinDayskVariants.min_daysk_variants` LeetCode problem `minimum-time-for-k-virus-variants-to-spread`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result ControlFlow Error open Aegis.MinDayskVariants ...
11
minimum-total-space-wasted-with-k-resizing-operations
1,959
Medium
[ "Array", "Dynamic Programming" ]
You are currently designing a dynamic array. You are given a 0-indexed integer array nums, where nums[i] is the number of elements that will be in the array at time i. In addition, you are given an integer k, the maximum number of times you can resize the array (to any size). The size of the array at time t, sizet, mus...
minSpaceWastedKResizing(nums: list_int, k: int) -> int
pub fn min_space_wasted_k_resizing(nums: &[i64], k: i64) -> i64
Aegis.MinSpaceWastedKResizing.min_space_wasted_k_resizing
pub fn min_space_wasted_k_resizing(nums: &[i64], k: i64) -> i64 { let n = nums.len(); if n == 0 { return 0; } let mut gmax_i64 = k + 1; if gmax_i64 > n as i64 { gmax_i64 = n as i64; } let gmax = gmax_i64 as usize; let mut cost: Vec<Vec<i64>> = Vec::new(); let mut l ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [min_space_wasted_k_resizing]: type definitions module public import Aeneas @[expose] public 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 -- [min_space_wasted_k_resizing]: function definitions module public import Aeneas public import Aegis.MinSpaceWastedKResizing.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.has...
import Aegis.MinSpaceWastedKResizing.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.MinSpaceWastedKResizing.min_space_wasted_k_resizing (Slice.from [10#i64, 20#i64] (by scalar_tac) : Slice Std.I64) 0#i64) (10#i64))}") #ev...
[ { "input": "[[10, 20], 0]", "output": "10" }, { "input": "[[10, 20, 30], 1]", "output": "10" }, { "input": "[[1000000, 1000000, 1000000], 2]", "output": "0" }, { "input": "[[5, 8, 6, 10], 1]", "output": "5" }, { "input": "[[10, 10, 10, 10, 10], 2]", "output": ...
117
false
117
verified
10
10
1
3,708
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MinSpaceWastedKResizing.Code.Funs /-! # Specifications of `Aegis.MinSpaceWastedKResizing.min_space_wasted_k_resizing` LeetCode problem `minimum-total-space-wasted-with-k-resizing-operations`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.MinSpac...
14
check-if-string-is-a-prefix-of-array
1,961
Easy
[ "Array", "Two Pointers", "String" ]
Given a string s and an array of strings words, determine whether s is a prefix string of words. A string s is a prefix string of words if s can be made by concatenating the first k strings in words for some positive k no larger than words.length. Return true if s is a prefix string of words, or false otherwise.   Exam...
isPrefixString(s: str, words: list_str) -> bool
pub fn is_prefix_string(s: &[u8], words: &[Vec<u8>]) -> bool
Aegis.IsPrefixString.is_prefix_string
pub fn is_prefix_string(s: &[u8], words: &[Vec<u8>]) -> bool { let n: usize = s.len(); let mut pos: usize = 0; let mut i: usize = 0; let mut result: bool = false; let mut finished: bool = false; while i < words.len() && !finished { let w = &words[i]; let wlen: usize = w.len(); ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [is_prefix_string]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option lint...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [is_prefix_string]: function definitions module public import Aeneas public import Aegis.IsPrefixString.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.IsPrefixString.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.IsPrefixString.is_prefix_string (Slice.from [97#u8, 98#u8, 99#u8] (by scalar_tac) : Slice Std.U8) (Slice.from [(alloc.vec.Vec.from [97#u8] (by sca...
[ { "input": "[\"abc\", [\"a\"]]", "output": "false" }, { "input": "[\"abcd\", [\"abcd\"]]", "output": "true" }, { "input": "[\"abcd\", [\"abc\"]]", "output": "false" }, { "input": "[\"aaaa\", [\"aa\", \"aa\"]]", "output": "true" }, { "input": "[\"abc\", [\"a\", \"b...
125
false
125
verified
10
10
2
3,639
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.IsPrefixString.Code.Funs /-! # Specifications of `Aegis.IsPrefixString.is_prefix_string` LeetCode problem `check-if-string-is-a-prefix-of-array`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.IsPrefixString (is_prefix_string) namespace AegisSpe...
14
remove-stones-to-minimize-the-total
1,962
Medium
[ "Greedy", "Array", "Heap (Priority Queue)" ]
You are given a 0-indexed integer array piles, where piles[i] represents the number of stones in the ith pile, and an integer k. You should apply the following operation exactly k times: Choose any piles[i] and remove floor(piles[i] / 2) stones from it. Notice that you can apply the operation on the same pile more th...
minStoneSum(piles: list_int, k: int) -> int
pub fn min_stone_sum(piles: &[i64], k: i64) -> i64
Aegis.MinStoneSum.min_stone_sum
pub fn min_stone_sum(piles: &[i64], k: i64) -> i64 { let n = piles.len(); let mut max_v: i64 = 0; let mut i: usize = 0; while i < n { let p = piles[i]; if p > max_v { max_v = p; } i += 1; } let mut lo: i64 = 1; let mut hi: i64 = max_v; while ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [min_stone_sum]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter....
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [min_stone_sum]: function definitions module public import Aeneas public import Aegis.MinStoneSum.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.MinStoneSum.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval aegisCase...
[ { "input": "[[1], 1]", "output": "1" }, { "input": "[[9999], 10000]", "output": "1" }, { "input": "[[5, 4, 9], 2]", "output": "12" }, { "input": "[[10, 10, 10], 1]", "output": "25" }, { "input": "[[100, 200, 300], 10]", "output": "57" }, { "input": "[[...
83
false
83
verified
10
10
3
25,500
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MinStoneSum.Code.Funs /-! # Specifications of `Aegis.MinStoneSum.min_stone_sum` LeetCode problem `remove-stones-to-minimize-the-total`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.MinStoneSum namespace AegisSpec.MinStoneSum def vals (p...
15
find-the-longest-valid-obstacle-course-at-each-position
1,964
Hard
[ "Binary Indexed Tree", "Array", "Binary Search" ]
You want to build some obstacle courses. You are given a 0-indexed integer array obstacles of length n, where obstacles[i] describes the height of the ith obstacle. For every index i between 0 and n - 1 (inclusive), find the length of the longest obstacle course in obstacles such that: You choose any number of obstacl...
longestObstacleCourseAtEachPosition(obstacles: list_int) -> list_int
pub fn longest_obstacle_course_at_each_position(obstacles: &[i64]) -> Vec<i64>
Aegis.LongestObstacleCourseAtEachPosition.longest_obstacle_course_at_each_position
pub fn longest_obstacle_course_at_each_position(obstacles: &[i64]) -> Vec<i64> { let n = obstacles.len(); let mut ans: Vec<i64> = Vec::new(); let mut tails: Vec<i64> = Vec::new(); let mut i: usize = 0; while i < n { let x: i64 = obstacles[i]; let mut lo: usize = 0; let mut ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [longest_obstacle_course_at_each_position]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariabl...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [longest_obstacle_course_at_each_position]: function definitions module public import Aeneas public import Aegis.LongestObstacleCourseAtEachPosition.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace fa...
import Aegis.LongestObstacleCourseAtEachPosition.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.LongestObstacleCourseAtEachPosition.longest_obstacle_course_at_each_position (Slice.from [1#i64] (by scalar_tac) : Slice Std....
[ { "input": "[[1]]", "output": "[1]" }, { "input": "[[2, 2, 1]]", "output": "[1, 2, 1]" }, { "input": "[[1, 2, 3, 2]]", "output": "[1, 2, 3, 3]" }, { "input": "[[5, 4, 3, 2, 1]]", "output": "[1, 1, 1, 1, 1]" }, { "input": "[[5, 5, 5, 5, 5]]", "output": "[1, 2, ...
128
false
128
verified
10
10
1
1,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.LongestObstacleCourseAtEachPosition.Code.Funs /-! # Specifications of `Aegis.LongestObstacleCourseAtEachPosition.longest_obstacle_course_at_each_position` LeetCode problem `find-the-longest-valid-obstacle-course-at-each-position`. Each `spec_<n>` theorem states one property of the function. -/ open Aene...
11
number-of-strings-that-appear-as-substrings-in-word
1,967
Easy
[ "Array", "String" ]
Given an array of strings patterns and a string word, return the number of strings in patterns that exist as a substring in word. A substring is a contiguous sequence of characters within a string.   Example 1: Input: patterns = ["a","abc","bc","d"], word = "abc" Output: 3 Explanation: - "a" appears as a substring in ...
numOfStrings(patterns: list_str, word: str) -> int
pub fn num_of_strings(patterns: &[Vec<u8>], word: &[u8]) -> i64
Aegis.NumOfStrings.num_of_strings
pub fn num_of_strings(patterns: &[Vec<u8>], word: &[u8]) -> i64 { let n = patterns.len(); let wlen = word.len(); let mut count: i64 = 0; let mut i: usize = 0; while i < n { let p = &patterns[i]; let plen = p.len(); let mut found: bool = false; if plen <= wlen { ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [num_of_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 -- [num_of_strings]: function definitions module public import Aeneas public import Aegis.NumOfStrings.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.NumOfStrings.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.NumOfStrings.num_of_strings (Slice.from [(alloc.vec.Vec.from [97#u8, 97#u8, 97#u8] (by scalar_tac) : alloc.vec.Vec Std.U8)] (by scalar_tac) : Slice ...
[ { "input": "[[\"aaa\"], \"aaaaa\"]", "output": "1" }, { "input": "[[\"abc\"], \"abc\"]", "output": "1" }, { "input": "[[\"z\"], \"abcz\"]", "output": "1" }, { "input": "[[\"hello\", \"world\"], \"helloworld\"]", "output": "2" }, { "input": "[[\"a\", \"b\", \"c\"],...
122
false
122
verified
10
10
1
774
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.NumOfStrings.Code.Funs /-! # Specifications of `Aegis.NumOfStrings.num_of_strings` LeetCode problem `number-of-strings-that-appear-as-substrings-in-word`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.NumOfStrings def pats (patterns :...
14
array-with-elements-not-equal-to-average-of-neighbors
1,968
Medium
[ "Greedy", "Array", "Sorting" ]
You are given a 0-indexed array nums of distinct integers. You want to rearrange the elements in the array such that every element in the rearranged array is not equal to the average of its neighbors. More formally, the rearranged array should have the property such that for every i in the range 1 <= i < nums.length - ...
rearrangeArray(nums: list_int) -> list_int
pub fn rearrange_array(nums: &[i64]) -> Vec<i64>
Aegis.RearrangeArray.rearrange_array
pub fn rearrange_array(nums: &[i64]) -> Vec<i64> { let n = nums.len(); let mut v: Vec<i64> = Vec::new(); let mut i = 0; while i < n { v.push(nums[i]); i += 1; } // Bottom-up merge sort. let mut width: usize = 1; while width < n { let mut tmp: Vec<i64> = Vec::new...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [rearrange_array]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linte...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [rearrange_array]: function definitions module public import Aeneas public import Aegis.RearrangeArray.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.RearrangeArray.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.RearrangeArray.rearrange_array (Slice.from [0#i64, 100000#i64, 50000#i64, 25000#i64, 75000#i64] (by scalar_tac) : Slice Std.I64)) ((alloc.vec.Vec....
[ { "input": "[[0, 100000, 50000, 25000, 75000]]", "output": "[0, 75000, 25000, 100000, 50000]" }, { "input": "[[3, 1, 2, 5, 4]]", "output": "[1, 4, 2, 5, 3]" }, { "input": "[[10, 5, 1, 6, 2]]", "output": "[1, 6, 2, 10, 5]" }, { "input": "[[5, 1, 3, 2, 4]]", "output": "[1, ...
115
false
115
verified
10
10
1
6,049
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.RearrangeArray.Code.Funs /-! # Specifications of `Aegis.RearrangeArray.rearrange_array` LeetCode problem `array-with-elements-not-equal-to-average-of-neighbors`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.RearrangeArray (rearrange_array) nam...
10
find-if-path-exists-in-graph
1,971
Easy
[ "Depth-First Search", "Breadth-First Search", "Union Find", "Graph" ]
There is a bi-directional graph with n vertices, where each vertex is labeled from 0 to n - 1 (inclusive). The edges in the graph are represented as a 2D integer array edges, where each edges[i] = [ui, vi] denotes a bi-directional edge between vertex ui and vertex vi. Every vertex pair is connected by at most one edge,...
validPath(n: int, edges: list_list_int, source: int, destination: int) -> bool
pub fn valid_path(n: i64, edges: &[Vec<i64>], source: i64, destination: i64) -> bool
Aegis.ValidPath.valid_path
pub fn valid_path(n: i64, edges: &[Vec<i64>], source: i64, destination: i64) -> bool { let mut parent: Vec<i64> = Vec::new(); let mut size: Vec<i64> = Vec::new(); let mut i: i64 = 0; while i < n { parent.push(i); size.push(1); i += 1; } let m: usize = edges.len(); l...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [valid_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 linter.sty...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [valid_path]: function definitions module public import Aeneas public import Aegis.ValidPath.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.ValidPath.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.ValidPath.valid_path 1#i64 (Slice.from [] (by scalar_tac) : Slice (alloc.vec.Vec Std.I64)) 0#i64 0#i64) (true))}") #eval (s!"CASE 1 {(Result.reducesTo ...
[ { "input": "[1, [], 0, 0]", "output": "true" }, { "input": "[100, [], 0, 99]", "output": "false" }, { "input": "[15, [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14]], 14, 0]", "output": "true" }, { "inpu...
4
false
4
verified
4
4
1
4,971
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.ValidPath.Code.Funs /-! # Specifications of `Aegis.ValidPath.valid_path` LeetCode problem `find-if-path-exists-in-graph`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.ValidPath open Aegis.ValidPath def edgeAt (edges : Slice (alloc.v...
10
count-nodes-equal-to-sum-of-descendants
1,973
Medium
[ "Tree", "Depth-First Search", "Binary Tree" ]
Given the root of a binary tree, return the number of nodes where the value of the node is equal to the sum of the values of its descendants. A descendant of a node x is any node that is on the path from node x to some leaf node. The sum is considered to be 0 if the node has no descendants.   Example 1: Input: root =...
equalToDescendants(root: tree) -> int
pub fn equal_to_descendants(root: &Tree) -> i64
Aegis.EqualToDescendants.equal_to_descendants
const BASE: i64 = 1_099_511_627_776; // 2^40, larger than any possible subtree sum pub fn equal_to_descendants(root: &Tree) -> i64 { fn dfs(t: &Tree) -> i64 { match t { Tree::Null => 0, Tree::Node(v, l, r) => { let left = dfs(&**l); let right = dfs(&*...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [equal_to_descendants]: type definitions module public import Aeneas @[expose] public section 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 -- [equal_to_descendants]: function definitions module public import Aeneas public import Aegis.EqualToDescendants.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand fal...
import Aegis.EqualToDescendants.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval ae...
[ { "input": "[[0]]", "output": "1" }, { "input": "[[10, 3, 4, 2, 1]]", "output": "2" }, { "input": "[[1, 2, 3, 4, 5]]", "output": "0" }, { "input": "[[1, 2, 3, 4, 5, 6, 7]]", "output": "0" }, { "input": "[[1, 0, 0, 0, 0, 0, 0]]", "output": "6" }, { "inp...
73
false
73
verified
10
10
4
36,364
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.EqualToDescendants.Code.Funs /-! # Specifications of `Aegis.EqualToDescendants.equal_to_descendants` LeetCode problem `count-nodes-equal-to-sum-of-descendants`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.EqualToDescendants namespace AegisSpe...
9
maximum-matrix-sum
1,975
Medium
[ "Greedy", "Array", "Matrix" ]
You are given an n x n integer matrix. You can do the following operation any number of times: Choose any two adjacent elements of matrix and multiply each of them by -1. Two elements are considered adjacent if and only if they share a border. Your goal is to maximize the summation of the matrix's elements. Return th...
maxMatrixSum(matrix: list_list_int) -> int
pub fn max_matrix_sum(matrix: &[Vec<i64>]) -> i64
Aegis.MaxMatrixSum.max_matrix_sum
pub fn max_matrix_sum(matrix: &[Vec<i64>]) -> i64 { let first = matrix[0][0]; let mut min_abs: i64 = if first < 0 { -first } else { first }; let mut total: i64 = 0; let mut odd_negatives: bool = false; let n = matrix.len(); let mut i = 0; while i < n { let row = &matrix[i]; ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [max_matrix_sum]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [max_matrix_sum]: function definitions module public import Aeneas public import Aegis.MaxMatrixSum.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.MaxMatrixSum.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.MaxMatrixSum.max_matrix_sum (Slice.from [(alloc.vec.Vec.from [(-1)#i64, (-2)#i64] (by scalar_tac) : alloc.vec.Vec Std.I64), (alloc.vec.Vec.from [3#i...
[ { "input": "[[[-1, -2], [3, 4]]]", "output": "10" }, { "input": "[[[1, 2], [3, -4]]]", "output": "8" }, { "input": "[[[1, 2], [3, 4]]]", "output": "10" }, { "input": "[[[100000, -100000], [-100000, 100000]]]", "output": "400000" }, { "input": "[[[1, -2], [-3, 4]]]...
85
false
85
verified
10
10
1
1,326
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MaxMatrixSum.Code.Funs /-! # Specifications of `Aegis.MaxMatrixSum.max_matrix_sum` LeetCode problem `maximum-matrix-sum`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.MaxMatrixSum namespace AegisSpec.MaxMatrixSum def entries (matrix : S...
13
number-of-ways-to-arrive-at-destination
1,976
Medium
[ "Graph", "Topological Sort", "Dynamic Programming", "Shortest Path" ]
You are in a city that consists of n intersections numbered from 0 to n - 1 with bi-directional roads between some intersections. The inputs are generated such that you can reach any intersection from any other intersection and that there is at most one road between any two intersections. You are given an integer n and...
countPaths(n: int, roads: list_list_int) -> int
pub fn count_paths(n: i64, roads: &[Vec<i64>]) -> i64
Aegis.CountPaths.count_paths
pub fn count_paths(n: i64, roads: &[Vec<i64>]) -> i64 { let mod_val: i64 = 1000000007; let inf: i64 = 1000000000000000000; let n_usize = n as usize; let mut adj: Vec<Vec<i64>> = Vec::new(); let mut i: usize = 0; while i < n_usize { let mut row: Vec<i64> = Vec::new(); let mut j: ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [count_paths]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter.st...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [count_paths]: function definitions module public import Aeneas public import Aegis.CountPaths.Code.Types public import Aegis.CountPaths.Code.FunsExternal @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false s...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [count_paths]: external functions. -- This is a template file: rename it to "FunsExternal.lean" and fill the holes. module public import Aeneas public import Aegis.CountPaths.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_opt...
import Aegis.CountPaths.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.CountPaths.count_paths 2#i64 (Slice.from [(alloc.vec.Vec.from [1#i64, 0#i64, 10#i64] (by scalar_tac) : alloc.vec.Vec Std.I64)] (by scalar_tac) : Slice...
[ { "input": "[2, [[1, 0, 10]]]", "output": "1" }, { "input": "[3, [[0, 1, 1], [1, 2, 1], [0, 2, 2]]]", "output": "2" }, { "input": "[3, [[0, 1, 2], [1, 2, 2], [0, 2, 3]]]", "output": "1" }, { "input": "[4, [[0, 1, 1], [0, 2, 5], [1, 2, 1], [2, 3, 1]]]", "output": "1" }, ...
64
false
64
verified
10
10
1
3,740
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.CountPaths.Code.Funs /-! # Specifications of `Aegis.CountPaths.count_paths` LeetCode problem `number-of-ways-to-arrive-at-destination`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result noncomputable section namespace AegisSpec.CountPaths open Aegis.CountPa...
9
number-of-ways-to-separate-numbers
1,977
Hard
[ "String", "Dynamic Programming", "Suffix Array" ]
You wrote down many positive integers in a string called num. However, you realized that you forgot to add commas to seperate the different numbers. You remember that the list of integers was non-decreasing and that no integer had leading zeros. Return the number of possible lists of integers that you could have writte...
numberOfCombinations(num: str) -> int
pub fn number_of_combinations(num: &[u8]) -> i64
Aegis.NumberOfCombinations.number_of_combinations
pub fn number_of_combinations(num: &[u8]) -> i64 { let n = num.len(); if n == 0 { return 0; } if num[0] == b'0' { return 0; } let modv: i64 = 1000000007; let mut prev_col: Vec<i64> = Vec::new(); let mut curr_f: Vec<i64> = Vec::new(); let mut total: Vec<i64> = Vec::n...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [number_of_combinations]: type definitions module public import Aeneas @[expose] public 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 -- [number_of_combinations]: function definitions module public import Aeneas public import Aegis.NumberOfCombinations.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand...
import Aegis.NumberOfCombinations.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": "[\"327\"]", "output": "2" }, { "input": "[\"11110000111100001111\"]", "output": "30" }, { "input": "[\"3333333333\"]", "output": "42" }, { "input": "[\"123456789012345678901234567890\"]", "output": "1451" }, { "input": "[\"0\"]", "output": "0" },...
105
false
105
verified
10
10
1
24,154
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.NumberOfCombinations.Code.Funs /-! # Specifications of `Aegis.NumberOfCombinations.number_of_combinations` LeetCode problem `number-of-ways-to-separate-numbers`. Each `spec_<n>` theorem states one property of the function. -/ namespace AegisSpec.NumberOfCombinations def modulus : Nat := 1000000007 def...
9
find-greatest-common-divisor-of-array
1,979
Easy
[ "Array", "Math", "Number Theory" ]
Given an integer array nums, return the greatest common divisor of the smallest number and largest number in nums. The greatest common divisor of two numbers is the largest positive integer that evenly divides both numbers.   Example 1: Input: nums = [2,5,6,9,10] Output: 2 Explanation: The smallest number in nums is 2...
findGCD(nums: list_int) -> int
pub fn find_gcd(nums: &[i64]) -> i64
Aegis.FindGcd.find_gcd
pub fn find_gcd(nums: &[i64]) -> i64 { let mut i: usize = 0; let mut smallest: i64 = nums[0]; let mut largest: i64 = nums[0]; while i < nums.len() { let x: i64 = nums[i]; if x < smallest { smallest = x; } if x > largest { largest = x; } ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [find_gcd]: type definitions module public import Aeneas @[expose] public section 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 -- [find_gcd]: function definitions module public import Aeneas public import Aegis.FindGcd.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.FindGcd.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.FindGcd.find_gcd (Slice.from [1#i64, 1000#i64] (by scalar_tac) : Slice Std.I64)) (1#i64))}") #eval (s!"CASE 1 {(Result.reducesTo (Aegis.FindGcd.find_gcd ...
[ { "input": "[[1, 1000]]", "output": "1" }, { "input": "[[3, 3]]", "output": "3" }, { "input": "[[1000, 1000]]", "output": "1000" }, { "input": "[[1000, 1]]", "output": "1" }, { "input": "[[48, 18]]", "output": "6" }, { "input": "[[999, 1000]]", "ou...
117
false
117
verified
10
10
1
432
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.FindGcd.Code.Funs /-! # Specifications of `Aegis.FindGcd.find_gcd` LeetCode problem `find-greatest-common-divisor-of-array`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.FindGcd def sliceVals (nums : Slice Std.I64) : List Int := ...
8
minimum-difference-between-highest-and-lowest-of-k-scores
1,984
Easy
[ "Array", "Sorting", "Sliding Window" ]
You are given a 0-indexed integer array nums, where nums[i] represents the score of the ith student. You are also given an integer k. Pick the scores of any k students from the array so that the difference between the highest and the lowest of the k scores is minimized. Return the minimum possible difference.   Example...
minimumDifference(nums: list_int, k: int) -> int
pub fn minimum_difference(nums: &[i64], k: i64) -> i64
Aegis.MinimumDifference.minimum_difference
pub fn minimum_difference(nums: &[i64], k: i64) -> i64 { if k <= 1 { return 0; } let n = nums.len(); let mut sorted: Vec<i64> = Vec::new(); let mut i: usize = 0; while i < n { sorted.push(nums[i]); i += 1; } let mut a: usize = 1; while a < n { let ke...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [minimum_difference]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option li...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [minimum_difference]: function definitions module public import Aeneas public import Aegis.MinimumDifference.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false ...
import Aegis.MinimumDifference.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.MinimumDifference.minimum_difference (Slice.from [90#i64] (by scalar_tac) : Slice Std.I64) 1#i64) (0#i64))}") #eval (s!"CASE 1 {(Result.reduces...
[ { "input": "[[90], 1]", "output": "0" }, { "input": "[[8, 10, 2], 2]", "output": "2" }, { "input": "[[9, 4, 1, 7], 2]", "output": "2" }, { "input": "[[4, 2, 1, 3], 2]", "output": "1" }, { "input": "[[4, 9, 1, 32, 13], 3]", "output": "8" }, { "input": "...
95
false
95
verified
10
10
1
1,417
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MinimumDifference.Code.Funs /-! # Specifications of `Aegis.MinimumDifference.minimum_difference` LeetCode problem `minimum-difference-between-highest-and-lowest-of-k-scores`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.MinimumDifference n...
8
minimum-number-of-work-sessions-to-finish-the-tasks
1,986
Medium
[ "Bit Manipulation", "Array", "Dynamic Programming", "Backtracking", "Bitmask" ]
There are n tasks assigned to you. The task times are represented as an integer array tasks of length n, where the ith task takes tasks[i] hours to finish. A work session is when you work for at most sessionTime consecutive hours and then take a break. You should finish the given tasks in a way that satisfies the follo...
minSessions(tasks: list_int, sessionTime: int) -> int
pub fn min_sessions(tasks: &[i64], sessionTime: i64) -> i64
Aegis.MinSessions.min_sessions
pub fn min_sessions(tasks: &[i64], sessionTime: i64) -> i64 { let n = tasks.len(); let total: usize = 1usize << n; let mut dp: Vec<i64> = Vec::new(); let mut used: Vec<i64> = Vec::new(); let mut i: usize = 0; while i < total { dp.push(1000000); used.push(0); i += 1; ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [min_sessions]: type definitions module public import Aeneas @[expose] public section 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_sessions]: function definitions module public import Aeneas public import Aegis.MinSessions.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.MinSessions.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": "[[14], 14]", "output": "1" }, { "input": "[[1, 2, 3], 3]", "output": "2" }, { "input": "[[10, 10, 10], 10]", "output": "3" }, { "input": "[[1, 3, 2, 4], 5]", "output": "2" }, { "input": "[[5, 5, 5, 5], 5]", "output": "4" }, { "input": "[[9,...
116
false
116
verified
10
10
2
4,111
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MinSessions.Code.Funs /-! # Specifications of `Aegis.MinSessions.min_sessions` LeetCode problem `minimum-number-of-work-sessions-to-finish-the-tasks`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.MinSessions open scoped BigOperator...
12
number-of-unique-good-subsequences
1,987
Hard
[ "String", "Dynamic Programming" ]
You are given a binary string binary. A subsequence of binary is considered good if it is not empty and has no leading zeros (with the exception of "0"). Find the number of unique good subsequences of binary. For example, if binary = "001", then all the good subsequences are ["0", "0", "1"], so the unique good subsequ...
numberOfUniqueGoodSubsequences(binary: str) -> int
pub fn number_of_unique_good_subsequences(binary: &[u8]) -> i64
Aegis.NumberOfUniqueGoodSubsequences.number_of_unique_good_subsequences
pub fn number_of_unique_good_subsequences(binary: &[u8]) -> i64 { let modv: i64 = 1000000007; let mut dp0: i64 = 0; let mut dp1: i64 = 0; let mut has_zero: bool = false; let n = binary.len(); let mut i: usize = 0; while i < n { if binary[i] == b'0' { dp0 = (dp0 + dp1) %...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [number_of_unique_good_subsequences]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables fal...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [number_of_unique_good_subsequences]: function definitions module public import Aeneas public import Aegis.NumberOfUniqueGoodSubsequences.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_opt...
import Aegis.NumberOfUniqueGoodSubsequences.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.NumberOfUniqueGoodSubsequences.number_of_unique_good_subsequences (Slice.from [49#u8, 48#u8, 49#u8] (by scalar_tac) : Slice Std.U8...
[ { "input": "[\"101\"]", "output": "5" }, { "input": "[\"1111\"]", "output": "4" }, { "input": "[\"1\"]", "output": "1" }, { "input": "[\"010101\"]", "output": "13" }, { "input": "[\"111000111\"]", "output": "43" }, { "input": "[\"10000100001\"]", "...
90
false
90
verified
10
10
1
1,410
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.NumberOfUniqueGoodSubsequences.Code.Funs /-! # Specifications of `Aegis.NumberOfUniqueGoodSubsequences.number_of_unique_good_subsequences` LeetCode problem `number-of-unique-good-subsequences`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace Aeg...
8
maximum-number-of-people-that-can-be-caught-in-tag
1,989
Medium
[ "Greedy", "Array" ]
You are playing a game of tag with your friends. In tag, people are divided into two teams: people who are "it", and people who are not "it". The people who are "it" want to catch as many people as possible who are not "it". You are given a 0-indexed integer array team containing only zeros (denoting people who are not...
catchMaximumAmountofPeople(team: list_int, dist: int) -> int
pub fn catch_maximum_amountof_people(team: &[i64], dist: i64) -> i64
Aegis.CatchMaximumAmountofPeople.catch_maximum_amountof_people
pub fn catch_maximum_amountof_people(team: &[i64], dist: i64) -> i64 { let n = team.len(); let mut i: usize = 0; let mut j: usize = 0; let mut ans: i64 = 0; while i < n && j < n { while i < n && team[i] != 0 { i += 1; } while j < n && team[j] != 1 { j...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [catch_maximum_amountof_people]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false se...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [catch_maximum_amountof_people]: function definitions module public import Aeneas public import Aegis.CatchMaximumAmountofPeople.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linte...
import Aegis.CatchMaximumAmountofPeople.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" ...
[ { "input": "[[0], 1]", "output": "0" }, { "input": "[[1], 1]", "output": "0" }, { "input": "[[0, 1, 0, 1, 0], 3]", "output": "2" }, { "input": "[[0, 0, 1, 1, 0, 0], 2]", "output": "2" }, { "input": "[[0, 0, 1, 1, 0, 0, 1], 2]", "output": "3" }, { "inpu...
115
false
115
verified
10
10
1
3,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.CatchMaximumAmountofPeople.Code.Funs /-! # Specifications of `Aegis.CatchMaximumAmountofPeople.catch_maximum_amountof_people` LeetCode problem `maximum-number-of-people-that-can-be-caught-in-tag`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace ...
12
find-the-middle-index-in-array
1,991
Easy
[ "Array", "Prefix Sum" ]
Given a 0-indexed integer array nums, find the leftmost middleIndex (i.e., the smallest amongst all the possible ones). A middleIndex is an index where nums[0] + nums[1] + ... + nums[middleIndex-1] == nums[middleIndex+1] + nums[middleIndex+2] + ... + nums[nums.length-1]. If middleIndex == 0, the left side sum is consid...
findMiddleIndex(nums: list_int) -> int
pub fn find_middle_index(nums: &[i64]) -> i64
Aegis.FindMiddleIndex.find_middle_index
pub fn find_middle_index(nums: &[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 mut left: i64 = 0; i = 0; while i < n { let right: i64 = total - left - nums[i]; if left == ri...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [find_middle_index]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option lin...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [find_middle_index]: function definitions module public import Aeneas public import Aegis.FindMiddleIndex.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.FindMiddleIndex.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval aegis...
[ { "input": "[[1]]", "output": "0" }, { "input": "[[0]]", "output": "0" }, { "input": "[[1, 100]]", "output": "-1" }, { "input": "[[0, 1]]", "output": "1" }, { "input": "[[2, 5]]", "output": "-1" }, { "input": "[[1, 0]]", "output": "0" }, { ...
94
false
94
verified
10
10
2
785
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.FindMiddleIndex.Code.Funs /-! # Specifications of `Aegis.FindMiddleIndex.find_middle_index` LeetCode problem `find-the-middle-index-in-array`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.FindMiddleIndex def vals (nums : Aeneas.Std.S...
13
the-number-of-good-subsets
1,994
Hard
[ "Bit Manipulation", "Array", "Math", "Dynamic Programming", "Bitmask" ]
You are given an integer array nums. We call a subset of nums good if its product can be represented as a product of one or more distinct prime numbers. For example, if nums = [1, 2, 3, 4]: [2, 3], [1, 2, 3], and [1, 3] are good subsets with products 6 = 2*3, 6 = 2*3, and 3 = 3 respectively. [1, 4] and [4] are not ...
numberOfGoodSubsets(nums: list_int) -> int
pub fn number_of_good_subsets(nums: &[i64]) -> i64
Aegis.NumberOfGoodSubsets.number_of_good_subsets
fn value_mask(v: i64) -> i64 { if v == 2 { 1 } else if v == 3 { 2 } else if v == 5 { 4 } else if v == 6 { 3 } else if v == 7 { 8 } else if v == 10 { 5 } else if v == 11 { 16 } else if v == 13 { 32 } else if v == 14 { ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [number_of_good_subsets]: type definitions module public import Aeneas @[expose] public 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 -- [number_of_good_subsets]: function definitions module public import Aeneas public import Aegis.NumberOfGoodSubsets.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand ...
import Aegis.NumberOfGoodSubsets.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval a...
[ { "input": "[[1, 1, 1, 1]]", "output": "0" }, { "input": "[[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]]", "output": "0" }, { "input": "[[4, 8, 9, 12, 18, 20, 24, 25, 27, 28, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]]", "output": "0" }, { "input": "[[1, 1, 1, 1, 1, 1, 1, ...
4
false
4
verified
4
4
1
7,720
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.NumberOfGoodSubsets.Code.Funs /-! # Specifications of `Aegis.NumberOfGoodSubsets.number_of_good_subsets` LeetCode problem `the-number-of-good-subsets`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.NumberOfGoodSubsets noncomputabl...
10
count-special-quadruplets
1,995
Easy
[ "Array", "Hash Table", "Enumeration" ]
Given a 0-indexed integer array nums, return the number of distinct quadruplets (a, b, c, d) such that: nums[a] + nums[b] + nums[c] == nums[d], and a < b < c < d   Example 1: Input: nums = [1,2,3,6] Output: 1 Explanation: The only quadruplet that satisfies the requirement is (0, 1, 2, 3) because 1 + 2 + 3 == 6. Exa...
countQuadruplets(nums: list_int) -> int
pub fn count_quadruplets(nums: &[i64]) -> i64
Aegis.CountQuadruplets.count_quadruplets
pub fn count_quadruplets(nums: &[i64]) -> i64 { let n = nums.len(); let mut count: i64 = 0; let mut a: usize = 0; while a < n { let mut b: usize = a + 1; while b < n { let mut c: usize = b + 1; while c < n { let mut d: usize = c + 1; ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [count_quadruplets]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option lin...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [count_quadruplets]: function definitions module public import Aeneas public import Aegis.CountQuadruplets.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.CountQuadruplets.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval aegi...
[ { "input": "[[1, 2, 3, 6]]", "output": "1" }, { "input": "[[3, 3, 6, 4, 5]]", "output": "0" }, { "input": "[[1, 1, 1, 3, 5]]", "output": "4" }, { "input": "[[1, 2, 3, 4, 5, 6]]", "output": "1" }, { "input": "[[1, 3, 6, 10, 15, 21, 28]]", "output": "3" }, {...
107
false
107
verified
10
10
1
477
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.CountQuadruplets.Code.Funs /-! # Specifications of `Aegis.CountQuadruplets.count_quadruplets` LeetCode problem `count-special-quadruplets`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.CountQuadruplets namespace AegisSpec.CountQuadruplets def...
10
the-number-of-weak-characters-in-the-game
1,996
Medium
[ "Stack", "Greedy", "Array", "Sorting", "Monotonic Stack" ]
You are playing a game that contains multiple characters, and each of the characters has two main properties: attack and defense. You are given a 2D integer array properties where properties[i] = [attacki, defensei] represents the properties of the ith character in the game. A character is said to be weak if any other ...
numberOfWeakCharacters(properties: list_list_int) -> int
pub fn number_of_weak_characters(properties: &[Vec<i64>]) -> i64
Aegis.NumberOfWeakCharacters.number_of_weak_characters
pub fn number_of_weak_characters(properties: &[Vec<i64>]) -> i64 { let n: usize = properties.len(); let mut max_attack: i64 = 0; let mut i: usize = 0; while i < n { if properties[i][0] > max_attack { max_attack = properties[i][0]; } i += 1; } let mut buckets...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [number_of_weak_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_op...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [number_of_weak_characters]: function definitions module public import Aeneas public import Aegis.NumberOfWeakCharacters.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCo...
import Aegis.NumberOfWeakCharacters.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eva...
[ { "input": "[[[2, 2], [3, 3]]]", "output": "1" }, { "input": "[[[5, 5], [6, 3], [3, 6]]]", "output": "0" }, { "input": "[[[1, 5], [10, 4], [4, 3]]]", "output": "1" }, { "input": "[[[1, 10], [10, 1], [4, 4], [4, 5]]]", "output": "0" }, { "input": "[[[1, 1], [2, 2],...
99
false
99
verified
10
10
1
6,648
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.NumberOfWeakCharacters.Code.Funs /-! # Specifications of `Aegis.NumberOfWeakCharacters.number_of_weak_characters` LeetCode problem `the-number-of-weak-characters-in-the-game`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.NumberOfWeakCharacter...
8
first-day-where-you-have-been-in-all-the-rooms
1,997
Medium
[ "Array", "Dynamic Programming" ]
There are n rooms you need to visit, labeled from 0 to n - 1. Each day is labeled, starting from 0. You will go in and visit one room a day. Initially on day 0, you visit room 0. The order you visit the rooms for the coming days is determined by the following rules and a given 0-indexed array nextVisit of length n: As...
firstDayBeenInAllRooms(nextVisit: list_int) -> int
pub fn first_day_been_in_all_rooms(nextVisit: &[i64]) -> i64
Aegis.FirstDayBeenInAllRooms.first_day_been_in_all_rooms
pub fn first_day_been_in_all_rooms(nextVisit: &[i64]) -> i64 { let md: i64 = 1000000007; let n = nextVisit.len(); if n == 0 { return 0; } let mut dp: Vec<i64> = Vec::new(); dp.push(0); let mut i: usize = 1; while i < n { let idx = nextVisit[i - 1] as usize; let...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [first_day_been_in_all_rooms]: type definitions module public import Aeneas @[expose] public 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 -- [first_day_been_in_all_rooms]: function definitions module public import Aeneas public import Aegis.FirstDayBeenInAllRooms.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hash...
import Aegis.FirstDayBeenInAllRooms.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eva...
[ { "input": "[[0, 0]]", "output": "2" }, { "input": "[[0, 0, 2]]", "output": "6" }, { "input": "[[0, 1, 0, 2]]", "output": "10" }, { "input": "[[0, 1, 2, 0]]", "output": "6" }, { "input": "[[0, 2, 1, 0]]", "output": "12" }, { "input": "[[0, 1, 1, 0]]", ...
110
false
110
verified
10
10
1
7,081
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.FirstDayBeenInAllRooms.Code.Funs /-! # Specifications of `Aegis.FirstDayBeenInAllRooms.first_day_been_in_all_rooms` LeetCode problem `first-day-where-you-have-been-in-all-the-rooms`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.FirstD...
12
gcd-sort-of-an-array
1,998
Hard
[ "Union Find", "Array", "Math", "Number Theory", "Sorting" ]
You are given an integer array nums, and you can perform the following operation any number of times on nums: Swap the positions of two elements nums[i] and nums[j] if gcd(nums[i], nums[j]) > 1 where gcd(nums[i], nums[j]) is the greatest common divisor of nums[i] and nums[j]. Return true if it is possible to sort num...
gcdSort(nums: list_int) -> bool
pub fn gcd_sort(nums: &[i64]) -> bool
Aegis.GcdSort.gcd_sort
fn find(parent: &mut Vec<i64>, x: i64) -> i64 { let mut root = x; while parent[root as usize] != root { root = parent[root as usize]; } let mut cur = x; while parent[cur as usize] != cur { let next = parent[cur as usize]; parent[cur as usize] = root; cur = next; ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [gcd_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.style...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [gcd_sort]: function definitions module public import Aeneas public import Aegis.GcdSort.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.GcdSort.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval aegisCase "ev...
[ { "input": "[[7, 21, 3]]", "output": "true" }, { "input": "[[8, 4, 12, 6]]", "output": "true" }, { "input": "[[1, 2, 3, 4]]", "output": "true" }, { "input": "[[5, 2, 6, 2]]", "output": "false" }, { "input": "[[12, 15, 18, 20, 25]]", "output": "true" }, { ...
168
false
168
verified
10
10
1
11,115
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.GcdSort.Code.Funs /-! # Specifications of `Aegis.GcdSort.gcd_sort` LeetCode problem `gcd-sort-of-an-array`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.GcdSort def vals (nums : Slice Std.I64) : List Int := nums.val.map (fun x => x.v...
12
smallest-greater-multiple-made-of-two-digits
1,999
Medium
[ "Math", "Enumeration" ]
Given three integers, k, digit1, and digit2, you want to find the smallest integer that is: Larger than k, A multiple of k, and Comprised of only the digits digit1 and/or digit2. Return the smallest such integer. If no such integer exists or the integer exceeds the limit of a signed 32-bit integer (231 - 1), return -...
findInteger(k: int, digit1: int, digit2: int) -> int
pub fn find_integer(k: i64, digit1: i64, digit2: i64) -> i64
Aegis.FindInteger.find_integer
pub fn find_integer(k: i64, digit1: i64, digit2: i64) -> i64 { let limit: i64 = 2147483647; let small = if digit1 < digit2 { digit1 } else { digit2 }; let large = if digit1 < digit2 { digit2 } else { digit1 }; if small == 0 && large == 0 { return -1; } let mut queue: Vec<i64> = Vec::n...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [find_integer]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter.s...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [find_integer]: function definitions module public import Aeneas public import Aegis.FindInteger.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.FindInteger.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval aegisCase...
[ { "input": "[5, 5, 5]", "output": "55" }, { "input": "[2, 0, 2]", "output": "20" }, { "input": "[2, 0, 0]", "output": "-1" }, { "input": "[10, 1, 0]", "output": "100" }, { "input": "[999, 9, 9]", "output": "999999" }, { "input": "[3, 4, 2]", "outpu...
119
false
119
verified
10
10
1
3,567
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.FindInteger.Code.Funs /-! # Specifications of `Aegis.FindInteger.find_integer` LeetCode problem `smallest-greater-multiple-made-of-two-digits`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.FindInteger def decDigitsFuel : Nat → Na...
12
number-of-pairs-of-interchangeable-rectangles
2,001
Medium
[ "Array", "Hash Table", "Math", "Counting", "Number Theory" ]
You are given n rectangles represented by a 0-indexed 2D integer array rectangles, where rectangles[i] = [widthi, heighti] denotes the width and height of the ith rectangle. Two rectangles i and j (i < j) are considered interchangeable if they have the same width-to-height ratio. More formally, two rectangles are inter...
interchangeableRectangles(rectangles: list_list_int) -> int
pub fn interchangeable_rectangles(rectangles: &[Vec<i64>]) -> i64
Aegis.InterchangeableRectangles.interchangeable_rectangles
fn gcd(mut a: i64, mut b: i64) -> i64 { while b != 0 { let r = a % b; a = b; b = r; } if a < 0 { -a } else { a } } pub fn interchangeable_rectangles(rectangles: &[Vec<i64>]) -> i64 { let n = rectangles.len(); if n <= 1 { return 0; } l...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [interchangeable_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_o...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [interchangeable_rectangles]: function definitions module public import Aeneas public import Aegis.InterchangeableRectangles.Code.Types public import Aegis.InterchangeableRectangles.Code.FunsExternal @[expose] public section open Aeneas Aeneas.Std Result ControlFlow...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [interchangeable_rectangles]: external functions. -- This is a template file: rename it to "FunsExternal.lean" and fill the holes. module public import Aeneas public import Aegis.InterchangeableRectangles.Code.Types @[expose] public section open Aeneas Aeneas.Std Re...
import Aegis.InterchangeableRectangles.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #...
[ { "input": "[[[4, 5], [7, 8]]]", "output": "0" }, { "input": "[[[5, 10], [10, 20], [20, 40], [40, 80]]]", "output": "6" }, { "input": "[[[2, 3], [3, 4], [4, 5], [5, 6]]]", "output": "0" }, { "input": "[[[5, 10], [10, 20], [15, 30], [20, 40]]]", "output": "6" }, { ...
84
false
84
verified
10
10
1
3,285
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.InterchangeableRectangles.Code.Funs /-! # Specifications of `Aegis.InterchangeableRectangles.interchangeable_rectangles` LeetCode problem `number-of-pairs-of-interchangeable-rectangles`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec....
10
maximum-product-of-the-length-of-two-palindromic-subsequences
2,002
Medium
[ "Bit Manipulation", "String", "Dynamic Programming", "Backtracking", "Bitmask" ]
Given a string s, find two disjoint palindromic subsequences of s such that the product of their lengths is maximized. The two subsequences are disjoint if they do not both pick a character at the same index. Return the maximum possible product of the lengths of the two palindromic subsequences. A subsequence is a stri...
maxProduct(s: str) -> int
pub fn max_product(s: &[u8]) -> i64
Aegis.MaxProduct.max_product
fn is_pal(s: &[u8], mask: usize) -> bool { let n = s.len(); let mut left: usize = 0; let mut right: usize = n; while left < right { while left < n && ((mask >> left) & 1usize) == 0usize { left += 1; } while right > 0 && ((mask >> (right - 1)) & 1usize) == 0usize { ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [max_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 linter.st...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [max_product]: function definitions module public import Aeneas public import Aegis.MaxProduct.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.MaxProduct.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": "[\"xyzyx\"]", "output": "6" }, { "input": "[\"aabbcc\"]", "output": "4" }, { "input": "[\"aaaa\"]", "output": "4" }, { "input": "[\"accbcaxxcxx\"]", "output": "25" }, { "input": "[\"madam\"]", "output": "6" }, { "input": "[\"noon\"]", "...
81
false
81
verified
10
10
1
12,780
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MaxProduct.Code.Funs /-! # Specifications of `Aegis.MaxProduct.max_product` LeetCode problem `maximum-product-of-the-length-of-two-palindromic-subsequences`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.MaxProduct abbrev IsLowerAscii...
10
subtree-removal-game-with-fibonacci-tree
2,005
Hard
[ "Tree", "Math", "Dynamic Programming", "Binary Tree", "Game Theory" ]
A Fibonacci tree is a binary tree created using the order function order(n): order(0) is the empty tree. order(1) is a binary tree with only one node. order(n) is a binary tree that consists of a root node with the left subtree as order(n - 2) and the right subtree as order(n - 1). Alice and Bob are playing a game wi...
findGameWinner(n: int) -> bool
pub fn find_game_winner(n: i64) -> bool
Aegis.FindGameWinner.find_game_winner
pub fn find_game_winner(n: i64) -> bool { n % 6 != 1 }
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [find_game_winner]: type definitions module public import Aeneas @[expose] public section 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_game_winner]: function definitions module public import Aeneas public import Aegis.FindGameWinner.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.FindGameWinner.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval aegisC...
[ { "input": "[3]", "output": "true" }, { "input": "[45]", "output": "true" }, { "input": "[53]", "output": "true" }, { "input": "[70]", "output": "true" }, { "input": "[43]", "output": "false" }, { "input": "[68]", "output": "true" }, { "inp...
100
false
100
verified
10
10
1
8,455
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
0
count-number-of-pairs-with-absolute-difference-k
2,006
Easy
[ "Array", "Hash Table", "Counting" ]
Given an integer array nums and an integer k, return the number of pairs (i, j) where i < j such that |nums[i] - nums[j]| == k. The value of |x| is defined as: x if x >= 0. -x if x < 0.   Example 1: Input: nums = [1,2,2,1], k = 1 Output: 4 Explanation: The pairs with an absolute difference of 1 are: - [1,2,2,1] - [1...
countKDifference(nums: list_int, k: int) -> int
pub fn count_k_difference(nums: &[i64], k: i64) -> i64
Aegis.CountKDifference.count_k_difference
pub fn count_k_difference(nums: &[i64], k: i64) -> i64 { let n = nums.len(); let mut count: i64 = 0; let mut i: usize = 0; while i < n { let mut j: usize = i + 1; while j < n { let mut diff = nums[i] - nums[j]; if diff < 0 { diff = -diff; ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [count_k_difference]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option li...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [count_k_difference]: function definitions module public import Aeneas public import Aegis.CountKDifference.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.CountKDifference.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval aegi...
[ { "input": "[[1, 3], 3]", "output": "0" }, { "input": "[[1, 1, 1, 1], 0]", "output": "6" }, { "input": "[[5, 5, 5, 5], 0]", "output": "6" }, { "input": "[[5, 1, 4, 1], 2]", "output": "0" }, { "input": "[[1, 2, 2, 1], 1]", "output": "4" }, { "input": "[...
106
false
106
verified
10
10
1
347
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.CountKDifference.Code.Funs /-! # Specifications of `Aegis.CountKDifference.count_k_difference` LeetCode problem `count-number-of-pairs-with-absolute-difference-k`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.CountKDifference (count_k_differenc...
10
find-original-array-from-doubled-array
2,007
Medium
[ "Greedy", "Array", "Hash Table", "Sorting" ]
An integer array original is transformed into a doubled array changed by appending twice the value of every element in original, and then randomly shuffling the resulting array. Given an array changed, return original if changed is a doubled array. If changed is not a doubled array, return an empty array. The elements ...
findOriginalArray(changed: list_int) -> list_int
pub fn find_original_array(changed: &[i64]) -> Vec<i64>
Aegis.FindOriginalArray.find_original_array
pub fn find_original_array(changed: &[i64]) -> Vec<i64> { let n = changed.len(); let mut result: Vec<i64> = Vec::new(); if n % 2 != 0 { return result; } if n == 0 { return result; } // Find maximum value; also validate non-negative. let mut max_val: i64 = 0; let mut...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [find_original_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 -- [find_original_array]: function definitions module public import Aeneas public import Aegis.FindOriginalArray.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false...
import Aegis.FindOriginalArray.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval aeg...
[ { "input": "[[1]]", "output": "[]" }, { "input": "[[1, 2]]", "output": "[1]" }, { "input": "[[2, 1]]", "output": "[1]" }, { "input": "[[6, 3, 0, 1]]", "output": "[]" }, { "input": "[[2, 4, 2, 4]]", "output": "[2, 2]" }, { "input": "[[0, 0, 0, 0]]", ...
122
true
122
verified
10
10
2
7,927
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.FindOriginalArray.Code.Funs /-! # Specifications of `Aegis.FindOriginalArray.find_original_array` LeetCode problem `find-original-array-from-doubled-array`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.FindOriginalArray namespace AegisSpec.Fin...
14
minimum-number-of-operations-to-make-array-continuous
2,009
Hard
[ "Array", "Hash Table", "Binary Search", "Sliding Window" ]
You are given an integer array nums. In one operation, you can replace any element in nums with any integer. nums is considered continuous if both of the following conditions are fulfilled: All elements in nums are unique. The difference between the maximum element and the minimum element in nums equals nums.length - ...
minOperations(nums: list_int) -> int
pub fn min_operations(nums: &[i64]) -> i64
Aegis.MinOperations.min_operations
pub fn min_operations(nums: &[i64]) -> i64 { let n = nums.len(); let mut v: Vec<i64> = Vec::new(); let mut i: usize = 0; while i < n { v.push(nums[i]); i = i + 1; } let len = v.len(); // Build a max heap. let mut start = len / 2; while start > 0 { start = s...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [min_operations]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [min_operations]: function definitions module public import Aeneas public import Aegis.MinOperations.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_opti...
import Aegis.MinOperations.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval aegisCa...
[ { "input": "[[1000000000]]", "output": "0" }, { "input": "[[1, 1000000000]]", "output": "1" }, { "input": "[[10, 10, 10, 10]]", "output": "3" }, { "input": "[[4, 2, 5, 3]]", "output": "0" }, { "input": "[[100, 101, 102, 1]]", "output": "1" }, { "input"...
136
false
136
verified
10
10
1
10,485
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MinOperations.Code.Funs /-! # Specifications of `Aegis.MinOperations.min_operations` LeetCode problem `minimum-number-of-operations-to-make-array-continuous`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.MinOperations namespace AegisSpec.M...
12
final-value-of-variable-after-performing-operations
2,011
Easy
[ "Array", "String", "Simulation" ]
There is a programming language with only four operations and one variable X: ++X and X++ increments the value of the variable X by 1. --X and X-- decrements the value of the variable X by 1. Initially, the value of X is 0. Given an array of strings operations containing a list of operations, return the final value o...
finalValueAfterOperations(operations: list_str) -> int
pub fn final_value_after_operations(operations: &[Vec<u8>]) -> i64
Aegis.FinalValueAfterOperations.final_value_after_operations
pub fn final_value_after_operations(operations: &[Vec<u8>]) -> i64 { let mut x: i64 = 0; let mut i: usize = 0; while i < operations.len() { let op = &operations[i]; if op[1] == b'+' { x += 1; } else { x -= 1; } i += 1; } x }
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [final_value_after_operations]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [final_value_after_operations]: function definitions module public import Aeneas public import Aegis.FinalValueAfterOperations.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter....
import Aegis.FinalValueAfterOperations.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #...
[ { "input": "[[\"--X\", \"X++\", \"X++\"]]", "output": "1" }, { "input": "[[\"++X\", \"++X\", \"X++\"]]", "output": "3" }, { "input": "[[\"X++\", \"++X\", \"--X\", \"X--\"]]", "output": "0" }, { "input": "[[\"--X\", \"--X\", \"X--\", \"X--\"]]", "output": "-4" }, { ...
88
false
88
verified
10
10
1
444
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.FinalValueAfterOperations.Code.Funs /-! # Specifications of `Aegis.FinalValueAfterOperations.final_value_after_operations` LeetCode problem `final-value-of-variable-after-performing-operations`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace Aegi...
12
sum-of-beauty-in-the-array
2,012
Medium
[ "Array" ]
You are given a 0-indexed integer array nums. For each index i (1 <= i <= nums.length - 2) the beauty of nums[i] equals: 2, if nums[j] < nums[i] < nums[k], for all 0 <= j < i and for all i < k <= nums.length - 1. 1, if nums[i - 1] < nums[i] < nums[i + 1], and the previous condition is not satisfied. 0, if none of the ...
sumOfBeauties(nums: list_int) -> int
pub fn sum_of_beauties(nums: &[i64]) -> i64
Aegis.SumOfBeauties.sum_of_beauties
pub fn sum_of_beauties(nums: &[i64]) -> i64 { let n = nums.len(); if n < 3 { return 0; } let mut suffix_min: Vec<i64> = Vec::new(); let mut i = 0; while i < n { suffix_min.push(0); i += 1; } let mut idx = n; let mut cur_min = nums[n - 1]; while idx > 0 {...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [sum_of_beauties]: type definitions module public import Aeneas @[expose] public section 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 -- [sum_of_beauties]: function definitions module public import Aeneas public import Aegis.SumOfBeauties.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_opt...
import Aegis.SumOfBeauties.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval aegisCa...
[ { "input": "[[3, 2, 1]]", "output": "0" }, { "input": "[[1, 2, 3]]", "output": "2" }, { "input": "[[2, 4, 6, 4]]", "output": "1" }, { "input": "[[9, 7, 5, 3, 1]]", "output": "0" }, { "input": "[[5, 3, 4, 2, 1]]", "output": "0" }, { "input": "[[1, 3, 5,...
136
false
136
verified
10
10
1
1,231
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.SumOfBeauties.Code.Funs /-! # Specifications of `Aegis.SumOfBeauties.sum_of_beauties` LeetCode problem `sum-of-beauty-in-the-array`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.SumOfBeauties open Classical namespace AegisSpec.SumOfBeauties d...
11
average-height-of-buildings-in-each-segment
2,015
Medium
[ "Greedy", "Array", "Sorting", "Heap (Priority Queue)" ]
A perfectly straight street is represented by a number line. The street has building(s) on it and is represented by a 2D integer array buildings, where buildings[i] = [starti, endi, heighti]. This means that there is a building with heighti in the half-closed segment [starti, endi). You want to describe the heights of ...
averageHeightOfBuildings(buildings: list_list_int) -> list_list_int
pub fn average_height_of_buildings(buildings: &[Vec<i64>]) -> Vec<Vec<i64>>
Aegis.AverageHeightOfBuildings.average_height_of_buildings
pub fn average_height_of_buildings(buildings: &[Vec<i64>]) -> Vec<Vec<i64>> { let n = buildings.len(); let mut events: Vec<Vec<i64>> = Vec::new(); let mut i: usize = 0; while i < n { let s = buildings[i][0]; let e = buildings[i][1]; let h = buildings[i][2]; let mut star...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [average_height_of_buildings]: type definitions module public import Aeneas @[expose] public 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 -- [average_height_of_buildings]: function definitions module public import Aeneas public import Aegis.AverageHeightOfBuildings.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.ha...
import Aegis.AverageHeightOfBuildings.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #e...
[ { "input": "[[[1, 5, 2], [1, 5, 2]]]", "output": "[[1, 5, 2]]" }, { "input": "[[[0, 2, 3], [2, 5, 3]]]", "output": "[[0, 5, 3]]" }, { "input": "[[[1, 2, 1], [5, 6, 1]]]", "output": "[[1, 2, 1], [5, 6, 1]]" }, { "input": "[[[0, 2, 3], [2, 5, 2]]]", "output": "[[0, 2, 3], [...
110
true
110
verified
10
10
1
10,915
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.AverageHeightOfBuildings.Code.Funs /-! # Specifications of `Aegis.AverageHeightOfBuildings.average_height_of_buildings` LeetCode problem `average-height-of-buildings-in-each-segment`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.Ave...
8
maximum-difference-between-increasing-elements
2,016
Easy
[ "Array" ]
Given a 0-indexed integer array nums of size n, find the maximum difference between nums[i] and nums[j] (i.e., nums[j] - nums[i]), such that 0 <= i < j < n and nums[i] < nums[j]. Return the maximum difference. If no such i and j exists, return -1.   Example 1: Input: nums = [7,1,5,4] Output: 4 Explanation: The maximum...
maximumDifference(nums: list_int) -> int
pub fn maximum_difference(nums: &[i64]) -> i64
Aegis.MaximumDifference.maximum_difference
pub fn maximum_difference(nums: &[i64]) -> i64 { let n = nums.len(); if n < 2 { return -1; } let mut min_val = nums[0]; let mut best = -1; let mut i = 1; while i < n { if nums[i] > min_val { let diff = nums[i] - min_val; if diff > best { ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [maximum_difference]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option li...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [maximum_difference]: function definitions module public import Aeneas public import Aegis.MaximumDifference.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false ...
import Aegis.MaximumDifference.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, 2, 999999999]]", "output": "999999998" }, { "input": "[[9, 4, 3, 2]]", "output": "-1" }, { "input": "[[1, 999999999, 2, 999999998]]", "output": "999999998" }, { "input": "[[1, 5, 2, 10]]", "output": "9" }, { "input": "[[1, 1, 1, 1]]", "output"...
118
false
118
verified
10
10
1
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.MaximumDifference.Code.Funs /-! # Specifications of `Aegis.MaximumDifference.maximum_difference` LeetCode problem `maximum-difference-between-increasing-elements`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.MaximumDifference namespace Ae...
9
grid-game
2,017
Medium
[ "Array", "Matrix", "Prefix Sum" ]
You are given a 0-indexed 2D array grid of size 2 x n, where grid[r][c] represents the number of points at position (r, c) on the matrix. Two robots are playing a game on this matrix. Both robots initially start at (0, 0) and want to reach (1, n-1). Each robot may only move to the right ((r, c) to (r, c + 1)) or down (...
gridGame(grid: list_list_int) -> int
pub fn grid_game(grid: &[Vec<i64>]) -> i64
Aegis.GridGame.grid_game
pub fn grid_game(grid: &[Vec<i64>]) -> i64 { if grid.len() < 2 { return 0; } let n = grid[0].len(); if n == 0 { return 0; } let mut top_suffix: i64 = 0; let mut i: usize = 0; while i < n { top_suffix += grid[0][i]; i += 1; } let mut bottom_prefi...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [grid_game]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter.styl...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [grid_game]: function definitions module public import Aeneas public import Aegis.GridGame.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.GridGame.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval aegisCase "e...
[ { "input": "[[[2, 5, 4], [1, 5, 1]]]", "output": "4" }, { "input": "[[[10, 10, 10], [1, 1, 1]]]", "output": "2" }, { "input": "[[[3, 3, 1], [8, 5, 2]]]", "output": "4" }, { "input": "[[[100000, 100000, 100000], [1, 1, 1]]]", "output": "2" }, { "input": "[[[1, 1, 1...
75
false
75
verified
10
10
1
2,261
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.GridGame.Code.Funs /-! # Specifications of `Aegis.GridGame.grid_game` LeetCode problem `grid-game`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.GridGame def row (grid : Slice (alloc.vec.Vec Std.I64)) (i : ℕ) : List ℤ := (grid.val....
12
brightest-position-on-street
2,021
Medium
[ "Array", "Ordered Set", "Prefix Sum", "Sorting" ]
A perfectly straight street is represented by a number line. The street has street lamp(s) on it and is represented by a 2D integer array lights. Each lights[i] = [positioni, rangei] indicates that there is a street lamp at position positioni that lights up the area from [positioni - rangei, positioni + rangei] (inclus...
brightestPosition(lights: list_list_int) -> int
pub fn brightest_position(lights: &[Vec<i64>]) -> i64
Aegis.BrightestPosition.brightest_position
pub fn brightest_position(lights: &[Vec<i64>]) -> i64 { let offset: i64 = 1000000000; let n = lights.len(); let mut events: Vec<i64> = Vec::new(); let mut i: usize = 0; while i < n { let pos = lights[i][0]; let range = lights[i][1]; let left = pos - range; let right ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [brightest_position]: type definitions module public import Aeneas @[expose] public section 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 -- [brightest_position]: function definitions module public import Aeneas public import Aegis.BrightestPosition.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false ...
import Aegis.BrightestPosition.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, 2]]]", "output": "-1" }, { "input": "[[[1, 0], [0, 1]]]", "output": "1" }, { "input": "[[[100000000, 100000000], [-100000000, 100000000]]]", "output": "0" }, { "input": "[[[10000000, 10000000], [10000001, 10000000]]]", "output": "1" }, { "input":...
114
false
114
verified
10
10
1
5,412
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.BrightestPosition.Code.Funs /-! # Specifications of `Aegis.BrightestPosition.brightest_position` LeetCode problem `brightest-position-on-street`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.BrightestPosition def asLight (v : all...
12
convert-1d-array-into-2d-array
2,022
Easy
[ "Array", "Matrix", "Simulation" ]
You are given a 0-indexed 1-dimensional (1D) integer array original, and two integers, m and n. You are tasked with creating a 2-dimensional (2D) array with m rows and n columns using all the elements from original. The elements from indices 0 to n - 1 (inclusive) of original should form the first row of the construct...
construct2DArray(original: list_int, m: int, n: int) -> list_list_int
pub fn construct2_d_array(original: &[i64], m: i64, n: i64) -> Vec<Vec<i64>>
Aegis.Construct2DArray.construct2_d_array
// Workaround so that the harness's `vec![]` for the empty 2-D result has a // concrete type (`Vec<Vec<i64>>`) and therefore is not ambiguous. macro_rules! vec { () => { ::std::vec::Vec::<::std::vec::Vec<i64>>::new() }; ($elem:expr; $n:expr) => { ::std::vec![$elem; $n] }; ($($x:expr)...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [construct2_d_array]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option li...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [construct2_d_array]: function definitions module public import Aeneas public import Aegis.Construct2DArray.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.Construct2DArray.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval aegi...
[ { "input": "[[1, 2], 1, 1]", "output": "[]" }, { "input": "[[1], 1, 1]", "output": "[[1]]" }, { "input": "[[12345], 1, 1]", "output": "[[12345]]" }, { "input": "[[42], 1, 1]", "output": "[[42]]" }, { "input": "[[25, 26, 27], 3, 1]", "output": "[[25], [26], [27...
85
false
85
verified
10
10
2
31,715
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.Construct2DArray.Code.Funs /-! # Specifications of `Aegis.Construct2DArray.construct2_d_array` LeetCode problem `convert-1d-array-into-2d-array`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.Construct2DArray abbrev VecI64 : Type ...
9
number-of-pairs-of-strings-with-concatenation-equal-to-target
2,023
Medium
[ "Array", "Hash Table", "String", "Counting" ]
Given an array of digit strings nums and a digit string target, return the number of pairs of indices (i, j) (where i != j) such that the concatenation of nums[i] + nums[j] equals target.   Example 1: Input: nums = ["777","7","77","77"], target = "7777" Output: 4 Explanation: Valid pairs are: - (0, 1): "777" + "7" - (...
numOfPairs(nums: list_str, target: str) -> int
pub fn num_of_pairs(nums: &[Vec<u8>], target: &[u8]) -> i64
Aegis.NumOfPairs.num_of_pairs
pub fn num_of_pairs(nums: &[Vec<u8>], target: &[u8]) -> i64 { let n = nums.len(); let target_len = target.len(); let mut ans: i64 = 0; let mut i = 0; while i < n { let a = &nums[i]; let a_len = a.len(); let mut j = 0; while j < n { if i != j { ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [num_of_pairs]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter.s...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [num_of_pairs]: function definitions module public import Aeneas public import Aegis.NumOfPairs.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.NumOfPairs.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": "[[\"10\", \"11\", \"1\"], \"101\"]", "output": "1" }, { "input": "[[\"99\", \"9\", \"999\"], \"9999\"]", "output": "2" }, { "input": "[[\"10\", \"100\", \"1\"], \"10100\"]", "output": "1" }, { "input": "[[\"50\", \"5\", \"500\"], \"505\"]", "output": "1" }, ...
127
false
127
verified
10
10
1
1,122
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.NumOfPairs.Code.Funs /-! # Specifications of `Aegis.NumOfPairs.num_of_pairs` LeetCode problem `number-of-pairs-of-strings-with-concatenation-equal-to-target`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open scoped BigOperators namespace AegisSpec.N...
7
maximum-number-of-ways-to-partition-an-array
2,025
Hard
[ "Array", "Hash Table", "Counting", "Enumeration", "Prefix Sum" ]
You are given a 0-indexed integer array nums of length n. The number of ways to partition nums is the number of pivot indices that satisfy both conditions: 1 <= pivot < n nums[0] + nums[1] + ... + nums[pivot - 1] == nums[pivot] + nums[pivot + 1] + ... + nums[n - 1] You are also given an integer k. You can choose to c...
waysToPartition(nums: list_int, k: int) -> int
pub fn ways_to_partition(nums: &[i64], k: i64) -> i64
Aegis.WaysToPartition.ways_to_partition
fn hash_index(key: i64, mask: usize) -> usize { let mut h = key; if h < 0 { h = -h; } h = h * 1000003; h = h ^ (h >> 17); h = h ^ (h << 5); h = h ^ (h >> 13); (h as usize) & mask } fn find_slot(keys: &[i64], mask: usize, key: i64, empty: i64) -> usize { let mut idx = hash_in...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [ways_to_partition]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option lin...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [ways_to_partition]: function definitions module public import Aeneas public import Aegis.WaysToPartition.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.WaysToPartition.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval aegis...
[ { "input": "[[0, 0, 0], 1]", "output": "2" }, { "input": "[[2, -1, 2], 3]", "output": "1" }, { "input": "[[100000, -100000, 100000, -100000], 0]", "output": "1" }, { "input": "[[1, 2, 3, 4, 5], 3]", "output": "0" }, { "input": "[[5, 5, 5, 5, 5], 5]", "output":...
117
false
117
verified
10
10
2
44,621
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.WaysToPartition.Code.Funs /-! # Specifications of `Aegis.WaysToPartition.ways_to_partition` LeetCode problem `maximum-number-of-ways-to-partition-an-array`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.WaysToPartition namespace AegisSpec.W...
12
minimum-moves-to-convert-string
2,027
Easy
[ "Greedy", "String" ]
You are given a string s consisting of n characters which are either 'X' or 'O'. A move is defined as selecting three consecutive characters of s and converting them to 'O'. Note that if a move is applied to the character 'O', it will stay the same. Return the minimum number of moves required so that all the characters...
minimumMoves(s: str) -> int
pub fn minimum_moves(s: &[u8]) -> i64
Aegis.MinimumMoves.minimum_moves
pub fn minimum_moves(s: &[u8]) -> i64 { let n = s.len(); let mut moves: i64 = 0; let mut i: usize = 0; while i < n { if s[i] == b'X' { moves += 1; i += 3; } else { i += 1; } } moves }
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [minimum_moves]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter....
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [minimum_moves]: function definitions module public import Aeneas public import Aegis.MinimumMoves.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option...
import Aegis.MinimumMoves.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval aegisCas...
[ { "input": "[\"XXXXXXXXXX\"]", "output": "4" }, { "input": "[\"OOXOOX\"]", "output": "2" }, { "input": "[\"OOXOOXOOXO\"]", "output": "3" }, { "input": "[\"OOXXOOXXOO\"]", "output": "2" }, { "input": "[\"XXOX\"]", "output": "2" }, { "input": "[\"OXOXOXO...
166
false
166
verified
10
10
1
347
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MinimumMoves.Code.Funs /-! # Specifications of `Aegis.MinimumMoves.minimum_moves` LeetCode problem `minimum-moves-to-convert-string`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.MinimumMoves def allOX (l : List U8) : Prop := ∀ b ∈ l...
16
find-missing-observations
2,028
Medium
[ "Array", "Math", "Simulation" ]
You have observations of n + m 6-sided dice rolls with each face numbered from 1 to 6. n of the observations went missing, and you only have the observations of m rolls. Fortunately, you have also calculated the average value of the n + m rolls. You are given an integer array rolls of length m where rolls[i] is the val...
missingRolls(rolls: list_int, mean: int, n: int) -> list_int
pub fn missing_rolls(rolls: &[i64], mean: i64, n: i64) -> Vec<i64>
Aegis.MissingRolls.missing_rolls
pub fn missing_rolls(rolls: &[i64], mean: i64, n: i64) -> Vec<i64> { let len = rolls.len(); let mut sum_existing: i64 = 0; let mut m: i64 = 0; let mut idx: usize = 0; while idx < len { sum_existing += rolls[idx]; m += 1; idx += 1; } let total_sum: i64 = mean * (n + ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [missing_rolls]: type definitions module public import Aeneas @[expose] public section 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 -- [missing_rolls]: function definitions module public import Aeneas public import Aegis.MissingRolls.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.MissingRolls.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval aegisCas...
[ { "input": "[[1], 6, 5]", "output": "[]" }, { "input": "[[6], 1, 5]", "output": "[]" }, { "input": "[[3], 4, 1]", "output": "[5]" }, { "input": "[[6], 6, 1]", "output": "[6]" }, { "input": "[[1, 3, 5], 2, 2]", "output": "[]" }, { "input": "[[1, 2], 3, ...
116
false
116
verified
10
10
1
6,615
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MissingRolls.Code.Funs /-! # Specifications of `Aegis.MissingRolls.missing_rolls` LeetCode problem `find-missing-observations`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result Aegis.MissingRolls namespace AegisSpec.MissingRolls def vals (l : List Std.I...
8
stone-game-ix
2,029
Medium
[ "Greedy", "Array", "Math", "Counting", "Game Theory" ]
Alice and Bob continue their games with stones. There is a row of n stones, and each stone has an associated value. You are given an integer array stones, where stones[i] is the value of the ith stone. Alice and Bob take turns, with Alice starting first. On each turn, the player may remove any stone from stones. The pl...
stoneGameIX(stones: list_int) -> bool
pub fn stone_game_ix(stones: &[i64]) -> bool
Aegis.StoneGameIx.stone_game_ix
pub fn stone_game_ix(stones: &[i64]) -> bool { let mut c0: i64 = 0; let mut c1: i64 = 0; let mut c2: i64 = 0; let n = stones.len(); let mut i: usize = 0; while i < n { let r = stones[i] % 3; if r == 0 { c0 += 1; } else if r == 1 { c1 += 1; ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [stone_game_ix]: type definitions module public import Aeneas @[expose] public section 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_ix]: function definitions module public import Aeneas public import Aegis.StoneGameIx.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.StoneGameIx.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval aegisCase...
[ { "input": "[[2]]", "output": "false" }, { "input": "[[2, 1]]", "output": "true" }, { "input": "[[3, 3, 3]]", "output": "false" }, { "input": "[[3, 6, 9]]", "output": "false" }, { "input": "[[3, 6, 9, 12, 15]]", "output": "false" }, { "input": "[[5, 1,...
108
false
108
verified
10
10
1
2,225
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.StoneGameIx.Code.Funs /-! # Specifications of `Aegis.StoneGameIx.stone_game_ix` LeetCode problem `stone-game-ix`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.StoneGameIx (stone_game_ix) namespace AegisSpec.StoneGameIx def values (stones : Sl...
4
count-subarrays-with-more-ones-than-zeros
2,031
Medium
[ "Binary Indexed Tree", "Segment Tree", "Array", "Binary Search", "Divide and Conquer", "Ordered Set", "Merge Sort" ]
You are given a binary array nums containing only the integers 0 and 1. Return the number of subarrays in nums that have more 1's than 0's. Since the answer may be very large, return it modulo 109 + 7. A subarray is a contiguous sequence of elements within an array.   Example 1: Input: nums = [0,1,1,0,1] Output: 9 Exp...
subarraysWithMoreZerosThanOnes(nums: list_int) -> int
pub fn subarrays_with_more_zeros_than_ones(nums: &[i64]) -> i64
Aegis.SubarraysWithMoreZerosThanOnes.subarrays_with_more_zeros_than_ones
pub fn subarrays_with_more_zeros_than_ones(nums: &[i64]) -> i64 { let n: usize = nums.len(); let size: usize = 2 * n + 2; let mut bit: Vec<i64> = Vec::new(); let mut z: usize = 0; while z < size { bit.push(0); z = z + 1; } let mut ans: i64 = 0; let mut pos: usize = n + ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [subarrays_with_more_zeros_than_ones]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables fa...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [subarrays_with_more_zeros_than_ones]: function definitions module public import Aeneas public import Aegis.SubarraysWithMoreZerosThanOnes.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_op...
import Aegis.SubarraysWithMoreZerosThanOnes.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b...
[ { "input": "[[1]]", "output": "1" }, { "input": "[[0]]", "output": "0" }, { "input": "[[1, 0, 1, 0, 1]]", "output": "6" }, { "input": "[[0, 0, 0, 0, 0]]", "output": "0" }, { "input": "[[1, 1, 1, 1, 1]]", "output": "15" }, { "input": "[[0, 1, 1, 0, 1]]"...
106
false
106
verified
10
10
1
9,180
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.SubarraysWithMoreZerosThanOnes.Code.Funs /-! # Specifications of `Aegis.SubarraysWithMoreZerosThanOnes.subarrays_with_more_zeros_than_ones` LeetCode problem `count-subarrays-with-more-ones-than-zeros`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespa...
13
two-out-of-three
2,032
Easy
[ "Bit Manipulation", "Array", "Hash Table" ]
Given three integer arrays nums1, nums2, and nums3, return a distinct array containing all the values that are present in at least two out of the three arrays. You may return the values in any order.   Example 1: Input: nums1 = [1,1,3,2], nums2 = [2,3], nums3 = [3] Output: [3,2] Explanation: The values that are presen...
twoOutOfThree(nums1: list_int, nums2: list_int, nums3: list_int) -> list_int
pub fn two_out_of_three(nums1: &[i64], nums2: &[i64], nums3: &[i64]) -> Vec<i64>
Aegis.TwoOutOfThree.two_out_of_three
fn contains(xs: &[i64], target: i64) -> bool { let mut i: usize = 0; while i < xs.len() { if xs[i] == target { return true; } i += 1; } false } pub fn two_out_of_three(nums1: &[i64], nums2: &[i64], nums3: &[i64]) -> Vec<i64> { let mut result: Vec<i64> = Vec::new(...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [two_out_of_three]: type definitions module public import Aeneas @[expose] public section 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 -- [two_out_of_three]: function definitions module public import Aeneas public import Aegis.TwoOutOfThree.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.TwoOutOfThree.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval aegisCa...
[ { "input": "[[100], [100], [100]]", "output": "[100]" }, { "input": "[[10], [10, 20], [10, 30]]", "output": "[10]" }, { "input": "[[99, 100], [1, 2], [3, 4]]", "output": "[]" }, { "input": "[[1, 2, 2], [4, 3, 3], [5]]", "output": "[]" }, { "input": "[[1, 2], [1, 3...
100
true
100
verified
10
10
1
1,077
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.TwoOutOfThree.Code.Funs /-! # Specifications of `Aegis.TwoOutOfThree.two_out_of_three` LeetCode problem `two-out-of-three`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.TwoOutOfThree (two_out_of_three) namespace AegisSpec.TwoOutOfThree def Oc...
17
minimum-operations-to-make-a-uni-value-grid
2,033
Medium
[ "Array", "Math", "Matrix", "Sorting" ]
You are given a 2D integer grid of size m x n and an integer x. In one operation, you can add x to or subtract x from any element in the grid. A uni-value grid is a grid where all the elements of it are equal. Return the minimum number of operations to make the grid uni-value. If it is not possible, return -1.   Exampl...
minOperations(grid: list_list_int, x: int) -> int
pub fn min_operations(grid: &[Vec<i64>], x: i64) -> i64
Aegis.MinOperations.min_operations
pub fn min_operations(grid: &[Vec<i64>], x: i64) -> i64 { let mut vals: Vec<i64> = Vec::new(); let m = grid.len(); let mut i = 0; while i < m { let row = &grid[i]; let n = row.len(); let mut j = 0; while j < n { vals.push(row[j]); j += 1; ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [min_operations]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [min_operations]: function definitions module public import Aeneas public import Aegis.MinOperations.Code.Types public import Aegis.MinOperations.Code.FunsExternal @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespac...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [min_operations]: external functions. -- This is a template file: rename it to "FunsExternal.lean" and fill the holes. module public import Aeneas public import Aegis.MinOperations.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error s...
import Aegis.MinOperations.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval aegisCa...
[ { "input": "[[[1, 5], [2, 3]], 1]", "output": "5" }, { "input": "[[[10, 10], [10, 10]], 5]", "output": "0" }, { "input": "[[[10, 10], [10, 10]], 3]", "output": "0" }, { "input": "[[[10, 12], [14, 16]], 2]", "output": "4" }, { "input": "[[[2, 4], [6, 8]], 2]", ...
95
false
95
verified
10
10
1
3,748
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": 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-uni-value-grid`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.MinOperations def rows (grid : Slic...
9
partition-array-into-two-arrays-to-minimize-sum-difference
2,035
Hard
[ "Bit Manipulation", "Array", "Two Pointers", "Binary Search", "Dynamic Programming", "Bitmask", "Ordered Set" ]
You are given an integer array nums of 2 * n integers. You need to partition nums into two arrays of length n to minimize the absolute difference of the sums of the arrays. To partition nums, put each element of nums into one of the two arrays. Return the minimum possible absolute difference.   Example 1: Input: nums...
minimumDifference(nums: list_int) -> int
pub fn minimum_difference(nums: &[i64]) -> i64
Aegis.MinimumDifference.minimum_difference
fn abs_i64(x: i64) -> i64 { if x < 0 { -x } else { x } } fn build_groups(nums: &[i64], start: usize, end: usize) -> Vec<Vec<i64>> { let h = end - start; let mut groups: Vec<Vec<i64>> = Vec::new(); let mut i: usize = 0; while i <= h { groups.push(Vec::new()); ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [minimum_difference]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option li...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [minimum_difference]: function definitions module public import Aeneas public import Aegis.MinimumDifference.Code.Types public import Aegis.MinimumDifference.Code.FunsExternal @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [minimum_difference]: external functions. -- This is a template file: rename it to "FunsExternal.lean" and fill the holes. module public import Aeneas public import Aegis.MinimumDifference.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow...
import Aegis.MinimumDifference.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": "[[-36, 36]]", "output": "72" }, { "input": "[[3, 9, 7, 3]]", "output": "2" }, { "input": "[[10000000, -10000000, 5000000, -5000000, 2500000, -2500000]]", "output": "5000000" }, { "input": "[[2, -1, 0, 4, -2, -9]]", "output": "0" }, { "input": "[[1, 2, ...
88
false
88
verified
10
10
1
5,042
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MinimumDifference.Code.Funs /-! # Specifications of `Aegis.MinimumDifference.minimum_difference` LeetCode problem `partition-array-into-two-arrays-to-minimize-sum-difference`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.MinimumDiffer...
13
maximum-alternating-subarray-sum
2,036
Medium
[ "Array", "Dynamic Programming" ]
A subarray of a 0-indexed integer array is a contiguous non-empty sequence of elements within an array. The alternating subarray sum of a subarray that ranges from index i to j (inclusive, 0 <= i <= j < nums.length) is nums[i] - nums[i+1] + nums[i+2] - ... +/- nums[j]. Given a 0-indexed integer array nums, return the m...
maximumAlternatingSubarraySum(nums: list_int) -> int
pub fn maximum_alternating_subarray_sum(nums: &[i64]) -> i64
Aegis.MaximumAlternatingSubarraySum.maximum_alternating_subarray_sum
pub fn maximum_alternating_subarray_sum(nums: &[i64]) -> i64 { let n = nums.len(); if n == 0 { return 0; } let mut plus: i64 = nums[0]; let mut minus: i64 = 0; let mut best: i64 = nums[0]; let mut i: usize = 1; while i < n { let x = nums[i]; let extend_plus = m...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [maximum_alternating_subarray_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...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [maximum_alternating_subarray_sum]: function definitions module public import Aeneas public import Aegis.MaximumAlternatingSubarraySum.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option...
import Aegis.MaximumAlternatingSubarraySum.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}...
[ { "input": "[[1]]", "output": "1" }, { "input": "[[5]]", "output": "5" }, { "input": "[[3, -1, 1, 2]]", "output": "5" }, { "input": "[[-1, 2, -3, 4, -5]]", "output": "14" }, { "input": "[[1, -1, 1, -1, 1]]", "output": "5" }, { "input": "[[1, 3, 5, 7, 9...
130
false
130
verified
10
10
1
2,687
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MaximumAlternatingSubarraySum.Code.Funs /-! # Specifications of `Aegis.MaximumAlternatingSubarraySum.maximum_alternating_subarray_sum` LeetCode problem `maximum-alternating-subarray-sum`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.M...
11
minimum-number-of-moves-to-seat-everyone
2,037
Easy
[ "Greedy", "Array", "Counting Sort", "Sorting" ]
There are n availabe seats and n students standing in a room. You are given an array seats of length n, where seats[i] is the position of the ith seat. You are also given the array students of length n, where students[j] is the position of the jth student. You may perform the following move any number of times: Increa...
minMovesToSeat(seats: list_int, students: list_int) -> int
pub fn min_moves_to_seat(seats: &[i64], students: &[i64]) -> i64
Aegis.MinMovesToSeat.min_moves_to_seat
pub fn min_moves_to_seat(seats: &[i64], students: &[i64]) -> i64 { let mut sorted_seats: Vec<i64> = Vec::new(); let mut i: usize = 0; while i < seats.len() { sorted_seats.push(seats[i]); i += 1; } let mut sorted_students: Vec<i64> = Vec::new(); i = 0; while i < students.len(...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [min_moves_to_seat]: type definitions module public import Aeneas @[expose] public section 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 -- [min_moves_to_seat]: function definitions module public import Aeneas public import Aegis.MinMovesToSeat.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.MinMovesToSeat.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval aegisC...
[ { "input": "[[10, 20, 30], [5, 15, 25]]", "output": "15" }, { "input": "[[3, 1, 5], [2, 7, 4]]", "output": "4" }, { "input": "[[1, 1, 1], [1, 1, 1]]", "output": "0" }, { "input": "[[50, 50, 50], [49, 50, 51]]", "output": "2" }, { "input": "[[10, 20, 30], [15, 25, ...
101
false
101
verified
10
10
1
2,017
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MinMovesToSeat.Code.Funs /-! # Specifications of `Aegis.MinMovesToSeat.min_moves_to_seat` LeetCode problem `minimum-number-of-moves-to-seat-everyone`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.MinMovesToSeat namespace AegisSpec.MinMovesToSe...
10
remove-colored-pieces-if-both-neighbors-are-the-same-color
2,038
Medium
[ "Greedy", "Math", "String", "Game Theory" ]
There are n pieces arranged in a line, and each piece is colored either by 'A' or by 'B'. You are given a string colors of length n where colors[i] is the color of the ith piece. Alice and Bob are playing a game where they take alternating turns removing pieces from the line. In this game, Alice moves first. Alice is ...
winnerOfGame(colors: str) -> bool
pub fn winner_of_game(colors: &[u8]) -> bool
Aegis.WinnerOfGame.winner_of_game
pub fn winner_of_game(colors: &[u8]) -> bool { let n = colors.len(); let mut alice_moves: i64 = 0; let mut bob_moves: i64 = 0; let mut i: usize = 0; while i < n { let c = colors[i]; let mut j = i; while j < n && colors[j] == c { j += 1; } let len...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [winner_of_game]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [winner_of_game]: function definitions module public import Aeneas public import Aegis.WinnerOfGame.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.WinnerOfGame.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": "[\"AABBAABB\"]", "output": "false" }, { "input": "[\"AAAAAAAAA\"]", "output": "true" }, { "input": "[\"AAABAAAAABBBB\"]", "output": "true" }, { "input": "[\"ABABABABAB\"]", "output": "false" }, { "input": "[\"AABBBBAAA\"]", "output": "false" }, ...
182
false
182
verified
10
10
1
1,061
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.WinnerOfGame.Code.Funs /-! # Specifications of `Aegis.WinnerOfGame.winner_of_game` LeetCode problem `remove-colored-pieces-if-both-neighbors-are-the-same-color`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.WinnerOfGame namespace AegisSpec...
10
the-time-when-the-network-becomes-idle
2,039
Medium
[ "Breadth-First Search", "Graph", "Array" ]
There is a network of n servers, labeled from 0 to n - 1. You are given a 2D integer array edges, where edges[i] = [ui, vi] indicates there is a message channel between servers ui and vi, and they can pass any number of messages to each other directly in one second. You are also given a 0-indexed integer array patience...
networkBecomesIdle(edges: list_list_int, patience: list_int) -> int
pub fn network_becomes_idle(edges: &[Vec<i64>], patience: &[i64]) -> i64
Aegis.NetworkBecomesIdle.network_becomes_idle
pub fn network_becomes_idle(edges: &[Vec<i64>], patience: &[i64]) -> i64 { let n = patience.len(); let mut adj: Vec<Vec<i64>> = Vec::new(); let mut i: usize = 0; while i < n { let row: Vec<i64> = Vec::new(); adj.push(row); i += 1; } let mut e: usize = 0; while e < e...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [network_becomes_idle]: type definitions module public import Aeneas @[expose] public section 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 -- [network_becomes_idle]: function definitions module public import Aeneas public import Aegis.NetworkBecomesIdle.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand fal...
import Aegis.NetworkBecomesIdle.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval ae...
[ { "input": "[[[0, 1], [1, 2]], [0, 2, 1]]", "output": "8" }, { "input": "[[[0, 1], [1, 2], [2, 0]], [0, 2, 1]]", "output": "4" }, { "input": "[[[0, 1], [0, 2], [1, 2]], [0, 10, 10]]", "output": "3" }, { "input": "[[[0, 1], [1, 3], [3, 4], [2, 4]], [0, 1, 2, 3, 4]]", "outp...
51
false
51
verified
10
10
1
5,823
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.NetworkBecomesIdle.Code.Funs /-! # Specifications of `Aegis.NetworkBecomesIdle.network_becomes_idle` LeetCode problem `the-time-when-the-network-becomes-idle`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.NetworkBecomesIdle def entry...
11
count-number-of-maximum-bitwise-or-subsets
2,044
Medium
[ "Bit Manipulation", "Array", "Backtracking", "Enumeration" ]
Given an integer array nums, find the maximum possible bitwise OR of a subset of nums and return the number of different non-empty subsets with the maximum bitwise OR. An array a is a subset of an array b if a can be obtained from b by deleting some (possibly zero) elements of b. Two subsets are considered different if...
countMaxOrSubsets(nums: list_int) -> int
pub fn count_max_or_subsets(nums: &[i64]) -> i64
Aegis.CountMaxOrSubsets.count_max_or_subsets
pub fn count_max_or_subsets(nums: &[i64]) -> i64 { let n: usize = nums.len(); let mut target: i64 = 0; let mut i: usize = 0; while i < n { target = target | nums[i]; i += 1; } let mut powers: Vec<i64> = Vec::new(); let mut p: i64 = 1; let mut k: usize = 0; while k <...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [count_max_or_subsets]: type definitions module public import Aeneas @[expose] public section 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_max_or_subsets]: function definitions module public import Aeneas public import Aegis.CountMaxOrSubsets.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand fals...
import Aegis.CountMaxOrSubsets.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval aeg...
[ { "input": "[[1]]", "output": "1" }, { "input": "[[3, 1]]", "output": "2" }, { "input": "[[15, 15, 15]]", "output": "7" }, { "input": "[[2, 2, 2]]", "output": "7" }, { "input": "[[3, 2, 1, 5]]", "output": "6" }, { "input": "[[15, 15, 15, 15]]", "ou...
113
false
113
verified
10
10
1
1,839
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.CountMaxOrSubsets.Code.Funs /-! # Specifications of `Aegis.CountMaxOrSubsets.count_max_or_subsets` LeetCode problem `count-number-of-maximum-bitwise-or-subsets`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.CountMaxOrSubsets namespace AegisSpe...
12
second-minimum-time-to-reach-destination
2,045
Hard
[ "Breadth-First Search", "Graph", "Shortest Path" ]
A city is represented as a bi-directional connected graph with n vertices where each vertex is labeled from 1 to n (inclusive). The edges in the graph are represented as a 2D integer array edges, where each edges[i] = [ui, vi] denotes a bi-directional edge between vertex ui and vertex vi. Every vertex pair is connected...
secondMinimum(n: int, edges: list_list_int, time: int, change: int) -> int
pub fn second_minimum(n: i64, edges: &[Vec<i64>], time: i64, change: i64) -> i64
Aegis.SecondMinimum.second_minimum
pub fn second_minimum(n: i64, edges: &[Vec<i64>], time: i64, change: i64) -> i64 { let nv = n as usize; let mut adj: Vec<Vec<i64>> = Vec::new(); let mut i = 0; while i < nv { adj.push(Vec::new()); i += 1; } let mut e = 0; while e < edges.len() { let u = edges[e][0] ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [second_minimum]: type definitions module public import Aeneas @[expose] public section 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 -- [second_minimum]: function definitions module public import Aeneas public import Aegis.SecondMinimum.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.SecondMinimum.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval aegisCa...
[ { "input": "[2, [[1, 2]], 3, 2]", "output": "11" }, { "input": "[3, [[1, 2], [2, 3]], 2, 3]", "output": "10" }, { "input": "[3, [[1, 2], [2, 3]], 5, 5]", "output": "35" }, { "input": "[4, [[1, 2], [2, 3], [3, 4]], 5, 7]", "output": "33" }, { "input": "[4, [[1, 2],...
84
false
84
verified
10
10
1
9,414
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.SecondMinimum.Code.Funs /-! # Specifications of `Aegis.SecondMinimum.second_minimum` LeetCode problem `second-minimum-time-to-reach-destination`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open scoped Classical namespace AegisSpec.SecondMinimum def ed...
11
sort-linked-list-already-sorted-using-absolute-values
2,046
Medium
[ "Linked List", "Two Pointers", "Sorting" ]
Given the head of a singly linked list that is sorted in non-decreasing order using the absolute values of its nodes, return the list sorted in non-decreasing order using the actual values of its nodes.   Example 1: Input: head = [0,2,-5,5,10,-10] Output: [-10,-5,0,2,5,10] Explanation: The list sorted in non-descendi...
sortLinkedList(head: linkedlist) -> linkedlist
pub fn sort_linked_list(head: &List) -> List
Aegis.SortLinkedList.sort_linked_list
pub fn sort_linked_list(head: &List) -> List { let mut negs: Vec<i64> = Vec::new(); let mut nonnegs: Vec<i64> = Vec::new(); let mut cur: &List = head; let mut done = false; while !done { match cur { List::Nil => { done = true; } List::Con...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [sort_linked_list]: type definitions module public import Aeneas @[expose] public section 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 -- [sort_linked_list]: function definitions module public import Aeneas public import Aegis.SortLinkedList.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.SortLinkedList.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" deriving ins...
[ { "input": "[[1]]", "output": "[1]" }, { "input": "[[-1, -2, -3]]", "output": "[-3, -2, -1]" }, { "input": "[[-1, 0, 1]]", "output": "[-1, 0, 1]" }, { "input": "[[3, 2, 1]]", "output": "[3, 2, 1]" }, { "input": "[[0, 1, 2]]", "output": "[0, 1, 2]" }, { ...
124
false
124
verified
10
10
1
5,563
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.SortLinkedList.Code.Funs /-! # Specifications of `Aegis.SortLinkedList.sort_linked_list` LeetCode problem `sort-linked-list-already-sorted-using-absolute-values`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result def Aegis.SortLinkedList.List.val : Aegis.Sort...
12
number-of-valid-words-in-a-sentence
2,047
Easy
[ "String" ]
A sentence consists of lowercase letters ('a' to 'z'), digits ('0' to '9'), hyphens ('-'), punctuation marks ('!', '.', and ','), and spaces (' ') only. Each sentence can be broken down into one or more tokens separated by one or more spaces ' '. A token is a valid word if all three of the following are true: It only ...
countValidWords(sentence: str) -> int
pub fn count_valid_words(sentence: &[u8]) -> i64
Aegis.CountValidWords.count_valid_words
fn is_lowercase(c: u8) -> bool { c >= b'a' && c <= b'z' } fn is_valid_token(sentence: &[u8], start: usize, end: usize) -> bool { let mut hyphens: i64 = 0; let mut puncts: i64 = 0; let mut p: usize = start; while p < end { let c = sentence[p]; if c >= b'0' && c <= b'9' { ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [count_valid_words]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option lin...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [count_valid_words]: function definitions module public import Aeneas public import Aegis.CountValidWords.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.CountValidWords.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval aegis...
[ { "input": "[\"no-digits123 or symbols#allowed\"]", "output": "2" }, { "input": "[\"a.b.c\"]", "output": "0" }, { "input": "[\"hello-world, this-is-a-test\"]", "output": "1" }, { "input": "[\"hello-\"]", "output": "0" }, { "input": "[\"a-\"]", "output": "0" ...
377
false
377
verified
10
10
1
5,189
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.CountValidWords.Code.Funs /-! # Specifications of `Aegis.CountValidWords.count_valid_words` LeetCode problem `number-of-valid-words-in-a-sentence`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.CountValidWords namespace AegisSpec.CountValidWord...
9
parallel-courses-iii
2,050
Hard
[ "Graph", "Topological Sort", "Array", "Dynamic Programming" ]
You are given an integer n, which indicates that there are n courses labeled from 1 to n. You are also given a 2D integer array relations where relations[j] = [prevCoursej, nextCoursej] denotes that course prevCoursej has to be completed before course nextCoursej (prerequisite relationship). Furthermore, you are given ...
minimumTime(n: int, relations: list_list_int, time: list_int) -> int
pub fn minimum_time(n: i64, relations: &[Vec<i64>], time: &[i64]) -> i64
Aegis.MinimumTime.minimum_time
pub fn minimum_time(n: i64, relations: &[Vec<i64>], time: &[i64]) -> i64 { let n_usize = n as usize; let mut adj: Vec<Vec<i64>> = Vec::new(); let mut i: usize = 0; while i < n_usize { let row: Vec<i64> = Vec::new(); adj.push(row); i += 1; } let mut indeg: Vec<i64> = Vec...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [minimum_time]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter.s...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [minimum_time]: function definitions module public import Aeneas public import Aegis.MinimumTime.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option l...
import Aegis.MinimumTime.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval aegisCase...
[ { "input": "[1, [], [5]]", "output": "5" }, { "input": "[3, [[1, 3], [2, 3]], [3, 2, 5]]", "output": "8" }, { "input": "[4, [[1, 2], [2, 3], [3, 4]], [1, 2, 3, 4]]", "output": "10" }, { "input": "[4, [[1, 2], [1, 3], [2, 4], [3, 4]], [4, 2, 3, 1]]", "output": "8" }, {...
60
false
60
verified
10
10
1
3,588
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MinimumTime.Code.Funs /-! # Specifications of `Aegis.MinimumTime.minimum_time` LeetCode problem `parallel-courses-iii`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.MinimumTime namespace AegisSpec.MinimumTime def timeList (time : Slice I64) :...
13
minimum-cost-to-separate-sentence-into-rows
2,052
Medium
[ "Array", "Dynamic Programming" ]
You are given a string sentence containing words separated by spaces, and an integer k. Your task is to separate sentence into rows where the number of characters in each row is at most k. You may assume that sentence does not begin or end with a space, and the words in sentence are separated by a single space. You can...
minimumCost(sentence: str, k: int) -> int
pub fn minimum_cost(sentence: &[u8], k: i64) -> i64
Aegis.MinimumCost.minimum_cost
pub fn minimum_cost(sentence: &[u8], k: i64) -> i64 { let n: usize = sentence.len(); if n == 0 { return 0; } let mut lengths: Vec<i64> = Vec::new(); let mut cur: i64 = 0; let mut p: usize = 0; while p < n { if sentence[p] == b' ' { lengths.push(cur); ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [minimum_cost]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter.s...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [minimum_cost]: function definitions module public import Aeneas public import Aegis.MinimumCost.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option l...
import Aegis.MinimumCost.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval aegisCase...
[ { "input": "[\"this is a test sentence for the problem\", 9]", "output": "18" }, { "input": "[\"i love leetcode\", 12]", "output": "36" }, { "input": "[\"this is a test sentence for the problem\", 15]", "output": "10" }, { "input": "[\"the quick brown fox jumps over the lazy ...
83
false
83
verified
10
10
1
4,324
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MinimumCost.Code.Funs /-! # Specifications of `Aegis.MinimumCost.minimum_cost` LeetCode problem `minimum-cost-to-separate-sentence-into-rows`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.MinimumCost def IsSpace (b : Std.U8) : Prop :...
9
two-best-non-overlapping-events
2,054
Medium
[ "Array", "Binary Search", "Dynamic Programming", "Sorting", "Heap (Priority Queue)" ]
You are given a 0-indexed 2D integer array of events where events[i] = [startTimei, endTimei, valuei]. The ith event starts at startTimei and ends at endTimei, and if you attend this event, you will receive a value of valuei. You can choose at most two non-overlapping events to attend such that the sum of their values ...
maxTwoEvents(events: list_list_int) -> int
pub fn max_two_events(events: &[Vec<i64>]) -> i64
Aegis.MaxTwoEvents.max_two_events
fn event_leq(events: &[Vec<i64>], a: usize, b: usize) -> bool { let end_a = events[a][1]; let end_b = events[b][1]; if end_a < end_b { return true; } if end_a > end_b { return false; } let start_a = events[a][0]; let start_b = events[b][0]; if start_a < start_b { ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [max_two_events]: type definitions module public import Aeneas @[expose] public section 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_two_events]: function definitions module public import Aeneas public import Aegis.MaxTwoEvents.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.MaxTwoEvents.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval aegisCas...
[ { "input": "[[[1, 1000000000, 1000000], [1000000000, 1000000000, 1000000]]]", "output": "1000000" }, { "input": "[[[1, 1000000000, 1], [1000000000, 1000000000, 1000000]]]", "output": "1000000" }, { "input": "[[[10, 20, 15], [20, 30, 10], [1, 10, 5]]]", "output": "15" }, { "in...
97
false
97
verified
10
10
1
9,118
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MaxTwoEvents.Code.Funs /-! # Specifications of `Aegis.MaxTwoEvents.max_two_events` LeetCode problem `two-best-non-overlapping-events`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.MaxTwoEvents namespace AegisSpec.MaxTwoEvents def fields...
12
plates-between-candles
2,055
Medium
[ "Array", "String", "Binary Search", "Prefix Sum" ]
There is a long table with a line of plates and candles arranged on top of it. You are given a 0-indexed string s consisting of characters '*' and '|' only, where a '*' represents a plate and a '|' represents a candle. You are also given a 0-indexed 2D integer array queries where queries[i] = [lefti, righti] denotes th...
platesBetweenCandles(s: str, queries: list_list_int) -> list_int
pub fn plates_between_candles(s: &[u8], queries: &[Vec<i64>]) -> Vec<i64>
Aegis.PlatesBetweenCandles.plates_between_candles
pub fn plates_between_candles(s: &[u8], queries: &[Vec<i64>]) -> Vec<i64> { let n = s.len(); // pref[i] = number of plates in s[0..i] let mut pref: Vec<i64> = Vec::new(); pref.push(0); let mut i = 0; while i < n { let mut val = pref[i]; if s[i] == b'*' { val += 1; ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [plates_between_candles]: type definitions module public import Aeneas @[expose] public 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 -- [plates_between_candles]: function definitions module public import Aeneas public import Aegis.PlatesBetweenCandles.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand...
import Aegis.PlatesBetweenCandles.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": "[\"**|**|***|\", [[2, 5], [5, 9]]]", "output": "[2, 3]" }, { "input": "[\"***||***\", [[0, 5], [2, 4]]]", "output": "[0, 0]" }, { "input": "[\"*|*|*|*|*|\", [[0, 5], [1, 4]]]", "output": "[2, 1]" }, { "input": "[\"*|*|*|*|*|*|*|\", [[0, 7], [1, 6], [2, 5]]]", ...
13
false
13
verified
10
10
1
3,939
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.PlatesBetweenCandles.Code.Funs /-! # Specifications of `Aegis.PlatesBetweenCandles.plates_between_candles` LeetCode problem `plates-between-candles`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.PlatesBetweenCandles def sLen (s :...
5
number-of-valid-move-combinations-on-chessboard
2,056
Hard
[ "Array", "String", "Backtracking", "Simulation" ]
There is an 8 x 8 chessboard containing n pieces (rooks, queens, or bishops). You are given a string array pieces of length n, where pieces[i] describes the type (rook, queen, or bishop) of the ith piece. In addition, you are given a 2D integer array positions also of length n, where positions[i] = [ri, ci] indicates t...
countCombinations(pieces: list_str, positions: list_list_int) -> int
pub fn count_combinations(pieces: &[Vec<u8>], positions: &[Vec<i64>]) -> i64
Aegis.CountCombinations.count_combinations
fn gen_moves(kind: u8, r: i64, c: i64) -> Vec<i64> { let mut m: Vec<i64> = Vec::new(); // Stay-in-place move: dr = 0, dc = 0, dist = 0 m.push(0i64); m.push(0i64); m.push(0i64); let mut di = 0i64; while di < 3 { let dr = di - 1; let mut dci = 0i64; while dci < 3 { ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [count_combinations]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option li...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [count_combinations]: function definitions module public import Aeneas public import Aegis.CountCombinations.Code.Types public import Aegis.CountCombinations.Code.FunsExternal @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [count_combinations]: external functions. -- This is a template file: rename it to "FunsExternal.lean" and fill the holes. module public import Aeneas public import Aegis.CountCombinations.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow...
import Aegis.CountCombinations.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": "[[\"bishop\"], [[4, 3]]]", "output": "12" }, { "input": "[[\"rook\"], [[1, 1]]]", "output": "15" }, { "input": "[[\"queen\"], [[1, 1]]]", "output": "22" }, { "input": "[[\"queen\", \"rook\"], [[1, 1], [2, 2]]]", "output": "309" }, { "input": "[[\"rook\...
100
false
100
verified
10
10
3
24,244
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.CountCombinations.Code.Funs /-! # Specifications of `Aegis.CountCombinations.count_combinations` LeetCode problem `number-of-valid-move-combinations-on-chessboard`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.CountCombinations def b...
16
smallest-index-with-equal-value
2,057
Easy
[ "Array" ]
Given a 0-indexed integer array nums, return the smallest index i of nums such that i mod 10 == nums[i], or -1 if such index does not exist. x mod y denotes the remainder when x is divided by y.   Example 1: Input: nums = [0,1,2] Output: 0 Explanation: i=0: 0 mod 10 = 0 == nums[0]. i=1: 1 mod 10 = 1 == nums[1]. i=2: ...
smallestEqual(nums: list_int) -> int
pub fn smallest_equal(nums: &[i64]) -> i64
Aegis.SmallestEqual.smallest_equal
pub fn smallest_equal(nums: &[i64]) -> i64 { let n = nums.len(); let mut i: usize = 0; while i < n { let r = (i as i64) % 10; if r == nums[i] { return i as i64; } i += 1; } -1 }
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [smallest_equal]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [smallest_equal]: function definitions module public import Aeneas public import Aegis.SmallestEqual.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.SmallestEqual.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval aegisCa...
[ { "input": "[[0, 1, 2]]", "output": "0" }, { "input": "[[4, 3, 2, 1]]", "output": "2" }, { "input": "[[0, 10, 20, 30]]", "output": "0" }, { "input": "[[0, 10, 20, 30, 40]]", "output": "0" }, { "input": "[[10, 20, 30, 40, 50, 60, 70, 80, 90]]", "output": "-1" ...
98
false
98
verified
10
10
1
126
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.SmallestEqual.Code.Funs /-! # Specifications of `Aegis.SmallestEqual.smallest_equal` LeetCode problem `smallest-index-with-equal-value`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.SmallestEqual /-- The function returns a result...
7
find-the-minimum-and-maximum-number-of-nodes-between-critical-points
2,058
Medium
[ "Linked List" ]
A critical point in a linked list is defined as either a local maxima or a local minima. A node is a local maxima if the current node has a value strictly greater than the previous node and the next node. A node is a local minima if the current node has a value strictly smaller than the previous node and the next node....
nodesBetweenCriticalPoints(head: linkedlist) -> list_int
pub fn nodes_between_critical_points(head: &List) -> Vec<i64>
Aegis.NodesBetweenCriticalPoints.nodes_between_critical_points
fn collect(l: &List, out: &mut Vec<i64>) { match l { List::Nil => {} List::Cons(v, next) => { out.push(*v); collect(&**next, out); } } } pub fn nodes_between_critical_points(head: &List) -> Vec<i64> { let mut vals: Vec<i64> = Vec::new(); collect(head, &mu...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [nodes_between_critical_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 se...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [nodes_between_critical_points]: function definitions module public import Aeneas public import Aegis.NodesBetweenCriticalPoints.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linte...
import Aegis.NodesBetweenCriticalPoints.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" ...
[ { "input": "[[3, 1]]", "output": "[-1, -1]" }, { "input": "[[5, 4, 3, 2, 1]]", "output": "[-1, -1]" }, { "input": "[[1, 2, 3, 4, 5]]", "output": "[-1, -1]" }, { "input": "[[1, 1, 1, 1, 1]]", "output": "[-1, -1]" }, { "input": "[[1, 2, 3, 4, 3, 2, 1]]", "output...
117
false
117
verified
10
10
2
7,248
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.NodesBetweenCriticalPoints.Code.Funs /-! # Specifications of `Aegis.NodesBetweenCriticalPoints.nodes_between_critical_points` LeetCode problem `find-the-minimum-and-maximum-number-of-nodes-between-critical-points`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Re...
15
number-of-spaces-cleaning-robot-cleaned
2,061
Medium
[ "Array", "Matrix", "Simulation" ]
A room is represented by a 0-indexed 2D binary matrix room where a 0 represents an empty space and a 1 represents a space with an object. The top left corner of the room will be empty in all test cases. A cleaning robot starts at the top left corner of the room and is facing right. The robot will continue heading strai...
numberOfCleanRooms(room: list_list_int) -> int
pub fn number_of_clean_rooms(room: &[Vec<i64>]) -> i64
Aegis.NumberOfCleanRooms.number_of_clean_rooms
pub fn number_of_clean_rooms(room: &[Vec<i64>]) -> i64 { let m = room.len(); if m == 0 { return 0; } let n = room[0].len(); if n == 0 { return 0; } let total_cells = m * n; let total_states = total_cells * 4; let mut seen: Vec<bool> = Vec::new(); let mut i: usi...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [number_of_clean_rooms]: type definitions module public import Aeneas @[expose] public section 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 -- [number_of_clean_rooms]: function definitions module public import Aeneas public import Aegis.NumberOfCleanRooms.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand fa...
import Aegis.NumberOfCleanRooms.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval ae...
[ { "input": "[[[0, 0, 0], [1, 1, 0], [0, 0, 0]]]", "output": "7" }, { "input": "[[[0, 0, 0], [0, 0, 0], [0, 0, 0]]]", "output": "8" }, { "input": "[[[0, 1, 0], [1, 0, 0], [0, 0, 0]]]", "output": "1" }, { "input": "[[[0, 0, 1], [0, 0, 0], [1, 0, 0]]]", "output": "4" }, ...
77
false
77
verified
10
10
1
4,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.NumberOfCleanRooms.Code.Funs /-! # Specifications of `Aegis.NumberOfCleanRooms.number_of_clean_rooms` LeetCode problem `number-of-spaces-cleaning-robot-cleaned`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result attribute [local instance] Classical.propDeci...
9