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
building-boxes
1,739
Hard
[ "Greedy", "Math", "Binary Search" ]
You have a cubic storeroom where the width, length, and height of the room are all equal to n units. You are asked to place n boxes in this room where each box is a cube of unit side length. There are however some rules to placing the boxes: You can place the boxes anywhere on the floor. If box x is placed on top of t...
minimumBoxes(n: int) -> int
pub fn minimum_boxes(n: i64) -> i64
Aegis.MinimumBoxes.minimum_boxes
pub fn minimum_boxes(n: i64) -> i64 { let mut remaining = n; let mut ans = 0i64; let mut h = 1i64; let mut layer = h * (h + 1) / 2; while remaining >= layer { remaining -= layer; ans += h; h += 1; layer = h * (h + 1) / 2; } let mut i = 1i64; while remai...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [minimum_boxes]: type definitions module public import Aeneas @[expose] public section 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_boxes]: function definitions module public import Aeneas public import Aegis.MinimumBoxes.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.MinimumBoxes.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.MinimumBoxes.minimum_boxes 8#i64) (6#i64))}") #eval (s!"CASE 1 {(Result.reducesTo (Aegis.MinimumBoxes.minimum_boxes 3#i64) (3#i64))}") #eval (s!"CAS...
[ { "input": "[8]", "output": "6" }, { "input": "[3]", "output": "3" }, { "input": "[100]", "output": "34" }, { "input": "[15]", "output": "9" }, { "input": "[4]", "output": "3" }, { "input": "[1000000]", "output": "16443" }, { "input": "[20]...
101
false
101
verified
10
10
1
6,340
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MinimumBoxes.Code.Funs /-! # Specifications of `Aegis.MinimumBoxes.minimum_boxes` LeetCode problem `building-boxes`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.MinimumBoxes namespace AegisSpec.MinimumBoxes def tri (a : ℤ) : ℤ := a * (a + 1)...
12
find-distance-in-a-binary-tree
1,740
Medium
[ "Tree", "Depth-First Search", "Breadth-First Search", "Hash Table", "Binary Tree" ]
Given the root of a binary tree and two integers p and q, return the distance between the nodes of value p and value q in the tree. The distance between two nodes is the number of edges on the path from one to the other.   Example 1: Input: root = [3,5,1,6,2,0,8,null,null,7,4], p = 5, q = 0 Output: 3 Explanation: The...
findDistance(root: tree, p: int, q: int) -> int
pub fn find_distance(root: &Tree, p: i64, q: i64) -> i64
Aegis.FindDistance.find_distance
const B: i64 = 100000; fn upd(best: i64, pi: i64, qj: i64) -> i64 { if pi > 0 { if qj > 0 { let d: i64 = (pi - 1) + (qj - 1); if d > best { return d; } } } best } // All arithmetic lives here: no borrows into the tree, so no borrow-contex...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [find_distance]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter....
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [find_distance]: function definitions module public import Aeneas public import Aegis.FindDistance.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.FindDistance.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.FindDistance.find_distance ((.Node 5#i64 (.Null) (.Null)) : Aegis.FindDistance.Tree) 5#i64 5#i64) (0#i64))}") #eval (s!"CASE 1 {(Result.reducesTo (A...
[ { "input": "[[5], 5, 5]", "output": "0" }, { "input": "[[1], 1, 1]", "output": "0" }, { "input": "[[2, 1], 1, 2]", "output": "1" }, { "input": "[[1, 2], 1, 2]", "output": "1" }, { "input": "[[2, 1, 3], 1, 3]", "output": "2" }, { "input": "[[1, 2, 3, 4,...
17
false
17
verified
10
10
4
62,494
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.FindDistance.Code.Funs /-! # Specifications of `Aegis.FindDistance.find_distance` LeetCode problem `find-distance-in-a-binary-tree`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result set_option autoImplicit false namespace AegisSpec.FindDistance open A...
12
maximum-number-of-balls-in-a-box
1,742
Easy
[ "Hash Table", "Math", "Counting" ]
You are working in a ball factory where you have n balls numbered from lowLimit up to highLimit inclusive (i.e., n == highLimit - lowLimit + 1), and an infinite number of boxes numbered from 1 to infinity. Your job at this factory is to put each ball in the box with a number equal to the sum of digits of the ball's num...
countBalls(lowLimit: int, highLimit: int) -> int
pub fn count_balls(lowLimit: i64, highLimit: i64) -> i64
Aegis.CountBalls.count_balls
fn digit_sum(mut n: i64) -> i64 { let mut sum: i64 = 0; while n > 0 { sum += n % 10; n /= 10; } sum } pub fn count_balls(lowLimit: i64, highLimit: i64) -> i64 { let mut counts: Vec<i64> = Vec::new(); let mut i: usize = 0; while i < 64 { counts.push(0); i += 1...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [count_balls]: type definitions module public import Aeneas @[expose] public section 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_balls]: function definitions module public import Aeneas public import Aegis.CountBalls.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.CountBalls.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.CountBalls.count_balls 999#i64 1000#i64) (1#i64))}") #eval (s!"CASE 1 {(Result.reducesTo (Aegis.CountBalls.count_balls 1000#i64 10000#i64) (615#i64))}...
[ { "input": "[999, 1000]", "output": "1" }, { "input": "[1000, 10000]", "output": "615" }, { "input": "[50000, 50500]", "output": "44" }, { "input": "[99, 999]", "output": "70" }, { "input": "[500, 550]", "output": "6" }, { "input": "[9999, 100000]", ...
86
false
86
verified
10
10
1
796
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.CountBalls.Code.Funs /-! # Specifications of `Aegis.CountBalls.count_balls` LeetCode problem `maximum-number-of-balls-in-a-box`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.CountBalls namespace AegisSpec.CountBalls def digitsRev (n : ℕ) : Li...
11
can-you-eat-your-favorite-candy-on-your-favorite-day
1,744
Medium
[ "Array", "Prefix Sum" ]
You are given a (0-indexed) array of positive integers candiesCount where candiesCount[i] represents the number of candies of the ith type you have. You are also given a 2D array queries where queries[i] = [favoriteTypei, favoriteDayi, dailyCapi]. You play a game with the following rules: You start eating candies on d...
canEat(candiesCount: list_int, queries: list_list_int) -> list_bool
pub fn can_eat(candiesCount: &[i64], queries: &[Vec<i64>]) -> Vec<bool>
Aegis.CanEat.can_eat
pub fn can_eat(candiesCount: &[i64], queries: &[Vec<i64>]) -> Vec<bool> { let n = candiesCount.len(); let mut prefix: Vec<i64> = Vec::new(); let mut sum: i64 = 0; let mut i: usize = 0; while i < n { prefix.push(sum); sum = sum + candiesCount[i]; i = i + 1; } prefix....
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [can_eat]: type definitions module public import Aeneas @[expose] public section 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 -- [can_eat]: function definitions module public import Aeneas public import Aegis.CanEat.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unus...
import Aegis.CanEat.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.CanEat.can_eat (Slice.from [1000000000#i64, 1000000000#i64, 1000000000#i64] (by scalar_tac) : Slice Std.I64) (Slice.from [(alloc.vec.Vec.from [0#i64, 5000...
[ { "input": "[[1000000000, 1000000000, 1000000000], [[0, 500000000, 500000000], [1, 1500000000, 500000000], [2, 2500000000, 500000000]]]", "output": "[true, true, true]" }, { "input": "[[1000000, 1000000, 1000000], [[0, 100000, 1000], [1, 200000, 500000], [2, 500000, 1]]]", "output": "[true, true...
55
false
55
verified
10
10
1
4,447
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.CanEat.Code.Funs /-! # Specifications of `Aegis.CanEat.can_eat` LeetCode problem `can-you-eat-your-favorite-candy-on-your-favorite-day`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.CanEat def candies (candiesCount : Slice Std.I6...
12
palindrome-partitioning-iv
1,745
Hard
[ "String", "Dynamic Programming" ]
Given a string s, return true if it is possible to split the string s into three non-empty palindromic substrings. Otherwise, return false.​​​​​ A string is said to be palindrome if it the same string when reversed.   Example 1: Input: s = "abcbdd" Output: true Explanation: "abcbdd" = "a" + "bcb" + "dd", and all three...
checkPartitioning(s: str) -> bool
pub fn check_partitioning(s: &[u8]) -> bool
Aegis.CheckPartitioning.check_partitioning
pub fn check_partitioning(s: &[u8]) -> bool { let n = s.len(); let total = n * n; let mut is_pal: Vec<bool> = Vec::new(); let mut k: usize = 0; while k < total { is_pal.push(false); k += 1; } let mut length: usize = 1; while length <= n { let mut i: usize = 0; ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [check_partitioning]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option li...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [check_partitioning]: function definitions module public import Aeneas public import Aegis.CheckPartitioning.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false ...
import Aegis.CheckPartitioning.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.CheckPartitioning.check_partitioning (Slice.from [97#u8, 98#u8, 99#u8, 98#u8, 97#u8] (by scalar_tac) : Slice Std.U8)) (true))}") #eval (s!"CASE...
[ { "input": "[\"abcba\"]", "output": "true" }, { "input": "[\"abcdcba\"]", "output": "true" }, { "input": "[\"aabbaa\"]", "output": "true" }, { "input": "[\"aaaaa\"]", "output": "true" }, { "input": "[\"abacdfgdcaba\"]", "output": "false" }, { "input": ...
165
false
165
verified
10
10
2
3,107
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.CheckPartitioning.Code.Funs /-! # Specifications of `Aegis.CheckPartitioning.check_partitioning` LeetCode problem `palindrome-partitioning-iv`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.CheckPartitioning namespace AegisSpec.CheckPartiti...
9
maximum-subarray-sum-after-one-operation
1,746
Medium
[ "Array", "Dynamic Programming" ]
You are given an integer array nums. You must perform exactly one operation where you can replace one element nums[i] with nums[i] * nums[i]. \r \r Return the maximum possible subarray sum after exactly one operation. The subarray must be non-empty.\r \r  \r Example 1:\r \r \r Input: nums = [2,-1,-4,-3]\r Output: 17\r ...
maxSumAfterOperation(nums: list_int) -> int
pub fn max_sum_after_operation(nums: &[i64]) -> i64
Aegis.MaxSumAfterOperation.max_sum_after_operation
pub fn max_sum_after_operation(nums: &[i64]) -> i64 { let n = nums.len(); if n == 0 { return 0; } let first = nums[0]; // Maximum subarray sum ending at the current index without using the operation. let mut best_no_op = first; // Maximum subarray sum ending at the current index a...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [max_sum_after_operation]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_opti...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [max_sum_after_operation]: function definitions module public import Aeneas public import Aegis.MaxSumAfterOperation.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashComman...
import Aegis.MaxSumAfterOperation.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.MaxSumAfterOperation.max_sum_after_operation (Slice.from [(-1)#i64] (by scalar_tac) : Slice Std.I64)) (1#i64))}") #eval (s!"CASE 1 {(Result....
[ { "input": "[[-1]]", "output": "1" }, { "input": "[[1]]", "output": "1" }, { "input": "[[0]]", "output": "0" }, { "input": "[[2, -1, -4, -3]]", "output": "17" }, { "input": "[[1, 2, 3, 4]]", "output": "22" }, { "input": "[[0, -2, 3, -1]]", "output"...
108
false
108
verified
10
10
1
3,041
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MaxSumAfterOperation.Code.Funs /-! # Specifications of `Aegis.MaxSumAfterOperation.max_sum_after_operation` LeetCode problem `maximum-subarray-sum-after-one-operation`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.MaxSumAfterOperation namespa...
11
sum-of-unique-elements
1,748
Easy
[ "Array", "Hash Table", "Counting" ]
You are given an integer array nums. The unique elements of an array are the elements that appear exactly once in the array. Return the sum of all the unique elements of nums.   Example 1: Input: nums = [1,2,3,2] Output: 4 Explanation: The unique elements are [1,3], and the sum is 4. Example 2: Input: nums = [1,1,1,...
sumOfUnique(nums: list_int) -> int
pub fn sum_of_unique(nums: &[i64]) -> i64
Aegis.SumOfUnique.sum_of_unique
pub fn sum_of_unique(nums: &[i64]) -> i64 { let n: usize = nums.len(); let mut sum: i64 = 0; let mut i: usize = 0; while i < n { let mut count: i64 = 0; let mut j: usize = 0; while j < n { if nums[j] == nums[i] { count += 1; } ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [sum_of_unique]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter....
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [sum_of_unique]: function definitions module public import Aeneas public import Aegis.SumOfUnique.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.SumOfUnique.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.SumOfUnique.sum_of_unique (Slice.from [1#i64] (by scalar_tac) : Slice Std.I64)) (1#i64))}") #eval (s!"CASE 1 {(Result.reducesTo (Aegis.SumOfUnique.su...
[ { "input": "[[1]]", "output": "1" }, { "input": "[[7]]", "output": "7" }, { "input": "[[5]]", "output": "5" }, { "input": "[[1, 2]]", "output": "3" }, { "input": "[[1, 2, 3, 2]]", "output": "4" }, { "input": "[[10, 20, 20, 10, 30]]", "output": "30"...
99
false
99
verified
10
10
1
403
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.SumOfUnique.Code.Funs /-! # Specifications of `Aegis.SumOfUnique.sum_of_unique` LeetCode problem `sum-of-unique-elements`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.SumOfUnique def vals (nums : Slice Std.I64) : List Int := num...
10
maximum-absolute-sum-of-any-subarray
1,749
Medium
[ "Array", "Dynamic Programming" ]
You are given an integer array nums. The absolute sum of a subarray [numsl, numsl+1, ..., numsr-1, numsr] is abs(numsl + numsl+1 + ... + numsr-1 + numsr). Return the maximum absolute sum of any (possibly empty) subarray of nums. Note that abs(x) is defined as follows: If x is a negative integer, then abs(x) = -x. If x...
maxAbsoluteSum(nums: list_int) -> int
pub fn max_absolute_sum(nums: &[i64]) -> i64
Aegis.MaxAbsoluteSum.max_absolute_sum
pub fn max_absolute_sum(nums: &[i64]) -> i64 { let mut cur: i64 = 0; let mut max_pref: i64 = 0; let mut min_pref: i64 = 0; let n = nums.len(); let mut i: usize = 0; while i < n { cur = cur + nums[i]; if cur > max_pref { max_pref = cur; } if cur < mi...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [max_absolute_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 lint...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [max_absolute_sum]: function definitions module public import Aeneas public import Aegis.MaxAbsoluteSum.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.MaxAbsoluteSum.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.MaxAbsoluteSum.max_absolute_sum (Slice.from [1#i64] (by scalar_tac) : Slice Std.I64)) (1#i64))}") #eval (s!"CASE 1 {(Result.reducesTo (Aegis.MaxAb...
[ { "input": "[[1]]", "output": "1" }, { "input": "[[0]]", "output": "0" }, { "input": "[[-1]]", "output": "1" }, { "input": "[[-10000, 10000, -10000, 10000]]", "output": "10000" }, { "input": "[[1, -3, 2, 3, -4]]", "output": "5" }, { "input": "[[10000, ...
110
false
110
verified
10
10
1
1,267
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MaxAbsoluteSum.Code.Funs /-! # Specifications of `Aegis.MaxAbsoluteSum.max_absolute_sum` LeetCode problem `maximum-absolute-sum-of-any-subarray`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.MaxAbsoluteSum (max_absolute_sum) namespace AegisSpe...
12
minimum-length-of-string-after-deleting-similar-ends
1,750
Medium
[ "Two Pointers", "String" ]
Given a string s consisting only of characters 'a', 'b', and 'c'. You are asked to apply the following algorithm on the string any number of times: Pick a non-empty prefix from the string s where all the characters in the prefix are equal. Pick a non-empty suffix from the string s where all the characters in this suff...
minimumLength(s: str) -> int
pub fn minimum_length(s: &[u8]) -> i64
Aegis.MinimumLength.minimum_length
pub fn minimum_length(s: &[u8]) -> i64 { let n = s.len(); if n == 0 { return 0; } let mut i: usize = 0; let mut j: usize = n - 1; while i < j { if s[i] != s[j] { break; } let c = s[i]; while i <= j { if s[i] != c { ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [minimum_length]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [minimum_length]: function definitions module public import Aeneas public import Aegis.MinimumLength.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.MinimumLength.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.MinimumLength.minimum_length (Slice.from [97#u8, 98#u8, 99#u8, 98#u8, 97#u8] (by scalar_tac) : Slice Std.U8)) (1#i64))}") #eval (s!"CASE 1 {(Result...
[ { "input": "[\"abcba\"]", "output": "1" }, { "input": "[\"ca\"]", "output": "2" }, { "input": "[\"abac\"]", "output": "4" }, { "input": "[\"aabccabba\"]", "output": "3" }, { "input": "[\"aabbaa\"]", "output": "0" }, { "input": "[\"aaaaa\"]", "outpu...
170
false
170
verified
10
10
1
6,335
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MinimumLength.Code.Funs /-! # Specifications of `Aegis.MinimumLength.minimum_length` LeetCode problem `minimum-length-of-string-after-deleting-similar-ends`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.MinimumLength def IsABC (b...
13
check-if-array-is-sorted-and-rotated
1,752
Easy
[ "Array" ]
Given an array nums, return true if the array was originally sorted in non-decreasing order, then rotated some number of positions (including zero). Otherwise, return false. There may be duplicates in the original array. Note: An array A rotated by x positions results in an array B of the same length such that B[i] == ...
check(nums: list_int) -> bool
pub fn check(nums: &[i64]) -> bool
Aegis.Check.check
pub fn check(nums: &[i64]) -> bool { let n = nums.len(); if n == 0 { return true; } let mut cnt: i64 = 0; let mut i: usize = 0; while i < n { let next = (i + 1) % n; if nums[i] > nums[next] { cnt += 1; } i += 1; } cnt <= 1 }
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [check]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter.style.wh...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [check]: function definitions module public import Aeneas public import Aegis.Check.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedV...
import Aegis.Check.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.Check.check (Slice.from [1#i64, 3#i64, 2#i64] (by scalar_tac) : Slice Std.I64)) (false))}") #eval (s!"CASE 1 {(Result.reducesTo (Aegis.Check.check (Slice.f...
[ { "input": "[[1, 3, 2]]", "output": "false" }, { "input": "[[2, 1, 2]]", "output": "true" }, { "input": "[[1, 2, 3]]", "output": "true" }, { "input": "[[1, 1, 1]]", "output": "true" }, { "input": "[[1, 2, 1]]", "output": "true" }, { "input": "[[3, 1, 2...
141
false
141
verified
10
10
1
401
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.Check.Code.Funs /-! # Specifications of `Aegis.Check.check` LeetCode problem `check-if-array-is-sorted-and-rotated`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.Check def elt (nums : Slice Std.I64) (i : ℕ) : ℤ := match nums.val[i]...
10
maximum-score-from-removing-stones
1,753
Medium
[ "Greedy", "Math", "Heap (Priority Queue)" ]
You are playing a solitaire game with three piles of stones of sizes a​​​​​​, b,​​​​​​ and c​​​​​​ respectively. Each turn you choose two different non-empty piles, take one stone from each, and add 1 point to your score. The game stops when there are fewer than two non-empty piles (meaning there are no more available ...
maximumScore(a: int, b: int, c: int) -> int
pub fn maximum_score(a: i64, b: i64, c: i64) -> i64
Aegis.MaximumScore.maximum_score
pub fn maximum_score(a: i64, b: i64, c: i64) -> i64 { let sum = a + b + c; let mut max = a; if b > max { max = b; } if c > max { max = c; } let rest = sum - max; if max >= rest { rest } else { sum / 2 } }
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [maximum_score]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter....
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [maximum_score]: function definitions module public import Aeneas public import Aegis.MaximumScore.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.MaximumScore.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.MaximumScore.maximum_score 10#i64 10#i64 1#i64) (10#i64))}") #eval (s!"CASE 1 {(Result.reducesTo (Aegis.MaximumScore.maximum_score 5#i64 7#i64 9#i64...
[ { "input": "[10, 10, 1]", "output": "10" }, { "input": "[5, 7, 9]", "output": "10" }, { "input": "[5, 5, 5]", "output": "7" }, { "input": "[1, 8, 8]", "output": "8" }, { "input": "[3, 3, 3]", "output": "4" }, { "input": "[100000, 1, 1]", "output": ...
88
false
88
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.MaximumScore.Code.Funs /-! # Specifications of `Aegis.MaximumScore.maximum_score` LeetCode problem `maximum-score-from-removing-stones`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.MaximumScore (maximum_score) namespace AegisSpec.MaximumS...
12
closest-subsequence-sum
1,755
Hard
[ "Bit Manipulation", "Array", "Two Pointers", "Dynamic Programming", "Bitmask", "Sorting" ]
You are given an integer array nums and an integer goal. You want to choose a subsequence of nums such that the sum of its elements is the closest possible to goal. That is, if the sum of the subsequence's elements is sum, then you want to minimize the absolute difference abs(sum - goal). Return the minimum possible va...
minAbsDifference(nums: list_int, goal: int) -> int
pub fn min_abs_difference(nums: &[i64], goal: i64) -> i64
Aegis.MinAbsDifference.min_abs_difference
fn subset_sums(nums: &[i64], start: usize, end: usize) -> Vec<i64> { let mut sums: Vec<i64> = Vec::new(); sums.push(0); let mut i = start; while i < end { let x = nums[i]; let old_len = sums.len(); let mut j = 0usize; while j < old_len { let s = sums[j]; ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [min_abs_difference]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option li...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [min_abs_difference]: function definitions module public import Aeneas public import Aegis.MinAbsDifference.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.MinAbsDifference.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.MinAbsDifference.min_abs_difference (Slice.from [10000000#i64, (-10000000)#i64] (by scalar_tac) : Slice Std.I64) 0#i64) (0#i64))}") #eval (s!"CA...
[ { "input": "[[10000000, -10000000], 0]", "output": "0" }, { "input": "[[1, 2, 3], -7]", "output": "7" }, { "input": "[[7, -9, 15, -2], -5]", "output": "1" }, { "input": "[[10000000, -10000000, 10000000, -10000000], 0]", "output": "0" }, { "input": "[[10000000, -10...
98
false
98
verified
10
10
1
5,408
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MinAbsDifference.Code.Funs /-! # Specifications of `Aegis.MinAbsDifference.min_abs_difference` LeetCode problem `closest-subsequence-sum`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result ControlFlow Error namespace AegisSpec.MinAbsDifference open Aegis.Min...
16
minimum-changes-to-make-alternating-binary-string
1,758
Easy
[ "String" ]
You are given a string s consisting only of the characters '0' and '1'. In one operation, you can change any '0' to '1' or vice versa. The string is called alternating if no two adjacent characters are equal. For example, the string "010" is alternating, while the string "0100" is not. Return the minimum number of oper...
minOperations(s: str) -> int
pub fn min_operations(s: &[u8]) -> i64
Aegis.MinOperations.min_operations
pub fn min_operations(s: &[u8]) -> i64 { let n = s.len(); let mut i: usize = 0; let mut mismatches: i64 = 0; let mut total: i64 = 0; while i < n { let expected_zero: u8; if i % 2 == 0 { expected_zero = b'0'; } else { expected_zero = b'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 @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_opti...
import Aegis.MinOperations.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.MinOperations.min_operations (Slice.from [49#u8, 49#u8, 49#u8, 49#u8] (by scalar_tac) : Slice Std.U8)) (2#i64))}") #eval (s!"CASE 1 {(Result.reduce...
[ { "input": "[\"1111\"]", "output": "2" }, { "input": "[\"101010\"]", "output": "0" }, { "input": "[\"111000\"]", "output": "2" }, { "input": "[\"1101101101\"]", "output": "4" }, { "input": "[\"001100\"]", "output": "3" }, { "input": "[\"10\"]", "ou...
117
false
117
verified
10
10
1
977
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MinOperations.Code.Funs /-! # Specifications of `Aegis.MinOperations.min_operations` LeetCode problem `minimum-changes-to-make-alternating-binary-string`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.MinOperations def byteAt (l : Lis...
10
count-number-of-homogenous-substrings
1,759
Medium
[ "Math", "String" ]
Given a string s, return the number of homogenous substrings of s. Since the answer may be too large, return it modulo 109 + 7. A string is homogenous if all the characters of the string are the same. A substring is a contiguous sequence of characters within a string.   Example 1: Input: s = "abbcccaa" Output: 13 Expl...
countHomogenous(s: str) -> int
pub fn count_homogenous(s: &[u8]) -> i64
Aegis.CountHomogenous.count_homogenous
pub fn count_homogenous(s: &[u8]) -> i64 { let modv: i64 = 1000000007; let n: usize = s.len(); let mut ans: i64 = 0; let mut cur: i64 = 0; let mut i: usize = 0; while i < n { if i == 0 { cur = 1; } else if s[i] == s[i - 1] { cur = cur + 1; } else ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [count_homogenous]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option lint...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [count_homogenous]: function definitions module public import Aeneas public import Aegis.CountHomogenous.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.CountHomogenous.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.CountHomogenous.count_homogenous (Slice.from [97#u8, 97#u8, 97#u8, 98#u8, 98#u8, 98#u8, 99#u8, 99#u8, 99#u8] (by scalar_tac) : Slice Std.U8)) (18...
[ { "input": "[\"aaabbbccc\"]", "output": "18" }, { "input": "[\"aabbccddeeefffggghhhiiii\"]", "output": "46" }, { "input": "[\"abcdefghijklmnopqrstuvwxyz\"]", "output": "26" }, { "input": "[\"xy\"]", "output": "2" }, { "input": "[\"aabbaa\"]", "output": "9" }...
78
false
78
verified
10
10
1
597
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.CountHomogenous.Code.Funs /-! # Specifications of `Aegis.CountHomogenous.count_homogenous` LeetCode problem `count-number-of-homogenous-substrings`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.CountHomogenous def bytesOf (s : Slice ...
13
minimum-limit-of-balls-in-a-bag
1,760
Medium
[ "Array", "Binary Search" ]
You are given an integer array nums where the ith bag contains nums[i] balls. You are also given an integer maxOperations. You can perform the following operation at most maxOperations times: Take any bag of balls and divide it into two new bags with a positive number of balls. For example, a bag of 5 balls can bec...
minimumSize(nums: list_int, maxOperations: int) -> int
pub fn minimum_size(nums: &[i64], maxOperations: i64) -> i64
Aegis.MinimumSize.minimum_size
pub fn minimum_size(nums: &[i64], maxOperations: i64) -> i64 { let n = nums.len(); let mut high: i64 = 1; let mut i: usize = 0; while i < n { if nums[i] > high { high = nums[i]; } i += 1; } let mut low: i64 = 1; while low < high { let mid: i64 = ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [minimum_size]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter.s...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [minimum_size]: function definitions module public import Aeneas public import Aegis.MinimumSize.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.MinimumSize.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.MinimumSize.minimum_size (Slice.from [1000000000#i64] (by scalar_tac) : Slice Std.I64) 1#i64) (500000000#i64))}") #eval (s!"CASE 1 {(Result.reducesTo...
[ { "input": "[[1000000000], 1]", "output": "500000000" }, { "input": "[[1000000000], 999999999]", "output": "1" }, { "input": "[[1000000000], 1000000000]", "output": "1" }, { "input": "[[9], 2]", "output": "3" }, { "input": "[[1000000000], 0]", "output": "10000...
99
false
99
verified
10
10
1
1,073
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MinimumSize.Code.Funs /-! # Specifications of `Aegis.MinimumSize.minimum_size` LeetCode problem `minimum-limit-of-balls-in-a-bag`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.MinimumSize open Aegis.MinimumSize def vals (nums : Slic...
16
minimum-degree-of-a-connected-trio-in-a-graph
1,761
Hard
[ "Graph" ]
You are given an undirected graph. You are given an integer n which is the number of nodes in the graph and an array edges, where each edges[i] = [ui, vi] indicates that there is an undirected edge between ui and vi. A connected trio is a set of three nodes where there is an edge between every pair of them. The degree ...
minTrioDegree(n: int, edges: list_list_int) -> int
pub fn min_trio_degree(n: i64, edges: &[Vec<i64>]) -> i64
Aegis.MinTrioDegree.min_trio_degree
pub fn min_trio_degree(n: i64, edges: &[Vec<i64>]) -> i64 { let nn: usize = n as usize; if nn < 3 { return -1; } // Degrees of all vertices. let mut deg: Vec<i64> = Vec::new(); let mut i: usize = 0; while i < nn { deg.push(0); i += 1; } let mut e: usize = 0;...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [min_trio_degree]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linte...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [min_trio_degree]: function definitions module public import Aeneas public import Aegis.MinTrioDegree.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.MinTrioDegree.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, [[1, 2], [2, 3]]]", "output": "-1" }, { "input": "[4, [[1, 2], [1, 3], [2, 3]]]", "output": "0" }, { "input": "[400, [[1, 2], [2, 3], [3, 1]]]", "output": "0" }, { "input": "[3, [[1, 2], [2, 3], [3, 1]]]", "output": "0" }, { "input": "[4, [[1, 2], ...
64
false
64
verified
10
10
3
42,174
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MinTrioDegree.Code.Funs /-! # Specifications of `Aegis.MinTrioDegree.min_trio_degree` LeetCode problem `minimum-degree-of-a-connected-trio-in-a-graph`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.MinTrioDegree (min_trio_degree) namespace Aegi...
9
buildings-with-an-ocean-view
1,762
Medium
[ "Stack", "Array", "Monotonic Stack" ]
There are n buildings in a line. You are given an integer array heights of size n that represents the heights of the buildings in the line. The ocean is to the right of the buildings. A building has an ocean view if the building can see the ocean without obstructions. Formally, a building has an ocean view if all the b...
findBuildings(heights: list_int) -> list_int
pub fn find_buildings(heights: &[i64]) -> Vec<i64>
Aegis.FindBuildings.find_buildings
pub fn find_buildings(heights: &[i64]) -> Vec<i64> { let n = heights.len(); if n == 0 { return Vec::new(); } let mut rev_indices: Vec<i64> = Vec::new(); let mut max_right: i64 = -1; let mut i = n; while i > 0 { i -= 1; let h = heights[i]; if h > max_right { ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [find_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_option linter...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [find_buildings]: function definitions module public import Aeneas public import Aegis.FindBuildings.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.FindBuildings.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.FindBuildings.find_buildings (Slice.from [1#i64] (by scalar_tac) : Slice Std.I64)) ((alloc.vec.Vec.from [0#i64] (by scalar_tac) : alloc.vec.Vec Std...
[ { "input": "[[1]]", "output": "[0]" }, { "input": "[[1, 3, 2, 4]]", "output": "[3]" }, { "input": "[[5, 5, 5, 5]]", "output": "[3]" }, { "input": "[[1, 2, 3, 4, 5]]", "output": "[4]" }, { "input": "[[1, 2, 2, 1]]", "output": "[2, 3]" }, { "input": "[[5...
128
false
128
verified
10
10
1
833
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.FindBuildings.Code.Funs /-! # Specifications of `Aegis.FindBuildings.find_buildings` LeetCode problem `buildings-with-an-ocean-view`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.FindBuildings def elem (l : List Std.I64) (i : Nat...
16
form-array-by-concatenating-subarrays-of-another-array
1,764
Medium
[ "Greedy", "Array", "Two Pointers", "String Matching" ]
You are given a 2D integer array groups of length n. You are also given an integer array nums. You are asked if you can choose n disjoint subarrays from the array nums such that the ith subarray is equal to groups[i] (0-indexed), and if i > 0, the (i-1)th subarray appears before the ith subarray in nums (i.e. the subar...
canChoose(groups: list_list_int, nums: list_int) -> bool
pub fn can_choose(groups: &[Vec<i64>], nums: &[i64]) -> bool
Aegis.CanChoose.can_choose
pub fn can_choose(groups: &[Vec<i64>], nums: &[i64]) -> bool { let m = nums.len(); let mut pos: usize = 0; let mut g: usize = 0; while g < groups.len() { let glen = groups[g].len(); let mut found = false; let mut start = pos; while start + glen <= m && !found { ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [can_choose]: type definitions module public import Aeneas @[expose] public section 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 -- [can_choose]: function definitions module public import Aeneas public import Aegis.CanChoose.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.CanChoose.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.CanChoose.can_choose (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]], [1]]", "output": "true" }, { "input": "[[[1]], [2]]", "output": "false" }, { "input": "[[[1], [2], [3]], [3, 2, 1]]", "output": "false" }, { "input": "[[[1], [2], [3]], [1, 2, 3]]", "output": "true" }, { "input": "[[[5, 5]], [5, 5, 5, 5]]", ...
148
false
148
verified
10
10
1
1,448
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.CanChoose.Code.Funs /-! # Specifications of `Aegis.CanChoose.can_choose` LeetCode problem `form-array-by-concatenating-subarrays-of-another-array`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.CanChoose abbrev I64 := Aeneas.Std.I64 ...
15
map-of-highest-peak
1,765
Medium
[ "Breadth-First Search", "Array", "Matrix" ]
You are given an integer matrix isWater of size m x n that represents a map of land and water cells. If isWater[i][j] == 0, cell (i, j) is a land cell. If isWater[i][j] == 1, cell (i, j) is a water cell. You must assign each cell a height in a way that follows these rules: The height of each cell must be non-negativ...
highestPeak(isWater: list_list_int) -> list_list_int
pub fn highest_peak(isWater: &[Vec<i64>]) -> Vec<Vec<i64>>
Aegis.HighestPeak.highest_peak
pub fn highest_peak(isWater: &[Vec<i64>]) -> Vec<Vec<i64>> { let m = isWater.len(); if m == 0 { return Vec::new(); } let n = isWater[0].len(); let inf: i64 = 1000000; let mut height: Vec<Vec<i64>> = Vec::new(); let mut i: usize = 0; while i < m { let mut row: Vec<i64> =...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [highest_peak]: type definitions module public import Aeneas @[expose] public section 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 -- [highest_peak]: function definitions module public import Aeneas public import Aegis.HighestPeak.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.HighestPeak.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.HighestPeak.highest_peak (Slice.from [(alloc.vec.Vec.from [0#i64, 1#i64] (by scalar_tac) : alloc.vec.Vec Std.I64), (alloc.vec.Vec.from [0#i64, 0#i64]...
[ { "input": "[[[0, 1], [0, 0]]]", "output": "[[1, 0], [2, 1]]" }, { "input": "[[[1, 1], [1, 1]]]", "output": "[[0, 0], [0, 0]]" }, { "input": "[[[0, 0, 0], [0, 1, 0], [0, 0, 0]]]", "output": "[[2, 1, 2], [1, 0, 1], [2, 1, 2]]" }, { "input": "[[[0, 0, 1], [1, 0, 0], [0, 0, 0]]]...
68
false
68
verified
10
10
1
10,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.HighestPeak.Code.Funs /-! # Specifications of `Aegis.HighestPeak.highest_peak` LeetCode problem `map-of-highest-peak`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.HighestPeak namespace AegisSpec.HighestPeak def numRows (isWater : Slice (allo...
13
tree-of-coprimes
1,766
Hard
[ "Tree", "Depth-First Search", "Array", "Math", "Number Theory" ]
There is a tree (i.e., a connected, undirected graph that has no cycles) consisting of n nodes numbered from 0 to n - 1 and exactly n - 1 edges. Each node has a value associated with it, and the root of the tree is node 0. To represent this tree, you are given an integer array nums and a 2D array edges. Each nums[i] re...
getCoprimes(nums: list_int, edges: list_list_int) -> list_int
pub fn get_coprimes(nums: &[i64], edges: &[Vec<i64>]) -> Vec<i64>
Aegis.GetCoprimes.get_coprimes
fn gcd(mut a: i64, mut b: i64) -> i64 { while b != 0 { let t = a % b; a = b; b = t; } if a < 0 { -a } else { a } } pub fn get_coprimes(nums: &[i64], edges: &[Vec<i64>]) -> Vec<i64> { let n = nums.len(); let mut ans: Vec<i64> = Vec::new(); let mut...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [get_coprimes]: type definitions module public import Aeneas @[expose] public section 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 -- [get_coprimes]: function definitions module public import Aeneas public import Aegis.GetCoprimes.Code.Types public import Aegis.GetCoprimes.Code.FunsExternal @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace fals...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [get_coprimes]: external functions. -- This is a template file: rename it to "FunsExternal.lean" and fill the holes. module public import Aeneas public import Aegis.GetCoprimes.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_o...
import Aegis.GetCoprimes.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.GetCoprimes.get_coprimes (Slice.from [2#i64, 3#i64, 3#i64, 2#i64] (by scalar_tac) : Slice Std.I64) (Slice.from [(alloc.vec.Vec.from [0#i64, 1#i64] (b...
[ { "input": "[[2, 3, 3, 2], [[0, 1], [1, 2], [1, 3]]]", "output": "[-1, 0, 0, 1]" }, { "input": "[[5, 6, 10, 2, 3, 6, 15], [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6]]]", "output": "[-1, 0, -1, 0, 0, 0, -1]" }, { "input": "[[7, 11, 13, 17, 19, 23, 29, 31, 37, 41], [[0, 1], [0, 2], [1,...
31
false
31
verified
10
10
6
101,597
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.GetCoprimes.Code.Funs /-! # Specifications of `Aegis.GetCoprimes.get_coprimes` LeetCode problem `tree-of-coprimes`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.GetCoprimes open Aegis.GetCoprimes def atI (l : List I64) (i : Na...
16
minimum-number-of-operations-to-move-all-balls-to-each-box
1,769
Medium
[ "Array", "String", "Prefix Sum" ]
You have n boxes. You are given a binary string boxes of length n, where boxes[i] is '0' if the ith box is empty, and '1' if it contains one ball. In one operation, you can move one ball from a box to an adjacent box. Box i is adjacent to box j if abs(i - j) == 1. Note that after doing so, there may be more than one ba...
minOperations(boxes: str) -> list_int
pub fn min_operations(boxes: &[u8]) -> Vec<i64>
Aegis.MinOperations.min_operations
pub fn min_operations(boxes: &[u8]) -> Vec<i64> { let n = boxes.len(); let mut ans: Vec<i64> = Vec::new(); let mut i = 0; while i < n { ans.push(0); i += 1; } let mut count: i64 = 0; let mut cost: i64 = 0; let mut idx: usize = 0; while idx < n { ans[idx] = an...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [min_operations]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [min_operations]: function definitions module public import Aeneas public import Aegis.MinOperations.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_opti...
import Aegis.MinOperations.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.MinOperations.min_operations (Slice.from [49#u8, 49#u8, 48#u8] (by scalar_tac) : Slice Std.U8)) ((alloc.vec.Vec.from [1#i64, 1#i64, 3#i64] (by scal...
[ { "input": "[\"110\"]", "output": "[1, 1, 3]" }, { "input": "[\"1111\"]", "output": "[6, 4, 4, 6]" }, { "input": "[\"0000\"]", "output": "[0, 0, 0, 0]" }, { "input": "[\"11111\"]", "output": "[10, 7, 6, 7, 10]" }, { "input": "[\"00000\"]", "output": "[0, 0, 0,...
85
false
85
verified
10
10
1
945
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": 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-move-all-balls-to-each-box`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.MinOperations namespace AegisSpec....
13
maximum-score-from-performing-multiplication-operations
1,770
Hard
[ "Array", "Dynamic Programming" ]
You are given two 0-indexed integer arrays nums and multipliers of size n and m respectively, where n >= m. You begin with a score of 0. You want to perform exactly m operations. On the ith operation (0-indexed) you will: Choose one integer x from either the start or the end of the array nums. Add multipliers[i] * x t...
maximumScore(nums: list_int, multipliers: list_int) -> int
pub fn maximum_score(nums: &[i64], multipliers: &[i64]) -> i64
Aegis.MaximumScore.maximum_score
pub fn maximum_score(nums: &[i64], multipliers: &[i64]) -> i64 { let n: usize = nums.len(); let m: usize = multipliers.len(); if m == 0 { return 0; } let neg: i64 = -1000000000000000000; let mut dp: Vec<i64> = Vec::new(); let mut k: usize = 0; while k <= m { dp.push(ne...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [maximum_score]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter....
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [maximum_score]: function definitions module public import Aeneas public import Aegis.MaximumScore.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.MaximumScore.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.MaximumScore.maximum_score (Slice.from [1#i64] (by scalar_tac) : Slice Std.I64) (Slice.from [1#i64] (by scalar_tac) : Slice Std.I64)) (1#i64))}") #e...
[ { "input": "[[1], [1]]", "output": "1" }, { "input": "[[100, 200, 300], [1, 2]]", "output": "700" }, { "input": "[[1, 2, 3], [3, 2, 1]]", "output": "14" }, { "input": "[[-1, -2, -3, -4, -5], [-1, -2, -3]]", "output": "23" }, { "input": "[[9, 8, 7, 6, 5], [-1, -2, ...
118
false
118
verified
10
10
1
2,643
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MaximumScore.Code.Funs /-! # Specifications of `Aegis.MaximumScore.maximum_score` LeetCode problem `maximum-score-from-performing-multiplication-operations`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.MaximumScore def entry (s : Sl...
16
maximize-palindrome-length-from-subsequences
1,771
Hard
[ "String", "Dynamic Programming" ]
You are given two strings, word1 and word2. You want to construct a string in the following manner: Choose some non-empty subsequence subsequence1 from word1. Choose some non-empty subsequence subsequence2 from word2. Concatenate the subsequences: subsequence1 + subsequence2, to make the string. Return the length of ...
longestPalindrome(word1: str, word2: str) -> int
pub fn longest_palindrome(word1: &[u8], word2: &[u8]) -> i64
Aegis.LongestPalindrome.longest_palindrome
pub fn longest_palindrome(word1: &[u8], word2: &[u8]) -> i64 { let n1: usize = word1.len(); let n2: usize = word2.len(); let n: usize = n1 + n2; let mut s: Vec<u8> = Vec::new(); let mut i: usize = 0; while i < n1 { s.push(word1[i]); i += 1; } i = 0; while i < n2 { ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [longest_palindrome]: type definitions module public import Aeneas @[expose] public section 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 -- [longest_palindrome]: function definitions module public import Aeneas public import Aegis.LongestPalindrome.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false ...
import Aegis.LongestPalindrome.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.LongestPalindrome.longest_palindrome (Slice.from [114#u8, 97#u8, 99#u8, 101#u8] (by scalar_tac) : Slice Std.U8) (Slice.from [99#u8, 97#u8, 114#...
[ { "input": "[\"race\", \"car\"]", "output": "7" }, { "input": "[\"a\", \"a\"]", "output": "2" }, { "input": "[\"aabb\", \"bbcc\"]", "output": "4" }, { "input": "[\"race\", \"care\"]", "output": "7" }, { "input": "[\"abcde\", \"edcba\"]", "output": "10" }, ...
120
false
120
verified
10
10
1
6,586
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.LongestPalindrome.Code.Funs /-! # Specifications of `Aegis.LongestPalindrome.longest_palindrome` LeetCode problem `maximize-palindrome-length-from-subsequences`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.LongestPalindrome open...
14
sort-features-by-popularity
1,772
Medium
[ "Array", "Hash Table", "String", "Sorting" ]
You are given a string array features where features[i] is a single word that represents the name of a feature of the latest product you are working on. You have made a survey where users have reported which features they like. You are given a string array responses, where each responses[i] is a string containing space...
sortFeatures(features: list_str, responses: list_str) -> list_str
pub fn sort_features(features: &[Vec<u8>], responses: &[Vec<u8>]) -> Vec<Vec<u8>>
Aegis.SortFeatures.sort_features
pub fn sort_features(features: &[Vec<u8>], responses: &[Vec<u8>]) -> Vec<Vec<u8>> { let n = features.len(); let rn = responses.len(); // pop[i] = number of responses containing feature i (at least once). let mut pop: Vec<i64> = Vec::new(); let mut i: usize = 0; while i < n { pop.push(0)...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [sort_features]: type definitions module public import Aeneas @[expose] public section 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 -- [sort_features]: function definitions module public import Aeneas public import Aegis.SortFeatures.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.SortFeatures.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.SortFeatures.sort_features (Slice.from [(alloc.vec.Vec.from [99#u8, 111#u8, 111#u8, 108#u8, 101#u8, 114#u8] (by scalar_tac) : alloc.vec.Vec Std.U8),...
[ { "input": "[[\"cooler\", \"lock\", \"touch\"], [\"i like cooler cooler\", \"lock touch cool\", \"locker like touch\"]]", "output": "[\"touch\", \"cooler\", \"lock\"]" }, { "input": "[[\"a\", \"aa\", \"b\", \"c\"], [\"a\", \"a aa\", \"a a a a a\", \"b a\"]]", "output": "[\"a\", \"aa\", \"b\", \"...
52
false
52
verified
10
10
3
25,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.SortFeatures.Code.Funs /-! # Specifications of `Aegis.SortFeatures.sort_features` LeetCode problem `sort-features-by-popularity`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.SortFeatures abbrev Bytes : Type := List Std.U8 def space...
8
closest-dessert-cost
1,774
Medium
[ "Array", "Dynamic Programming", "Backtracking" ]
You would like to make dessert and are preparing to buy the ingredients. You have n ice cream base flavors and m types of toppings to choose from. You must follow these rules when making your dessert: There must be exactly one ice cream base. You can add one or more types of topping or have no toppings at all. There a...
closestCost(baseCosts: list_int, toppingCosts: list_int, target: int) -> int
pub fn closest_cost(baseCosts: &[i64], toppingCosts: &[i64], target: i64) -> i64
Aegis.ClosestCost.closest_cost
pub fn closest_cost(baseCosts: &[i64], toppingCosts: &[i64], target: i64) -> i64 { let mut sums: Vec<i64> = Vec::new(); sums.push(0); let m = toppingCosts.len(); let mut i = 0; while i < m { let t = toppingCosts[i]; let old_len = sums.len(); let mut additions: Vec<i64> = Vec...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [closest_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 -- [closest_cost]: function definitions module public import Aeneas public import Aegis.ClosestCost.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.ClosestCost.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.ClosestCost.closest_cost (Slice.from [1#i64, 7#i64] (by scalar_tac) : Slice Std.I64) (Slice.from [3#i64, 4#i64] (by scalar_tac) : Slice Std.I64) 10#i...
[ { "input": "[[1, 7], [3, 4], 10]", "output": "10" }, { "input": "[[4, 8], [1, 3], 15]", "output": "15" }, { "input": "[[5], [1, 2, 3], 8]", "output": "8" }, { "input": "[[4], [1, 2, 3], 8]", "output": "8" }, { "input": "[[3, 10], [2, 5], 9]", "output": "8" }...
99
false
99
verified
10
10
1
1,884
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.ClosestCost.Code.Funs /-! # Specifications of `Aegis.ClosestCost.closest_cost` LeetCode problem `closest-dessert-cost`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.ClosestCost open Aegis.ClosestCost def sliceInts (s : Slice I64) : ...
16
find-nearest-point-that-has-the-same-x-or-y-coordinate
1,779
Easy
[ "Array" ]
You are given two integers, x and y, which represent your current location on a Cartesian grid: (x, y). You are also given an array points where each points[i] = [ai, bi] represents that a point exists at (ai, bi). A point is valid if it shares the same x-coordinate or the same y-coordinate as your location. Return the...
nearestValidPoint(x: int, y: int, points: list_list_int) -> int
pub fn nearest_valid_point(x: i64, y: i64, points: &[Vec<i64>]) -> i64
Aegis.NearestValidPoint.nearest_valid_point
pub fn nearest_valid_point(x: i64, y: i64, points: &[Vec<i64>]) -> i64 { let n = points.len(); let mut i: usize = 0; let mut index: i64 = 0; let mut best_index: i64 = -1; let mut best_dist: i64 = 0; let mut found: bool = false; while i < n { let px = points[i][0]; let py = p...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [nearest_valid_point]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option l...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [nearest_valid_point]: function definitions module public import Aeneas public import Aegis.NearestValidPoint.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false...
import Aegis.NearestValidPoint.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.NearestValidPoint.nearest_valid_point 3#i64 4#i64 (Slice.from [(alloc.vec.Vec.from [3#i64, 4#i64] (by scalar_tac) : alloc.vec.Vec Std.I64)] (by...
[ { "input": "[3, 4, [[3, 4]]]", "output": "0" }, { "input": "[3, 4, [[2, 3]]]", "output": "-1" }, { "input": "[1, 1, [[2, 2], [3, 3], [4, 4]]]", "output": "-1" }, { "input": "[5, 5, [[10, 10], [5, 5], [1, 1]]]", "output": "1" }, { "input": "[5, 5, [[5, 5], [6, 6], ...
121
false
121
verified
10
10
1
916
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.NearestValidPoint.Code.Funs /-! # Specifications of `Aegis.NearestValidPoint.nearest_valid_point` LeetCode problem `find-nearest-point-that-has-the-same-x-or-y-coordinate`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.NearestValidPo...
10
check-if-number-is-a-sum-of-powers-of-three
1,780
Medium
[ "Math" ]
Given an integer n, return true if it is possible to represent n as the sum of distinct powers of three. Otherwise, return false. An integer y is a power of three if there exists an integer x such that y == 3x.   Example 1: Input: n = 12 Output: true Explanation: 12 = 31 + 32 Example 2: Input: n = 91 Output: true Ex...
checkPowersOfThree(n: int) -> bool
pub fn check_powers_of_three(n: i64) -> bool
Aegis.CheckPowersOfThree.check_powers_of_three
pub fn check_powers_of_three(n: i64) -> bool { let mut x = n; while x > 0 { if x % 3 == 2 { return false; } x = x / 3; } true }
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [check_powers_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...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [check_powers_of_three]: function definitions module public import Aeneas public import Aegis.CheckPowersOfThree.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand fa...
import Aegis.CheckPowersOfThree.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.CheckPowersOfThree.check_powers_of_three 59049#i64) (true))}") #eval (s!"CASE 1 {(Result.reducesTo (Aegis.CheckPowersOfThree.check_powers_of_t...
[ { "input": "[59049]", "output": "true" }, { "input": "[3]", "output": "true" }, { "input": "[729]", "output": "true" }, { "input": "[12]", "output": "true" }, { "input": "[243]", "output": "true" }, { "input": "[21]", "output": "false" }, { ...
110
false
110
verified
10
10
1
306
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.CheckPowersOfThree.Code.Funs /-! # Specifications of `Aegis.CheckPowersOfThree.check_powers_of_three` LeetCode problem `check-if-number-is-a-sum-of-powers-of-three`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.CheckPowersOfThree ...
10
sum-of-beauty-of-all-substrings
1,781
Medium
[ "Hash Table", "String", "Counting" ]
The beauty of a string is the difference in frequencies between the most frequent and least frequent characters. For example, the beauty of "abaacc" is 3 - 1 = 2. Given a string s, return the sum of beauty of all of its substrings.   Example 1: Input: s = "aabcb" Output: 5 Explanation: The substrings with non-zero b...
beautySum(s: str) -> int
pub fn beauty_sum(s: &[u8]) -> i64
Aegis.BeautySum.beauty_sum
pub fn beauty_sum(s: &[u8]) -> i64 { let n = s.len(); let mut total: i64 = 0; let mut i: usize = 0; while i < n { let mut cnt: Vec<i64> = Vec::new(); let mut k: usize = 0; while k < 26 { cnt.push(0); k += 1; } let mut j: usize = i; ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [beauty_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.sty...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [beauty_sum]: function definitions module public import Aeneas public import Aegis.BeautySum.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.BeautySum.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.BeautySum.beauty_sum (Slice.from [120#u8, 121#u8, 122#u8, 122#u8, 120#u8, 121#u8, 122#u8, 122#u8, 120#u8, 121#u8, 122#u8, 122#u8] (by scalar_tac) : Sli...
[ { "input": "[\"xyzzxyzzxyzz\"]", "output": "87" }, { "input": "[\"aaabbbccc\"]", "output": "29" }, { "input": "[\"aabcb\"]", "output": "5" }, { "input": "[\"abcdefghijklmnopqrstuvwxyz\"]", "output": "0" }, { "input": "[\"abcdedcba\"]", "output": "16" }, { ...
103
false
103
verified
10
10
1
1,148
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.BeautySum.Code.Funs /-! # Specifications of `Aegis.BeautySum.beauty_sum` LeetCode problem `sum-of-beauty-of-all-substrings`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.BeautySum open Aegis.BeautySum def byteList (s : Slice S...
15
count-pairs-of-nodes
1,782
Hard
[ "Graph", "Array", "Two Pointers", "Binary Search", "Sorting" ]
You are given an undirected graph defined by an integer n, the number of nodes, and a 2D integer array edges, the edges in the graph, where edges[i] = [ui, vi] indicates that there is an undirected edge between ui and vi. You are also given an integer array queries. Let incident(a, b) be defined as the number of edges ...
countPairs(n: int, edges: list_list_int, queries: list_int) -> list_int
pub fn count_pairs(n: i64, edges: &[Vec<i64>], queries: &[i64]) -> Vec<i64>
Aegis.CountPairs.count_pairs
fn sort_i64_vec(mut v: Vec<i64>) -> Vec<i64> { let n = v.len(); if n <= 1 { return v; } let mut width: usize = 1; while width < n { let mut next: Vec<i64> = Vec::new(); let mut left: usize = 0; while left < n { let mut mid = left + width; if ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [count_pairs]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter.st...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [count_pairs]: function definitions module public import Aeneas public import Aegis.CountPairs.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option lin...
import Aegis.CountPairs.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.CountPairs.count_pairs 4#i64 (Slice.from [(alloc.vec.Vec.from [1#i64, 2#i64] (by scalar_tac) : alloc.vec.Vec Std.I64), (alloc.vec.Vec.from [2#i64, 4#i...
[ { "input": "[4, [[1, 2], [2, 4], [1, 3], [2, 3], [2, 1]], [2, 3]]", "output": "[6, 5]" }, { "input": "[5, [[1, 5], [1, 5], [3, 4], [2, 5], [1, 3], [5, 1], [2, 3], [2, 5]], [1, 2, 3, 4, 5]]", "output": "[10, 10, 9, 8, 6]" }, { "input": "[10, [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7]...
50
false
50
verified
10
10
1
15,741
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.CountPairs.Code.Funs /-! # Specifications of `Aegis.CountPairs.count_pairs` LeetCode problem `count-pairs-of-nodes`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result ControlFlow Error open Aegis.CountPairs set_option maxHeartbeats 1000000 namespace Ae...
17
check-if-binary-string-has-at-most-one-segment-of-ones
1,784
Easy
[ "String" ]
Given a binary string s ​​​​​without leading zeros, return true​​​ if s contains at most one contiguous segment of ones. Otherwise, return false.   Example 1: Input: s = "1001" Output: false Explanation: The ones do not form a contiguous segment. Example 2: Input: s = "110" Output: true   Constraints: 1 <= s.length...
checkOnesSegment(s: str) -> bool
pub fn check_ones_segment(s: &[u8]) -> bool
Aegis.CheckOnesSegment.check_ones_segment
pub fn check_ones_segment(s: &[u8]) -> bool { let n = s.len(); let mut segments: i64 = 0; let mut i: usize = 0; while i < n { if s[i] == b'1' { if i == 0 || s[i - 1] != b'1' { segments += 1; } } i += 1; } segments <= 1 }
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [check_ones_segment]: type definitions module public import Aeneas @[expose] public section 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 -- [check_ones_segment]: function definitions module public import Aeneas public import Aegis.CheckOnesSegment.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.CheckOnesSegment.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.CheckOnesSegment.check_ones_segment (Slice.from [49#u8, 49#u8, 49#u8, 49#u8] (by scalar_tac) : Slice Std.U8)) (true))}") #eval (s!"CASE 1 {(Resu...
[ { "input": "[\"1111\"]", "output": "true" }, { "input": "[\"1000001\"]", "output": "false" }, { "input": "[\"111\"]", "output": "true" }, { "input": "[\"11110000\"]", "output": "true" }, { "input": "[\"100000\"]", "output": "true" }, { "input": "[\"110...
113
false
113
verified
10
10
1
385
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.CheckOnesSegment.Code.Funs /-! # Specifications of `Aegis.CheckOnesSegment.check_ones_segment` LeetCode problem `check-if-binary-string-has-at-most-one-segment-of-ones`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.CheckOnesSegment ...
15
minimum-elements-to-add-to-form-a-given-sum
1,785
Medium
[ "Greedy", "Array" ]
You are given an integer array nums and two integers limit and goal. The array nums has an interesting property that abs(nums[i]) <= limit. Return the minimum number of elements you need to add to make the sum of the array equal to goal. The array must maintain its property that abs(nums[i]) <= limit. Note that abs(x) ...
minElements(nums: list_int, limit: int, goal: int) -> int
pub fn min_elements(nums: &[i64], limit: i64, goal: i64) -> i64
Aegis.MinElements.min_elements
pub fn min_elements(nums: &[i64], limit: i64, goal: i64) -> i64 { let mut sum: i64 = 0; let mut i: usize = 0; while i < nums.len() { sum += nums[i]; i += 1; } let mut diff: i64 = goal - sum; if diff < 0 { diff = -diff; } if diff == 0 { return 0; } ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [min_elements]: type definitions module public import Aeneas @[expose] public section 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_elements]: function definitions module public import Aeneas public import Aegis.MinElements.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.MinElements.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.MinElements.min_elements (Slice.from [1000000#i64] (by scalar_tac) : Slice Std.I64) 500000#i64 2000000#i64) (2#i64))}") #eval (s!"CASE 1 {(Result.red...
[ { "input": "[[1000000], 500000, 2000000]", "output": "2" }, { "input": "[[1, -1, 1], 3, -4]", "output": "2" }, { "input": "[[1, 2, 3], 1, 6]", "output": "0" }, { "input": "[[0, 0, 0], 1, 3]", "output": "3" }, { "input": "[[2, 2, 2], 2, 6]", "output": "0" }, ...
106
false
106
verified
10
10
1
480
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MinElements.Code.Funs /-! # Specifications of `Aegis.MinElements.min_elements` LeetCode problem `minimum-elements-to-add-to-form-a-given-sum`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.MinElements def total (nums : Slice Std.I...
8
number-of-restricted-paths-from-first-to-last-node
1,786
Medium
[ "Graph", "Topological Sort", "Dynamic Programming", "Shortest Path", "Heap (Priority Queue)" ]
There is an undirected weighted connected graph. You are given a positive integer n which denotes that the graph has n nodes labeled from 1 to n, and an array edges where each edges[i] = [ui, vi, weighti] denotes that there is an edge between nodes ui and vi with weight equal to weighti. A path from node start to node ...
countRestrictedPaths(n: int, edges: list_list_int) -> int
pub fn count_restricted_paths(n: i64, edges: &[Vec<i64>]) -> i64
Aegis.CountRestrictedPaths.count_restricted_paths
fn heap_push(heap: &mut Vec<i64>, x: i64) { heap.push(x); let mut i = heap.len() - 1; let mut stop = false; while i > 0 && !stop { let p = (i - 1) / 2; if heap[p] <= heap[i] { stop = true; } else { let tmp = heap[p]; heap[p] = heap[i]; ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [count_restricted_paths]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_optio...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [count_restricted_paths]: function definitions module public import Aeneas public import Aegis.CountRestrictedPaths.Code.Types public import Aegis.CountRestrictedPaths.Code.FunsExternal @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_opt...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [count_restricted_paths]: external functions. -- This is a template file: rename it to "FunsExternal.lean" and fill the holes. module public import Aeneas public import Aegis.CountRestrictedPaths.Code.Types @[expose] public section open Aeneas Aeneas.Std Result Cont...
import Aegis.CountRestrictedPaths.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.CountRestrictedPaths.count_restricted_paths 3#i64 (Slice.from [(alloc.vec.Vec.from [1#i64, 2#i64, 5#i64] (by scalar_tac) : alloc.vec.Vec Std...
[ { "input": "[3, [[1, 2, 5], [1, 3, 6], [2, 3, 1]]]", "output": "2" }, { "input": "[4, [[1, 2, 1], [2, 3, 2], [3, 4, 3], [4, 1, 4]]]", "output": "1" }, { "input": "[6, [[1, 2, 2], [1, 3, 4], [2, 4, 3], [3, 4, 1], [4, 5, 2], [5, 6, 1]]]", "output": "2" }, { "input": "[5, [[1, 2...
45
false
45
verified
10
10
1
11,702
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.CountRestrictedPaths.Code.Funs /-! # Specifications of `Aegis.CountRestrictedPaths.count_restricted_paths` LeetCode problem `number-of-restricted-paths-from-first-to-last-node`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result set_option autoImplicit false...
6
make-the-xor-of-all-segments-equal-to-zero
1,787
Hard
[ "Bit Manipulation", "Array", "Dynamic Programming" ]
You are given an array nums​​​ and an integer k​​​​​. The XOR of a segment [left, right] where left <= right is the XOR of all the elements with indices between left and right, inclusive: nums[left] XOR nums[left+1] XOR ... XOR nums[right]. Return the minimum number of elements to change in the array such that the XOR ...
minChanges(nums: list_int, k: int) -> int
pub fn min_changes(nums: &[i64], k: i64) -> i64
Aegis.MinChanges.min_changes
pub fn min_changes(nums: &[i64], k: i64) -> i64 { const M: usize = 1024; const INF: i64 = 1_000_000_000; let n = nums.len(); let kk = k as usize; let mut dp: Vec<i64> = Vec::new(); dp.push(0); let mut i: usize = 1; while i < M { dp.push(INF); i += 1; } let mut ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [min_changes]: type definitions module public import Aeneas @[expose] public section 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 -- [min_changes]: function definitions module public import Aeneas public import Aegis.MinChanges.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.MinChanges.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.MinChanges.min_changes (Slice.from [0#i64, 0#i64, 0#i64, 0#i64, 0#i64] (by scalar_tac) : Slice Std.I64) 2#i64) (0#i64))}") #eval (s!"CASE 1 {(Result.r...
[ { "input": "[[0, 0, 0, 0, 0], 2]", "output": "0" }, { "input": "[[1, 1, 1, 1, 1], 5]", "output": "1" }, { "input": "[[1, 3, 5, 7, 9], 5]", "output": "1" }, { "input": "[[1, 2, 0, 3, 0], 1]", "output": "3" }, { "input": "[[1, 1, 1, 1, 1, 1], 6]", "output": "0" ...
113
false
113
verified
10
10
1
13,437
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MinChanges.Code.Funs /-! # Specifications of `Aegis.MinChanges.min_changes` LeetCode problem `make-the-xor-of-all-segments-equal-to-zero`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.MinChanges def xorAll : List Std.I64 → Std.I64 ...
16
find-center-of-star-graph
1,791
Easy
[ "Graph" ]
There is an undirected star graph consisting of n nodes labeled from 1 to n. A star graph is a graph where there is one center node and exactly n - 1 edges that connect the center node with every other node. You are given a 2D integer array edges where each edges[i] = [ui, vi] indicates that there is an edge between th...
findCenter(edges: list_list_int) -> int
pub fn find_center(edges: &[Vec<i64>]) -> i64
Aegis.FindCenter.find_center
pub fn find_center(edges: &[Vec<i64>]) -> i64 { let a0 = edges[0][0]; let a1 = edges[0][1]; let b0 = edges[1][0]; let b1 = edges[1][1]; if a0 == b0 || a0 == b1 { a0 } else { a1 } }
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [find_center]: type definitions module public import Aeneas @[expose] public section 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 -- [find_center]: function definitions module public import Aeneas public import Aegis.FindCenter.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.FindCenter.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.FindCenter.find_center (Slice.from [(alloc.vec.Vec.from [3#i64, 1#i64] (by scalar_tac) : alloc.vec.Vec Std.I64), (alloc.vec.Vec.from [2#i64, 1#i64] (b...
[ { "input": "[[[3, 1], [2, 1]]]", "output": "1" }, { "input": "[[[1, 2], [2, 3], [4, 2]]]", "output": "2" }, { "input": "[[[3, 1], [1, 2], [1, 4], [1, 5]]]", "output": "1" }, { "input": "[[[10, 5], [10, 8], [10, 3], [10, 1]]]", "output": "10" }, { "input": "[[[4, 3...
58
false
58
verified
10
10
1
391
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.FindCenter.Code.Funs /-! # Specifications of `Aegis.FindCenter.find_center` LeetCode problem `find-center-of-star-graph`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.FindCenter (find_center) namespace AegisSpec.FindCenter def vecInts (e : al...
10
maximum-score-of-a-good-subarray
1,793
Hard
[ "Stack", "Array", "Two Pointers", "Binary Search", "Monotonic Stack" ]
You are given an array of integers nums (0-indexed) and an integer k. The score of a subarray (i, j) is defined as min(nums[i], nums[i+1], ..., nums[j]) * (j - i + 1). A good subarray is a subarray where i <= k <= j. Return the maximum possible score of a good subarray.   Example 1: Input: nums = [1,4,3,7,4,5], k = 3 ...
maximumScore(nums: list_int, k: int) -> int
pub fn maximum_score(nums: &[i64], k: i64) -> i64
Aegis.MaximumScore.maximum_score
pub fn maximum_score(nums: &[i64], k: i64) -> i64 { let n = nums.len(); let mut start: usize = 0; let mut pos: i64 = 0; while pos < k { start += 1; pos += 1; } let mut left = start; let mut right = start; let mut cur_min = nums[start]; let mut best = cur_min; le...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [maximum_score]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter....
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [maximum_score]: function definitions module public import Aeneas public import Aegis.MaximumScore.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.MaximumScore.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.MaximumScore.maximum_score (Slice.from [10#i64, 10#i64, 10#i64, 10#i64, 10#i64] (by scalar_tac) : Slice Std.I64) 2#i64) (50#i64))}") #eval (s!"CASE ...
[ { "input": "[[10, 10, 10, 10, 10], 2]", "output": "50" }, { "input": "[[9, 7, 5, 3, 1], 2]", "output": "15" }, { "input": "[[1, 2, 3, 4, 5], 2]", "output": "9" }, { "input": "[[10, 20, 30, 40, 50], 2]", "output": "90" }, { "input": "[[1, 4, 3, 7, 4, 5], 3]", "...
98
false
98
verified
10
10
1
2,814
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MaximumScore.Code.Funs /-! # Specifications of `Aegis.MaximumScore.maximum_score` LeetCode problem `maximum-score-of-a-good-subarray`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.MaximumScore (maximum_score) namespace AegisSpec.MaximumScore ...
9
count-pairs-of-equal-substrings-with-minimum-difference
1,794
Medium
[ "Greedy", "Hash Table", "String" ]
You are given two strings firstString and secondString that are 0-indexed and consist only of lowercase English letters. Count the number of index quadruples (i,j,a,b) that satisfy the following conditions: 0 <= i <= j < firstString.length 0 <= a <= b < secondString.length The substring of firstString that starts at t...
countQuadruples(firstString: str, secondString: str) -> int
pub fn count_quadruples(firstString: &[u8], secondString: &[u8]) -> i64
Aegis.CountQuadruples.count_quadruples
pub fn count_quadruples(first_string: &[u8], second_string: &[u8]) -> i64 { let mut first: Vec<i64> = Vec::new(); let mut last: Vec<i64> = Vec::new(); let mut k: usize = 0; while k < 26 { first.push(-1); last.push(-1); k += 1; } let n = first_string.len(); let mut i...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [count_quadruples]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option lint...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [count_quadruples]: function definitions module public import Aeneas public import Aegis.CountQuadruples.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.CountQuadruples.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.CountQuadruples.count_quadruples (Slice.from [97#u8, 98#u8, 99#u8, 100#u8, 101#u8, 102#u8, 103#u8, 104#u8, 105#u8, 106#u8, 107#u8, 108#u8, 109#u8...
[ { "input": "[\"abcdefghijklmnopqrstuvwxyz\", \"zyxwvutsrqponmlkjihgfedcba\"]", "output": "1" }, { "input": "[\"abcabcabc\", \"cbacbacba\"]", "output": "1" }, { "input": "[\"abc\", \"cab\"]", "output": "2" }, { "input": "[\"xyz\", \"zyxzyxzyx\"]", "output": "1" }, { ...
82
false
82
verified
10
10
1
2,978
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.CountQuadruples.Code.Funs /-! # Specifications of `Aegis.CountQuadruples.count_quadruples` LeetCode problem `count-pairs-of-equal-substrings-with-minimum-difference`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.CountQuadruples set_option maxH...
14
second-largest-digit-in-a-string
1,796
Easy
[ "Hash Table", "String" ]
Given an alphanumeric string s, return the second largest numerical digit that appears in s, or -1 if it does not exist. An alphanumeric string is a string consisting of lowercase English letters and digits.   Example 1: Input: s = "dfa12321afd" Output: 2 Explanation: The digits that appear in s are [1, 2, 3]. The sec...
secondHighest(s: str) -> int
pub fn second_highest(s: &[u8]) -> i64
Aegis.SecondHighest.second_highest
pub fn second_highest(s: &[u8]) -> i64 { let mut largest: i64 = -1; let mut second: i64 = -1; let mut i: usize = 0; while i < s.len() { let b = s[i]; if b >= b'0' && b <= b'9' { let d: i64 = (b - b'0') as i64; if d > largest { second = largest; ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [second_highest]: type definitions module public import Aeneas @[expose] public section 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_highest]: function definitions module public import Aeneas public import Aegis.SecondHighest.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.SecondHighest.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.SecondHighest.second_highest (Slice.from [57#u8, 56#u8, 55#u8, 54#u8, 53#u8, 52#u8, 51#u8, 50#u8, 49#u8, 48#u8] (by scalar_tac) : Slice Std.U8)) (8...
[ { "input": "[\"9876543210\"]", "output": "8" }, { "input": "[\"same1same1same1\"]", "output": "-1" }, { "input": "[\"abcdefghij0\"]", "output": "-1" }, { "input": "[\"abc1111\"]", "output": "-1" }, { "input": "[\"1a\"]", "output": "-1" }, { "input": "[...
131
false
131
verified
10
10
1
336
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.SecondHighest.Code.Funs /-! # Specifications of `Aegis.SecondHighest.second_highest` LeetCode problem `second-largest-digit-in-a-string`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.SecondHighest open Aegis.SecondHighest def ...
6
maximum-number-of-consecutive-values-you-can-make
1,798
Medium
[ "Greedy", "Array", "Sorting" ]
You are given an integer array coins of length n which represents the n coins that you own. The value of the ith coin is coins[i]. You can make some value x if you can choose some of your n coins such that their values sum up to x. Return the maximum number of consecutive integer values that you can make with your coin...
getMaximumConsecutive(coins: list_int) -> int
pub fn get_maximum_consecutive(coins: &[i64]) -> i64
Aegis.GetMaximumConsecutive.get_maximum_consecutive
pub fn get_maximum_consecutive(coins: &[i64]) -> i64 { let n = coins.len(); if n == 0 { return 1; } // Copy the input into an owned vector so it can be sorted. let mut a: Vec<i64> = Vec::new(); let mut i: usize = 0; while i < n { a.push(coins[i]); i += 1; } ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [get_maximum_consecutive]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_opti...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [get_maximum_consecutive]: function definitions module public import Aeneas public import Aegis.GetMaximumConsecutive.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashComma...
import Aegis.GetMaximumConsecutive.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval...
[ { "input": "[[1]]", "output": "2" }, { "input": "[[2]]", "output": "1" }, { "input": "[[40000]]", "output": "1" }, { "input": "[[1, 3]]", "output": "2" }, { "input": "[[1, 2, 5]]", "output": "4" }, { "input": "[[2, 2, 2, 2]]", "output": "1" }, ...
98
false
98
verified
10
10
3
10,435
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.GetMaximumConsecutive.Code.Funs /-! # Specifications of `Aegis.GetMaximumConsecutive.get_maximum_consecutive` LeetCode problem `maximum-number-of-consecutive-values-you-can-make`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.GetMaxi...
14
maximum-ascending-subarray-sum
1,800
Easy
[ "Array" ]
Given an array of positive integers nums, return the maximum possible sum of an strictly increasing subarray in nums. A subarray is defined as a contiguous sequence of numbers in an array.   Example 1: Input: nums = [10,20,30,5,10,50] Output: 65 Explanation: [5,10,50] is the ascending subarray with the maximum sum of ...
maxAscendingSum(nums: list_int) -> int
pub fn max_ascending_sum(nums: &[i64]) -> i64
Aegis.MaxAscendingSum.max_ascending_sum
pub fn max_ascending_sum(nums: &[i64]) -> i64 { let n = nums.len(); if n == 0 { return 0; } let mut current_sum = nums[0]; let mut best_sum = nums[0]; let mut i = 1; while i < n { if nums[i] > nums[i - 1] { current_sum += nums[i]; } else { cu...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [max_ascending_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 lin...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [max_ascending_sum]: function definitions module public import Aeneas public import Aegis.MaxAscendingSum.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.MaxAscendingSum.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.MaxAscendingSum.max_ascending_sum (Slice.from [10#i64] (by scalar_tac) : Slice Std.I64)) (10#i64))}") #eval (s!"CASE 1 {(Result.reducesTo (Aegis....
[ { "input": "[[10]]", "output": "10" }, { "input": "[[1]]", "output": "1" }, { "input": "[[100]]", "output": "100" }, { "input": "[[100, 100, 100]]", "output": "100" }, { "input": "[[100, 99, 98, 97, 96]]", "output": "100" }, { "input": "[[10, 20, 30, 4...
128
false
128
verified
10
10
1
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.MaxAscendingSum.Code.Funs /-! # Specifications of `Aegis.MaxAscendingSum.max_ascending_sum` LeetCode problem `maximum-ascending-subarray-sum`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.MaxAscendingSum def vals (nums : Slice Std.I6...
11
number-of-orders-in-the-backlog
1,801
Medium
[ "Array", "Simulation", "Heap (Priority Queue)" ]
You are given a 2D integer array orders, where each orders[i] = [pricei, amounti, orderTypei] denotes that amounti orders have been placed of type orderTypei at the price pricei. The orderTypei is:\r \r \r 0 if it is a batch of buy orders, or\r 1 if it is a batch of sell orders.\r \r \r Note that orders[i] represents...
getNumberOfBacklogOrders(orders: list_list_int) -> int
pub fn get_number_of_backlog_orders(orders: &[Vec<i64>]) -> i64
Aegis.GetNumberOfBacklogOrders.get_number_of_backlog_orders
fn heap_push_min(keys: &mut Vec<i64>, amounts: &mut Vec<i64>, key: i64, amount: i64) { keys.push(key); amounts.push(amount); let mut i = keys.len() - 1; while i > 0 { let parent = (i - 1) / 2; if keys[parent] <= keys[i] { break; } let tmp_key = keys[i]; ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [get_number_of_backlog_orders]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [get_number_of_backlog_orders]: function definitions module public import Aeneas public import Aegis.GetNumberOfBacklogOrders.Code.Types public import Aegis.GetNumberOfBacklogOrders.Code.FunsExternal @[expose] public section open Aeneas Aeneas.Std Result ControlFlow...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [get_number_of_backlog_orders]: external functions. -- This is a template file: rename it to "FunsExternal.lean" and fill the holes. module public import Aeneas public import Aegis.GetNumberOfBacklogOrders.Code.Types @[expose] public section open Aeneas Aeneas.Std R...
import Aegis.GetNumberOfBacklogOrders.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.GetNumberOfBacklogOrders.get_number_of_backlog_orders (Slice.from [(alloc.vec.Vec.from [5#i64, 5#i64, 0#i64] (by scalar_tac) : alloc.vec...
[ { "input": "[[[5, 5, 0], [5, 5, 1]]]", "output": "0" }, { "input": "[[[7, 1000000000, 1], [15, 3, 0], [5, 999999995, 0], [5, 1, 1]]]", "output": "999999984" }, { "input": "[[[1, 10, 0], [1, 10, 1], [1, 10, 0], [1, 10, 1]]]", "output": "0" }, { "input": "[[[100, 1, 0], [200, 2...
113
false
113
verified
10
10
1
8,916
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.GetNumberOfBacklogOrders.Code.Funs /-! # Specifications of `Aegis.GetNumberOfBacklogOrders.get_number_of_backlog_orders` LeetCode problem `number-of-orders-in-the-backlog`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.GetNumberOfBackl...
8
maximum-value-at-a-given-index-in-a-bounded-array
1,802
Medium
[ "Greedy", "Binary Search" ]
You are given three positive integers: n, index, and maxSum. You want to construct an array nums (0-indexed) that satisfies the following conditions: nums.length == n nums[i] is a positive integer where 0 <= i < n. abs(nums[i] - nums[i+1]) <= 1 where 0 <= i < n-1. The sum of all the elements of nums does not exceed ma...
maxValue(n: int, index: int, maxSum: int) -> int
pub fn max_value(n: i64, index: i64, maxSum: i64) -> i64
Aegis.MaxValue.max_value
pub fn max_value(n: i64, index: i64, maxSum: i64) -> i64 { let mut lo: i64 = 1; let mut hi: i64 = maxSum; while lo < hi { let mid: i64 = lo + (hi - lo + 1) / 2; if minimal_sum(n, index, mid) <= maxSum { lo = mid; } else { hi = mid - 1; } } l...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [max_value]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter.styl...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [max_value]: function definitions module public import Aeneas public import Aegis.MaxValue.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.MaxValue.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.MaxValue.max_value 1#i64 0#i64 1#i64) (1#i64))}") #eval (s!"CASE 1 {(Result.reducesTo (Aegis.MaxValue.max_value 10#i64 5#i64 50#i64) (7#i64))}") #eval (...
[ { "input": "[1, 0, 1]", "output": "1" }, { "input": "[10, 5, 50]", "output": "7" }, { "input": "[6, 1, 10]", "output": "3" }, { "input": "[1000000000, 500000000, 1000000000]", "output": "1" }, { "input": "[4, 2, 6]", "output": "2" }, { "input": "[20, 1...
92
false
92
verified
10
10
1
4,209
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MaxValue.Code.Funs /-! # Specifications of `Aegis.MaxValue.max_value` LeetCode problem `maximum-value-at-a-given-index-in-a-bounded-array`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.MaxValue def absDiff (a b : Int) : Int := if a ≤...
18
count-pairs-with-xor-in-a-range
1,803
Hard
[ "Bit Manipulation", "Trie", "Array" ]
Given a (0-indexed) integer array nums and two integers low and high, return the number of nice pairs.\r \r A nice pair is a pair (i, j) where 0 <= i < j < nums.length and low <= (nums[i] XOR nums[j]) <= high.\r \r  \r Example 1:\r \r \r Input: nums = [1,4,2,7], low = 2, high = 6\r Output: 6\r Explanation: All nice pai...
countPairs(nums: list_int, low: int, high: int) -> int
pub fn count_pairs(nums: &[i64], low: i64, high: i64) -> i64
Aegis.CountPairs.count_pairs
fn count_leq(x: i64, limit: i64, ch0: &[i64], ch1: &[i64], cnt: &[i64]) -> i64 { if limit < 0 { return 0; } let max_bit: i64 = 15; let mut cur: i64 = 0; let mut ans: i64 = 0; let mut bit: i64 = max_bit; while bit >= 0 { if cur == -1 { return ans; } ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [count_pairs]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter.st...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [count_pairs]: function definitions module public import Aeneas public import Aegis.CountPairs.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option lin...
import Aegis.CountPairs.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.CountPairs.count_pairs (Slice.from [1#i64, 4#i64, 2#i64, 7#i64] (by scalar_tac) : Slice Std.I64) 2#i64 6#i64) (6#i64))}") #eval (s!"CASE 1 {(Result.re...
[ { "input": "[[1, 4, 2, 7], 2, 6]", "output": "6" }, { "input": "[[1, 3, 5, 7, 9], 1, 10]", "output": "8" }, { "input": "[[10, 20, 30, 40, 50], 15, 25]", "output": "1" }, { "input": "[[9, 8, 4, 2, 1], 5, 14]", "output": "8" }, { "input": "[[12345, 67890, 13579, 246...
100
false
100
verified
10
10
2
66,187
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.CountPairs.Code.Funs /-! # Specifications of `Aegis.CountPairs.count_pairs` LeetCode problem `count-pairs-with-xor-in-a-range`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.CountPairs def xor64 (a b : Int) : Int := (BitVec.ofInt 64 a...
9
number-of-different-integers-in-a-string
1,805
Easy
[ "Hash Table", "String" ]
You are given a string word that consists of digits and lowercase English letters. You will replace every non-digit character with a space. For example, "a123bc34d8ef34" will become " 123  34 8  34". Notice that you are left with some integers that are separated by at least one space: "123", "34", "8", and "34". Return...
numDifferentIntegers(word: str) -> int
pub fn num_different_integers(word: &[u8]) -> i64
Aegis.NumDifferentIntegers.num_different_integers
pub fn num_different_integers(word: &[u8]) -> i64 { let mut seen: Vec<Vec<u8>> = Vec::new(); let mut i: usize = 0; while i < word.len() { if word[i] >= b'0' && word[i] <= b'9' { let run_start = i; while i < word.len() && word[i] >= b'0' && word[i] <= b'9' { ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [num_different_integers]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_optio...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [num_different_integers]: function definitions module public import Aeneas public import Aegis.NumDifferentIntegers.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand...
import Aegis.NumDifferentIntegers.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.NumDifferentIntegers.num_different_integers (Slice.from [97#u8, 49#u8, 98#u8, 50#u8, 99#u8, 51#u8, 100#u8, 52#u8, 101#u8, 53#u8, 102#u8, 54#...
[ { "input": "[\"a1b2c3d4e5f6g7h8i9j0\"]", "output": "10" }, { "input": "[\"a123bc34d8ef34\"]", "output": "3" }, { "input": "[\"a1a2a3a4a5a6a7a8a9a0\"]", "output": "10" }, { "input": "[\"100leetcode\"]", "output": "1" }, { "input": "[\"a1a1a1\"]", "output": "1" ...
124
false
124
verified
10
10
1
2,603
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.NumDifferentIntegers.Code.Funs /-! # Specifications of `Aegis.NumDifferentIntegers.num_different_integers` LeetCode problem `number-of-different-integers-in-a-string`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.NumDifferentIntegers ...
12
minimum-number-of-operations-to-reinitialize-a-permutation
1,806
Medium
[ "Array", "Math", "Simulation" ]
You are given an even integer n​​​​​​. You initially have a permutation perm of size n​​ where perm[i] == i​ (0-indexed)​​​​. In one operation, you will create a new array arr, and for each i: If i % 2 == 0, then arr[i] = perm[i / 2]. If i % 2 == 1, then arr[i] = perm[n / 2 + (i - 1) / 2]. You will then assign arr​​​...
reinitializePermutation(n: int) -> int
pub fn reinitialize_permutation(n: i64) -> i64
Aegis.ReinitializePermutation.reinitialize_permutation
pub fn reinitialize_permutation(n: i64) -> i64 { let half: i64 = n / 2; let mut cur: i64 = 1; let mut ops: i64 = 0; loop { if cur < half { cur = cur * 2; } else { cur = (cur - half) * 2 + 1; } ops += 1; if cur == 1 { break; ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [reinitialize_permutation]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_opt...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [reinitialize_permutation]: function definitions module public import Aeneas public import Aegis.ReinitializePermutation.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCo...
import Aegis.ReinitializePermutation.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.ReinitializePermutation.reinitialize_permutation 8#i64) (3#i64))}") #eval (s!"CASE 1 {(Result.reducesTo (Aegis.ReinitializePermutation.re...
[ { "input": "[8]", "output": "3" }, { "input": "[4]", "output": "2" }, { "input": "[12]", "output": "10" }, { "input": "[14]", "output": "12" }, { "input": "[16]", "output": "4" }, { "input": "[18]", "output": "8" }, { "input": "[6]", "o...
38
false
38
verified
10
10
1
1,700
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.ReinitializePermutation.Code.Funs /-! # Specifications of `Aegis.ReinitializePermutation.reinitialize_permutation` LeetCode problem `minimum-number-of-operations-to-reinitialize-a-permutation`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace Aeg...
11
maximize-number-of-nice-divisors
1,808
Hard
[ "Recursion", "Math", "Number Theory" ]
You are given a positive integer primeFactors. You are asked to construct a positive integer n that satisfies the following conditions:\r \r \r The number of prime factors of n (not necessarily distinct) is at most primeFactors.\r The number of nice divisors of n is maximized. Note that a divisor of n is nice if it...
maxNiceDivisors(primeFactors: int) -> int
pub fn max_nice_divisors(primeFactors: i64) -> i64
Aegis.MaxNiceDivisors.max_nice_divisors
const MOD: i64 = 1_000_000_007; fn mod_pow(mut base: i64, mut exp: i64) -> i64 { let mut result: i64 = 1; while exp > 0 { if exp % 2 == 1 { result = (result * base) % MOD; } base = (base * base) % MOD; exp = exp / 2; } result } pub fn max_nice_divisors(prime...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [max_nice_divisors]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option lin...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [max_nice_divisors]: function definitions module public import Aeneas public import Aegis.MaxNiceDivisors.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.MaxNiceDivisors.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.MaxNiceDivisors.max_nice_divisors 1#i64) (1#i64))}") #eval (s!"CASE 1 {(Result.reducesTo (Aegis.MaxNiceDivisors.max_nice_divisors 3#i64) (3#i64))...
[ { "input": "[1]", "output": "1" }, { "input": "[3]", "output": "3" }, { "input": "[2]", "output": "2" } ]
3
false
3
verified
3
3
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 Mathlib import Aegis.MaxNiceDivisors.Code.Funs /-! # Specifications of `Aegis.MaxNiceDivisors.max_nice_divisors` LeetCode problem `maximize-number-of-nice-divisors`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open scoped BigOperators namespace AegisSpec.Max...
10
determine-color-of-a-chessboard-square
1,812
Easy
[ "Math", "String" ]
You are given coordinates, a string that represents the coordinates of a square of the chessboard. Below is a chessboard for your reference. Return true if the square is white, and false if the square is black. The coordinate will always represent a valid chessboard square. The coordinate will always have the letter f...
squareIsWhite(coordinates: str) -> bool
pub fn square_is_white(coordinates: &[u8]) -> bool
Aegis.SquareIsWhite.square_is_white
pub fn square_is_white(coordinates: &[u8]) -> bool { let col: i64 = (coordinates[0] - b'a') as i64; let row: i64 = (coordinates[1] - b'1') as i64; let sum: i64 = col + row; sum % 2 != 0 }
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [square_is_white]: type definitions module public import Aeneas @[expose] public section 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 -- [square_is_white]: function definitions module public import Aeneas public import Aegis.SquareIsWhite.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.SquareIsWhite.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.SquareIsWhite.square_is_white (Slice.from [100#u8, 53#u8] (by scalar_tac) : Slice Std.U8)) (true))}") #eval (s!"CASE 1 {(Result.reducesTo (Aegis.Sq...
[ { "input": "[\"d5\"]", "output": "true" }, { "input": "[\"e4\"]", "output": "true" }, { "input": "[\"b8\"]", "output": "false" }, { "input": "[\"b2\"]", "output": "false" }, { "input": "[\"a1\"]", "output": "false" }, { "input": "[\"g8\"]", "output...
74
false
74
verified
10
10
1
240
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.SquareIsWhite.Code.Funs /-! # Specifications of `Aegis.SquareIsWhite.square_is_white` LeetCode problem `determine-color-of-a-chessboard-square`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.SquareIsWhite def byteAt (coordinates : Sli...
9
sentence-similarity-iii
1,813
Medium
[ "Array", "Two Pointers", "String" ]
You are given two strings sentence1 and sentence2, each representing a sentence composed of words. A sentence is a list of words that are separated by a single space with no leading or trailing spaces. Each word consists of only uppercase and lowercase English characters. Two sentences s1 and s2 are considered similar ...
areSentencesSimilar(sentence1: str, sentence2: str) -> bool
pub fn are_sentences_similar(sentence1: &[u8], sentence2: &[u8]) -> bool
Aegis.AreSentencesSimilar.are_sentences_similar
fn count_words(s: &[u8]) -> usize { if s.len() == 0 { return 0; } let mut count = 1usize; let mut i = 0usize; while i < s.len() { if s[i] == b' ' { count = count + 1; } i = i + 1; } count } fn word_start(s: &[u8], idx: usize) -> usize { if idx...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [are_sentences_similar]: type definitions module public import Aeneas @[expose] public section 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_sentences_similar]: function definitions module public import Aeneas public import Aegis.AreSentencesSimilar.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand f...
import Aegis.AreSentencesSimilar.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.AreSentencesSimilar.are_sentences_similar (Slice.from [83#u8, 105#u8, 109#u8, 105#u8, 108#u8, 97#u8, 114#u8, 32#u8, 115#u8, 101#u8, 110#u8, 1...
[ { "input": "[\"Similar sentences\", \"Similar similar sentences\"]", "output": "true" }, { "input": "[\"Start end\", \"Start middle end\"]", "output": "true" }, { "input": "[\"Eating right now\", \"Eating\"]", "output": "true" }, { "input": "[\"A quick brown fox\", \"A quick ...
197
false
197
verified
10
10
1
6,351
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.AreSentencesSimilar.Code.Funs /-! # Specifications of `Aegis.AreSentencesSimilar.are_sentences_similar` LeetCode problem `sentence-similarity-iii`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.AreSentencesSimilar namespace AegisSpec.AreSentenc...
11
count-nice-pairs-in-an-array
1,814
Medium
[ "Array", "Hash Table", "Math", "Counting" ]
You are given an array nums that consists of non-negative integers. Let us define rev(x) as the reverse of the non-negative integer x. For example, rev(123) = 321, and rev(120) = 21. A pair of indices (i, j) is nice if it satisfies all of the following conditions: 0 <= i < j < nums.length nums[i] + rev(nums[j]) == num...
countNicePairs(nums: list_int) -> int
pub fn count_nice_pairs(nums: &[i64]) -> i64
Aegis.CountNicePairs.count_nice_pairs
fn reverse_num(mut x: i64) -> i64 { let mut r: i64 = 0; while x > 0 { r = r * 10 + (x % 10); x = x / 10; } r } fn merge_sort(mut a: Vec<i64>) -> Vec<i64> { let n = a.len(); let mut width: usize = 1; while width < n { let mut merged: Vec<i64> = Vec::new(); le...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [count_nice_pairs]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option lint...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [count_nice_pairs]: function definitions module public import Aeneas public import Aegis.CountNicePairs.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.CountNicePairs.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.CountNicePairs.count_nice_pairs (Slice.from [100#i64, 10#i64, 1#i64] (by scalar_tac) : Slice Std.I64)) (0#i64))}") #eval (s!"CASE 1 {(Result.reduc...
[ { "input": "[[100, 10, 1]]", "output": "0" }, { "input": "[[100, 200, 300, 400]]", "output": "0" }, { "input": "[[123, 321, 213, 132]]", "output": "1" }, { "input": "[[987654321, 123456789, 234567890, 345678901]]", "output": "0" }, { "input": "[[123, 321, 120, 21]...
107
false
107
verified
10
10
1
4,464
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.CountNicePairs.Code.Funs /-! # Specifications of `Aegis.CountNicePairs.count_nice_pairs` LeetCode problem `count-nice-pairs-in-an-array`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.CountNicePairs namespace AegisSpec.CountNicePairs def M : ℤ...
12
maximum-number-of-groups-getting-fresh-donuts
1,815
Hard
[ "Bit Manipulation", "Memoization", "Array", "Dynamic Programming", "Bitmask" ]
There is a donuts shop that bakes donuts in batches of batchSize. They have a rule where they must serve all of the donuts of a batch before serving any donuts of the next batch. You are given an integer batchSize and an integer array groups, where groups[i] denotes that there is a group of groups[i] customers that wil...
maxHappyGroups(batchSize: int, groups: list_int) -> int
pub fn max_happy_groups(batchSize: i64, groups: &[i64]) -> i64
Aegis.MaxHappyGroups.max_happy_groups
pub fn max_happy_groups(batchSize: i64, groups: &[i64]) -> i64 { let b: usize = batchSize as usize; let mut cnt: Vec<i64> = Vec::new(); let mut i: usize = 0; while i < b { cnt.push(0); i += 1; } let mut base_happy: i64 = 0; let mut idx: usize = 0; while idx < groups.len...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [max_happy_groups]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option lint...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [max_happy_groups]: function definitions module public import Aeneas public import Aegis.MaxHappyGroups.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.MaxHappyGroups.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.MaxHappyGroups.max_happy_groups 4#i64 (Slice.from [4#i64, 8#i64, 12#i64, 16#i64, 20#i64] (by scalar_tac) : Slice Std.I64)) (5#i64))}") #eval (s!"C...
[ { "input": "[4, [4, 8, 12, 16, 20]]", "output": "5" }, { "input": "[3, [3, 6, 9, 12, 15]]", "output": "5" }, { "input": "[5, [5, 10, 15, 20, 25]]", "output": "5" }, { "input": "[5, [1, 2, 3, 4, 5]]", "output": "3" }, { "input": "[2, [1, 2, 3, 4, 5]]", "output"...
125
false
125
verified
10
10
1
21,797
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MaxHappyGroups.Code.Funs /-! # Specifications of `Aegis.MaxHappyGroups.max_happy_groups` LeetCode problem `maximum-number-of-groups-getting-fresh-donuts`. Each `spec_<n>` theorem states one property of the function. -/ set_option autoImplicit false open Aeneas.Std open Aeneas.Std.Result open Aegis.MaxH...
13
finding-the-users-active-minutes
1,817
Medium
[ "Array", "Hash Table" ]
You are given the logs for users' actions on LeetCode, and an integer k. The logs are represented by a 2D integer array logs where each logs[i] = [IDi, timei] indicates that the user with IDi performed an action at the minute timei. Multiple users can perform actions simultaneously, and a single user can perform multip...
findingUsersActiveMinutes(logs: list_list_int, k: int) -> list_int
pub fn finding_users_active_minutes(logs: &[Vec<i64>], k: i64) -> Vec<i64>
Aegis.FindingUsersActiveMinutes.finding_users_active_minutes
pub fn finding_users_active_minutes(logs: &[Vec<i64>], k: i64) -> Vec<i64> { let n = logs.len(); let mut keys: Vec<i64> = Vec::new(); let mut i = 0; while i < n { let id = logs[i][0]; let time = logs[i][1]; keys.push(id * 100001 + time); i += 1; } let m = keys.l...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [finding_users_active_minutes]: type definitions module public import Aeneas @[expose] public 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 -- [finding_users_active_minutes]: function definitions module public import Aeneas public import Aegis.FindingUsersActiveMinutes.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter....
import Aegis.FindingUsersActiveMinutes.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.FindingUsersActiveMinutes.finding_users_active_minutes (Slice.from [(alloc.vec.Vec.from [0#i64, 1#i64] (by scalar_tac) : alloc.vec.Vec ...
[ { "input": "[[[0, 1], [1, 1], [2, 1], [3, 1]], 1]", "output": "[4]" }, { "input": "[[[1, 1], [2, 2], [2, 3]], 4]", "output": "[1, 1, 0, 0]" }, { "input": "[[[10, 10], [10, 10], [10, 11], [11, 12]], 3]", "output": "[1, 1, 0]" }, { "input": "[[[1, 1], [1, 1], [1, 1], [1, 1], [1...
108
false
108
verified
10
10
1
7,091
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.FindingUsersActiveMinutes.Code.Funs /-! # Specifications of `Aegis.FindingUsersActiveMinutes.finding_users_active_minutes` LeetCode problem `finding-the-users-active-minutes`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.FindingUsersA...
11
minimum-absolute-sum-difference
1,818
Medium
[ "Array", "Binary Search", "Ordered Set", "Sorting" ]
You are given two positive integer arrays nums1 and nums2, both of length n. The absolute sum difference of arrays nums1 and nums2 is defined as the sum of |nums1[i] - nums2[i]| for each 0 <= i < n (0-indexed). You can replace at most one element of nums1 with any other element in nums1 to minimize the absolute sum dif...
minAbsoluteSumDiff(nums1: list_int, nums2: list_int) -> int
pub fn min_absolute_sum_diff(nums1: &[i64], nums2: &[i64]) -> i64
Aegis.MinAbsoluteSumDiff.min_absolute_sum_diff
const MOD: i64 = 1_000_000_007; fn sorted_copy(nums: &[i64]) -> Vec<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 += 1; } if n <= 1 { return v; } let mut temp: Vec<i64> = Vec::new(); let ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [min_absolute_sum_diff]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [min_absolute_sum_diff]: function definitions module public import Aeneas public import Aegis.MinAbsoluteSumDiff.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand fa...
import Aegis.MinAbsoluteSumDiff.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.MinAbsoluteSumDiff.min_absolute_sum_diff (Slice.from [100000#i64, 100000#i64, 100000#i64] (by scalar_tac) : Slice Std.I64) (Slice.from [1#i64,...
[ { "input": "[[100000, 100000, 100000], [1, 1, 1]]", "output": "299997" }, { "input": "[[1, 7, 5], [2, 3, 5]]", "output": "3" }, { "input": "[[100000, 100000, 100000], [1, 1, 1]]", "output": "299997" }, { "input": "[[1, 2, 3], [6, 5, 4]]", "output": "7" }, { "input...
87
false
87
verified
10
10
1
7,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.MinAbsoluteSumDiff.Code.Funs /-! # Specifications of `Aegis.MinAbsoluteSumDiff.min_absolute_sum_diff` LeetCode problem `minimum-absolute-sum-difference`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.MinAbsoluteSumDiff (min_absolute_sum_diff) ...
12
number-of-different-subsequences-gcds
1,819
Hard
[ "Array", "Math", "Counting", "Number Theory" ]
You are given an array nums that consists of positive integers. The GCD of a sequence of numbers is defined as the greatest integer that divides all the numbers in the sequence evenly. For example, the GCD of the sequence [4,6,16] is 2. A subsequence of an array is a sequence that can be formed by removing some eleme...
countDifferentSubsequenceGCDs(nums: list_int) -> int
pub fn count_different_subsequence_gc_ds(nums: &[i64]) -> i64
Aegis.CountDifferentSubsequenceGcDs.count_different_subsequence_gc_ds
fn gcd_i64(mut a: i64, mut b: i64) -> i64 { while b != 0 { let t = a % b; a = b; b = t; } a } pub fn count_different_subsequence_gc_ds(nums: &[i64]) -> i64 { let n = nums.len(); if n == 0 { return 0; } // For very small inputs, directly enumerate all non-emp...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [count_different_subsequence_gc_ds]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables fals...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [count_different_subsequence_gc_ds]: function definitions module public import Aeneas public import Aegis.CountDifferentSubsequenceGcDs.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_optio...
import Aegis.CountDifferentSubsequenceGcDs.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": "[[100000]]", "output": "1" }, { "input": "[[6, 10, 3]]", "output": "5" }, { "input": "[[100000, 200000, 150000]]", "output": "4" }, { "input": "[[7, 7, 7, 7]]", "output": "1" }, { "input": "[[2, 4, 6, 8,...
101
false
101
verified
10
10
2
30,070
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.CountDifferentSubsequenceGcDs.Code.Funs /-! # Specifications of `Aegis.CountDifferentSubsequenceGcDs.count_different_subsequence_gc_ds` LeetCode problem `number-of-different-subsequences-gcds`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace Aeg...
8
maximum-number-of-accepted-invitations
1,820
Medium
[ "Depth-First Search", "Graph", "Array", "Matrix" ]
There are m boys and n girls in a class attending an upcoming party. You are given an m x n integer matrix grid, where grid[i][j] equals 0 or 1. If grid[i][j] == 1, then that means the ith boy can invite the jth girl to the party. A boy can invite at most one girl, and a girl can accept at most one invitation from a bo...
maximumInvitations(grid: list_list_int) -> int
pub fn maximum_invitations(grid: &[Vec<i64>]) -> i64
Aegis.MaximumInvitations.maximum_invitations
pub fn maximum_invitations(grid: &[Vec<i64>]) -> i64 { let m = grid.len(); if m == 0 { return 0; } let n = grid[0].len(); // match_girl[j] = boy matched to girl j, or m if unmatched. let mut match_girl: Vec<usize> = Vec::new(); let mut j = 0; while j < n { match_girl.pus...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [maximum_invitations]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option l...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [maximum_invitations]: function definitions module public import Aeneas public import Aegis.MaximumInvitations.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand fals...
import Aegis.MaximumInvitations.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.MaximumInvitations.maximum_invitations (Slice.from [(alloc.vec.Vec.from [1#i64] (by scalar_tac) : alloc.vec.Vec Std.I64)] (by scalar_tac) : Sl...
[ { "input": "[[[1]]]", "output": "1" }, { "input": "[[[1, 1], [1, 1]]]", "output": "2" }, { "input": "[[[1, 0], [0, 1], [1, 0]]]", "output": "2" }, { "input": "[[[1, 1], [0, 0], [1, 1]]]", "output": "2" }, { "input": "[[[1, 1, 1], [1, 0, 1], [0, 0, 1]]]", "outp...
77
false
77
verified
10
10
1
5,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.MaximumInvitations.Code.Funs /-! # Specifications of `Aegis.MaximumInvitations.maximum_invitations` LeetCode problem `maximum-number-of-accepted-invitations`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.MaximumInvitations open Aegis...
16
sign-of-the-product-of-an-array
1,822
Easy
[ "Array", "Math" ]
Implement a function signFunc(x) that returns: 1 if x is positive. -1 if x is negative. 0 if x is equal to 0. You are given an integer array nums. Let product be the product of all values in the array nums. Return signFunc(product).   Example 1: Input: nums = [-1,-2,-3,-4,3,2,1] Output: 1 Explanation: The product of...
arraySign(nums: list_int) -> int
pub fn array_sign(nums: &[i64]) -> i64
Aegis.ArraySign.array_sign
pub fn array_sign(nums: &[i64]) -> i64 { let mut sign: i64 = 1; let mut i: usize = 0; let n: usize = nums.len(); while i < n { let x: i64 = nums[i]; if x == 0 { return 0; } if x < 0 { sign = -sign; } i = i + 1; } sign }
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [array_sign]: type definitions module public import Aeneas @[expose] public section 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 -- [array_sign]: function definitions module public import Aeneas public import Aegis.ArraySign.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.ArraySign.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.ArraySign.array_sign (Slice.from [(-1)#i64] (by scalar_tac) : Slice Std.I64)) ((-1)#i64))}") #eval (s!"CASE 1 {(Result.reducesTo (Aegis.ArraySign.array...
[ { "input": "[[-1]]", "output": "-1" }, { "input": "[[1]]", "output": "1" }, { "input": "[[0]]", "output": "0" }, { "input": "[[0, 0, 0]]", "output": "0" }, { "input": "[[100, -100, 100]]", "output": "-1" }, { "input": "[[100, -100, 1]]", "output": ...
93
false
93
verified
10
10
1
551
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.ArraySign.Code.Funs /-! # Specifications of `Aegis.ArraySign.array_sign` LeetCode problem `sign-of-the-product-of-an-array`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.ArraySign (array_sign) namespace AegisSpec.ArraySign def vals (nums : Sl...
16
find-the-winner-of-the-circular-game
1,823
Medium
[ "Recursion", "Queue", "Array", "Math", "Simulation" ]
There are n friends that are playing a game. The friends are sitting in a circle and are numbered from 1 to n in clockwise order. More formally, moving clockwise from the ith friend brings you to the (i+1)th friend for 1 <= i < n, and moving clockwise from the nth friend brings you to the 1st friend. The rules of the g...
findTheWinner(n: int, k: int) -> int
pub fn find_the_winner(n: i64, k: i64) -> i64
Aegis.FindTheWinner.find_the_winner
pub fn find_the_winner(n: i64, k: i64) -> i64 { let mut ans: i64 = 0; let mut i: i64 = 2; while i <= n { ans = (ans + k) % i; i = i + 1; } ans + 1 }
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [find_the_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 linte...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [find_the_winner]: function definitions module public import Aeneas public import Aegis.FindTheWinner.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.FindTheWinner.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.FindTheWinner.find_the_winner 3#i64 1#i64) (3#i64))}") #eval (s!"CASE 1 {(Result.reducesTo (Aegis.FindTheWinner.find_the_winner 3#i64 3#i64) (2#i64...
[ { "input": "[3, 1]", "output": "3" }, { "input": "[3, 3]", "output": "2" }, { "input": "[5, 2]", "output": "3" }, { "input": "[7, 3]", "output": "4" }, { "input": "[7, 1]", "output": "7" }, { "input": "[6, 5]", "output": "1" }, { "input": "...
83
false
83
verified
10
10
1
341
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.FindTheWinner.Code.Funs /-! # Specifications of `Aegis.FindTheWinner.find_the_winner` LeetCode problem `find-the-winner-of-the-circular-game`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.FindTheWinner def circle (m : Nat) : List...
11
minimum-sideway-jumps
1,824
Medium
[ "Greedy", "Array", "Dynamic Programming" ]
There is a 3 lane road of length n that consists of n + 1 points labeled from 0 to n. A frog starts at point 0 in the second lane and wants to jump to point n. However, there could be obstacles along the way. You are given an array obstacles of length n + 1 where each obstacles[i] (ranging from 0 to 3) describes an obs...
minSideJumps(obstacles: list_int) -> int
pub fn min_side_jumps(obstacles: &[i64]) -> i64
Aegis.MinSideJumps.min_side_jumps
pub fn min_side_jumps(obstacles: &[i64]) -> i64 { let inf: i64 = 1_000_000_000; // Minimum side jumps to be at point 0 in lanes 1, 2, 3. // The frog starts in lane 2, but may side-jump at point 0. let mut a: i64 = 1; let mut b: i64 = 0; let mut c: i64 = 1; let n: usize = obstacles.len(); ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [min_side_jumps]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [min_side_jumps]: function definitions module public import Aeneas public import Aegis.MinSideJumps.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.MinSideJumps.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.MinSideJumps.min_side_jumps (Slice.from [0#i64, 1#i64, 2#i64, 3#i64, 0#i64] (by scalar_tac) : Slice Std.I64)) (2#i64))}") #eval (s!"CASE 1 {(Result....
[ { "input": "[[0, 1, 2, 3, 0]]", "output": "2" }, { "input": "[[0, 0, 0, 0, 0, 0]]", "output": "0" }, { "input": "[[0, 2, 1, 0, 3, 0]]", "output": "2" }, { "input": "[[0, 1, 1, 3, 3, 0]]", "output": "0" }, { "input": "[[0, 3, 2, 1, 3, 0]]", "output": "3" }, ...
132
false
132
verified
10
10
1
8,147
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MinSideJumps.Code.Funs /-! # Specifications of `Aegis.MinSideJumps.min_side_jumps` LeetCode problem `minimum-sideway-jumps`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.MinSideJumps def vals (obstacles : Slice Std.I64) : List In...
11
faulty-sensor
1,826
Easy
[ "Array", "Two Pointers" ]
An experiment is being conducted in a lab. To ensure accuracy, there are two sensors collecting data simultaneously. You are given two arrays sensor1 and sensor2, where sensor1[i] and sensor2[i] are the ith data points collected by the two sensors. However, this type of sensor has a chance of being defective, which cau...
badSensor(sensor1: list_int, sensor2: list_int) -> int
pub fn bad_sensor(sensor1: &[i64], sensor2: &[i64]) -> i64
Aegis.BadSensor.bad_sensor
pub fn bad_sensor(sensor1: &[i64], sensor2: &[i64]) -> i64 { let n = sensor1.len(); let mut i: usize = 0; while i < n && sensor1[i] == sensor2[i] { i += 1; } if i == n { return -1; } let mut can1: bool = true; let mut can2: bool = true; let mut j: usize = i; w...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [bad_sensor]: type definitions module public import Aeneas @[expose] public section 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 -- [bad_sensor]: function definitions module public import Aeneas public import Aegis.BadSensor.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.BadSensor.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.BadSensor.bad_sensor (Slice.from [1#i64, 3#i64, 4#i64] (by scalar_tac) : Slice Std.I64) (Slice.from [1#i64, 2#i64, 4#i64] (by scalar_tac) : Slice Std.I...
[ { "input": "[[1, 3, 4], [1, 2, 4]]", "output": "1" }, { "input": "[[1, 2, 3], [1, 3, 4]]", "output": "2" }, { "input": "[[3, 4, 5, 6], [4, 5, 6, 3]]", "output": "2" }, { "input": "[[10, 20, 30, 40], [10, 20, 35, 40]]", "output": "1" }, { "input": "[[5, 6, 7, 8], [...
125
false
125
verified
10
10
1
27,807
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.BadSensor.Code.Funs /-! # Specifications of `Aegis.BadSensor.bad_sensor` LeetCode problem `faulty-sensor`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Aeneas.Std.Result namespace AegisSpec.BadSensor abbrev I64Slice := Slice Std.I64 def valAt (s : I64Slice) (...
12
minimum-operations-to-make-the-array-increasing
1,827
Easy
[ "Greedy", "Array" ]
You are given an integer array nums (0-indexed). In one operation, you can choose an element of the array and increment it by 1.\r \r \r For example, if nums = [1,2,3], you can choose to increment nums[1] to make nums = [1,3,3].\r \r \r Return the minimum number of operations needed to make nums strictly increasing.\r...
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(); if n == 0 { return 0; } let mut operations: i64 = 0; let mut previous: i64 = nums[0]; let mut i: usize = 1; while i < n { let current = nums[i]; if current <= previous { let target = previ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [min_operations]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [min_operations]: function definitions module public import Aeneas public import Aegis.MinOperations.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_opti...
import Aegis.MinOperations.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.MinOperations.min_operations (Slice.from [1#i64] (by scalar_tac) : Slice Std.I64)) (0#i64))}") #eval (s!"CASE 1 {(Result.reducesTo (Aegis.MinOperat...
[ { "input": "[[1]]", "output": "0" }, { "input": "[[8]]", "output": "0" }, { "input": "[[1, 1, 1]]", "output": "3" }, { "input": "[[10000, 10000, 10000, 10000]]", "output": "6" }, { "input": "[[5, 4, 3, 2, 1]]", "output": "20" }, { "input": "[[10000, 1,...
118
false
118
verified
10
10
1
503
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": 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-the-array-increasing`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.MinOperations def contents (nums : ...
15
queries-on-number-of-points-inside-a-circle
1,828
Medium
[ "Geometry", "Array", "Math" ]
You are given an array points where points[i] = [xi, yi] is the coordinates of the ith point on a 2D plane. Multiple points can have the same coordinates. You are also given an array queries where queries[j] = [xj, yj, rj] describes a circle centered at (xj, yj) with a radius of rj. For each query queries[j], compute t...
countPoints(points: list_list_int, queries: list_list_int) -> list_int
pub fn count_points(points: &[Vec<i64>], queries: &[Vec<i64>]) -> Vec<i64>
Aegis.CountPoints.count_points
pub fn count_points(points: &[Vec<i64>], queries: &[Vec<i64>]) -> Vec<i64> { let mut answer: Vec<i64> = Vec::new(); let point_count = points.len(); let query_count = queries.len(); let mut j: usize = 0; while j < query_count { let cx = queries[j][0]; let cy = queries[j][1]; ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [count_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.s...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [count_points]: function definitions module public import Aeneas public import Aegis.CountPoints.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.CountPoints.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.CountPoints.count_points (Slice.from [(alloc.vec.Vec.from [1#i64, 3#i64] (by scalar_tac) : alloc.vec.Vec Std.I64), (alloc.vec.Vec.from [3#i64, 3#i64]...
[ { "input": "[[[1, 3], [3, 3], [5, 3], [2, 2]], [[2, 3, 1], [4, 3, 1], [1, 1, 2]]]", "output": "[3, 2, 2]" }, { "input": "[[[10, 10], [20, 20], [30, 30], [40, 40], [50, 50]], [[25, 25, 10], [15, 15, 5], [35, 35, 20]]]", "output": "[2, 0, 2]" }, { "input": "[[[0, 0], [500, 500], [250, 250]...
51
false
51
verified
10
10
1
666
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.CountPoints.Code.Funs /-! # Specifications of `Aegis.CountPoints.count_points` LeetCode problem `queries-on-number-of-points-inside-a-circle`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aeneas.Std.alloc.vec namespace AegisSpec.CountPoints open Ae...
14
check-if-the-sentence-is-pangram
1,832
Easy
[ "Hash Table", "String" ]
A pangram is a sentence where every letter of the English alphabet appears at least once. Given a string sentence containing only lowercase English letters, return true if sentence is a pangram, or false otherwise.   Example 1: Input: sentence = "thequickbrownfoxjumpsoverthelazydog" Output: true Explanation: sentence ...
checkIfPangram(sentence: str) -> bool
pub fn check_if_pangram(sentence: &[u8]) -> bool
Aegis.CheckIfPangram.check_if_pangram
pub fn check_if_pangram(sentence: &[u8]) -> bool { let mut seen: Vec<bool> = Vec::new(); let mut i: usize = 0; while i < 26 { seen.push(false); i += 1; } let mut idx: usize = 0; while idx < sentence.len() { let c: u8 = sentence[idx]; if c >= b'a' && c <= b'z' { ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [check_if_pangram]: type definitions module public import Aeneas @[expose] public section 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 -- [check_if_pangram]: function definitions module public import Aeneas public import Aegis.CheckIfPangram.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.CheckIfPangram.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.CheckIfPangram.check_if_pangram (Slice.from [97#u8, 97#u8, 98#u8, 98#u8, 99#u8, 99#u8, 100#u8, 100#u8, 101#u8, 101#u8, 102#u8, 102#u8, 103#u8, 103...
[ { "input": "[\"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\"]", "output": "true" }, { "input": "[\"quickbrownfoxjumpsoverthelazydog\"]", "output": "true" }, { "input": "[\"aaaaabbbbbccccc\"]", "output": "false" }, { "input": "[\"a\"]", "output": "false" }, { ...
98
false
98
verified
10
10
2
1,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.CheckIfPangram.Code.Funs /-! # Specifications of `Aegis.CheckIfPangram.check_if_pangram` LeetCode problem `check-if-the-sentence-is-pangram`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.CheckIfPangram def OccursIn (s : Slice Std.U8)...
12
maximum-ice-cream-bars
1,833
Medium
[ "Greedy", "Array", "Counting Sort", "Sorting" ]
It is a sweltering summer day, and a boy wants to buy some ice cream bars. At the store, there are n ice cream bars. You are given an array costs of length n, where costs[i] is the price of the ith ice cream bar in coins. The boy initially has coins coins to spend, and he wants to buy as many ice cream bars as possible...
maxIceCream(costs: list_int, coins: int) -> int
pub fn max_ice_cream(costs: &[i64], coins: i64) -> i64
Aegis.MaxIceCream.max_ice_cream
pub fn max_ice_cream(costs: &[i64], coins: i64) -> i64 { let n = costs.len(); if n == 0 { return 0; } let mut arr: Vec<i64> = Vec::new(); let mut max_cost: i64 = 0; let mut i: usize = 0; while i < n { let c = costs[i]; arr.push(c); if c > max_cost { ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [max_ice_cream]: type definitions module public import Aeneas @[expose] public section 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_ice_cream]: function definitions module public import Aeneas public import Aegis.MaxIceCream.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.MaxIceCream.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": "[[100000], 100000]", "output": "1" }, { "input": "[[1, 3, 2, 4, 1], 7]", "output": "4" }, { "input": "[[5, 5, 5, 5, 5], 15]", "output": "3" }, { "input": "[[10, 20, 30, 40, 50], 100]", "output": "4" }, { ...
75
false
75
verified
10
10
3
9,611
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MaxIceCream.Code.Funs /-! # Specifications of `Aegis.MaxIceCream.max_ice_cream` LeetCode problem `maximum-ice-cream-bars`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.MaxIceCream open Aegis.MaxIceCream def costsOf (costs : Slice St...
11
single-threaded-cpu
1,834
Medium
[ "Array", "Sorting", "Heap (Priority Queue)" ]
You are given n​​​​​​ tasks labeled from 0 to n - 1 represented by a 2D integer array tasks, where tasks[i] = [enqueueTimei, processingTimei] means that the i​​​​​​th​​​​ task will be available to process at enqueueTimei and will take processingTimei to finish processing. You have a single-threaded CPU that can process...
getOrder(tasks: list_list_int) -> list_int
pub fn get_order(tasks: &[Vec<i64>]) -> Vec<i64>
Aegis.GetOrder.get_order
fn idx_less(tasks: &[Vec<i64>], a: i64, b: i64) -> bool { let ai = a as usize; let bi = b as usize; let ea = tasks[ai][0]; let eb = tasks[bi][0]; if ea < eb { true } else if ea > eb { false } else { a < b } } fn sort_by_enqueue(tasks: &[Vec<i64>], arr: &mut Vec<i...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [get_order]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter.styl...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [get_order]: function definitions module public import Aeneas public import Aegis.GetOrder.Code.Types public import Aegis.GetOrder.Code.FunsExternal @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_opt...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [get_order]: external functions. -- This is a template file: rename it to "FunsExternal.lean" and fill the holes. module public import Aeneas public import Aegis.GetOrder.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option ...
import Aegis.GetOrder.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.GetOrder.get_order (Slice.from [(alloc.vec.Vec.from [1#i64, 3#i64] (by scalar_tac) : alloc.vec.Vec Std.I64), (alloc.vec.Vec.from [2#i64, 2#i64] (by scal...
[ { "input": "[[[1, 3], [2, 2], [3, 1], [4, 4]]]", "output": "[0, 2, 1, 3]" }, { "input": "[[[3, 1], [1, 2], [2, 4], [1, 4]]]", "output": "[1, 0, 2, 3]" }, { "input": "[[[5, 5], [8, 2], [1, 9], [3, 8]]]", "output": "[2, 1, 0, 3]" }, { "input": "[[[5, 2], [1, 2], [3, 1], [2, 1]]...
109
false
109
verified
10
10
1
8,689
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.GetOrder.Code.Funs /-! # Specifications of `Aegis.GetOrder.get_order` LeetCode problem `single-threaded-cpu`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.GetOrder abbrev TaskArray : Type := Aeneas.Std.Slice (Aeneas.Std.alloc.vec.Vec...
14
find-xor-sum-of-all-pairs-bitwise-and
1,835
Hard
[ "Bit Manipulation", "Array", "Math" ]
The XOR sum of a list is the bitwise XOR of all its elements. If the list only contains one element, then its XOR sum will be equal to this element. For example, the XOR sum of [1,2,3,4] is equal to 1 XOR 2 XOR 3 XOR 4 = 4, and the XOR sum of [3] is equal to 3. You are given two 0-indexed arrays arr1 and arr2 that co...
getXORSum(arr1: list_int, arr2: list_int) -> int
pub fn get_xor_sum(arr1: &[i64], arr2: &[i64]) -> i64
Aegis.GetXorSum.get_xor_sum
pub fn get_xor_sum(arr1: &[i64], arr2: &[i64]) -> i64 { let mut xor1: i64 = 0; let mut xor2: i64 = 0; let mut i: usize = 0; while i < arr1.len() { xor1 ^= arr1[i]; i += 1; } let mut j: usize = 0; while j < arr2.len() { xor2 ^= arr2[j]; j += 1; } xor...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [get_xor_sum]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter.st...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [get_xor_sum]: function definitions module public import Aeneas public import Aegis.GetXorSum.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option lint...
import Aegis.GetXorSum.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.GetXorSum.get_xor_sum (Slice.from [1000000000#i64] (by scalar_tac) : Slice Std.I64) (Slice.from [1000000000#i64] (by scalar_tac) : Slice Std.I64)) (100...
[ { "input": "[[1000000000], [1000000000]]", "output": "1000000000" }, { "input": "[[12], [4]]", "output": "4" }, { "input": "[[314159265], [271828182]]", "output": "271679616" }, { "input": "[[1000000000, 500000000], [500000000, 1000000000]]", "output": "643280640" }, ...
103
false
103
verified
10
10
1
378
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.GetXorSum.Code.Funs /-! # Specifications of `Aegis.GetXorSum.get_xor_sum` LeetCode problem `find-xor-sum-of-all-pairs-bitwise-and`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.GetXorSum namespace AegisSpec.GetXorSum def words (l : List Std.I...
13
remove-duplicates-from-an-unsorted-linked-list
1,836
Medium
[ "Hash Table", "Linked List" ]
Given the head of a linked list, find all the values that appear more than once in the list and delete the nodes that have any of those values.\r \r Return the linked list after the deletions.\r \r  \r Example 1:\r \r \r Input: head = [1,2,3,2]\r Output: [1,3]\r Explanation: 2 appears twice in the linked list, so all 2...
deleteDuplicatesUnsorted(head: linkedlist) -> linkedlist
pub fn delete_duplicates_unsorted(head: &List) -> List
Aegis.DeleteDuplicatesUnsorted.delete_duplicates_unsorted
pub fn delete_duplicates_unsorted(head: &List) -> List { // Collect all values in the original order. let mut vals: Vec<i64> = Vec::new(); let mut cur: &List = head; let mut running: bool = true; while running { match cur { List::Nil => { running = false; ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [delete_duplicates_unsorted]: type definitions module public import Aeneas @[expose] public 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 -- [delete_duplicates_unsorted]: function definitions module public import Aeneas public import Aegis.DeleteDuplicatesUnsorted.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.has...
import Aegis.DeleteDuplicatesUnsorted.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}" de...
[ { "input": "[[1]]", "output": "[1]" }, { "input": "[[1, 2]]", "output": "[1, 2]" }, { "input": "[[1, 2, 3, 2]]", "output": "[1, 3]" }, { "input": "[[100000, 99999, 100000, 99999, 99998]]", "output": "[99998]" }, { "input": "[[100000, 100000, 100000, 99999, 99999, ...
35
false
35
verified
10
10
2
15,951
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.DeleteDuplicatesUnsorted.Code.Funs /-! # Specifications of `Aegis.DeleteDuplicatesUnsorted.delete_duplicates_unsorted` LeetCode problem `remove-duplicates-from-an-unsorted-linked-list`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.DeleteDuplica...
16
sum-of-digits-in-base-k
1,837
Easy
[ "Math" ]
Given an integer n (in base 10) and a base k, return the sum of the digits of n after converting n from base 10 to base k. After converting, each digit should be interpreted as a base 10 number, and the sum should be returned in base 10.   Example 1: Input: n = 34, k = 6 Output: 9 Explanation: 34 (base 10) expressed i...
sumBase(n: int, k: int) -> int
pub fn sum_base(n: i64, k: i64) -> i64
Aegis.SumBase.sum_base
pub fn sum_base(n: i64, k: i64) -> i64 { let mut x = n; let mut sum = 0; while x > 0 { sum += x % k; x /= k; } sum }
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [sum_base]: type definitions module public import Aeneas @[expose] public section 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_base]: function definitions module public import Aeneas public import Aegis.SumBase.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.SumBase.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.SumBase.sum_base 64#i64 2#i64) (1#i64))}") #eval (s!"CASE 1 {(Result.reducesTo (Aegis.SumBase.sum_base 7#i64 3#i64) (3#i64))}") #eval (s!"CASE 2 {(Result...
[ { "input": "[64, 2]", "output": "1" }, { "input": "[7, 3]", "output": "3" }, { "input": "[42, 5]", "output": "6" }, { "input": "[50, 4]", "output": "5" }, { "input": "[100, 3]", "output": "4" }, { "input": "[10, 10]", "output": "1" }, { "in...
87
false
87
verified
10
10
1
114
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.SumBase.Code.Funs /-! # Specifications of `Aegis.SumBase.sum_base` LeetCode problem `sum-of-digits-in-base-k`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.SumBase def digitSum (k n : ℕ) : ℕ := ∑ i ∈ Finset.range (Nat.log k n + 1),...
12
frequency-of-the-most-frequent-element
1,838
Medium
[ "Greedy", "Array", "Binary Search", "Prefix Sum", "Sorting", "Sliding Window" ]
The frequency of an element is the number of times it occurs in an array. You are given an integer array nums and an integer k. In one operation, you can choose an index of nums and increment the element at that index by 1. Return the maximum possible frequency of an element after performing at most k operations.   Exa...
maxFrequency(nums: list_int, k: int) -> int
pub fn max_frequency(nums: &[i64], k: i64) -> i64
Aegis.MaxFrequency.max_frequency
fn merge_sort(mut v: Vec<i64>) -> Vec<i64> { let n = v.len(); if n < 2 { return v; } let mut width: usize = 1; while width < n { let mut merged: Vec<i64> = Vec::new(); let mut start: usize = 0; while start < n { let mid = if start + width < n { ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [max_frequency]: type definitions module public import Aeneas @[expose] public section 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_frequency]: function definitions module public import Aeneas public import Aegis.MaxFrequency.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.MaxFrequency.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, 100000], 100000]", "output": "2" }, { "input": "[[1, 100000], 99999]", "output": "2" }, { "input": "[[1, 2, 4], 5]", "output": "3" }, { "input": "[[100000, 100000, 100000], 300000]", "output": "3" }, { "input": "[[3, 9, 6], 2]", "output": "1" ...
99
false
99
verified
10
10
2
10,068
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MaxFrequency.Code.Funs /-! # Specifications of `Aegis.MaxFrequency.max_frequency` LeetCode problem `frequency-of-the-most-frequent-element`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.MaxFrequency def numsList (nums : Slice Std.I64...
13
longest-substring-of-all-vowels-in-order
1,839
Medium
[ "String", "Sliding Window" ]
A string is considered beautiful if it satisfies the following conditions: Each of the 5 English vowels ('a', 'e', 'i', 'o', 'u') must appear at least once in it. The letters must be sorted in alphabetical order (i.e. all 'a's before 'e's, all 'e's before 'i's, etc.). For example, strings "aeiou" and "aaaaaaeiiiioou"...
longestBeautifulSubstring(word: str) -> int
pub fn longest_beautiful_substring(word: &[u8]) -> i64
Aegis.LongestBeautifulSubstring.longest_beautiful_substring
pub fn longest_beautiful_substring(word: &[u8]) -> i64 { let n = word.len(); let mut ans: i64 = 0; let mut i: usize = 0; while i < n { let seg_start = i; let mut j = i + 1; while j < n { if word[j] >= word[j - 1] { j += 1; } else { ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [longest_beautiful_substring]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [longest_beautiful_substring]: function definitions module public import Aeneas public import Aegis.LongestBeautifulSubstring.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.h...
import Aegis.LongestBeautifulSubstring.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.LongestBeautifulSubstring.longest_beautiful_substring (Slice.from [97#u8, 101#u8, 105#u8, 97#u8, 97#u8, 105#u8, 111#u8, 97#u8, 97#u8, 9...
[ { "input": "[\"aeiaaioaaaaeiiaaaiiiiiouuuooaauuaeiuuuuuuuuuuuuuuuuuuuuaaa\"]", "output": "0" }, { "input": "[\"aeiaaioaaaaeiiaaaiiiiiouuuaauuaeiu\"]", "output": "0" }, { "input": "[\"aeiaaioaaaaeiiaaaiiiiiouuuuuuuuuuuuuuuuuuuuaaaaaaeiou\"]", "output": "10" }, { "input": "[\"a...
20
false
20
verified
10
10
1
4,418
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.LongestBeautifulSubstring.Code.Funs /-! # Specifications of `Aegis.LongestBeautifulSubstring.longest_beautiful_substring` LeetCode problem `longest-substring-of-all-vowels-in-order`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.Longes...
14
maximum-building-height
1,840
Hard
[ "Array", "Math", "Sorting" ]
You want to build n new buildings in a city. The new buildings will be built in a line and are labeled from 1 to n. However, there are city restrictions on the heights of the new buildings: The height of each building must be a non-negative integer. The height of the first building must be 0. The height difference bet...
maxBuilding(n: int, restrictions: list_list_int) -> int
pub fn max_building(n: i64, restrictions: &[Vec<i64>]) -> i64
Aegis.MaxBuilding.max_building
pub fn max_building(n: i64, restrictions: &[Vec<i64>]) -> i64 { let mut points: Vec<Vec<i64>> = Vec::new(); let mut start: Vec<i64> = Vec::new(); start.push(1); start.push(0); points.push(start); let mut has_n = false; let m = restrictions.len(); let mut i = 0; while i < m { ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [max_building]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter.s...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [max_building]: function definitions module public import Aeneas public import Aegis.MaxBuilding.Code.Types public import Aegis.MaxBuilding.Code.FunsExternal @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace fals...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [max_building]: external functions. -- This is a template file: rename it to "FunsExternal.lean" and fill the holes. module public import Aeneas public import Aegis.MaxBuilding.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_o...
import Aegis.MaxBuilding.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.MaxBuilding.max_building 6#i64 (Slice.from [] (by scalar_tac) : Slice (alloc.vec.Vec Std.I64))) (5#i64))}") #eval (s!"CASE 1 {(Result.reducesTo (Aegi...
[ { "input": "[6, []]", "output": "5" }, { "input": "[1000000, [[500000, 500000]]]", "output": "999999" }, { "input": "[999, [[999, 1]]]", "output": "499" }, { "input": "[1000000, [[999999, 999999]]]", "output": "999999" }, { "input": "[5, [[2, 1], [4, 1]]]", "o...
87
false
87
verified
10
10
1
5,509
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MaxBuilding.Code.Funs /-! # Specifications of `Aegis.MaxBuilding.max_building` LeetCode problem `maximum-building-height`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.MaxBuilding def iabs (x : Int) : Int := if x ≥ 0 then x else -x ...
12
maximum-element-after-decreasing-and-rearranging
1,846
Medium
[ "Greedy", "Array", "Sorting" ]
You are given an array of positive integers arr. Perform some operations (possibly none) on arr so that it satisfies these conditions: The value of the first element in arr must be 1. The absolute difference between any 2 adjacent elements must be less than or equal to 1. In other words, abs(arr[i] - arr[i - 1]) <= 1 ...
maximumElementAfterDecrementingAndRearranging(arr: list_int) -> int
pub fn maximum_element_after_decrementing_and_rearranging(arr: &[i64]) -> i64
Aegis.MaximumElementAfterDecrementingAndRearranging.maximum_element_after_decrementing_and_rearranging
pub fn maximum_element_after_decrementing_and_rearranging(arr: &[i64]) -> i64 { let n = arr.len(); let n_i64 = n as i64; let mut counts: Vec<i64> = Vec::new(); let mut i: usize = 0; while i <= n { counts.push(0); i += 1; } i = 0; while i < n { let mut v = arr[i]...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [maximum_element_after_decrementing_and_rearranging]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unu...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [maximum_element_after_decrementing_and_rearranging]: function definitions module public import Aeneas public import Aegis.MaximumElementAfterDecrementingAndRearranging.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option li...
import Aegis.MaximumElementAfterDecrementingAndRearranging.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.MaximumElementAfterDecrementingAndRearranging.maximum_element_after_decrementing_and_rearranging (Slice.from [1#i64...
[ { "input": "[[1]]", "output": "1" }, { "input": "[[3, 2, 1]]", "output": "3" }, { "input": "[[100, 1, 1000]]", "output": "3" }, { "input": "[[5, 4, 3, 2, 1]]", "output": "5" }, { "input": "[[1, 1000000000, 2, 3, 4]]", "output": "5" }, { "input": "[[9, ...
135
false
135
verified
10
10
1
4,162
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MaximumElementAfterDecrementingAndRearranging.Code.Funs /-! # Specifications of `Aegis.MaximumElementAfterDecrementingAndRearranging.maximum_element_after_decrementing_and_rearranging` LeetCode problem `maximum-element-after-decreasing-and-rearranging`. Each `spec_<n>` theorem states one property of the ...
14
closest-room
1,847
Hard
[ "Array", "Binary Search", "Ordered Set", "Sorting" ]
There is a hotel with n rooms. The rooms are represented by a 2D integer array rooms where rooms[i] = [roomIdi, sizei] denotes that there is a room with room number roomIdi and size equal to sizei. Each roomIdi is guaranteed to be unique. You are also given k queries in a 2D array queries where queries[j] = [preferredj...
closestRoom(rooms: list_list_int, queries: list_list_int) -> list_int
pub fn closest_room(rooms: &[Vec<i64>], queries: &[Vec<i64>]) -> Vec<i64>
Aegis.ClosestRoom.closest_room
pub fn closest_room(rooms: &[Vec<i64>], queries: &[Vec<i64>]) -> Vec<i64> { let n = rooms.len(); let k = queries.len(); // Extract ids and sizes in original order. let mut cur_ids: Vec<i64> = Vec::new(); let mut cur_sizes: Vec<i64> = Vec::new(); let mut i = 0usize; while i < n { cur...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [closest_room]: type definitions module public import Aeneas @[expose] public section 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 -- [closest_room]: function definitions module public import Aeneas public import Aegis.ClosestRoom.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.ClosestRoom.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": "[[[10000000, 10000000]], [[10000000, 10000000]]]", "output": "[10000000]" }, { "input": "[[[1, 10000000], [10000000, 1]], [[5000000, 5000000], [10000000, 10000000]]]", "output": "[1, 1]" }, { "input": "[[[10000000, 10000000], [1, 1]], [[10000000, 10000000], [2, 1]]]", "ou...
213
false
213
verified
10
10
5
95,256
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.ClosestRoom.Code.Funs /-! # Specifications of `Aegis.ClosestRoom.closest_room` LeetCode problem `closest-room`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.ClosestRoom def rowGet (rows : Slice (alloc.vec.Vec Std.I64)) (i j : Nat) : ...
15
minimum-distance-to-the-target-element
1,848
Easy
[ "Array" ]
Given an integer array nums (0-indexed) and two integers target and start, find an index i such that nums[i] == target and abs(i - start) is minimized. Note that abs(x) is the absolute value of x. Return abs(i - start). It is guaranteed that target exists in nums.   Example 1: Input: nums = [1,2,3,4,5], target = 5, st...
getMinDistance(nums: list_int, target: int, start: int) -> int
pub fn get_min_distance(nums: &[i64], target: i64, start: i64) -> i64
Aegis.GetMinDistance.get_min_distance
pub fn get_min_distance(nums: &[i64], target: i64, start: i64) -> i64 { let n = nums.len(); let mut ans = n as i64; let mut i = 0; while i < n { if nums[i] == target { let idx = i as i64; let d = if idx >= start { idx - start } else { start - idx }; if d < ans...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [get_min_distance]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option lint...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [get_min_distance]: function definitions module public import Aeneas public import Aegis.GetMinDistance.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.GetMinDistance.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.GetMinDistance.get_min_distance (Slice.from [1#i64] (by scalar_tac) : Slice Std.I64) 1#i64 0#i64) (0#i64))}") #eval (s!"CASE 1 {(Result.reducesTo ...
[ { "input": "[[1], 1, 0]", "output": "0" }, { "input": "[[5, 1, 4, 1], 1, 2]", "output": "1" }, { "input": "[[1, 5, 3, 4, 5], 5, 2]", "output": "1" }, { "input": "[[4, 1, 3, 5, 2], 2, 1]", "output": "3" }, { "input": "[[4, 1, 3, 5, 6], 3, 1]", "output": "1" }...
117
false
117
verified
10
10
1
466
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.GetMinDistance.Code.Funs /-! # Specifications of `Aegis.GetMinDistance.get_min_distance` LeetCode problem `minimum-distance-to-the-target-element`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.GetMinDistance def nth (nums : Slice...
10
splitting-a-string-into-descending-consecutive-values
1,849
Medium
[ "String", "Backtracking" ]
You are given a string s that consists of only digits. Check if we can split s into two or more non-empty substrings such that the numerical values of the substrings are in descending order and the difference between numerical values of every two adjacent substrings is equal to 1. For example, the string s = "0090089"...
splitString(s: str) -> bool
pub fn split_string(s: &[u8]) -> bool
Aegis.SplitString.split_string
fn dec(canon: &[u8]) -> Vec<u8> { let len = canon.len(); let mut out: Vec<u8> = Vec::new(); let mut i = 0; while i < len { out.push(canon[i]); i += 1; } let mut j = len; let mut borrow: u8 = 1; while j > 0 && borrow == 1 { j -= 1; let d = out[j] - b'0'; ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [split_string]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter.s...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [split_string]: function definitions module public import Aeneas public import Aegis.SplitString.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.SplitString.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.SplitString.split_string (Slice.from [50#u8, 49#u8] (by scalar_tac) : Slice Std.U8)) (true))}") #eval (s!"CASE 1 {(Result.reducesTo (Aegis.SplitStrin...
[ { "input": "[\"21\"]", "output": "true" }, { "input": "[\"9876543210\"]", "output": "true" }, { "input": "[\"050043\"]", "output": "true" }, { "input": "[\"989796959493929190\"]", "output": "true" }, { "input": "[\"1009998\"]", "output": "true" }, { "i...
135
false
135
verified
10
10
2
34,942
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.SplitString.Code.Funs /-! # Specifications of `Aegis.SplitString.split_string` LeetCode problem `splitting-a-string-into-descending-consecutive-values`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Aeneas.Std.Result open Aegis.SplitString namespace AegisSpec.Sp...
11
minimum-adjacent-swaps-to-reach-the-kth-smallest-number
1,850
Medium
[ "Greedy", "Two Pointers", "String" ]
You are given a string num, representing a large integer, and an integer k. We call some integer wonderful if it is a permutation of the digits in num and is greater in value than num. There can be many wonderful integers. However, we only care about the smallest-valued ones. For example, when num = "5489355142": T...
getMinSwaps(num: str, k: int) -> int
pub fn get_min_swaps(num: &[u8], k: i64) -> i64
Aegis.GetMinSwaps.get_min_swaps
pub fn get_min_swaps(num: &[u8], k: i64) -> i64 { let n = num.len(); if n < 2 { return 0; } let mut target: Vec<u8> = Vec::new(); let mut i: usize = 0; while i < n { target.push(num[i]); i += 1; } let mut done: i64 = 0; while done < k { let mut pivot...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [get_min_swaps]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter....
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [get_min_swaps]: function definitions module public import Aeneas public import Aegis.GetMinSwaps.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.GetMinSwaps.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.GetMinSwaps.get_min_swaps (Slice.from [49#u8, 49#u8, 49#u8, 50#u8, 50#u8, 50#u8, 51#u8, 51#u8, 51#u8] (by scalar_tac) : Slice Std.U8) 10#i64) (3#i64)...
[ { "input": "[\"111222333\", 10]", "output": "3" }, { "input": "[\"1234567890\", 5]", "output": "2" }, { "input": "[\"1111111111\", 5]", "output": "0" }, { "input": "[\"9876543210\", 3]", "output": "0" }, { "input": "[\"5489355142\", 4]", "output": "2" }, {...
105
false
105
verified
10
10
1
6,320
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.GetMinSwaps.Code.Funs /-! # Specifications of `Aegis.GetMinSwaps.get_min_swaps` LeetCode problem `minimum-adjacent-swaps-to-reach-the-kth-smallest-number`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result ControlFlow Error namespace AegisSpec.GetMinSwaps ...
10
minimum-interval-to-include-each-query
1,851
Hard
[ "Array", "Binary Search", "Sorting", "Line Sweep", "Heap (Priority Queue)" ]
You are given a 2D integer array intervals, where intervals[i] = [lefti, righti] describes the ith interval starting at lefti and ending at righti (inclusive). The size of an interval is defined as the number of integers it contains, or more formally righti - lefti + 1. You are also given an integer array queries. The ...
minInterval(intervals: list_list_int, queries: list_int) -> list_int
pub fn min_interval(intervals: &[Vec<i64>], queries: &[i64]) -> Vec<i64>
Aegis.MinInterval.min_interval
fn interval_len(intervals: &[Vec<i64>], idx: usize) -> i64 { intervals[idx][1] - intervals[idx][0] + 1 } fn interval_less(intervals: &[Vec<i64>], a: usize, b: usize) -> bool { interval_len(intervals, a) < interval_len(intervals, b) } fn heap_push(intervals: &[Vec<i64>], heap: &mut Vec<usize>, x: usize) { ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [min_interval]: type definitions module public import Aeneas @[expose] public section 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_interval]: function definitions module public import Aeneas public import Aegis.MinInterval.Code.Types public import Aegis.MinInterval.Code.FunsExternal @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace fals...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [min_interval]: external functions. -- This is a template file: rename it to "FunsExternal.lean" and fill the holes. module public import Aeneas public import Aegis.MinInterval.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_o...
import Aegis.MinInterval.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.MinInterval.min_interval (Slice.from [(alloc.vec.Vec.from [1#i64, 1#i64] (by scalar_tac) : alloc.vec.Vec Std.I64)] (by scalar_tac) : Slice (alloc.vec...
[ { "input": "[[[1, 1]], [1]]", "output": "[1]" }, { "input": "[[[10000000, 10000000]], [10000000]]", "output": "[1]" }, { "input": "[[[1, 10000000]], [1, 5000000, 10000000]]", "output": "[10000000, 10000000, 10000000]" }, { "input": "[[[1, 1], [2, 2]], [1, 2, 3]]", "output...
104
false
104
verified
10
10
1
10,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.MinInterval.Code.Funs /-! # Specifications of `Aegis.MinInterval.min_interval` LeetCode problem `minimum-interval-to-include-each-query`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.MinInterval def row (intervals : Slice (alloc....
9
distinct-numbers-in-each-subarray
1,852
Medium
[ "Array", "Hash Table", "Sliding Window" ]
You are given an integer array nums of length n and an integer k. Your task is to find the number of distinct elements in every subarray of size k within nums. Return an array ans such that ans[i] is the count of distinct elements in nums[i..(i + k - 1)] for each index 0 <= i < n - k.   Example 1: Input: nums = [1,2,3...
distinctNumbers(nums: list_int, k: int) -> list_int
pub fn distinct_numbers(nums: &[i64], k: i64) -> Vec<i64>
Aegis.DistinctNumbers.distinct_numbers
pub fn distinct_numbers(nums: &[i64], k: i64) -> Vec<i64> { let mut ans: Vec<i64> = Vec::new(); if k <= 0 { return ans; } let n = nums.len(); let kk = k as usize; if kk > n { return ans; } // Number of windows = n - k + 1. let num_windows = n - kk + 1; let mu...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [distinct_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 lint...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [distinct_numbers]: function definitions module public import Aeneas public import Aegis.DistinctNumbers.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.DistinctNumbers.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": "[[10, 20, 30, 40, 50], 2]", "output": "[2, 2, 2, 2]" }, { "input": "[[5, 5, 5, 5, 5], 2]", "output": "[1, 1, 1, 1]" }, { "input": "[[5, 5, 5, 5, 5], 1]", "output": "[1, 1, 1, 1, 1]" }, { "input": "[[10, 20, 10, 20, 30, 40, 50], 5]", "output": "[3, 4, 5]" }, ...
108
false
108
verified
10
10
2
8,920
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.DistinctNumbers.Code.Funs /-! # Specifications of `Aegis.DistinctNumbers.distinct_numbers` LeetCode problem `distinct-numbers-in-each-subarray`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.DistinctNumbers namespace AegisSpec.DistinctNumbe...
13
maximum-population-year
1,854
Easy
[ "Array", "Counting", "Prefix Sum" ]
You are given a 2D integer array logs where each logs[i] = [birthi, deathi] indicates the birth and death years of the ith person. The population of some year x is the number of people alive during that year. The ith person is counted in year x's population if x is in the inclusive range [birthi, deathi - 1]. Note that...
maximumPopulation(logs: list_list_int) -> int
pub fn maximum_population(logs: &[Vec<i64>]) -> i64
Aegis.MaximumPopulation.maximum_population
pub fn maximum_population(logs: &[Vec<i64>]) -> i64 { // Difference array over years 1950..=2050 (101 entries). let mut diff: Vec<i64> = Vec::new(); let mut k: usize = 0; while k < 101 { diff.push(0); k = k + 1; } // Apply each person's birth (+1) and death (-1) events. let ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [maximum_population]: type definitions module public import Aeneas @[expose] public section 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_population]: function definitions module public import Aeneas public import Aegis.MaximumPopulation.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false ...
import Aegis.MaximumPopulation.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.MaximumPopulation.maximum_population (Slice.from [(alloc.vec.Vec.from [1950#i64, 2050#i64] (by scalar_tac) : alloc.vec.Vec Std.I64)] (by scalar...
[ { "input": "[[[1950, 2050]]]", "output": "1950" }, { "input": "[[[1993, 1999], [2000, 2010]]]", "output": "1993" }, { "input": "[[[2000, 2005], [2005, 2010], [2010, 2015]]]", "output": "2000" }, { "input": "[[[2000, 2010], [1990, 2000], [2000, 2020]]]", "output": "2000" ...
91
false
91
verified
10
10
2
3,229
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MaximumPopulation.Code.Funs /-! # Specifications of `Aegis.MaximumPopulation.maximum_population` LeetCode problem `maximum-population-year`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.MaximumPopulation abbrev Logs : Type := Slice (...
10
maximum-subarray-min-product
1,856
Medium
[ "Stack", "Array", "Prefix Sum", "Monotonic Stack" ]
The min-product of an array is equal to the minimum value in the array multiplied by the array's sum. For example, the array [3,2,5] (minimum value is 2) has a min-product of 2 * (3+2+5) = 2 * 10 = 20. Given an array of integers nums, return the maximum min-product of any non-empty subarray of nums. Since the answer ...
maxSumMinProduct(nums: list_int) -> int
pub fn max_sum_min_product(nums: &[i64]) -> i64
Aegis.MaxSumMinProduct.max_sum_min_product
pub fn max_sum_min_product(nums: &[i64]) -> i64 { let n = nums.len(); let mut prefix: Vec<i64> = Vec::new(); prefix.push(0); let mut i: usize = 0; while i < n { let next_sum = prefix[i] + nums[i]; prefix.push(next_sum); i += 1; } let mut stack: Vec<usize> = Vec::new...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [max_sum_min_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 l...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [max_sum_min_product]: function definitions module public import Aeneas public import Aegis.MaxSumMinProduct.Code.Types public import Aegis.MaxSumMinProduct.Code.FunsExternal @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter....
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [max_sum_min_product]: external functions. -- This is a template file: rename it to "FunsExternal.lean" and fill the holes. module public import Aeneas public import Aegis.MaxSumMinProduct.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow...
import Aegis.MaxSumMinProduct.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.MaxSumMinProduct.max_sum_min_product (Slice.from [1#i64] (by scalar_tac) : Slice Std.I64)) (1#i64))}") #eval (s!"CASE 1 {(Result.reducesTo (Aegi...
[ { "input": "[[1]]", "output": "1" }, { "input": "[[10000000]]", "output": "999300007" }, { "input": "[[2, 1]]", "output": "4" }, { "input": "[[1, 2]]", "output": "4" }, { "input": "[[10000000, 9999999, 9999998, 9999997]]", "output": "817200025" }, { "i...
101
false
101
verified
10
10
1
4,832
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MaxSumMinProduct.Code.Funs /-! # Specifications of `Aegis.MaxSumMinProduct.max_sum_min_product` LeetCode problem `maximum-subarray-min-product`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.MaxSumMinProduct def p : Int := 1000000...
10
largest-color-value-in-a-directed-graph
1,857
Hard
[ "Graph", "Topological Sort", "Memoization", "Hash Table", "Dynamic Programming", "Counting" ]
There is a directed graph of n colored nodes and m edges. The nodes are numbered from 0 to n - 1.\r \r You are given a string colors where colors[i] is a lowercase English letter representing the color of the ith node in this graph (0-indexed). You are also given a 2D array edges where edges[j] = [aj, bj] indicates tha...
largestPathValue(colors: str, edges: list_list_int) -> int
pub fn largest_path_value(colors: &[u8], edges: &[Vec<i64>]) -> i64
Aegis.LargestPathValue.largest_path_value
pub fn largest_path_value(colors: &[u8], edges: &[Vec<i64>]) -> i64 { let n = colors.len(); if n == 0 { return 0; } let mut head: Vec<i64> = Vec::new(); let mut indeg: Vec<i64> = Vec::new(); let mut i = 0; while i < n { head.push(-1); indeg.push(0); i += 1; ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [largest_path_value]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option li...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [largest_path_value]: function definitions module public import Aeneas public import Aegis.LargestPathValue.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.LargestPathValue.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.LargestPathValue.largest_path_value (Slice.from [97#u8, 98#u8, 99#u8, 100#u8, 101#u8] (by scalar_tac) : Slice Std.U8) (Slice.from [] (by scalar_...
[ { "input": "[\"abcde\", []]", "output": "1" }, { "input": "[\"a\", []]", "output": "1" }, { "input": "[\"a\", [[0, 0]]]", "output": "-1" }, { "input": "[\"ab\", [[0, 1]]]", "output": "1" }, { "input": "[\"xyz\", [[0, 1], [1, 2]]]", "output": "1" }, { "...
84
false
84
verified
10
10
1
5,699
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.LargestPathValue.Code.Funs /-! # Specifications of `Aegis.LargestPathValue.largest_path_value` LeetCode problem `largest-color-value-in-a-directed-graph`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.LargestPathValue def colorAt ...
11
incremental-memory-leak
1,860
Medium
[ "Math", "Simulation" ]
You are given two integers memory1 and memory2 representing the available memory in bits on two memory sticks. There is currently a faulty program running that consumes an increasing amount of memory every second. At the ith second (starting from 1), i bits of memory are allocated to the stick with more available memor...
memLeak(memory1: int, memory2: int) -> list_int
pub fn mem_leak(memory1: i64, memory2: i64) -> Vec<i64>
Aegis.MemLeak.mem_leak
pub fn mem_leak(memory1: i64, memory2: i64) -> Vec<i64> { let mut m1 = memory1; let mut m2 = memory2; let mut time: i64 = 1; let mut crashed: bool = false; while !crashed { if m1 >= m2 { if m1 >= time { m1 -= time; time += 1; } else { ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [mem_leak]: type definitions module public import Aeneas @[expose] public section 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 -- [mem_leak]: function definitions module public import Aeneas public import Aegis.MemLeak.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.MemLeak.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.MemLeak.mem_leak 0#i64 0#i64) ((alloc.vec.Vec.from [1#i64, 0#i64, 0#i64] (by scalar_tac) : alloc.vec.Vec Std.I64)))}") #eval (s!"CASE 1 {(Result.reducesT...
[ { "input": "[0, 0]", "output": "[1, 0, 0]" }, { "input": "[2147483647, 2147483647]", "output": "[92681, 88047, 41707]" }, { "input": "[1000000000, 1000000000]", "output": "[63245, 49116, 17494]" }, { "input": "[15, 10]", "output": "[7, 4, 0]" }, { "input": "[100, ...
81
false
81
verified
10
10
2
1,392
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MemLeak.Code.Funs /-! # Specifications of `Aegis.MemLeak.mem_leak` LeetCode problem `incremental-memory-leak`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.MemLeak def IsLeastT (n t : ℤ) : Prop := (1 : ℤ) ≤ t ∧ n < t * (t + 1) / 2 ...
14
sum-of-floored-pairs
1,862
Hard
[ "Array", "Math", "Binary Search", "Prefix Sum" ]
Given an integer array nums, return the sum of floor(nums[i] / nums[j]) for all pairs of indices 0 <= i, j < nums.length in the array. Since the answer may be too large, return it modulo 109 + 7. The floor() function returns the integer part of the division.   Example 1: Input: nums = [2,5,9] Output: 10 Explanation: f...
sumOfFlooredPairs(nums: list_int) -> int
pub fn sum_of_floored_pairs(nums: &[i64]) -> i64
Aegis.SumOfFlooredPairs.sum_of_floored_pairs
pub fn sum_of_floored_pairs(nums: &[i64]) -> i64 { let n: usize = nums.len(); if n == 0 { return 0; } let modv: i64 = 1000000007; // For small inputs, direct evaluation is both simple and fast. if n <= 128 { let mut ans: i64 = 0; let mut i: usize = 0; while i < ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [sum_of_floored_pairs]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [sum_of_floored_pairs]: function definitions module public import Aeneas public import Aegis.SumOfFlooredPairs.Code.Types public import Aegis.SumOfFlooredPairs.Code.FunsExternal @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option lint...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [sum_of_floored_pairs]: external functions. -- This is a template file: rename it to "FunsExternal.lean" and fill the holes. module public import Aeneas public import Aegis.SumOfFlooredPairs.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFl...
import Aegis.SumOfFlooredPairs.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval aeg...
[ { "input": "[[2, 5, 9]]", "output": "10" }, { "input": "[[100000, 1, 100000]]", "output": "200005" }, { "input": "[[100000, 100000, 100000]]", "output": "9" }, { "input": "[[100000, 50000, 25000, 12500, 6250]]", "output": "57" }, { "input": "[[10, 20, 30, 40, 50]]...
60
false
60
verified
10
10
3
20,855
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.SumOfFlooredPairs.Code.Funs /-! # Specifications of `Aegis.SumOfFlooredPairs.sum_of_floored_pairs` LeetCode problem `sum-of-floored-pairs`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.SumOfFlooredPairs def M : Int := 1000000007 def...
10
sum-of-all-subset-xor-totals
1,863
Easy
[ "Bit Manipulation", "Array", "Math", "Backtracking", "Combinatorics", "Enumeration" ]
The XOR total of an array is defined as the bitwise XOR of all its elements, or 0 if the array is empty. For example, the XOR total of the array [2,5,6] is 2 XOR 5 XOR 6 = 1. Given an array nums, return the sum of all XOR totals for every subset of nums.  Note: Subsets with the same elements should be counted multipl...
subsetXORSum(nums: list_int) -> int
pub fn subset_xor_sum(nums: &[i64]) -> i64
Aegis.SubsetXorSum.subset_xor_sum
pub fn subset_xor_sum(nums: &[i64]) -> i64 { let n = nums.len(); if n == 0 { return 0; } let mut bit_or: i64 = 0; let mut i: usize = 0; while i < n { bit_or |= nums[i]; i += 1; } let mut multiplier: i64 = 1; let mut j: usize = 1; while j < n { mu...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [subset_xor_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 -- [subset_xor_sum]: function definitions module public import Aeneas public import Aegis.SubsetXorSum.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.SubsetXorSum.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.SubsetXorSum.subset_xor_sum (Slice.from [1#i64] (by scalar_tac) : Slice Std.I64)) (1#i64))}") #eval (s!"CASE 1 {(Result.reducesTo (Aegis.SubsetXorSu...
[ { "input": "[[1]]", "output": "1" }, { "input": "[[1, 3]]", "output": "6" }, { "input": "[[5, 1, 6]]", "output": "28" }, { "input": "[[10, 20, 30]]", "output": "120" }, { "input": "[[10, 11, 12]]", "output": "60" }, { "input": "[[2, 3, 5]]", "outpu...
99
false
99
verified
10
10
1
541
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.SubsetXorSum.Code.Funs /-! # Specifications of `Aegis.SubsetXorSum.subset_xor_sum` LeetCode problem `sum-of-all-subset-xor-totals`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.SubsetXorSum open Aegis.SubsetXorSum def vals (nu...
15
minimum-number-of-swaps-to-make-the-binary-string-alternating
1,864
Medium
[ "Greedy", "String" ]
Given a binary string s, return the minimum number of character swaps to make it alternating, or -1 if it is impossible. The string is called alternating if no two adjacent characters are equal. For example, the strings "010" and "1010" are alternating, while the string "0100" is not. Any two characters may be swapped,...
minSwaps(s: str) -> int
pub fn min_swaps(s: &[u8]) -> i64
Aegis.MinSwaps.min_swaps
pub fn min_swaps(s: &[u8]) -> i64 { let n: usize = s.len(); let mut zeros: i64 = 0; let mut i: usize = 0; while i < n { if s[i] == b'0' { zeros += 1; } i += 1; } let n_i64: i64 = n as i64; let mut mismatch_start0: i64 = 0; i = 0; while i < n { ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [min_swaps]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter.styl...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [min_swaps]: function definitions module public import Aeneas public import Aegis.MinSwaps.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter....
import Aegis.MinSwaps.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.MinSwaps.min_swaps (Slice.from [49#u8, 49#u8, 49#u8, 49#u8] (by scalar_tac) : Slice Std.U8)) ((-1)#i64))}") #eval (s!"CASE 1 {(Result.reducesTo (Aegis.M...
[ { "input": "[\"1111\"]", "output": "-1" }, { "input": "[\"1100110\"]", "output": "2" }, { "input": "[\"110011\"]", "output": "-1" }, { "input": "[\"00110011\"]", "output": "2" }, { "input": "[\"0101010\"]", "output": "0" }, { "input": "[\"111\"]", ...
243
false
243
verified
10
10
1
1,773
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MinSwaps.Code.Funs /-! # Specifications of `Aegis.MinSwaps.min_swaps` LeetCode problem `minimum-number-of-swaps-to-make-the-binary-string-alternating`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.MinSwaps def bytes (s : Slice Std.U8...
12
number-of-ways-to-rearrange-sticks-with-k-sticks-visible
1,866
Hard
[ "Math", "Dynamic Programming", "Combinatorics" ]
There are n uniquely-sized sticks whose lengths are integers from 1 to n. You want to arrange the sticks such that exactly k sticks are visible from the left. A stick is visible from the left if there are no longer sticks to the left of it. For example, if the sticks are arranged [1,3,2,5,4], then the sticks with leng...
rearrangeSticks(n: int, k: int) -> int
pub fn rearrange_sticks(n: i64, k: i64) -> i64
Aegis.RearrangeSticks.rearrange_sticks
pub fn rearrange_sticks(n: i64, k: i64) -> i64 { let md: i64 = 1000000007; if k <= 0 { if n == 0 && k == 0 { return 1; } return 0; } if n <= 0 || k > n { return 0; } let kk: usize = k as usize; let nn: usize = n as usize; let mut dp: Vec<i6...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [rearrange_sticks]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option lint...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [rearrange_sticks]: function definitions module public import Aeneas public import Aegis.RearrangeSticks.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.RearrangeSticks.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.RearrangeSticks.rearrange_sticks 10#i64 1#i64) (362880#i64))}") #eval (s!"CASE 1 {(Result.reducesTo (Aegis.RearrangeSticks.rearrange_sticks 1000#...
[ { "input": "[10, 1]", "output": "362880" }, { "input": "[1000, 500]", "output": "761367694" }, { "input": "[7, 4]", "output": "735" }, { "input": "[1, 1]", "output": "1" }, { "input": "[3, 2]", "output": "3" }, { "input": "[100, 50]", "output": "76...
57
false
57
verified
10
10
1
3,826
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.RearrangeSticks.Code.Funs /-! # Specifications of `Aegis.RearrangeSticks.rearrange_sticks` LeetCode problem `number-of-ways-to-rearrange-sticks-with-k-sticks-visible`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.RearrangeSticks open scoped Big...
10
product-of-two-run-length-encoded-arrays
1,868
Medium
[ "Array", "Two Pointers" ]
Run-length encoding is a compression algorithm that allows for an integer array nums with many segments of consecutive repeated numbers to be represented by a (generally smaller) 2D array encoded. Each encoded[i] = [vali, freqi] describes the ith segment of repeated numbers in nums where vali is the value that is repea...
findRLEArray(encoded1: list_list_int, encoded2: list_list_int) -> list_list_int
pub fn find_rle_array(encoded1: &[Vec<i64>], encoded2: &[Vec<i64>]) -> Vec<Vec<i64>>
Aegis.FindRleArray.find_rle_array
pub fn find_rle_array(encoded1: &[Vec<i64>], encoded2: &[Vec<i64>]) -> Vec<Vec<i64>> { let n1 = encoded1.len(); let n2 = encoded2.len(); let mut out: Vec<Vec<i64>> = Vec::new(); let mut i: usize = 0; let mut j: usize = 0; let mut rem1: i64 = 0; let mut rem2: i64 = 0; if n1 > 0 { ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [find_rle_array]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [find_rle_array]: function definitions module public import Aeneas public import Aegis.FindRleArray.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.FindRleArray.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.FindRleArray.find_rle_array (Slice.from [(alloc.vec.Vec.from [10#i64, 4#i64] (by scalar_tac) : alloc.vec.Vec Std.I64)] (by scalar_tac) : Slice (allo...
[ { "input": "[[[10, 4]], [[2, 4]]]", "output": "[[20, 4]]" }, { "input": "[[[1, 5]], [[2, 5]]]", "output": "[[2, 5]]" }, { "input": "[[[5, 4]], [[2, 4]]]", "output": "[[10, 4]]" }, { "input": "[[[5, 4]], [[1, 4]]]", "output": "[[5, 4]]" }, { "input": "[[[7, 4]], [[...
99
false
99
verified
10
10
1
2,692
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.FindRleArray.Code.Funs /-! # Specifications of `Aegis.FindRleArray.find_rle_array` LeetCode problem `product-of-two-run-length-encoded-arrays`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.FindRleArray open Aegis.FindRleArray abbrev...
13
longer-contiguous-segments-of-ones-than-zeros
1,869
Easy
[ "String" ]
Given a binary string s, return true if the longest contiguous segment of 1's is strictly longer than the longest contiguous segment of 0's in s, or return false otherwise. For example, in s = "110100010" the longest continuous segment of 1s has length 2, and the longest continuous segment of 0s has length 3. Note th...
checkZeroOnes(s: str) -> bool
pub fn check_zero_ones(s: &[u8]) -> bool
Aegis.CheckZeroOnes.check_zero_ones
pub fn check_zero_ones(s: &[u8]) -> bool { let n = s.len(); let mut max_ones: i64 = 0; let mut max_zeros: i64 = 0; let mut cur_ones: i64 = 0; let mut cur_zeros: i64 = 0; let mut i: usize = 0; while i < n { if s[i] == b'1' { cur_ones += 1; cur_zeros = 0; ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [check_zero_ones]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linte...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [check_zero_ones]: function definitions module public import Aeneas public import Aegis.CheckZeroOnes.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.CheckZeroOnes.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.CheckZeroOnes.check_zero_ones (Slice.from [49#u8, 49#u8, 49#u8, 49#u8] (by scalar_tac) : Slice Std.U8)) (true))}") #eval (s!"CASE 1 {(Result.reduce...
[ { "input": "[\"1111\"]", "output": "true" }, { "input": "[\"111000\"]", "output": "false" }, { "input": "[\"101010\"]", "output": "false" }, { "input": "[\"11100111\"]", "output": "true" }, { "input": "[\"11001100\"]", "output": "false" }, { "input": "...
161
false
161
verified
10
10
1
390
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.CheckZeroOnes.Code.Funs /-! # Specifications of `Aegis.CheckZeroOnes.check_zero_ones` LeetCode problem `longer-contiguous-segments-of-ones-than-zeros`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.CheckZeroOnes def byteAt (s : Sl...
15
jump-game-vii
1,871
Medium
[ "String", "Dynamic Programming", "Prefix Sum", "Sliding Window" ]
You are given a 0-indexed binary string s and two integers minJump and maxJump. In the beginning, you are standing at index 0, which is equal to '0'. You can move from index i to index j if the following conditions are fulfilled: i + minJump <= j <= min(i + maxJump, s.length - 1), and s[j] == '0'. Return true if you ...
canReach(s: str, minJump: int, maxJump: int) -> bool
pub fn can_reach(s: &[u8], minJump: i64, maxJump: i64) -> bool
Aegis.CanReach.can_reach
pub fn can_reach(s: &[u8], minJump: i64, maxJump: i64) -> bool { let n = s.len(); if n == 0 { return false; } if n == 1 { return true; } let min_j = minJump as usize; let max_j = maxJump as usize; let mut reach: Vec<bool> = Vec::new(); let mut k: usize = 0; whil...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [can_reach]: type definitions module public import Aeneas @[expose] public section 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 -- [can_reach]: function definitions module public import Aeneas public import Aegis.CanReach.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.CanReach.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.CanReach.can_reach (Slice.from [48#u8, 49#u8, 48#u8, 48#u8, 49#u8, 48#u8, 48#u8, 48#u8, 49#u8, 48#u8, 48#u8, 48#u8, 49#u8, 48#u8, 48#u8, 48#u8] (by scal...
[ { "input": "[\"0100100010001000\", 2, 5]", "output": "true" }, { "input": "[\"00001000\", 2, 4]", "output": "true" }, { "input": "[\"0010010010010010010010010010010010010010\", 2, 4]", "output": "true" }, { "input": "[\"011010\", 2, 3]", "output": "true" }, { "inp...
49
false
49
verified
10
10
1
4,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.CanReach.Code.Funs /-! # Specifications of `Aegis.CanReach.can_reach` LeetCode problem `jump-game-vii`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.CanReach def byteAt (s : Slice U8) (i : Nat) : Option Nat := (s.val[i]?).map (fun b ...
14
stone-game-viii
1,872
Hard
[ "Array", "Math", "Dynamic Programming", "Game Theory", "Prefix Sum" ]
Alice and Bob take turns playing a game, with Alice starting first.\r \r There are n stones arranged in a row. On each player's turn, while the number of stones is more than one, they will do the following:\r \r \r Choose an integer x > 1, and remove the leftmost x stones from the row.\r Add the sum of the removed st...
stoneGameVIII(stones: list_int) -> int
pub fn stone_game_viii(stones: &[i64]) -> i64
Aegis.StoneGameViii.stone_game_viii
pub fn stone_game_viii(stones: &[i64]) -> i64 { let n = stones.len(); let mut prefix: Vec<i64> = Vec::new(); let mut sum: i64 = 0; let mut i: usize = 0; while i < n { sum += stones[i]; prefix.push(sum); i += 1; } let mut ans: i64 = prefix[n - 1]; let mut j: usi...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [stone_game_viii]: type definitions module public import Aeneas @[expose] public section 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 -- [stone_game_viii]: function definitions module public import Aeneas public import Aegis.StoneGameViii.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.StoneGameViii.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.StoneGameViii.stone_game_viii (Slice.from [(-10)#i64, (-12)#i64] (by scalar_tac) : Slice Std.I64)) ((-22)#i64))}") #eval (s!"CASE 1 {(Result.reduce...
[ { "input": "[[-10, -12]]", "output": "-22" }, { "input": "[[1, 2, 3, 4, 5]]", "output": "15" }, { "input": "[[100, -100, 100, -100, 100]]", "output": "100" }, { "input": "[[-1, -2, -3, -4, -5]]", "output": "5" }, { "input": "[[-5, -4, -3, -2, -1]]", "output": ...
79
false
79
verified
10
10
1
1,740
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.StoneGameViii.Code.Funs /-! # Specifications of `Aegis.StoneGameViii.stone_game_viii` LeetCode problem `stone-game-viii`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.StoneGameViii def P (s : List I64) (m : Nat) : Int := ((s.take m)....
13
substrings-of-size-three-with-distinct-characters
1,876
Easy
[ "Hash Table", "String", "Counting", "Sliding Window" ]
A string is good if there are no repeated characters. Given a string s​​​​​, return the number of good substrings of length three in s​​​​​​. Note that if there are multiple occurrences of the same substring, every occurrence should be counted. A substring is a contiguous sequence of characters in a string.   Example 1...
countGoodSubstrings(s: str) -> int
pub fn count_good_substrings(s: &[u8]) -> i64
Aegis.CountGoodSubstrings.count_good_substrings
pub fn count_good_substrings(s: &[u8]) -> i64 { let n = s.len(); if n < 3 { return 0; } let mut count: i64 = 0; let mut i: usize = 0; while i + 2 < n { if s[i] != s[i + 1] && s[i] != s[i + 2] && s[i + 1] != s[i + 2] { count += 1; } i += 1; } ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [count_good_substrings]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [count_good_substrings]: function definitions module public import Aeneas public import Aegis.CountGoodSubstrings.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand f...
import Aegis.CountGoodSubstrings.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.CountGoodSubstrings.count_good_substrings (Slice.from [120#u8, 121#u8, 122#u8, 120#u8, 121#u8, 122#u8, 120#u8, 121#u8, 122#u8] (by scalar_tac...
[ { "input": "[\"xyzxyzxyz\"]", "output": "7" }, { "input": "[\"abcabcabc\"]", "output": "7" }, { "input": "[\"xyzzaz\"]", "output": "1" }, { "input": "[\"aabbcc\"]", "output": "0" }, { "input": "[\"abacab\"]", "output": "2" }, { "input": "[\"qqqppprrr\"...
96
false
96
verified
10
10
1
375
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.CountGoodSubstrings.Code.Funs /-! # Specifications of `Aegis.CountGoodSubstrings.count_good_substrings` LeetCode problem `substrings-of-size-three-with-distinct-characters`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.CountGoodSubstr...
10
minimize-maximum-pair-sum-in-array
1,877
Medium
[ "Greedy", "Array", "Two Pointers", "Sorting" ]
The pair sum of a pair (a,b) is equal to a + b. The maximum pair sum is the largest pair sum in a list of pairs.\r \r \r For example, if we have pairs (1,5), (2,3), and (4,4), the maximum pair sum would be max(1+5, 2+3, 4+4) = max(6, 5, 8) = 8.\r \r \r Given an array nums of even length n, pair up the elements of nums...
minPairSum(nums: list_int) -> int
pub fn min_pair_sum(nums: &[i64]) -> i64
Aegis.MinPairSum.min_pair_sum
pub fn min_pair_sum(nums: &[i64]) -> i64 { let n = nums.len(); if n == 0 { return 0; } let mut v: Vec<i64> = Vec::new(); let mut i: usize = 0; while i < n { v.push(nums[i]); i += 1; } // Build a max-heap. let mut start: usize = n / 2; while start > 0 { ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [min_pair_sum]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter.s...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [min_pair_sum]: function definitions module public import Aeneas public import Aegis.MinPairSum.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.MinPairSum.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, 10, 10, 10]]", "output": "20" }, { "input": "[[1, 1, 1, 1]]", "output": "2" }, { "input": "[[3, 5, 2, 3]]", "output": "7" }, { "input": "[[1, 6, 2, 5, 3, 4]]", "output": "7" }, { "input": "[[100000, 1, 100000, 1, 100000, 1]]", "output": "1000...
97
false
97
verified
10
10
2
5,415
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MinPairSum.Code.Funs /-! # Specifications of `Aegis.MinPairSum.min_pair_sum` LeetCode problem `minimize-maximum-pair-sum-in-array`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result set_option maxHeartbeats 1000000 namespace AegisSpec.MinPairSum def vals (n...
11
get-biggest-three-rhombus-sums-in-a-grid
1,878
Medium
[ "Array", "Math", "Matrix", "Prefix Sum", "Sorting", "Heap (Priority Queue)" ]
You are given an m x n integer matrix grid​​​. A rhombus sum is the sum of the elements that form the border of a regular rhombus shape in grid​​​. The rhombus must have the shape of a square rotated 45 degrees with each of the corners centered in a grid cell. Below is an image of four valid rhombus shapes with the cor...
getBiggestThree(grid: list_list_int) -> list_int
pub fn get_biggest_three(grid: &[Vec<i64>]) -> Vec<i64>
Aegis.GetBiggestThree.get_biggest_three
pub fn get_biggest_three(grid: &[Vec<i64>]) -> Vec<i64> { let m = grid.len(); if m == 0 { return Vec::new(); } let n = grid[0].len(); if n == 0 { return Vec::new(); } let mut top0: i64 = -1; let mut top1: i64 = -1; let mut top2: i64 = -1; let mut i: usize = 0; ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [get_biggest_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 lin...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [get_biggest_three]: function definitions module public import Aeneas public import Aegis.GetBiggestThree.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.GetBiggestThree.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.GetBiggestThree.get_biggest_three (Slice.from [(alloc.vec.Vec.from [5#i64] (by scalar_tac) : alloc.vec.Vec Std.I64)] (by scalar_tac) : Slice (all...
[ { "input": "[[[5]]]", "output": "[5]" }, { "input": "[[[1]]]", "output": "[1]" }, { "input": "[[[7, 7, 7]]]", "output": "[7]" }, { "input": "[[[100000, 100000], [100000, 100000]]]", "output": "[100000]" }, { "input": "[[[1, 2], [2, 1]]]", "output": "[2, 1]" ...
118
false
118
verified
10
10
1
5,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.GetBiggestThree.Code.Funs /-! # Specifications of `Aegis.GetBiggestThree.get_biggest_three` LeetCode problem `get-biggest-three-rhombus-sums-in-a-grid`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.GetBiggestThree def rowLen (grid : ...
15
minimum-xor-sum-of-two-arrays
1,879
Hard
[ "Bit Manipulation", "Array", "Dynamic Programming", "Bitmask" ]
You are given two integer arrays nums1 and nums2 of length n. The XOR sum of the two integer arrays is (nums1[0] XOR nums2[0]) + (nums1[1] XOR nums2[1]) + ... + (nums1[n - 1] XOR nums2[n - 1]) (0-indexed). For example, the XOR sum of [1,2,3] and [3,2,1] is equal to (1 XOR 3) + (2 XOR 2) + (3 XOR 1) = 2 + 0 + 2 = 4. R...
minimumXORSum(nums1: list_int, nums2: list_int) -> int
pub fn minimum_xor_sum(nums1: &[i64], nums2: &[i64]) -> i64
Aegis.MinimumXorSum.minimum_xor_sum
pub fn minimum_xor_sum(nums1: &[i64], nums2: &[i64]) -> i64 { let n = nums1.len(); if n == 0 { return 0; } let total = 1usize << n; let inf: i64 = 1i64 << 60; let mut dp: Vec<i64> = Vec::new(); let mut k = 0usize; while k < total { dp.push(inf); k += 1; } ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [minimum_xor_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 linte...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [minimum_xor_sum]: function definitions module public import Aeneas public import Aegis.MinimumXorSum.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.MinimumXorSum.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.MinimumXorSum.minimum_xor_sum (Slice.from [1#i64] (by scalar_tac) : Slice Std.I64) (Slice.from [1#i64] (by scalar_tac) : Slice Std.I64)) (0#i64))}"...
[ { "input": "[[1], [1]]", "output": "0" }, { "input": "[[1, 2], [2, 3]]", "output": "2" }, { "input": "[[3, 4, 2], [4, 2, 2]]", "output": "1" }, { "input": "[[4, 6, 2], [9, 3, 5]]", "output": "17" }, { "input": "[[5, 10, 15], [15, 10, 5]]", "output": "0" }, ...
93
false
93
verified
10
10
1
1,398
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MinimumXorSum.Code.Funs /-! # Specifications of `Aegis.MinimumXorSum.minimum_xor_sum` LeetCode problem `minimum-xor-sum-of-two-arrays`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.MinimumXorSum namespace AegisSpec.MinimumXorSum def elem (xs ...
13
process-tasks-using-servers
1,882
Medium
[ "Array", "Heap (Priority Queue)" ]
You are given two 0-indexed integer arrays servers and tasks of lengths n​​​​​​ and m​​​​​​ respectively. servers[i] is the weight of the i​​​​​​th​​​​ server, and tasks[j] is the time needed to process the j​​​​​​th​​​​ task in seconds. Tasks are assigned to the servers using a task queue. Initially, all servers are f...
assignTasks(servers: list_int, tasks: list_int) -> list_int
pub fn assign_tasks(servers: &[i64], tasks: &[i64]) -> Vec<i64>
Aegis.AssignTasks.assign_tasks
fn free_less(a_weight: i64, a_idx: i64, b_weight: i64, b_idx: i64) -> bool { if a_weight < b_weight { return true; } if a_weight > b_weight { return false; } a_idx < b_idx } fn free_push(weights: &mut Vec<i64>, indices: &mut Vec<i64>, w: i64, idx: i64) { weights.push(w); ind...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [assign_tasks]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter.s...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [assign_tasks]: function definitions module public import Aeneas public import Aegis.AssignTasks.Code.Types public import Aegis.AssignTasks.Code.FunsExternal @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace fals...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [assign_tasks]: external functions. -- This is a template file: rename it to "FunsExternal.lean" and fill the holes. module public import Aeneas public import Aegis.AssignTasks.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_o...
import Aegis.AssignTasks.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.AssignTasks.assign_tasks (Slice.from [1#i64] (by scalar_tac) : Slice Std.I64) (Slice.from [10#i64] (by scalar_tac) : Slice Std.I64)) ((alloc.vec.Vec....
[ { "input": "[[1], [10]]", "output": "[0]" }, { "input": "[[10, 20, 30], [3, 2, 1]]", "output": "[0, 1, 2]" }, { "input": "[[1, 2, 3], [3, 2, 1]]", "output": "[0, 1, 2]" }, { "input": "[[1, 1, 1], [10, 20, 30, 40, 50]]", "output": "[0, 1, 2, 0, 1]" }, { "input": "[...
111
false
111
verified
10
10
1
14,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.AssignTasks.Code.Funs /-! # Specifications of `Aegis.AssignTasks.assign_tasks` LeetCode problem `process-tasks-using-servers`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.AssignTasks def vals (s : Slice Std.I64) : List ℤ := s.va...
5
minimum-skips-to-arrive-at-meeting-on-time
1,883
Hard
[ "Array", "Dynamic Programming" ]
You are given an integer hoursBefore, the number of hours you have to travel to your meeting. To arrive at your meeting, you have to travel through n roads. The road lengths are given as an integer array dist of length n, where dist[i] describes the length of the ith road in kilometers. In addition, you are given an in...
minSkips(dist: list_int, speed: int, hoursBefore: int) -> int
pub fn min_skips(dist: &[i64], speed: i64, hoursBefore: i64) -> i64
Aegis.MinSkips.min_skips
pub fn min_skips(dist: &[i64], speed: i64, hoursBefore: i64) -> i64 { let n = dist.len(); let inf: i64 = 1_000_000_000_000_000_000; let mut dp: Vec<i64> = Vec::new(); let mut i = 0; while i <= n { dp.push(inf); i += 1; } dp[0] = 0; let mut road = 0; while road < n {...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [min_skips]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter.styl...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [min_skips]: function definitions module public import Aeneas public import Aegis.MinSkips.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.MinSkips.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.MinSkips.min_skips (Slice.from [10#i64, 10#i64, 10#i64] (by scalar_tac) : Slice Std.I64) 5#i64 6#i64) (0#i64))}") #eval (s!"CASE 1 {(Result.reducesTo (A...
[ { "input": "[[10, 10, 10], 5, 6]", "output": "0" }, { "input": "[[10, 10, 10], 10, 3]", "output": "0" }, { "input": "[[1, 3, 2], 4, 2]", "output": "1" }, { "input": "[[100000, 100000, 100000], 100000, 3]", "output": "0" }, { "input": "[[10, 10, 10], 5, 5]", "o...
114
false
114
verified
10
10
1
3,797
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MinSkips.Code.Funs /-! # Specifications of `Aegis.MinSkips.min_skips` LeetCode problem `minimum-skips-to-arrive-at-meeting-on-time`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.MinSkips set_option autoImplicit false noncomput...
11
egg-drop-with-2-eggs-and-n-floors
1,884
Medium
[ "Math", "Dynamic Programming" ]
You are given two identical eggs and you have access to a building with n floors labeled from 1 to n. You know that there exists a floor f where 0 <= f <= n such that any egg dropped at a floor higher than f will break, and any egg dropped at or below floor f will not break. In each move, you may take an unbroken egg a...
twoEggDrop(n: int) -> int
pub fn two_egg_drop(n: i64) -> i64
Aegis.TwoEggDrop.two_egg_drop
pub fn two_egg_drop(n: i64) -> i64 { let mut moves: i64 = 0; let mut covered: i64 = 0; while covered < n { moves += 1; covered += moves; } moves }
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [two_egg_drop]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter.s...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [two_egg_drop]: function definitions module public import Aeneas public import Aegis.TwoEggDrop.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.TwoEggDrop.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.TwoEggDrop.two_egg_drop 8#i64) (4#i64))}") #eval (s!"CASE 1 {(Result.reducesTo (Aegis.TwoEggDrop.two_egg_drop 1000#i64) (45#i64))}") #eval (s!"CASE 2 ...
[ { "input": "[8]", "output": "4" }, { "input": "[1000]", "output": "45" }, { "input": "[5]", "output": "3" }, { "input": "[81]", "output": "13" }, { "input": "[999]", "output": "45" }, { "input": "[15]", "output": "5" }, { "input": "[64]", ...
46
false
46
verified
10
10
1
433
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.TwoEggDrop.Code.Funs /-! # Specifications of `Aegis.TwoEggDrop.two_egg_drop` LeetCode problem `egg-drop-with-2-eggs-and-n-floors`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.TwoEggDrop namespace AegisSpec.TwoEggDrop def T (m : ℤ) : ℤ := m ...
9
count-pairs-in-two-arrays
1,885
Medium
[ "Array", "Two Pointers", "Binary Search", "Sorting" ]
Given two integer arrays nums1 and nums2 of length n, count the pairs of indices (i, j) such that i < j and nums1[i] + nums1[j] > nums2[i] + nums2[j]. Return the number of pairs satisfying the condition.   Example 1: Input: nums1 = [2,1,2,1], nums2 = [1,2,1,2] Output: 1 Explanation: The pairs satisfying the condition ...
countPairs(nums1: list_int, nums2: list_int) -> int
pub fn count_pairs(nums1: &[i64], nums2: &[i64]) -> i64
Aegis.CountPairs.count_pairs
pub fn count_pairs(nums1: &[i64], nums2: &[i64]) -> i64 { let n = nums1.len(); if n < 2 { return 0; } let mut d: Vec<i64> = Vec::new(); let mut i: usize = 0; while i < n { d.push(nums1[i] - nums2[i]); i += 1; } let mut buf: Vec<i64> = Vec::new(); i = 0; ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [count_pairs]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter.st...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [count_pairs]: function definitions module public import Aeneas public import Aegis.CountPairs.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option lin...
import Aegis.CountPairs.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval aegisCase ...
[ { "input": "[[100000, 100000, 100000], [1, 1, 1]]", "output": "3" }, { "input": "[[100000, 100000, 100000], [1, 1, 1]]", "output": "3" }, { "input": "[[100000, 1, 1, 1], [1, 100000, 100000, 100000]]", "output": "0" }, { "input": "[[5, 5, 5, 5], [1, 1, 1, 1]]", "output": "...
73
false
73
verified
10
10
2
20,442
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.CountPairs.Code.Funs /-! # Specifications of `Aegis.CountPairs.count_pairs` LeetCode problem `count-pairs-in-two-arrays`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.CountPairs open Aegis.CountPairs def vals (s : Slice Std.I64) : L...
14
determine-whether-matrix-can-be-obtained-by-rotation
1,886
Easy
[ "Array", "Matrix" ]
Given two n x n binary matrices mat and target, return true if it is possible to make mat equal to target by rotating mat in 90-degree increments, or false otherwise.   Example 1: Input: mat = [[0,1],[1,0]], target = [[1,0],[0,1]] Output: true Explanation: We can rotate mat 90 degrees clockwise to make mat equal targ...
findRotation(mat: list_list_int, target: list_list_int) -> bool
pub fn find_rotation(mat: &[Vec<i64>], target: &[Vec<i64>]) -> bool
Aegis.FindRotation.find_rotation
pub fn find_rotation(mat: &[Vec<i64>], target: &[Vec<i64>]) -> bool { let n = mat.len(); if n == 0 { return true; } let mut rot: usize = 0; while rot < 4 { let mut same = true; let mut i: usize = 0; while i < n { let mut j: usize = 0; while ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [find_rotation]: type definitions module public import Aeneas @[expose] public section 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_rotation]: function definitions module public import Aeneas public import Aegis.FindRotation.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.FindRotation.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.FindRotation.find_rotation (Slice.from [(alloc.vec.Vec.from [0#i64, 1#i64] (by scalar_tac) : alloc.vec.Vec Std.I64), (alloc.vec.Vec.from [1#i64, 0#i...
[ { "input": "[[[0, 1], [1, 0]], [[1, 0], [0, 1]]]", "output": "true" }, { "input": "[[[1, 1], [0, 0]], [[0, 1], [0, 1]]]", "output": "true" }, { "input": "[[[1, 0], [0, 1]], [[0, 1], [1, 0]]]", "output": "true" }, { "input": "[[[0, 1], [1, 1]], [[1, 0], [0, 1]]]", "output"...
79
false
79
verified
10
10
1
1,980
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.FindRotation.Code.Funs /-! # Specifications of `Aegis.FindRotation.find_rotation` LeetCode problem `determine-whether-matrix-can-be-obtained-by-rotation`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.FindRotation namespace AegisSpec.FindRo...
6
reduction-operations-to-make-the-array-elements-equal
1,887
Medium
[ "Array", "Sorting" ]
Given an integer array nums, your goal is to make all elements in nums equal. To complete one operation, follow these steps: Find the largest value in nums. Let its index be i (0-indexed) and its value be largest. If there are multiple elements with the largest value, pick the smallest i. Find the next largest value i...
reductionOperations(nums: list_int) -> int
pub fn reduction_operations(nums: &[i64]) -> i64
Aegis.ReductionOperations.reduction_operations
pub fn reduction_operations(nums: &[i64]) -> i64 { let n = nums.len(); if n == 0 { return 0; } let mut max_val = nums[0]; let mut i: usize = 1; while i < n { if nums[i] > max_val { max_val = nums[i]; } i += 1; } let mut a: Vec<i64> = Vec::new...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [reduction_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 ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [reduction_operations]: function definitions module public import Aeneas public import Aegis.ReductionOperations.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand fa...
import Aegis.ReductionOperations.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": "[[5]]", "output": "0" }, { "input": "[[1, 1, 1]]", "output": "0" }, { "input": "[[5, 1, 3]]", "output": "3" }, { "input": "[[4, 3, 2, 1]]", "output": "6" }, { "input": "[[100000, 99999, 99998, 99997, 99996]]", "output": "10" }, { "input": "...
99
false
99
verified
10
10
2
19,691
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.ReductionOperations.Code.Funs /-! # Specifications of `Aegis.ReductionOperations.reduction_operations` LeetCode problem `reduction-operations-to-make-the-array-elements-equal`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.ReductionOperations ...
14
minimum-number-of-flips-to-make-the-binary-string-alternating
1,888
Medium
[ "Greedy", "String", "Dynamic Programming", "Sliding Window" ]
You are given a binary string s. You are allowed to perform two types of operations on the string in any sequence: Type-1: Remove the character at the start of the string s and append it to the end of the string. Type-2: Pick any character in s and flip its value, i.e., if its value is '0' it becomes '1' and vice-vers...
minFlips(s: str) -> int
pub fn min_flips(s: &[u8]) -> i64
Aegis.MinFlips.min_flips
pub fn min_flips(s: &[u8]) -> i64 { let n = s.len(); if n == 0 { return 0; } let n_i64 = n as i64; // mismatches compared with the pattern starting with '0': // 0, 1, 0, 1, ... let mut mism0: i64 = 0; let mut i: usize = 0; while i < n { let expected: u8 = if i % 2 =...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [min_flips]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter.styl...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [min_flips]: function definitions module public import Aeneas public import Aegis.MinFlips.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.MinFlips.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.MinFlips.min_flips (Slice.from [49#u8, 48#u8, 48#u8, 49#u8, 48#u8, 48#u8, 49#u8, 48#u8, 48#u8] (by scalar_tac) : Slice Std.U8)) (3#i64))}") #eval (s!"CA...
[ { "input": "[\"100100100\"]", "output": "3" }, { "input": "[\"1111\"]", "output": "2" }, { "input": "[\"110011\"]", "output": "3" }, { "input": "[\"111000111000\"]", "output": "4" }, { "input": "[\"11110000\"]", "output": "4" }, { "input": "[\"1110\"]"...
153
false
153
verified
10
10
1
7,721
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MinFlips.Code.Funs /-! # Specifications of `Aegis.MinFlips.min_flips` LeetCode problem `minimum-number-of-flips-to-make-the-binary-string-alternating`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.MinFlips namespace AegisSpec.MinFlips def sl...
10
minimum-space-wasted-from-packaging
1,889
Hard
[ "Array", "Binary Search", "Prefix Sum", "Sorting" ]
You have n packages that you are trying to place in boxes, one package in each box. There are m suppliers that each produce boxes of different sizes (with infinite supply). A package can be placed in a box if the size of the package is less than or equal to the size of the box. The package sizes are given as an integer...
minWastedSpace(packages: list_int, boxes: list_list_int) -> int
pub fn min_wasted_space(packages: &[i64], boxes: &[Vec<i64>]) -> i64
Aegis.MinWastedSpace.min_wasted_space
fn sort_vec(mut v: Vec<i64>) -> Vec<i64> { let n = v.len(); if n <= 1 { return v; } let mut width: usize = 1; while width < n { let mut temp: Vec<i64> = Vec::new(); let mut z: usize = 0; while z < n { temp.push(0); z += 1; } l...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [min_wasted_space]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option lint...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [min_wasted_space]: function definitions module public import Aeneas public import Aegis.MinWastedSpace.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.MinWastedSpace.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.MinWastedSpace.min_wasted_space (Slice.from [100000#i64] (by scalar_tac) : Slice Std.I64) (Slice.from [(alloc.vec.Vec.from [100000#i64] (by scalar...
[ { "input": "[[100000], [[100000]]]", "output": "0" }, { "input": "[[1, 100000], [[1], [100000]]]", "output": "99999" }, { "input": "[[1, 100000], [[50000], [150000], [100000]]]", "output": "99999" }, { "input": "[[100000], [[99999, 99998, 99997, 99996, 99995]]]", "output"...
93
false
93
verified
10
10
1
8,134
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MinWastedSpace.Code.Funs /-! # Specifications of `Aegis.MinWastedSpace.min_wasted_space` LeetCode problem `minimum-space-wasted-from-packaging`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.MinWastedSpace namespace AegisSpec.MinWastedSpace no...
16
cutting-ribbons
1,891
Medium
[ "Array", "Binary Search" ]
You are given an integer array ribbons, where ribbons[i] represents the length of the ith ribbon, and an integer k. You may cut any of the ribbons into any number of segments of positive integer lengths, or perform no cuts at all. For example, if you have a ribbon of length 4, you can: Keep the ribbon of length 4, ...
maxLength(ribbons: list_int, k: int) -> int
pub fn max_length(ribbons: &[i64], k: i64) -> i64
Aegis.MaxLength.max_length
pub fn max_length(ribbons: &[i64], k: i64) -> i64 { let n = ribbons.len(); let mut max_ribbon: i64 = 0; let mut i: usize = 0; while i < n { if ribbons[i] > max_ribbon { max_ribbon = ribbons[i]; } i += 1; } let mut lo: i64 = 0; let mut hi: i64 = max_ribbo...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [max_length]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter.sty...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [max_length]: function definitions module public import Aeneas public import Aegis.MaxLength.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.MaxLength.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.MaxLength.max_length (Slice.from [100000#i64] (by scalar_tac) : Slice Std.I64) 1#i64) (100000#i64))}") #eval (s!"CASE 1 {(Result.reducesTo (Aegis.MaxLe...
[ { "input": "[[100000], 1]", "output": "100000" }, { "input": "[[1], 1]", "output": "1" }, { "input": "[[100000, 100000, 100000], 100000]", "output": "2" }, { "input": "[[100000, 100000, 100000], 3]", "output": "100000" }, { "input": "[[10, 20, 30], 5]", "outpu...
100
false
100
verified
10
10
1
1,514
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MaxLength.Code.Funs /-! # Specifications of `Aegis.MaxLength.max_length` LeetCode problem `cutting-ribbons`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.MaxLength open Aegis.MaxLength def pieces (ribbons : Slice I64) (x : ℤ) : ℤ :=...
14