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
smallest-value-after-replacing-with-sum-of-prime-factors
2,507
Medium
[ "Math", "Number Theory", "Simulation" ]
You are given a positive integer n. Continuously replace n with the sum of its prime factors. Note that if a prime factor divides n multiple times, it should be included in the sum as many times as it divides n. Return the smallest value n will take on.   Example 1: Input: n = 15 Output: 5 Explanation: Initially, n ...
smallestValue(n: int) -> int
pub fn smallest_value(n: i64) -> i64
Aegis.SmallestValue.smallest_value
fn sum_prime_factors(mut x: i64) -> i64 { let mut sum = 0; let mut d = 2; while d * d <= x { while x % d == 0 { sum += d; x = x / d; } d += 1; } if x > 1 { sum += x; } sum } pub fn smallest_value(n: i64) -> i64 { let mut cur = n...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [smallest_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...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [smallest_value]: function definitions module public import Aeneas public import Aegis.SmallestValue.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.SmallestValue.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]", "output": "3" }, { "input": "[15]", "output": "5" }, { "input": "[100]", "output": "5" }, { "input": "[44]", "output": "5" }, { "input": "[28]", "output": "11" }, { "input": "[97]", "output": "97" }, { "input": "[99999]", ...
45
false
45
verified
10
10
1
2,102
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.SmallestValue.Code.Funs /-! # Specifications of `Aegis.SmallestValue.smallest_value` LeetCode problem `smallest-value-after-replacing-with-sum-of-prime-factors`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std open Aeneas.Std.Result namespace AegisSpec.SmallestVal...
10
add-edges-to-make-degrees-of-all-nodes-even
2,508
Hard
[ "Graph", "Hash Table" ]
There is an undirected graph consisting of n nodes numbered from 1 to n. You are given the integer n and a 2D array edges where edges[i] = [ai, bi] indicates that there is an edge between nodes ai and bi. The graph can be disconnected. You can add at most two additional edges (possibly none) to this graph so that there...
isPossible(n: int, edges: list_list_int) -> bool
pub fn is_possible(n: i64, edges: &[Vec<i64>]) -> bool
Aegis.IsPossible.is_possible
fn edge_exists(edges: &[Vec<i64>], u: i64, v: i64) -> bool { let mut i: usize = 0; while i < edges.len() { let a = edges[i][0]; let b = edges[i][1]; if (a == u && b == v) || (a == v && b == u) { return true; } i += 1; } false } pub fn is_possible(n: i...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [is_possible]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter.st...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [is_possible]: function definitions module public import Aeneas public import Aegis.IsPossible.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.IsPossible.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval aegisCase ...
[ { "input": "[4, [[1, 2], [3, 4]]]", "output": "true" }, { "input": "[4, [[1, 2], [1, 3], [1, 4]]]", "output": "false" }, { "input": "[7, [[1, 2], [3, 4], [5, 6], [6, 7]]]", "output": "false" }, { "input": "[8, [[1, 2], [3, 4], [5, 6], [7, 8]]]", "output": "false" }, {...
82
false
82
verified
10
10
1
8,043
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.IsPossible.Code.Funs /-! # Specifications of `Aegis.IsPossible.is_possible` LeetCode problem `add-edges-to-make-degrees-of-all-nodes-even`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.IsPossible namespace AegisSpec.IsPossible def edgeA...
12
cycle-length-queries-in-a-tree
2,509
Hard
[ "Tree", "Array", "Binary Tree" ]
You are given an integer n. There is a complete binary tree with 2n - 1 nodes. The root of that tree is the node with the value 1, and every node with a value val in the range [1, 2n - 1 - 1] has two children where: The left node has the value 2 * val, and The right node has the value 2 * val + 1. You are also given ...
cycleLengthQueries(n: int, queries: list_list_int) -> list_int
pub fn cycle_length_queries(n: i64, queries: &[Vec<i64>]) -> Vec<i64>
Aegis.CycleLengthQueries.cycle_length_queries
pub fn cycle_length_queries(n: i64, queries: &[Vec<i64>]) -> Vec<i64> { let _ = n; let mut answers: Vec<i64> = Vec::new(); let m = queries.len(); let mut i: usize = 0; while i < m { let q = &queries[i]; let mut a: i64 = q[0]; let mut b: i64 = q[1]; let mut dist: i64 ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [cycle_length_queries]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [cycle_length_queries]: function definitions module public import Aeneas public import Aegis.CycleLengthQueries.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand fal...
import Aegis.CycleLengthQueries.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval ae...
[ { "input": "[2, [[1, 2]]]", "output": "[2]" }, { "input": "[5, [[31, 15], [10, 18], [9, 20]]]", "output": "[2, 6, 6]" }, { "input": "[3, [[5, 3], [4, 7], [2, 3]]]", "output": "[4, 5, 3]" }, { "input": "[5, [[15, 7], [10, 14], [3, 12]]]", "output": "[2, 7, 3]" }, { ...
70
false
70
verified
10
10
1
2,021
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.CycleLengthQueries.Code.Funs /-! # Specifications of `Aegis.CycleLengthQueries.cycle_length_queries` LeetCode problem `cycle-length-queries-in-a-tree`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.CycleLengthQueries def depth (x : ℤ)...
14
check-if-there-is-a-path-with-equal-number-of-0s-and-1s
2,510
Medium
[ "Array", "Dynamic Programming", "Matrix" ]
You are given a 0-indexed m x n binary matrix grid. You can move from a cell (row, col) to any of the cells (row + 1, col) or (row, col + 1). Return true if there is a path from (0, 0) to (m - 1, n - 1) that visits an equal number of 0's and 1's. Otherwise return false.   Example 1: Input: grid = [[0,1,0,0],[0,1,0,0]...
isThereAPath(grid: list_list_int) -> bool
pub fn is_there_a_path(grid: &[Vec<i64>]) -> bool
Aegis.IsThereAPath.is_there_a_path
pub fn is_there_a_path(grid: &[Vec<i64>]) -> bool { let m = grid.len(); let n = grid[0].len(); // We track (#1 - #0) along a path. Its absolute value is at most m + n - 1. let offset = m + n; let width = offset * 2 + 1; let total = m * n * width; let mut dp: Vec<bool> = Vec::new(); let...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [is_there_a_path]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linte...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [is_there_a_path]: function definitions module public import Aeneas public import Aegis.IsThereAPath.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.IsThereAPath.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": "[[[0, 1], [1, 0]]]", "output": "false" }, { "input": "[[[1, 1], [0, 0]]]", "output": "false" }, { "input": "[[[1, 1], [1, 1]]]", "output": "false" }, { "input": "[[[1, 1, 1, 1], [0, 0, 0, 0]]]", "output": "false" }, { "input": "[[[0, 0, 1, 1], [1, 1, 0...
87
false
87
verified
10
10
2
7,979
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.IsThereAPath.Code.Funs /-! # Specifications of `Aegis.IsThereAPath.is_there_a_path` LeetCode problem `check-if-there-is-a-path-with-equal-number-of-0s-and-1s`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.IsThereAPath abbrev Grid...
10
maximum-enemy-forts-that-can-be-captured
2,511
Easy
[ "Array", "Two Pointers" ]
You are given a 0-indexed integer array forts of length n representing the positions of several forts. forts[i] can be -1, 0, or 1 where: -1 represents there is no fort at the ith position. 0 indicates there is an enemy fort at the ith position. 1 indicates the fort at the ith the position is under your command. Now ...
captureForts(forts: list_int) -> int
pub fn capture_forts(forts: &[i64]) -> i64
Aegis.CaptureForts.capture_forts
pub fn capture_forts(forts: &[i64]) -> i64 { let n = forts.len(); let mut ans: i64 = 0; let mut g: i64 = 0; // previous non-zero value (1 or -1); 0 means none yet let mut c: i64 = 0; // number of zeros seen since the previous non-zero let mut i: usize = 0; while i < n { let v = forts[i]...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [capture_forts]: type definitions module public import Aeneas @[expose] public section 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 -- [capture_forts]: function definitions module public import Aeneas public import Aegis.CaptureForts.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.CaptureForts.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]]", "output": "0" }, { "input": "[[0]]", "output": "0" }, { "input": "[[1]]", "output": "0" }, { "input": "[[1, -1]]", "output": "0" }, { "input": "[[0, 0, 0, 0]]", "output": "0" }, { "input": "[[0, 0, 1, -1]]", "output": "0" }, ...
100
false
100
verified
10
10
4
24,151
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.CaptureForts.Code.Funs /-! # Specifications of `Aegis.CaptureForts.capture_forts` LeetCode problem `maximum-enemy-forts-that-can-be-captured`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.CaptureForts open Aegis.CaptureForts (capture...
13
reward-top-k-students
2,512
Medium
[ "Array", "Hash Table", "String", "Sorting", "Heap (Priority Queue)" ]
You are given two string arrays positive_feedback and negative_feedback, containing the words denoting positive and negative feedback, respectively. Note that no word is both positive and negative. Initially every student has 0 points. Each positive word in a feedback report increases the points of a student by 3, wher...
topStudents(positive_feedback: list_str, negative_feedback: list_str, report: list_str, student_id: list_int, k: int) -> list_int
pub fn top_students(positive_feedback: &[Vec<u8>], negative_feedback: &[Vec<u8>], report: &[Vec<u8>], student_id: &[i64], k: i64) -> Vec<i64>
Aegis.TopStudents.top_students
fn cmp_dict_word(dict: &[Vec<u8>], i: usize, j: usize) -> i64 { let li = dict[i].len(); let lj = dict[j].len(); let mut t = 0; while t < li && t < lj { let a = dict[i][t]; let b = dict[j][t]; if a < b { return -1; } if a > b { return 1; ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [top_students]: type definitions module public import Aeneas @[expose] public section 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 -- [top_students]: function definitions module public import Aeneas public import Aegis.TopStudents.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.TopStudents.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": "[[\"good\", \"excellent\"], [\"bad\", \"poor\"], [\"the student is good and excellent\", \"the student is bad but tries\"], [3, 4], 1]", "output": "[3]" }, { "input": "[[\"good\", \"excellent\"], [\"bad\", \"poor\"], [\"the student is good and excellent\", \"the student is bad\"], [3, 4]...
82
false
82
verified
10
10
1
13,708
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.TopStudents.Code.Funs /-! # Specifications of `Aegis.TopStudents.top_students` LeetCode problem `reward-top-k-students`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.TopStudents abbrev Word := List Std.U8 def IsLowerByte (b : Std.U8...
15
minimize-the-maximum-of-two-arrays
2,513
Medium
[ "Math", "Binary Search", "Number Theory" ]
We have two arrays arr1 and arr2 which are initially empty. You need to add positive integers to them such that they satisfy all the following conditions: arr1 contains uniqueCnt1 distinct positive integers, each of which is not divisible by divisor1. arr2 contains uniqueCnt2 distinct positive integers, each of which ...
minimizeSet(divisor1: int, divisor2: int, uniqueCnt1: int, uniqueCnt2: int) -> int
pub fn minimize_set(divisor1: i64, divisor2: i64, uniqueCnt1: i64, uniqueCnt2: i64) -> i64
Aegis.MinimizeSet.minimize_set
fn gcd(mut a: i64, mut b: i64) -> i64 { while b != 0 { let t = a % b; a = b; b = t; } a } fn feasible(x: i64, divisor1: i64, divisor2: i64, unique_cnt1: i64, unique_cnt2: i64, lcm: i64) -> bool { let can1 = x - x / divisor1; let can2 = x - x / divisor2; let can_both = x ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [minimize_set]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter.s...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [minimize_set]: function definitions module public import Aeneas public import Aegis.MinimizeSet.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.MinimizeSet.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval aegisCase...
[ { "input": "[2, 7, 1, 3]", "output": "4" }, { "input": "[2, 4, 8, 2]", "output": "15" }, { "input": "[100, 101, 100000000, 100000000]", "output": "200019803" }, { "input": "[100, 200, 100000000, 100000000]", "output": "201005025" }, { "input": "[5, 10, 5, 5]", ...
108
false
108
verified
10
10
1
3,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.MinimizeSet.Code.Funs /-! # Specifications of `Aegis.MinimizeSet.minimize_set` LeetCode problem `minimize-the-maximum-of-two-arrays`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aeneas.Std.Result namespace AegisSpec.MinimizeSet def Feasible (d1 d2...
14
shortest-distance-to-target-string-in-a-circular-array
2,515
Easy
[ "Array", "String" ]
You are given a 0-indexed circular string array words and a string target. A circular array means that the array's end connects to the array's beginning. Formally, the next element of words[i] is words[(i + 1) % n] and the previous element of words[i] is words[(i - 1 + n) % n], where n is the length of words. Startin...
closestTarget(words: list_str, target: str, startIndex: int) -> int
pub fn closest_target(words: &[Vec<u8>], target: &[u8], startIndex: i64) -> i64
Aegis.ClosestTarget.closest_target
pub fn closest_target(words: &[Vec<u8>], target: &[u8], startIndex: i64) -> i64 { let n = words.len(); let n_i = n as i64; let mut ans: i64 = -1; let mut i: usize = 0; while i < n { let w = &words[i]; let w_len = w.len(); let mut same = true; if w_len != target.len(...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [closest_target]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [closest_target]: function definitions module public import Aeneas public import Aegis.ClosestTarget.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.ClosestTarget.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": "[[\"single\"], \"single\", 0]", "output": "0" }, { "input": "[[\"unique\"], \"unique\", 0]", "output": "0" }, { "input": "[[\"abc\", \"def\", \"ghi\"], \"xyz\", 1]", "output": "-1" }, { "input": "[[\"dog\", \"cat\", \"bat\"], \"dog\", 2]", "output": "1" }, ...
247
false
247
verified
10
10
1
2,502
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.ClosestTarget.Code.Funs /-! # Specifications of `Aegis.ClosestTarget.closest_target` LeetCode problem `shortest-distance-to-target-string-in-a-circular-array`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.ClosestTarget def isAsciiLow...
7
maximum-tastiness-of-candy-basket
2,517
Medium
[ "Greedy", "Array", "Binary Search", "Sorting" ]
You are given an array of positive integers price where price[i] denotes the price of the ith candy and a positive integer k. The store sells baskets of k distinct candies. The tastiness of a candy basket is the smallest absolute difference of the prices of any two candies in the basket. Return the maximum tastiness of...
maximumTastiness(price: list_int, k: int) -> int
pub fn maximum_tastiness(price: &[i64], k: i64) -> i64
Aegis.MaximumTastiness.maximum_tastiness
pub fn maximum_tastiness(price: &[i64], k: i64) -> i64 { let n = price.len(); if n == 0 { return 0; } let mut sorted: Vec<i64> = Vec::new(); let mut i: usize = 0; while i < n { sorted.push(price[i]); i += 1; } sorted.sort(); let max_diff: i64 = sorted[n - 1]...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [maximum_tastiness]: type definitions module public import Aeneas @[expose] public section 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 -- [maximum_tastiness]: function definitions module public import Aeneas public import Aegis.MaximumTastiness.Code.Types public import Aegis.MaximumTastiness.Code.FunsExternal @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.du...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [maximum_tastiness]: external functions. -- This is a template file: rename it to "FunsExternal.lean" and fill the holes. module public import Aeneas public import Aegis.MaximumTastiness.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow E...
import Aegis.MaximumTastiness.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval aegi...
[ { "input": "[[1, 3, 1], 2]", "output": "2" }, { "input": "[[1, 1000000000, 2, 999999999], 2]", "output": "999999999" }, { "input": "[[7, 7, 7, 7], 2]", "output": "0" }, { "input": "[[1000000000, 1, 1000000000, 1, 1000000000], 3]", "output": "0" }, { "input": "[[10...
81
false
81
verified
10
10
1
1,809
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MaximumTastiness.Code.Funs /-! # Specifications of `Aegis.MaximumTastiness.maximum_tastiness` LeetCode problem `maximum-tastiness-of-candy-basket`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.MaximumTastiness (maximum_tastiness) namespace...
16
number-of-great-partitions
2,518
Hard
[ "Array", "Dynamic Programming" ]
You are given an array nums consisting of positive integers and an integer k. Partition the array into two ordered groups such that each element is in exactly one group. A partition is called great if the sum of elements of each group is greater than or equal to k. Return the number of distinct great partitions. Since ...
countPartitions(nums: list_int, k: int) -> int
pub fn count_partitions(nums: &[i64], k: i64) -> i64
Aegis.CountPartitions.count_partitions
pub fn count_partitions(nums: &[i64], k: i64) -> i64 { let modv: i64 = 1000000007; let n: usize = nums.len(); let mut total: i64 = 0; let mut i: usize = 0; while i < n { total += nums[i]; i += 1; } if total < 2 * k { return 0; } let kk: usize = k as usize; ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [count_partitions]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option lint...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [count_partitions]: function definitions module public import Aeneas public import Aegis.CountPartitions.Code.Types public import Aegis.CountPartitions.Code.FunsExternal @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNa...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [count_partitions]: external functions. -- This is a template file: rename it to "FunsExternal.lean" and fill the holes. module public import Aeneas public import Aegis.CountPartitions.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Err...
import Aegis.CountPartitions.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": "[[6, 6], 2]", "output": "2" }, { "input": "[[3, 3, 3], 4]", "output": "0" }, { "input": "[[1000, 1000, 1000], 1]", "output": "6" }, { "input": "[[10, 20, 30, 40], 50]", "output": "2" }, { "input": "[[1, 1, 1, 1], 2]", "output": "6" }, { "in...
101
false
101
verified
10
10
1
3,926
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.CountPartitions.Code.Funs /-! # Specifications of `Aegis.CountPartitions.count_partitions` LeetCode problem `number-of-great-partitions`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.CountPartitions def modulus : ℤ := 1000000007 ...
14
count-the-number-of-k-big-indices
2,519
Hard
[ "Binary Indexed Tree", "Segment Tree", "Array", "Binary Search", "Divide and Conquer", "Ordered Set", "Merge Sort" ]
You are given a 0-indexed integer array nums and a positive integer k. We call an index i k-big if the following conditions are satisfied: There exist at least k different indices idx1 such that idx1 < i and nums[idx1] < nums[i]. There exist at least k different indices idx2 such that idx2 > i and nums[idx2] < nums[i]...
kBigIndices(nums: list_int, k: int) -> int
pub fn k_big_indices(nums: &[i64], k: i64) -> i64
Aegis.KBigIndices.k_big_indices
pub fn k_big_indices(nums: &[i64], k: i64) -> i64 { let n = nums.len(); if n == 0 { return 0; } let n_i = n as i64; let mut left_ok: Vec<bool> = Vec::new(); let mut t = 0; while t < n { left_ok.push(false); t += 1; } // lowbit[i] = largest power of two divi...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [k_big_indices]: type definitions module public import Aeneas @[expose] public section 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 -- [k_big_indices]: function definitions module public import Aeneas public import Aegis.KBigIndices.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.KBigIndices.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, 1], 3]", "output": "0" }, { "input": "[[1, 2, 3, 4, 5], 2]", "output": "0" }, { "input": "[[5, 4, 3, 2, 1], 1]", "output": "0" }, { "input": "[[2, 3, 6, 5, 2, 3], 2]", "output": "2" }, { "input": "[[1, 3, 2, 4, 5, 6, 7, 8, 9, 10], 4]", "out...
80
false
80
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.KBigIndices.Code.Funs /-! # Specifications of `Aegis.KBigIndices.k_big_indices` LeetCode problem `count-the-number-of-k-big-indices`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.KBigIndices def valAt (xs : List Std.I64) (i : Nat...
11
count-the-digits-that-divide-a-number
2,520
Easy
[ "Math" ]
Given an integer num, return the number of digits in num that divide num. An integer val divides nums if nums % val == 0.   Example 1: Input: num = 7 Output: 1 Explanation: 7 divides itself, hence the answer is 1. Example 2: Input: num = 121 Output: 2 Explanation: 121 is divisible by 1, but not 2. Since 1 occurs twi...
countDigits(num: int) -> int
pub fn count_digits(num: i64) -> i64
Aegis.CountDigits.count_digits
pub fn count_digits(num: i64) -> i64 { let mut count: i64 = 0; let mut temp: i64 = num; while temp > 0 { let digit: i64 = temp % 10; if digit != 0 && num % digit == 0 { count += 1; } temp = temp / 10; } count }
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [count_digits]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter.s...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [count_digits]: function definitions module public import Aeneas public import Aegis.CountDigits.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.CountDigits.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": "[111111111]", "output": "9" }, { "input": "[666]", "output": "3" }, { "input": "[999]", "output": "3" }, { "input": "[222]", "output": "3" }, { "input": "[1122]", "output": "4" }, { "input": "[123456789]", "output": "3" }, { "in...
71
false
71
verified
10
10
1
225
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.CountDigits.Code.Funs /-! # Specifications of `Aegis.CountDigits.count_digits` LeetCode problem `count-the-digits-that-divide-a-number`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.CountDigits namespace AegisSpec.CountDigits def numDigits (...
11
distinct-prime-factors-of-product-of-array
2,521
Medium
[ "Array", "Hash Table", "Math", "Number Theory" ]
Given an array of positive integers nums, return the number of distinct prime factors in the product of the elements of nums. Note that: A number greater than 1 is called prime if it is divisible by only 1 and itself. An integer val1 is a factor of another integer val2 if val2 / val1 is an integer.   Example 1: Inpu...
distinctPrimeFactors(nums: list_int) -> int
pub fn distinct_prime_factors(nums: &[i64]) -> i64
Aegis.DistinctPrimeFactors.distinct_prime_factors
pub fn distinct_prime_factors(nums: &[i64]) -> i64 { let mut primes: Vec<i64> = Vec::new(); let mut count: i64 = 0; let mut i: usize = 0; while i < nums.len() { let mut x: i64 = nums[i]; let mut d: i64 = 2; while d * d <= x { if x % d == 0 { let mut ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [distinct_prime_factors]: type definitions module public import Aeneas @[expose] public 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 -- [distinct_prime_factors]: function definitions module public import Aeneas public import Aegis.DistinctPrimeFactors.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand...
import Aegis.DistinctPrimeFactors.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": "[[999, 1000]]", "output": "4" }, { "input": "[[100, 200, 300]]", "output": "3" }, { "input": "[[210, 154, 90]]", "output": "5" }, { "input": "[[1023, 500, 729]]", "output": "5" }, { "input": "[[100, 200, 300, 400]]", "output": "3" }, { "inp...
115
false
115
verified
10
10
1
1,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.DistinctPrimeFactors.Code.Funs /-! # Specifications of `Aegis.DistinctPrimeFactors.distinct_prime_factors` LeetCode problem `distinct-prime-factors-of-product-of-array`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.DistinctPrimeFactor...
14
closest-prime-numbers-in-range
2,523
Medium
[ "Math", "Number Theory" ]
Given two positive integers left and right, find the two integers num1 and num2 such that: left <= num1 < num2 <= right . Both num1 and num2 are prime numbers. num2 - num1 is the minimum amongst all other pairs satisfying the above conditions. Return the positive integer array ans = [num1, num2]. If there are multipl...
closestPrimes(left: int, right: int) -> list_int
pub fn closest_primes(left: i64, right: i64) -> Vec<i64>
Aegis.ClosestPrimes.closest_primes
fn floor_sqrt(n: i64) -> i64 { let mut r: i64 = 0; while (r + 1) * (r + 1) <= n { r += 1; } r } fn build_small_primes(limit: i64) -> Vec<i64> { let cap: usize = (limit + 1) as usize; let mut comp: Vec<bool> = Vec::new(); let mut i: usize = 0; while i < cap { comp.push(fa...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [closest_primes]: type definitions module public import Aeneas @[expose] public section 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 -- [closest_primes]: function definitions module public import Aeneas public import Aegis.ClosestPrimes.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.ClosestPrimes.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": "[500, 550]", "output": "[521, 523]" }, { "input": "[1000, 1100]", "output": "[1019, 1021]" }, { "input": "[10000, 10020]", "output": "[10007, 10009]" }, { "input": "[1000, 1010]", "output": "[-1, -1]" }, { "input": "[999983, 999999]", "output": "[-...
95
false
95
verified
10
10
5
73,736
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.ClosestPrimes.Code.Funs /-! # Specifications of `Aegis.ClosestPrimes.closest_primes` LeetCode problem `closest-prime-numbers-in-range`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.ClosestPrimes abbrev I64 := Aeneas.Std.I64 ab...
11
find-xor-beauty-of-array
2,527
Medium
[ "Bit Manipulation", "Array", "Math" ]
You are given a 0-indexed integer array nums. The effective value of three indices i, j, and k is defined as ((nums[i] | nums[j]) & nums[k]). The xor-beauty of the array is the XORing of the effective values of all the possible triplets of indices (i, j, k) where 0 <= i, j, k < n. Return the xor-beauty of nums. Note th...
xorBeauty(nums: list_int) -> int
pub fn xor_beauty(nums: &[i64]) -> i64
Aegis.XorBeauty.xor_beauty
pub fn xor_beauty(nums: &[i64]) -> i64 { let mut ans: i64 = 0; let mut i: usize = 0; while i < nums.len() { ans ^= nums[i]; i += 1; } ans }
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [xor_beauty]: type definitions module public import Aeneas @[expose] public section 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 -- [xor_beauty]: function definitions module public import Aeneas public import Aegis.XorBeauty.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.XorBeauty.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, 4]]", "output": "5" }, { "input": "[[1, 1, 1, 1]]", "output": "0" }, { "input": "[[1000000000, 500000000, 250000000, 125000000]]", "output": "801260736" }, { "input": "[[1000000000, 999999999, 888888888, 777777777]]", "output": "446738358" }, { "i...
97
false
97
verified
10
10
1
215
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.XorBeauty.Code.Funs /-! # Specifications of `Aegis.XorBeauty.xor_beauty` LeetCode problem `find-xor-beauty-of-array`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.XorBeauty def bitAt (x : Int) (b : Nat) : Bool := x.testBit b def bit...
7
maximize-the-minimum-powered-city
2,528
Hard
[ "Greedy", "Queue", "Array", "Binary Search", "Prefix Sum", "Sliding Window" ]
You are given a 0-indexed integer array stations of length n, where stations[i] represents the number of power stations in the ith city. Each power station can provide power to every city in a fixed range. In other words, if the range is denoted by r, then a power station at city i can provide power to all cities j suc...
maxPower(stations: list_int, r: int, k: int) -> int
pub fn max_power(stations: &[i64], r: i64, k: i64) -> i64
Aegis.MaxPower.max_power
pub fn max_power(stations: &[i64], r: i64, k: i64) -> i64 { let n: usize = stations.len(); if n == 0 { return 0; } let n_i: i64 = n as i64; // Build the initial power of every city using a difference array. let mut diff: Vec<i64> = Vec::new(); let mut z: usize = 0; while z <= n ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [max_power]: type definitions module public import Aeneas @[expose] public section 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_power]: function definitions module public import Aeneas public import Aegis.MaxPower.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.MaxPower.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval aegisCase "e...
[ { "input": "[[0, 0, 0, 0], 2, 5]", "output": "5" }, { "input": "[[0, 0, 0, 0], 2, 10]", "output": "10" }, { "input": "[[4, 4, 4, 4], 0, 3]", "output": "4" }, { "input": "[[1, 2, 4, 5, 0], 1, 2]", "output": "5" }, { "input": "[[0, 0, 0, 0, 0], 2, 5]", "output":...
118
false
118
verified
10
10
1
7,291
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MaxPower.Code.Funs /-! # Specifications of `Aegis.MaxPower.max_power` LeetCode problem `maximize-the-minimum-powered-city`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.MaxPower (max_power) open scoped BigOperators namespace AegisSpec.Ma...
12
maximum-count-of-positive-integer-and-negative-integer
2,529
Easy
[ "Array", "Binary Search", "Counting" ]
Given an array nums sorted in non-decreasing order, return the maximum between the number of positive integers and the number of negative integers. In other words, if the number of positive integers in nums is pos and the number of negative integers is neg, then return the maximum of pos and neg. Note that 0 is neith...
maximumCount(nums: list_int) -> int
pub fn maximum_count(nums: &[i64]) -> i64
Aegis.MaximumCount.maximum_count
pub fn maximum_count(nums: &[i64]) -> i64 { let n = nums.len(); let mut neg: i64 = 0; let mut pos: i64 = 0; let mut i: usize = 0; while i < n { if nums[i] < 0 { neg = neg + 1; } else if nums[i] > 0 { pos = pos + 1; } i = i + 1; } if n...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [maximum_count]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter....
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [maximum_count]: function definitions module public import Aeneas public import Aegis.MaximumCount.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.MaximumCount.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, 0, 1]]", "output": "1" }, { "input": "[[-1, 0, 1]]", "output": "1" }, { "input": "[[-2000, 0, 2000]]", "output": "1" }, { "input": "[[-1000, 0, 1000]]", "output": "1" }, { "input": "[[5, 20, 66, 1314]]", "output": "4" }, { "input": "[...
96
false
96
verified
10
10
1
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.MaximumCount.Code.Funs /-! # Specifications of `Aegis.MaximumCount.maximum_count` LeetCode problem `maximum-count-of-positive-integer-and-negative-integer`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.MaximumCount def posCount (...
14
maximal-score-after-applying-k-operations
2,530
Medium
[ "Greedy", "Array", "Heap (Priority Queue)" ]
You are given a 0-indexed integer array nums and an integer k. You have a starting score of 0. In one operation: choose an index i such that 0 <= i < nums.length, increase your score by nums[i], and replace nums[i] with ceil(nums[i] / 3). Return the maximum possible score you can attain after applying exactly k opera...
maxKelements(nums: list_int, k: int) -> int
pub fn max_kelements(nums: &[i64], k: i64) -> i64
Aegis.MaxKelements.max_kelements
pub fn max_kelements(nums: &[i64], k: i64) -> i64 { let n = nums.len(); if n == 0 { return 0; } let mut heap: Vec<i64> = Vec::new(); let mut i = 0usize; while i < n { heap.push(nums[i]); i += 1; } // Build a max-heap. let mut start = n / 2; while start >...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [max_kelements]: type definitions module public import Aeneas @[expose] public section 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_kelements]: function definitions module public import Aeneas public import Aegis.MaxKelements.Code.Types public import Aegis.MaxKelements.Code.FunsExternal @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace f...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [max_kelements]: external functions. -- This is a template file: rename it to "FunsExternal.lean" and fill the holes. module public import Aeneas public import Aegis.MaxKelements.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set...
import Aegis.MaxKelements.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], 1]", "output": "1" }, { "input": "[[1000000000, 1000000000, 1000000000], 3]", "output": "3000000000" }, { "input": "[[9, 9, 9, 9, 9], 4]", "output": "36" }, { "input": "[[10, 10, 10, 10, 10], 5]", "output": "50" }, { "input": "[[1, 2, 3, 4, 5], 2...
89
false
89
verified
10
10
1
3,687
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MaxKelements.Code.Funs /-! # Specifications of `Aegis.MaxKelements.max_kelements` LeetCode problem `maximal-score-after-applying-k-operations`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.MaxKelements (max_kelements) namespace AegisSpec.M...
13
make-number-of-distinct-characters-equal
2,531
Medium
[ "Hash Table", "String", "Counting" ]
You are given two 0-indexed strings word1 and word2. A move consists of choosing two indices i and j such that 0 <= i < word1.length and 0 <= j < word2.length and swapping word1[i] with word2[j]. Return true if it is possible to get the number of distinct characters in word1 and word2 to be equal with exactly one move....
isItPossible(word1: str, word2: str) -> bool
pub fn is_it_possible(word1: &[u8], word2: &[u8]) -> bool
Aegis.IsItPossible.is_it_possible
pub fn is_it_possible(word1: &[u8], word2: &[u8]) -> bool { let mut cnt1: Vec<i64> = Vec::new(); let mut cnt2: Vec<i64> = Vec::new(); let mut i: usize = 0; while i < 26 { cnt1.push(0); cnt2.push(0); i += 1; } i = 0; while i < word1.len() { let idx: usize = (...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [is_it_possible]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [is_it_possible]: function definitions module public import Aeneas public import Aegis.IsItPossible.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.IsItPossible.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": "[\"abcde\", \"fghij\"]", "output": "true" }, { "input": "[\"xyz\", \"zyx\"]", "output": "true" }, { "input": "[\"aaa\", \"bbb\"]", "output": "true" }, { "input": "[\"ac\", \"b\"]", "output": "false" }, { "input": "[\"unique\", \"letters\"]", "outpu...
119
false
119
verified
10
10
2
8,334
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.IsItPossible.Code.Funs /-! # Specifications of `Aegis.IsItPossible.is_it_possible` LeetCode problem `make-number-of-distinct-characters-equal`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.IsItPossible abbrev Byte : Type := Aenea...
11
number-of-good-binary-strings
2,533
Medium
[ "Dynamic Programming" ]
You are given four integers minLength, maxLength, oneGroup and zeroGroup. A binary string is good if it satisfies the following conditions: The length of the string is in the range [minLength, maxLength]. The size of each block of consecutive 1's is a multiple of oneGroup. For example in a binary string 00110111100 ...
goodBinaryStrings(minLength: int, maxLength: int, oneGroup: int, zeroGroup: int) -> int
pub fn good_binary_strings(minLength: i64, maxLength: i64, oneGroup: i64, zeroGroup: i64) -> i64
Aegis.GoodBinaryStrings.good_binary_strings
pub fn good_binary_strings(minLength: i64, maxLength: i64, oneGroup: i64, zeroGroup: i64) -> i64 { let modv: i64 = 1000000007; let min_len = minLength as usize; let max_len = maxLength as usize; let one = oneGroup as usize; let zero = zeroGroup as usize; let mut dp: Vec<i64> = Vec::new(); ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [good_binary_strings]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option l...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [good_binary_strings]: function definitions module public import Aeneas public import Aegis.GoodBinaryStrings.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false...
import Aegis.GoodBinaryStrings.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": "[3, 7, 3, 3]", "output": "6" }, { "input": "[4, 4, 4, 3]", "output": "1" }, { "input": "[5, 10, 5, 5]", "output": "6" }, { "input": "[3, 7, 3, 5]", "output": "3" }, { "input": "[2, 3, 1, 2]", "output": "5" }, { "input": "[3, 10, 3, 4]", ...
97
false
97
verified
10
10
1
2,831
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.GoodBinaryStrings.Code.Funs /-! # Specifications of `Aegis.GoodBinaryStrings.good_binary_strings` LeetCode problem `number-of-good-binary-strings`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.GoodBinaryStrings namespace AegisSpec.GoodBina...
12
time-taken-to-cross-the-door
2,534
Hard
[ "Queue", "Array", "Simulation" ]
There are n persons numbered from 0 to n - 1 and a door. Each person can enter or exit through the door once, taking one second. You are given a non-decreasing integer array arrival of size n, where arrival[i] is the arrival time of the ith person at the door. You are also given an array state of size n, where state[i]...
timeTaken(arrival: list_int, state: list_int) -> list_int
pub fn time_taken(arrival: &[i64], state: &[i64]) -> Vec<i64>
Aegis.TimeTaken.time_taken
pub fn time_taken(arrival: &[i64], state: &[i64]) -> Vec<i64> { let n = arrival.len(); let mut answer: Vec<i64> = Vec::new(); let mut i: usize = 0; while i < n { answer.push(0); i += 1; } if n == 0 { return answer; } let mut next_enter: usize = 0; while nex...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [time_taken]: type definitions module public import Aeneas @[expose] public section 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 -- [time_taken]: function definitions module public import Aeneas public import Aegis.TimeTaken.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.TimeTaken.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": "[[0, 0, 0], [1, 0, 1]]", "output": "[0, 2, 1]" }, { "input": "[[0, 0, 0, 0, 0], [0, 0, 0, 0, 0]]", "output": "[0, 1, 2, 3, 4]" }, { "input": "[[0, 0, 1, 2, 3], [0, 1, 0, 1, 0]]", "output": "[1, 0, 2, 4, 3]" }, { "input": "[[1, 2, 3, 4, 5], [0, 1, 0, 1, 0]]", "...
97
false
97
verified
10
10
1
8,142
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.TimeTaken.Code.Funs /-! # Specifications of `Aegis.TimeTaken.time_taken` LeetCode problem `time-taken-to-cross-the-door`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.TimeTaken def valueAt (l : List I64) (i : Nat) : Int := (l.getD ...
13
difference-between-element-sum-and-digit-sum-of-an-array
2,535
Easy
[ "Array", "Math" ]
You are given a positive integer array nums. The element sum is the sum of all the elements in nums. The digit sum is the sum of all the digits (not necessarily distinct) that appear in nums. Return the absolute difference between the element sum and digit sum of nums. Note that the absolute difference between two in...
differenceOfSum(nums: list_int) -> int
pub fn difference_of_sum(nums: &[i64]) -> i64
Aegis.DifferenceOfSum.difference_of_sum
pub fn difference_of_sum(nums: &[i64]) -> i64 { let mut element_sum: i64 = 0; let mut digit_sum: i64 = 0; let n = nums.len(); let mut i: usize = 0; while i < n { let mut x = nums[i]; element_sum += x; while x > 0 { digit_sum += x % 10; x = x / 10; ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [difference_of_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 -- [difference_of_sum]: function definitions module public import Aeneas public import Aegis.DifferenceOfSum.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.DifferenceOfSum.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval aegis...
[ { "input": "[[1]]", "output": "0" }, { "input": "[[10, 100, 1000]]", "output": "1107" }, { "input": "[[999, 1000, 1001]]", "output": "2970" }, { "input": "[[123, 456, 789]]", "output": "1323" }, { "input": "[[111, 222, 333]]", "output": "648" }, { "inp...
99
false
99
verified
10
10
1
526
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.DifferenceOfSum.Code.Funs /-! # Specifications of `Aegis.DifferenceOfSum.difference_of_sum` LeetCode problem `difference-between-element-sum-and-digit-sum-of-an-array`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.DifferenceOfSum ...
10
increment-submatrices-by-one
2,536
Medium
[ "Array", "Matrix", "Prefix Sum" ]
You are given a positive integer n, indicating that we initially have an n x n 0-indexed integer matrix mat filled with zeroes. You are also given a 2D integer array query. For each query[i] = [row1i, col1i, row2i, col2i], you should do the following operation: Add 1 to every element in the submatrix with the top left...
rangeAddQueries(n: int, queries: list_list_int) -> list_list_int
pub fn range_add_queries(n: i64, queries: &[Vec<i64>]) -> Vec<Vec<i64>>
Aegis.RangeAddQueries.range_add_queries
pub fn range_add_queries(n: i64, queries: &[Vec<i64>]) -> Vec<Vec<i64>> { let n_usize: usize = n as usize; let size: usize = n_usize + 1; let mut diff: Vec<Vec<i64>> = Vec::new(); let mut i: usize = 0; while i < size { let mut row: Vec<i64> = Vec::new(); let mut j: usize = 0; ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [range_add_queries]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option lin...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [range_add_queries]: function definitions module public import Aeneas public import Aegis.RangeAddQueries.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.RangeAddQueries.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval aegis...
[ { "input": "[1, [[0, 0, 0, 0]]]", "output": "[[1]]" }, { "input": "[2, [[0, 0, 1, 1]]]", "output": "[[1, 1], [1, 1]]" }, { "input": "[3, [[1, 1, 2, 2], [0, 0, 1, 1]]]", "output": "[[1, 1, 0], [1, 2, 1], [0, 1, 1]]" }, { "input": "[3, [[0, 0, 2, 2], [1, 1, 1, 1], [0, 1, 1, 2]]...
73
false
73
verified
10
10
1
2,561
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.RangeAddQueries.Code.Funs /-! # Specifications of `Aegis.RangeAddQueries.range_add_queries` LeetCode problem `increment-submatrices-by-one`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.RangeAddQueries namespace AegisSpec.RangeAddQueries def ...
13
count-the-number-of-good-subarrays
2,537
Medium
[ "Array", "Hash Table", "Sliding Window" ]
Given an integer array nums and an integer k, return the number of good subarrays of nums. A subarray arr is good if there are at least k pairs of indices (i, j) such that i < j and arr[i] == arr[j]. A subarray is a contiguous non-empty sequence of elements within an array.   Example 1: Input: nums = [1,1,1,1,1], k = ...
countGood(nums: list_int, k: int) -> int
pub fn count_good(nums: &[i64], k: i64) -> i64
Aegis.CountGood.count_good
pub fn count_good(nums: &[i64], k: i64) -> i64 { let n = nums.len(); if k <= 0 { let n64 = n as i64; return n64 * (n64 + 1) / 2; } if n == 0 { return 0; } let mut sorted: Vec<i64> = Vec::new(); let mut i = 0; while i < n { sorted.push(nums[i]); ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [count_good]: type definitions module public import Aeneas @[expose] public section 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 -- [count_good]: function definitions module public import Aeneas public import Aegis.CountGood.Code.Types public import Aegis.CountGood.Code.FunsExternal @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [count_good]: external functions. -- This is a template file: rename it to "FunsExternal.lean" and fill the holes. module public import Aeneas public import Aegis.CountGood.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_optio...
import Aegis.CountGood.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": "0" }, { "input": "[[1, 1], 1]", "output": "1" }, { "input": "[[1, 1, 1, 1, 1], 10]", "output": "1" }, { "input": "[[10, 20, 10, 20, 10], 4]", "output": "1" }, { "input": "[[1, 2, 3, 4, 5], 1]", "output": "0" }, { "inpu...
116
false
116
verified
10
10
1
4,274
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.CountGood.Code.Funs /-! # Specifications of `Aegis.CountGood.count_good` LeetCode problem `count-the-number-of-good-subarrays`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.CountGood namespace AegisSpec.CountGood def vals (s : Slice Std.I64) ...
14
difference-between-maximum-and-minimum-price-sum
2,538
Hard
[ "Tree", "Depth-First Search", "Array", "Dynamic Programming" ]
There exists an undirected and initially unrooted tree with n nodes indexed from 0 to n - 1. You are given the integer n and a 2D integer array edges of length n - 1, where edges[i] = [ai, bi] indicates that there is an edge between nodes ai and bi in the tree. Each node has an associated price. You are given an intege...
maxOutput(n: int, edges: list_list_int, price: list_int) -> int
pub fn max_output(n: i64, edges: &[Vec<i64>], price: &[i64]) -> i64
Aegis.MaxOutput.max_output
pub fn max_output(n: i64, edges: &[Vec<i64>], price: &[i64]) -> i64 { let n_us = n as usize; let m_edges = edges.len(); let mut deg: Vec<i64> = Vec::new(); let mut i = 0usize; while i < n_us { deg.push(0); i += 1; } let mut e = 0usize; while e < m_edges { let a ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [max_output]: type definitions module public import Aeneas @[expose] public section 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_output]: function definitions module public import Aeneas public import Aegis.MaxOutput.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.MaxOutput.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, [], [100]]", "output": "0" }, { "input": "[3, [[0, 1], [1, 2]], [1, 1, 1]]", "output": "2" }, { "input": "[4, [[0, 1], [1, 2], [1, 3]], [10, 5, 1, 1]]", "output": "15" }, { "input": "[4, [[0, 1], [1, 2], [1, 3]], [1, 2, 3, 4]]", "output": "6" }, { ...
58
false
58
verified
10
10
1
16,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.MaxOutput.Code.Funs /-! # Specifications of `Aegis.MaxOutput.max_output` LeetCode problem `difference-between-maximum-and-minimum-price-sum`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.MaxOutput def priceList (price : Slice I64...
16
minimum-common-value
2,540
Easy
[ "Array", "Hash Table", "Two Pointers", "Binary Search" ]
Given two integer arrays nums1 and nums2, sorted in non-decreasing order, return the minimum integer common to both arrays. If there is no common integer amongst nums1 and nums2, return -1. Note that an integer is said to be common to nums1 and nums2 if both arrays have at least one occurrence of that integer.   Exampl...
getCommon(nums1: list_int, nums2: list_int) -> int
pub fn get_common(nums1: &[i64], nums2: &[i64]) -> i64
Aegis.GetCommon.get_common
pub fn get_common(nums1: &[i64], nums2: &[i64]) -> i64 { let n1 = nums1.len(); let n2 = nums2.len(); let mut i: usize = 0; let mut j: usize = 0; while i < n1 && j < n2 { if nums1[i] == nums2[j] { return nums1[i]; } else if nums1[i] < nums2[j] { i += 1; ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [get_common]: type definitions module public import Aeneas @[expose] public section 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 -- [get_common]: function definitions module public import Aeneas public import Aegis.GetCommon.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.GetCommon.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": "[[1000000000], [1000000000]]", "output": "1000000000" }, { "input": "[[1], [2]]", "output": "-1" }, { "input": "[[1], [1]]", "output": "1" }, { "input": "[[1, 2, 3], [2, 4]]", "output": "2" }, { "input": "[[1, 2, 2, 3], [2, 2]]", "output": "2" },...
103
false
103
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.GetCommon.Code.Funs /-! # Specifications of `Aegis.GetCommon.get_common` LeetCode problem `minimum-common-value`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.GetCommon def OccursAt (nums : Slice Std.I64) (i : Nat) (x : Int) : Prop :...
14
minimum-operations-to-make-array-equal-ii
2,541
Medium
[ "Greedy", "Array", "Math" ]
You are given two integer arrays nums1 and nums2 of equal length n and an integer k. You can perform the following operation on nums1: Choose two indexes i and j and increment nums1[i] by k and decrement nums1[j] by k. In other words, nums1[i] = nums1[i] + k and nums1[j] = nums1[j] - k. nums1 is said to be equal to n...
minOperations(nums1: list_int, nums2: list_int, k: int) -> int
pub fn min_operations(nums1: &[i64], nums2: &[i64], k: i64) -> i64
Aegis.MinOperations.min_operations
pub fn min_operations(nums1: &[i64], nums2: &[i64], k: i64) -> i64 { let n = nums1.len(); let mut result: i64 = 0; if k == 0 { let mut ok = true; let mut i = 0; while i < n { if nums1[i] != nums2[i] { ok = false; } i += 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 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": "[[10, 20, 30], [20, 30, 40], 10]", "output": "-1" }, { "input": "[[1, 2, 3], [3, 2, 1], 2]", "output": "1" }, { "input": "[[1, 1, 1], [2, 2, 2], 0]", "output": "-1" }, { "input": "[[1, 2, 3], [1, 2, 3], 0]", "output": "0" }, { "input": "[[0, 0, 0], [0,...
109
false
109
verified
10
10
2
3,223
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": 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-array-equal-ii`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.MinOperations def nums (s : Slice Std.I64...
13
maximum-subsequence-score
2,542
Medium
[ "Greedy", "Array", "Sorting", "Heap (Priority Queue)" ]
You are given two 0-indexed integer arrays nums1 and nums2 of equal length n and a positive integer k. You must choose a subsequence of indices from nums1 of length k. For chosen indices i0, i1, ..., ik - 1, your score is defined as: The sum of the selected elements from nums1 multiplied with the minimum of the select...
maxScore(nums1: list_int, nums2: list_int, k: int) -> int
pub fn max_score(nums1: &[i64], nums2: &[i64], k: i64) -> i64
Aegis.MaxScore.max_score
pub fn max_score(nums1: &[i64], nums2: &[i64], k: i64) -> i64 { let n = nums1.len(); if n == 0 { return 0; } let mut max_v = nums2[0]; let mut i = 1usize; while i < n { if nums2[i] > max_v { max_v = nums2[i]; } i += 1; } let size = (max_v as ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [max_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.styl...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [max_score]: function definitions module public import Aeneas public import Aegis.MaxScore.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.MaxScore.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval aegisCase "e...
[ { "input": "[[1, 3, 3, 2], [2, 1, 3, 4], 3]", "output": "12" }, { "input": "[[0, 0, 0, 0], [100, 200, 300, 400], 2]", "output": "0" }, { "input": "[[0, 0, 0, 0], [0, 0, 0, 0], 4]", "output": "0" }, { "input": "[[5, 5, 5, 5], [1, 1, 1, 1], 2]", "output": "10" }, { ...
114
false
114
verified_partial
10
5
1
10,841
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MaxScore.Code.Funs /-! # Specifications of `Aegis.MaxScore.max_score` LeetCode problem `maximum-subsequence-score`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.MaxScore def contents (s : Slice Std.I64) : List ℤ := s.val.map (fun...
13
check-if-point-is-reachable
2,543
Hard
[ "Math", "Number Theory" ]
There exists an infinitely large grid. You are currently at point (1, 1), and you need to reach the point (targetX, targetY) using a finite number of steps. In one step, you can move from point (x, y) to any one of the following points: (x, y - x) (x - y, y) (2 * x, y) (x, 2 * y) Given two integers targetX and target...
isReachable(targetX: int, targetY: int) -> bool
pub fn is_reachable(targetX: i64, targetY: i64) -> bool
Aegis.IsReachable.is_reachable
pub fn is_reachable(targetX: i64, targetY: i64) -> bool { let mut a: i64 = targetX; let mut b: i64 = targetY; while b != 0 { let r: i64 = a % b; a = b; b = r; } let mut g: i64 = a; while g > 1 && g % 2 == 0 { g = g / 2; } g == 1 }
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [is_reachable]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter.s...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [is_reachable]: function definitions module public import Aeneas public import Aegis.IsReachable.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.IsReachable.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": "[7, 3]", "output": "true" }, { "input": "[6, 9]", "output": "false" }, { "input": "[16, 8]", "output": "true" }, { "input": "[3, 5]", "output": "true" }, { "input": "[10, 1]", "output": "true" }, { "input": "[1, 1]", "output": "true" ...
86
false
86
verified
10
10
1
15,313
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.IsReachable.Code.Funs /-! # Specifications of `Aegis.IsReachable.is_reachable` LeetCode problem `check-if-point-is-reachable`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.IsReachable def Step (p q : ℤ × ℤ) : Prop := q = (p.1...
8
alternating-digit-sum
2,544
Easy
[ "Math" ]
You are given a positive integer n. Each digit of n has a sign according to the following rules: The most significant digit is assigned a positive sign. Each other digit has an opposite sign to its adjacent digits. Return the sum of all digits with their corresponding sign.   Example 1: Input: n = 521 Output: 4 Expl...
alternateDigitSum(n: int) -> int
pub fn alternate_digit_sum(n: i64) -> i64
Aegis.AlternateDigitSum.alternate_digit_sum
pub fn alternate_digit_sum(n: i64) -> i64 { let mut temp: i64 = n; let mut len: usize = 0; while temp > 0 { len += 1; temp /= 10; } let mut divisor: i64 = 1; let mut j: usize = 1; while j < len { divisor *= 10; j += 1; } let mut sum: i64 = 0; le...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [alternate_digit_sum]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option l...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [alternate_digit_sum]: function definitions module public import Aeneas public import Aegis.AlternateDigitSum.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false...
import Aegis.AlternateDigitSum.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": "[987654321]", "output": "5" }, { "input": "[123]", "output": "2" }, { "input": "[987]", "output": "8" }, { "input": "[9]", "output": "9" }, { "input": "[123456789]", "output": "5" }, { "input": "[111]", "output": "1" }, { "input...
55
false
55
verified
10
10
1
1,080
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.AlternateDigitSum.Code.Funs /-! # Specifications of `Aegis.AlternateDigitSum.alternate_digit_sum` LeetCode problem `alternating-digit-sum`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.AlternateDigitSum def numDigits (n : ℕ) : ℕ ...
15
sort-the-students-by-their-kth-score
2,545
Medium
[ "Array", "Matrix", "Sorting" ]
There is a class with m students and n exams. You are given a 0-indexed m x n integer matrix score, where each row represents one student and score[i][j] denotes the score the ith student got in the jth exam. The matrix score contains distinct integers only. You are also given an integer k. Sort the students (i.e., the...
sortTheStudents(score: list_list_int, k: int) -> list_list_int
pub fn sort_the_students(score: &[Vec<i64>], k: i64) -> Vec<Vec<i64>>
Aegis.SortTheStudents.sort_the_students
pub fn sort_the_students(score: &[Vec<i64>], k: i64) -> Vec<Vec<i64>> { let m = score.len(); let m_i = m as i64; let kk = k as usize; // ranks[i] = number of students with a strictly greater k-th score. // (scores are distinct, so this is exactly student i's descending position) let mut ranks: ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [sort_the_students]: type definitions module public import Aeneas @[expose] public section 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 -- [sort_the_students]: function definitions module public import Aeneas public import Aegis.SortTheStudents.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.SortTheStudents.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": "[[[100]], 0]", "output": "[[100]]" }, { "input": "[[[3, 4], [5, 6]], 0]", "output": "[[5, 6], [3, 4]]" }, { "input": "[[[20, 10], [15, 5], [25, 15]], 1]", "output": "[[25, 15], [20, 10], [15, 5]]" }, { "input": "[[[20, 30], [15, 25], [10, 15]], 1]", "output": ...
83
false
83
verified
10
10
4
31,868
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.SortTheStudents.Code.Funs /-! # Specifications of `Aegis.SortTheStudents.sort_the_students` LeetCode problem `sort-the-students-by-their-kth-score`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result set_option autoImplicit false namespace AegisSpec.SortTheSt...
12
apply-bitwise-operations-to-make-strings-equal
2,546
Medium
[ "Bit Manipulation", "String" ]
You are given two 0-indexed binary strings s and target of the same length n. You can do the following operation on s any number of times: Choose two different indices i and j where 0 <= i, j < n. Simultaneously, replace s[i] with (s[i] OR s[j]) and s[j] with (s[i] XOR s[j]). For example, if s = "0110", you can choos...
makeStringsEqual(s: str, target: str) -> bool
pub fn make_strings_equal(s: &[u8], target: &[u8]) -> bool
Aegis.MakeStringsEqual.make_strings_equal
pub fn make_strings_equal(s: &[u8], target: &[u8]) -> bool { let mut s_has_one: bool = false; let mut target_has_one: bool = false; let mut i: usize = 0; while i < s.len() { if s[i] == b'1' { s_has_one = true; } i += 1; } let mut j: usize = 0; while j < ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [make_strings_equal]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option li...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [make_strings_equal]: function definitions module public import Aeneas public import Aegis.MakeStringsEqual.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.MakeStringsEqual.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval aegi...
[ { "input": "[\"1001\", \"1001\"]", "output": "true" }, { "input": "[\"1010\", \"0110\"]", "output": "true" }, { "input": "[\"11\", \"00\"]", "output": "false" }, { "input": "[\"0000\", \"0000\"]", "output": "true" }, { "input": "[\"1100\", \"0011\"]", "output"...
95
false
95
verified
10
10
1
547
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MakeStringsEqual.Code.Funs /-! # Specifications of `Aegis.MakeStringsEqual.make_strings_equal` LeetCode problem `apply-bitwise-operations-to-make-strings-equal`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.MakeStringsEqual namespace AegisSpec...
7
minimum-cost-to-split-an-array
2,547
Hard
[ "Array", "Hash Table", "Dynamic Programming", "Counting" ]
You are given an integer array nums and an integer k. Split the array into some number of non-empty subarrays. The cost of a split is the sum of the importance value of each subarray in the split. Let trimmed(subarray) be the version of the subarray where all numbers which appear only once are removed. For example, tr...
minCost(nums: list_int, k: int) -> int
pub fn min_cost(nums: &[i64], k: i64) -> i64
Aegis.MinCost.min_cost
pub fn min_cost(nums: &[i64], k: i64) -> i64 { let n: usize = nums.len(); if n == 0 { return 0; } // Determine a safe size for frequency buckets (values may exceed n-1). let mut maxv: usize = 0; let mut a: usize = 0; while a < n { let v: usize = nums[a] as usize; if ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [min_cost]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter.style...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [min_cost]: function definitions module public import Aeneas public import Aegis.MinCost.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.un...
import Aegis.MinCost.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval aegisCase "ev...
[ { "input": "[[1], 10]", "output": "10" }, { "input": "[[1], 100]", "output": "100" }, { "input": "[[1, 2], 1]", "output": "1" }, { "input": "[[1, 2, 3, 4, 5], 3]", "output": "3" }, { "input": "[[1, 2, 1, 2, 1], 2]", "output": "6" }, { "input": "[[1, 1,...
122
false
122
verified
10
10
2
3,819
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MinCost.Code.Funs /-! # Specifications of `Aegis.MinCost.min_cost` LeetCode problem `minimum-cost-to-split-an-array`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.MinCost (min_cost) namespace AegisSpec.MinCost def toList (nums : Slice S...
12
count-distinct-numbers-on-board
2,549
Easy
[ "Array", "Hash Table", "Math", "Simulation" ]
You are given a positive integer n, that is initially placed on a board. Every day, for 109 days, you perform the following procedure: For each number x present on the board, find all numbers 1 <= i <= n such that x % i == 1. Then, place those numbers on the board. Return the number of distinct integers present on th...
distinctIntegers(n: int) -> int
pub fn distinct_integers(n: i64) -> i64
Aegis.DistinctIntegers.distinct_integers
pub fn distinct_integers(n: i64) -> i64 { if n == 1 { 1 } else { n - 1 } }
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [distinct_integers]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option lin...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [distinct_integers]: function definitions module public import Aeneas public import Aegis.DistinctIntegers.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false se...
import Aegis.DistinctIntegers.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval aegi...
[ { "input": "[3]", "output": "2" }, { "input": "[99]", "output": "98" }, { "input": "[20]", "output": "19" }, { "input": "[100]", "output": "99" }, { "input": "[1]", "output": "1" }, { "input": "[10]", "output": "9" }, { "input": "[5]", ...
50
false
50
verified
10
10
1
180
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.DistinctIntegers.Code.Funs /-! # Specifications of `Aegis.DistinctIntegers.distinct_integers` LeetCode problem `count-distinct-numbers-on-board`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result noncomputable section namespace AegisSpec.DistinctIntegers...
10
put-marbles-in-bags
2,551
Hard
[ "Greedy", "Array", "Sorting", "Heap (Priority Queue)" ]
You have k bags. You are given a 0-indexed integer array weights where weights[i] is the weight of the ith marble. You are also given the integer k. Divide the marbles into the k bags according to the following rules: No bag is empty. If the ith marble and jth marble are in a bag, then all marbles with an index betwee...
putMarbles(weights: list_int, k: int) -> int
pub fn put_marbles(weights: &[i64], k: i64) -> i64
Aegis.PutMarbles.put_marbles
pub fn put_marbles(weights: &[i64], k: i64) -> i64 { let n = weights.len(); if k <= 1 || n <= 1 { return 0; } let mut sums: Vec<i64> = Vec::new(); let mut i: usize = 0; while i + 1 < n { sums.push(weights[i] + weights[i + 1]); i += 1; } sums.sort(); let m =...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [put_marbles]: type definitions module public import Aeneas @[expose] public section 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 -- [put_marbles]: function definitions module public import Aeneas public import Aegis.PutMarbles.Code.Types public import Aegis.PutMarbles.Code.FunsExternal @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false s...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [put_marbles]: external functions. -- This is a template file: rename it to "FunsExternal.lean" and fill the holes. module public import Aeneas public import Aegis.PutMarbles.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_opt...
import Aegis.PutMarbles.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, 3], 2]", "output": "0" }, { "input": "[[1, 3, 5, 1], 2]", "output": "4" }, { "input": "[[1, 1, 1, 1, 1], 5]", "output": "0" }, { "input": "[[4, 1, 5, 1, 2], 3]", "output": "4" }, { "input": "[[4, 1, 5, 1, 2], 3]", "output": "4" }, { "i...
87
false
87
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.PutMarbles.Code.Funs /-! # Specifications of `Aegis.PutMarbles.put_marbles` LeetCode problem `put-marbles-in-bags`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.PutMarbles namespace AegisSpec.PutMarbles def vals (w : Slice Std.I64) : List ℤ :...
14
maximum-number-of-integers-to-choose-from-a-range-i
2,554
Medium
[ "Greedy", "Array", "Hash Table", "Binary Search", "Sorting" ]
You are given an integer array banned and two integers n and maxSum. You are choosing some number of integers following the below rules: The chosen integers have to be in the range [1, n]. Each integer can be chosen at most once. The chosen integers should not be in the array banned. The sum of the chosen integers sho...
maxCount(banned: list_int, n: int, maxSum: int) -> int
pub fn max_count(banned: &[i64], n: i64, maxSum: i64) -> i64
Aegis.MaxCount.max_count
fn banned_sum_up_to(x: i64, bits: &[i64], sum_pref: &[i64]) -> i64 { if x <= 0 { return 0; } let xu: usize = x as usize; let q: usize = xu / 32; let rem: usize = xu % 32; let mut s: i64 = sum_pref[q]; if rem > 0 { if q < bits.len() { let word: i64 = bits[q]; ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [max_count]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter.styl...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [max_count]: function definitions module public import Aeneas public import Aegis.MaxCount.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.MaxCount.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval aegisCase "e...
[ { "input": "[[], 10, 55]", "output": "10" }, { "input": "[[], 10000, 50000000]", "output": "9999" }, { "input": "[[], 100, 5000]", "output": "99" }, { "input": "[[], 50, 1275]", "output": "50" }, { "input": "[[11], 7, 50]", "output": "7" }, { "input": ...
101
false
101
verified
10
10
2
21,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.MaxCount.Code.Funs /-! # Specifications of `Aegis.MaxCount.max_count` LeetCode problem `maximum-number-of-integers-to-choose-from-a-range-i`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.MaxCount namespace AegisSpec.MaxCount def sliceVals (s ...
14
maximize-win-from-two-segments
2,555
Medium
[ "Array", "Binary Search", "Sliding Window" ]
There are some prizes on the X-axis. You are given an integer array prizePositions that is sorted in non-decreasing order, where prizePositions[i] is the position of the ith prize. There could be different prizes at the same position on the line. You are also given an integer k. You are allowed to select two segments w...
maximizeWin(prizePositions: list_int, k: int) -> int
pub fn maximize_win(prizePositions: &[i64], k: i64) -> i64
Aegis.MaximizeWin.maximize_win
pub fn maximize_win(prizePositions: &[i64], k: i64) -> i64 { let n = prizePositions.len(); // best_prefix[i] = maximum prizes obtainable from the first i prizes // using at most one segment. let mut best_prefix: Vec<i64> = Vec::new(); let mut t = 0usize; while t <= n { best_prefix.push(...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [maximize_win]: type definitions module public import Aeneas @[expose] public section 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 -- [maximize_win]: function definitions module public import Aeneas public import Aegis.MaximizeWin.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.MaximizeWin.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval aegisCase...
[ { "input": "[[1, 2, 3, 4], 0]", "output": "2" }, { "input": "[[1, 3, 5, 7, 9], 1]", "output": "2" }, { "input": "[[5, 5, 5, 5, 5], 1]", "output": "5" }, { "input": "[[5, 5, 5, 5, 5], 3]", "output": "5" }, { "input": "[[1, 3, 5, 7, 9], 2]", "output": "4" }, ...
98
false
98
verified
10
10
1
2,145
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MaximizeWin.Code.Funs /-! # Specifications of `Aegis.MaximizeWin.maximize_win` LeetCode problem `maximize-win-from-two-segments`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.MaximizeWin def vals (p : Slice Std.I64) : List ℤ := p.val...
16
disconnect-path-in-a-binary-matrix-by-at-most-one-flip
2,556
Medium
[ "Depth-First Search", "Breadth-First Search", "Array", "Dynamic Programming", "Matrix" ]
You are given a 0-indexed m x n binary matrix grid. You can move from a cell (row, col) to any of the cells (row + 1, col) or (row, col + 1) that has the value 1. The matrix is disconnected if there is no path from (0, 0) to (m - 1, n - 1). You can flip the value of at most one (possibly none) cell. You cannot flip the...
isPossibleToCutPath(grid: list_list_int) -> bool
pub fn is_possible_to_cut_path(grid: &[Vec<i64>]) -> bool
Aegis.IsPossibleToCutPath.is_possible_to_cut_path
fn compute_reach( grid: &[Vec<i64>], m: usize, n: usize, bi: usize, bj: usize, ) -> Vec<bool> { let total = m * n; let mut r: Vec<bool> = Vec::new(); let mut k = 0usize; while k < total { r.push(false); k += 1; } let mut i = 0usize; while i < m { ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [is_possible_to_cut_path]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_opti...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [is_possible_to_cut_path]: function definitions module public import Aeneas public import Aegis.IsPossibleToCutPath.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand...
import Aegis.IsPossibleToCutPath.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval a...
[ { "input": "[[[1, 0], [0, 1]]]", "output": "true" }, { "input": "[[[1, 1], [1, 1]]]", "output": "false" }, { "input": "[[[1, 1, 1], [1, 0, 0], [1, 1, 1]]]", "output": "true" }, { "input": "[[[1, 1, 1], [1, 0, 1], [1, 1, 1]]]", "output": "false" }, { "input": "[[[1...
81
false
81
verified
10
10
2
30,130
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.IsPossibleToCutPath.Code.Funs /-! # Specifications of `Aegis.IsPossibleToCutPath.is_possible_to_cut_path` LeetCode problem `disconnect-path-in-a-binary-matrix-by-at-most-one-flip`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.IsPoss...
13
maximum-number-of-integers-to-choose-from-a-range-ii
2,557
Medium
[ "Greedy", "Array", "Binary Search", "Sorting" ]
You are given an integer array banned and two integers n and maxSum. You are choosing some number of integers following the below rules: The chosen integers have to be in the range [1, n]. Each integer can be chosen at most once. The chosen integers should not be in the array banned. The sum of the chosen integers sho...
maxCount(banned: list_int, n: int, maxSum: int) -> int
pub fn max_count(banned: &[i64], n: i64, maxSum: i64) -> i64
Aegis.MaxCount.max_count
pub fn max_count(banned: &[i64], n: i64, maxSum: i64) -> i64 { let mut bs: Vec<i64> = Vec::new(); let m = banned.len(); let mut i: usize = 0; while i < m { let b = banned[i]; if b >= 1 && b <= n { bs.push(b); } i += 1; } bs.sort(); let mut count: ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [max_count]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter.styl...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [max_count]: function definitions module public import Aeneas public import Aegis.MaxCount.Code.Types public import Aegis.MaxCount.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 -- [max_count]: external functions. -- This is a template file: rename it to "FunsExternal.lean" and fill the holes. module public import Aeneas public import Aegis.MaxCount.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option ...
import Aegis.MaxCount.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval aegisCase "e...
[ { "input": "[[], 10, 55]", "output": "10" }, { "input": "[[], 10, 50]", "output": "9" }, { "input": "[[], 1000000000, 1000000000000000]", "output": "44721359" }, { "input": "[[5], 5, 5]", "output": "2" }, { "input": "[[1], 100, 5000]", "output": "98" }, { ...
107
false
107
verified
10
10
1
5,516
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MaxCount.Code.Funs /-! # Specifications of `Aegis.MaxCount.max_count` LeetCode problem `maximum-number-of-integers-to-choose-from-a-range-ii`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.MaxCount def occursIn (l : List I64) (v : ℤ) ...
15
take-gifts-from-the-richest-pile
2,558
Easy
[ "Array", "Simulation", "Heap (Priority Queue)" ]
You are given an integer array gifts denoting the number of gifts in various piles. Every second, you do the following: Choose the pile with the maximum number of gifts. If there is more than one pile with the maximum number of gifts, choose any. Reduce the number of gifts in the pile to the floor of the square root o...
pickGifts(gifts: list_int, k: int) -> int
pub fn pick_gifts(gifts: &[i64], k: i64) -> i64
Aegis.PickGifts.pick_gifts
fn isqrt(n: i64) -> i64 { let mut lo: i64 = 0; let mut hi: i64 = n; let mut ans: i64 = 0; while lo <= hi { let mid: i64 = lo + (hi - lo) / 2; if mid * mid <= n { ans = mid; lo = mid + 1; } else { hi = mid - 1; } } ans } pub f...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [pick_gifts]: type definitions module public import Aeneas @[expose] public section 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 -- [pick_gifts]: function definitions module public import Aeneas public import Aegis.PickGifts.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.PickGifts.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": "[[1000000000], 1000]", "output": "1" }, { "input": "[[1000000000], 10]", "output": "1" }, { "input": "[[1000000000], 1]", "output": "31622" }, { "input": "[[999999999], 1000]", "output": "1" }, { "input": "[[16, 81, 49], 3]", "output": "20" }, ...
108
false
108
verified
10
10
1
1,610
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.PickGifts.Code.Funs /-! # Specifications of `Aegis.PickGifts.pick_gifts` LeetCode problem `take-gifts-from-the-richest-pile`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.PickGifts def giftsInts (gifts : Slice Std.I64) : List ℤ := gi...
14
find-the-array-concatenation-value
2,562
Easy
[ "Array", "Two Pointers", "Simulation" ]
You are given a 0-indexed integer array nums. The concatenation of two numbers is the number formed by concatenating their numerals. For example, the concatenation of 15, 49 is 1549. The concatenation value of nums is initially equal to 0. Perform this operation until nums becomes empty: If nums has a size greater t...
findTheArrayConcVal(nums: list_int) -> int
pub fn find_the_array_conc_val(nums: &[i64]) -> i64
Aegis.FindTheArrayConcVal.find_the_array_conc_val
pub fn find_the_array_conc_val(nums: &[i64]) -> i64 { let n = nums.len(); let half = n / 2; let mut ans: i64 = 0; let mut i: usize = 0; while i < half { let first = nums[i]; let last = nums[n - 1 - i]; let mut mult: i64 = 1; let mut temp = last; if temp == ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [find_the_array_conc_val]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_opti...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [find_the_array_conc_val]: function definitions module public import Aeneas public import Aegis.FindTheArrayConcVal.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand...
import Aegis.FindTheArrayConcVal.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": "[[9]]", "output": "9" }, { "input": "[[1]]", "output": "1" }, { "input": "[[9999]]", "output": "9999" }, { "input": "[[10000]]", "output": "10000" }, { "input": "[[10, 20]]", "output": "1020" }, { "input": "[[1234, 5678, 9101]]", "outpu...
119
false
119
verified
10
10
1
1,599
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.FindTheArrayConcVal.Code.Funs /-! # Specifications of `Aegis.FindTheArrayConcVal.find_the_array_conc_val` LeetCode problem `find-the-array-concatenation-value`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.FindTheArrayConcVal def...
8
count-the-number-of-fair-pairs
2,563
Medium
[ "Array", "Two Pointers", "Binary Search", "Sorting" ]
Given a 0-indexed integer array nums of size n and two integers lower and upper, return the number of fair pairs. A pair (i, j) is fair if: 0 <= i < j < n, and lower <= nums[i] + nums[j] <= upper   Example 1: Input: nums = [0,1,7,4,4,5], lower = 3, upper = 6 Output: 6 Explanation: There are 6 fair pairs: (0,3), (0,4...
countFairPairs(nums: list_int, lower: int, upper: int) -> int
pub fn count_fair_pairs(nums: &[i64], lower: i64, upper: i64) -> i64
Aegis.CountFairPairs.count_fair_pairs
pub fn count_fair_pairs(nums: &[i64], lower: i64, upper: i64) -> i64 { let n = nums.len(); let mut sorted: Vec<i64> = Vec::new(); let mut i: usize = 0; while i < n { sorted.push(nums[i]); i += 1; } sorted.sort(); let m = sorted.len(); if m == 0 { return 0; ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [count_fair_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_fair_pairs]: function definitions module public import Aeneas public import Aegis.CountFairPairs.Code.Types public import Aegis.CountFairPairs.Code.FunsExternal @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupName...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [count_fair_pairs]: external functions. -- This is a template file: rename it to "FunsExternal.lean" and fill the holes. module public import Aeneas public import Aegis.CountFairPairs.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Erro...
import Aegis.CountFairPairs.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval aegisC...
[ { "input": "[[1000000000, -1000000000, 500000000, -500000000], 0, 0]", "output": "2" }, { "input": "[[1000000000, -1000000000, 500000000, -500000000], -1500000000, 1500000000]", "output": "6" }, { "input": "[[5, 5, 5, 5, 5], 10, 10]", "output": "10" }, { "input": "[[-1, 0, 1,...
89
false
89
verified
10
10
1
3,532
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.CountFairPairs.Code.Funs /-! # Specifications of `Aegis.CountFairPairs.count_fair_pairs` LeetCode problem `count-the-number-of-fair-pairs`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.CountFairPairs namespace AegisSpec.CountFairPairs def val...
13
substring-xor-queries
2,564
Medium
[ "Bit Manipulation", "Array", "Hash Table", "String" ]
You are given a binary string s, and a 2D integer array queries where queries[i] = [firsti, secondi]. For the ith query, find the shortest substring of s whose decimal value, val, yields secondi when bitwise XORed with firsti. In other words, val ^ firsti == secondi. The answer to the ith query is the endpoints (0-inde...
substringXorQueries(s: str, queries: list_list_int) -> list_list_int
pub fn substring_xor_queries(s: &[u8], queries: &[Vec<i64>]) -> Vec<Vec<i64>>
Aegis.SubstringXorQueries.substring_xor_queries
pub fn substring_xor_queries(s: &[u8], queries: &[Vec<i64>]) -> Vec<Vec<i64>> { let n = s.len(); let mut child0: Vec<i64> = Vec::new(); let mut child1: Vec<i64> = Vec::new(); let mut earliest: Vec<i64> = Vec::new(); child0.push(-1); child1.push(-1); earliest.push(-1); let mut first_ze...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [substring_xor_queries]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [substring_xor_queries]: function definitions module public import Aeneas public import Aegis.SubstringXorQueries.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand f...
import Aegis.SubstringXorQueries.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval a...
[ { "input": "[\"1\", [[4, 5]]]", "output": "[[0, 0]]" }, { "input": "[\"0101\", [[12, 8]]]", "output": "[[-1, -1]]" }, { "input": "[\"101101\", [[0, 5], [1, 2]]]", "output": "[[0, 2], [2, 3]]" }, { "input": "[\"1100110011\", [[15, 0], [7, 8], [3, 12], [5, 10]]]", "output":...
100
false
100
verified
10
10
1
17,029
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.SubstringXorQueries.Code.Funs /-! # Specifications of `Aegis.SubstringXorQueries.substring_xor_queries` LeetCode problem `substring-xor-queries`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.SubstringXorQueries open Aegis.SubstringXo...
13
subsequence-with-the-minimum-score
2,565
Hard
[ "Two Pointers", "String", "Binary Search" ]
You are given two strings s and t. You are allowed to remove any number of characters from the string t. The score of the string is 0 if no characters are removed from the string t, otherwise: Let left be the minimum index among all removed characters. Let right be the maximum index among all removed characters. Then...
minimumScore(s: str, t: str) -> int
pub fn minimum_score(s: &[u8], t: &[u8]) -> i64
Aegis.MinimumScore.minimum_score
pub fn minimum_score(s: &[u8], t: &[u8]) -> i64 { let n: usize = s.len(); let m: usize = t.len(); // pre[l] = earliest ending position in s for the prefix t[0..l]. // pre[0] = -1. If the prefix is impossible, store n as a sentinel. let mut pre: Vec<i64> = Vec::new(); pre.push(-1); let mut ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [minimum_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 -- [minimum_score]: function definitions module public import Aeneas public import Aegis.MinimumScore.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.MinimumScore.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": "[\"abcd\", \"abcde\"]", "output": "1" }, { "input": "[\"hello\", \"world\"]", "output": "5" }, { "input": "[\"abcdefghij\", \"fihgjedcba\"]", "output": "8" }, { "input": "[\"abcde\", \"edcba\"]", "output": "4" }, { "input": "[\"aaaaa\", \"aa\"]", "...
130
false
130
verified
10
10
1
21,549
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MinimumScore.Code.Funs /-! # Specifications of `Aegis.MinimumScore.minimum_score` LeetCode problem `subsequence-with-the-minimum-score`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.MinimumScore (minimum_score) namespace AegisSpec.MinimumScore...
12
minimum-score-by-changing-two-elements
2,567
Medium
[ "Greedy", "Array", "Sorting" ]
You are given an integer array nums. The low score of nums is the minimum absolute difference between any two integers. The high score of nums is the maximum absolute difference between any two integers. The score of nums is the sum of the high and low scores. Return the minimum score after changing two elements of n...
minimizeSum(nums: list_int) -> int
pub fn minimize_sum(nums: &[i64]) -> i64
Aegis.MinimizeSum.minimize_sum
pub fn minimize_sum(nums: &[i64]) -> i64 { let n = nums.len(); let mut mn0: i64 = 1000000000000000000; let mut mn1: i64 = 1000000000000000000; let mut mn2: i64 = 1000000000000000000; let mut mx0: i64 = -1000000000000000000; let mut mx1: i64 = -1000000000000000000; let mut mx2: i64 = -10000...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [minimize_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 -- [minimize_sum]: function definitions module public import Aeneas public import Aegis.MinimizeSum.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.MinimizeSum.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, 4, 3]]", "output": "0" }, { "input": "[[10, 100, 1000, 10000, 100000]]", "output": "990" }, { "input": "[[1, 4, 7, 8, 5]]", "output": "3" }, { "input": "[[5, 5, 5, 5, 5]]", "output": "0" }, { "input": "[[1, 2, 3, 1000000000, 1000000001, 1000000002...
82
false
82
verified
10
10
1
5,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.MinimizeSum.Code.Funs /-! # Specifications of `Aegis.MinimizeSum.minimize_sum` LeetCode problem `minimum-score-by-changing-two-elements`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.MinimizeSum set_option autoImplicit false namespace A...
13
minimum-impossible-or
2,568
Medium
[ "Bit Manipulation", "Brainteaser", "Array" ]
You are given a 0-indexed integer array nums. We say that an integer x is expressible from nums if there exist some integers 0 <= index1 < index2 < ... < indexk < nums.length for which nums[index1] | nums[index2] | ... | nums[indexk] = x. In other words, an integer is expressible if it can be written as the bitwise OR ...
minImpossibleOR(nums: list_int) -> int
pub fn min_impossible_or(nums: &[i64]) -> i64
Aegis.MinImpossibleOr.min_impossible_or
pub fn min_impossible_or(nums: &[i64]) -> i64 { let mut p: i64 = 1; let mut checked: usize = 0; while checked < 32 { let mut found: bool = false; let mut i: usize = 0; while i < nums.len() { if nums[i] == p { found = true; } i += ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [min_impossible_or]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option lin...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [min_impossible_or]: function definitions module public import Aeneas public import Aegis.MinImpossibleOr.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.MinImpossibleOr.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": "[[2, 1]]", "output": "4" }, { "input": "[[5, 3, 2]]", "output": "1" }, { "input": "[[7, 14, 28]]", "output": "1" }, { "input": "[[3, 6, 9]]", "output": "1" }, { "input": "[[7, 14, 21, 28]]", "output": "1" }, { "input": "[[3, 6, 9, 12]]", ...
108
false
108
verified
10
10
1
2,002
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MinImpossibleOr.Code.Funs /-! # Specifications of `Aegis.MinImpossibleOr.min_impossible_or` LeetCode problem `minimum-impossible-or`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.MinImpossibleOr def atIdx (nums : Slice Std.I64) (...
14
minimum-operations-to-reduce-an-integer-to-0
2,571
Medium
[ "Greedy", "Bit Manipulation", "Dynamic Programming" ]
You are given a positive integer n, you can do the following operation any number of times: Add or subtract a power of 2 from n. Return the minimum number of operations to make n equal to 0. A number x is power of 2 if x == 2i where i >= 0.   Example 1: Input: n = 39 Output: 3 Explanation: We can do the following op...
minOperations(n: int) -> int
pub fn min_operations(n: i64) -> i64
Aegis.MinOperations.min_operations
pub fn min_operations(n: i64) -> i64 { let mut x: i64 = n; let mut ans: i64 = 0; while x > 0 { if x % 2 == 1 { if x % 4 == 3 { x += 1; } else { x -= 1; } ans += 1; } else { x = x / 2; } }...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [min_operations]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [min_operations]: function definitions module public import Aeneas public import Aegis.MinOperations.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_opti...
import Aegis.MinOperations.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval aegisCa...
[ { "input": "[3]", "output": "2" }, { "input": "[63]", "output": "2" }, { "input": "[100]", "output": "3" }, { "input": "[50000]", "output": "6" }, { "input": "[4]", "output": "1" }, { "input": "[64]", "output": "1" }, { "input": "[16]", ...
60
false
60
verified
10
10
1
2,471
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MinOperations.Code.Funs /-! # Specifications of `Aegis.MinOperations.min_operations` LeetCode problem `minimum-operations-to-reduce-an-integer-to-0`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std open Aeneas.Std.Result open scoped BigOperators namespace AegisSpe...
15
left-and-right-sum-differences
2,574
Easy
[ "Array", "Prefix Sum" ]
You are given a 0-indexed integer array nums of size n. Define two arrays leftSum and rightSum where: leftSum[i] is the sum of elements to the left of the index i in the array nums. If there is no such element, leftSum[i] = 0. rightSum[i] is the sum of elements to the right of the index i in the array nums. If there i...
leftRightDifference(nums: list_int) -> list_int
pub fn left_right_difference(nums: &[i64]) -> Vec<i64>
Aegis.LeftRightDifference.left_right_difference
pub fn left_right_difference(nums: &[i64]) -> Vec<i64> { let n = nums.len(); let mut total: i64 = 0; let mut i: usize = 0; while i < n { total += nums[i]; i += 1; } let mut answer: Vec<i64> = Vec::new(); let mut left_sum: i64 = 0; i = 0; while i < n { let r...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [left_right_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...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [left_right_difference]: function definitions module public import Aeneas public import Aegis.LeftRightDifference.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand f...
import Aegis.LeftRightDifference.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval a...
[ { "input": "[[1]]", "output": "[0]" }, { "input": "[[5]]", "output": "[0]" }, { "input": "[[1, 2]]", "output": "[2, 1]" }, { "input": "[[5, 10]]", "output": "[10, 5]" }, { "input": "[[1, 2]]", "output": "[2, 1]" }, { "input": "[[10, 20, 30]]", "out...
131
false
131
verified
10
10
1
540
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.LeftRightDifference.Code.Funs /-! # Specifications of `Aegis.LeftRightDifference.left_right_difference` LeetCode problem `left-and-right-sum-differences`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result ControlFlow Error namespace AegisSpec.LeftRightDiffere...
13
find-the-divisibility-array-of-a-string
2,575
Medium
[ "Array", "Math", "String" ]
You are given a 0-indexed string word of length n consisting of digits, and a positive integer m. The divisibility array div of word is an integer array of length n such that: div[i] = 1 if the numeric value of word[0,...,i] is divisible by m, or div[i] = 0 otherwise. Return the divisibility array of word.   Example ...
divisibilityArray(word: str, m: int) -> list_int
pub fn divisibility_array(word: &[u8], m: i64) -> Vec<i64>
Aegis.DivisibilityArray.divisibility_array
pub fn divisibility_array(word: &[u8], m: i64) -> Vec<i64> { let n = word.len(); let mut out: Vec<i64> = Vec::new(); let mut rem: i64 = 0; let mut i: usize = 0; while i < n { let digit: i64 = (word[i] as i64) - 48; rem = (rem * 10 + digit) % m; if rem == 0 { out...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [divisibility_array]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option li...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [divisibility_array]: function definitions module public import Aeneas public import Aegis.DivisibilityArray.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false ...
import Aegis.DivisibilityArray.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": "[\"1010\", 10]", "output": "[0, 1, 0, 1]" }, { "input": "[\"00000\", 1]", "output": "[1, 1, 1, 1, 1]" }, { "input": "[\"00000\", 5]", "output": "[1, 1, 1, 1, 1]" }, { "input": "[\"998244353\", 3]", "output": "[1, 1, 0, 0, 0, 1, 1, 0, 0]" }, { "input": ...
6
false
6
verified
6
6
1
661
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.DivisibilityArray.Code.Funs /-! # Specifications of `Aegis.DivisibilityArray.divisibility_array` LeetCode problem `find-the-divisibility-array-of-a-string`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.DivisibilityArray def digit (c ...
9
find-the-maximum-number-of-marked-indices
2,576
Medium
[ "Greedy", "Array", "Two Pointers", "Binary Search", "Sorting" ]
You are given a 0-indexed integer array nums. Initially, all of the indices are unmarked. You are allowed to make this operation any number of times: Pick two different unmarked indices i and j such that 2 * nums[i] <= nums[j], then mark i and j. Return the maximum possible number of marked indices in nums using the ...
maxNumOfMarkedIndices(nums: list_int) -> int
pub fn max_num_of_marked_indices(nums: &[i64]) -> i64
Aegis.MaxNumOfMarkedIndices.max_num_of_marked_indices
pub fn max_num_of_marked_indices(nums: &[i64]) -> i64 { let n = nums.len(); let mut a: Vec<i64> = Vec::new(); let mut i: usize = 0; while i < n { a.push(nums[i]); i += 1; } a.sort(); let mut low: usize = 0; let mut high: usize = n / 2 + 1; while low + 1 < high { ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [max_num_of_marked_indices]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_op...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [max_num_of_marked_indices]: function definitions module public import Aeneas public import Aegis.MaxNumOfMarkedIndices.Code.Types public import Aegis.MaxNumOfMarkedIndices.Code.FunsExternal @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error se...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [max_num_of_marked_indices]: external functions. -- This is a template file: rename it to "FunsExternal.lean" and fill the holes. module public import Aeneas public import Aegis.MaxNumOfMarkedIndices.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ...
import Aegis.MaxNumOfMarkedIndices.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": "[[7, 6, 8]]", "output": "0" }, { "input": "[[1000000000, 1000000000, 1000000000, 1000000000]]", "output": "0" }, { "input": "[[3, 5, 2, 4]]", "output": "2" }, { "input": "[[9, 2, 5, 4]]", "output": "4" }, { "input": "[[10, 20, 30, 40, 50]]", "outpu...
119
false
119
verified
10
10
1
5,252
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MaxNumOfMarkedIndices.Code.Funs /-! # Specifications of `Aegis.MaxNumOfMarkedIndices.max_num_of_marked_indices` LeetCode problem `find-the-maximum-number-of-marked-indices`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.MaxNumOfMarkedIndices (ma...
10
minimum-time-to-visit-a-cell-in-a-grid
2,577
Hard
[ "Breadth-First Search", "Graph", "Array", "Matrix", "Shortest Path", "Heap (Priority Queue)" ]
You are given a m x n matrix grid consisting of non-negative integers where grid[row][col] represents the minimum time required to be able to visit the cell (row, col), which means you can visit the cell (row, col) only when the time you visit it is greater than or equal to grid[row][col]. You are standing in the top-l...
minimumTime(grid: list_list_int) -> int
pub fn minimum_time(grid: &[Vec<i64>]) -> i64
Aegis.MinimumTime.minimum_time
fn heap_push(h_idx: &mut Vec<usize>, h_key: &mut Vec<i64>, idx: usize, key: i64) { h_idx.push(idx); h_key.push(key); let mut i = h_idx.len() - 1; while i > 0 { let parent = (i - 1) / 2; if h_key[parent] <= h_key[i] { break; } let tmp_idx = h_idx[parent]; ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [minimum_time]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter.s...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [minimum_time]: function definitions module public import Aeneas public import Aegis.MinimumTime.Code.Types public import Aegis.MinimumTime.Code.FunsExternal @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace fals...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [minimum_time]: external functions. -- This is a template file: rename it to "FunsExternal.lean" and fill the holes. module public import Aeneas public import Aegis.MinimumTime.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_o...
import Aegis.MinimumTime.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval aegisCase...
[ { "input": "[[[0, 0], [0, 1]]]", "output": "2" }, { "input": "[[[0, 1], [2, 1]]]", "output": "2" }, { "input": "[[[0, 100], [101, 100]]]", "output": "-1" }, { "input": "[[[0, 1], [2, 3]]]", "output": "4" }, { "input": "[[[0, 2, 4], [3, 2, 1], [1, 0, 4]]]", "ou...
114
false
114
verified
10
10
1
9,471
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MinimumTime.Code.Funs /-! # Specifications of `Aegis.MinimumTime.minimum_time` LeetCode problem `minimum-time-to-visit-a-cell-in-a-grid`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.MinimumTime open Aeneas Aeneas.Std Result open Aeg...
12
split-with-minimum-sum
2,578
Easy
[ "Greedy", "Math", "Sorting" ]
Given a positive integer num, split it into two non-negative integers num1 and num2 such that: The concatenation of num1 and num2 is a permutation of num. In other words, the sum of the number of occurrences of each digit in num1 and num2 is equal to the number of occurrences of that digit in num. num1 and num2 c...
splitNum(num: int) -> int
pub fn split_num(num: i64) -> i64
Aegis.SplitNum.split_num
pub fn split_num(num: i64) -> i64 { let mut n: i64 = num; let mut digits: Vec<i64> = Vec::new(); while n > 0 { let d: i64 = n % 10; digits.push(d); n = n / 10; } let len = digits.len(); // Manual insertion-style sort of the digits in ascending order. let mut i: usi...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [split_num]: type definitions module public import Aeneas @[expose] public section 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 -- [split_num]: function definitions module public import Aeneas public import Aegis.SplitNum.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.SplitNum.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval aegisCase "e...
[ { "input": "[10]", "output": "1" }, { "input": "[687]", "output": "75" }, { "input": "[4325]", "output": "59" }, { "input": "[1111111111]", "output": "22222" }, { "input": "[1234]", "output": "37" }, { "input": "[222]", "output": "24" }, { ...
86
false
86
verified
10
10
1
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.SplitNum.Code.Funs /-! # Specifications of `Aegis.SplitNum.split_num` LeetCode problem `split-with-minimum-sum`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.SplitNum namespace AegisSpec.SplitNum def decDigits : Nat → List Nat | 0 =...
17
count-total-number-of-colored-cells
2,579
Medium
[ "Math" ]
There exists an infinitely large two-dimensional grid of uncolored unit cells. You are given a positive integer n, indicating that you must do the following routine for n minutes: At the first minute, color any arbitrary unit cell blue. Every minute thereafter, color blue every uncolored cell that touches a blue cell....
coloredCells(n: int) -> int
pub fn colored_cells(n: i64) -> i64
Aegis.ColoredCells.colored_cells
pub fn colored_cells(n: i64) -> i64 { let rings = n - 1; 1 + 2 * n * rings }
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [colored_cells]: type definitions module public import Aeneas @[expose] public section 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 -- [colored_cells]: function definitions module public import Aeneas public import Aegis.ColoredCells.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.ColoredCells.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval aegisCas...
[ { "input": "[3]", "output": "13" }, { "input": "[100000]", "output": "19999800001" }, { "input": "[100]", "output": "19801" }, { "input": "[10000]", "output": "199980001" }, { "input": "[2]", "output": "5" }, { "input": "[1]", "output": "1" }, ...
37
false
37
verified
10
10
1
257
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.ColoredCells.Code.Funs /-! # Specifications of `Aegis.ColoredCells.colored_cells` LeetCode problem `count-total-number-of-colored-cells`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.ColoredCells open Aegis.ColoredCells (colored_...
14
count-number-of-possible-root-nodes
2,581
Hard
[ "Tree", "Depth-First Search", "Array", "Hash Table", "Dynamic Programming" ]
Alice has an undirected tree with n nodes labeled from 0 to n - 1. The tree is represented as a 2D integer array edges of length n - 1 where edges[i] = [ai, bi] indicates that there is an edge between nodes ai and bi in the tree. Alice wants Bob to find the root of the tree. She allows Bob to make several guesses about...
rootCount(edges: list_list_int, guesses: list_list_int, k: int) -> int
pub fn root_count(edges: &[Vec<i64>], guesses: &[Vec<i64>], k: i64) -> i64
Aegis.RootCount.root_count
pub fn root_count(edges: &[Vec<i64>], guesses: &[Vec<i64>], k: i64) -> i64 { let n: usize = edges.len() + 1; let mut adj: Vec<Vec<i64>> = Vec::new(); let mut i: usize = 0; while i < n { adj.push(Vec::new()); i += 1; } i = 0; while i < edges.len() { let a = edges[i][...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [root_count]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter.sty...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [root_count]: function definitions module public import Aeneas public import Aegis.RootCount.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.RootCount.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": "[[[0, 1], [0, 2]], [[0, 1]], 1]", "output": "2" }, { "input": "[[[0, 1], [1, 2], [2, 3]], [[1, 2], [2, 3]], 2]", "output": "2" }, { "input": "[[[0, 1], [0, 2], [0, 3]], [[0, 1], [0, 2], [0, 3]], 2]", "output": "4" }, { "input": "[[[0, 1], [0, 2], [0, 3]], [[0, 1],...
70
false
70
verified
10
10
1
12,662
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.RootCount.Code.Funs /-! # Specifications of `Aegis.RootCount.root_count` LeetCode problem `count-number-of-possible-root-nodes`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.RootCount namespace AegisSpec.RootCount def vecVal (v : alloc.vec.Ve...
10
pass-the-pillow
2,582
Easy
[ "Math", "Simulation" ]
There are n people standing in a line labeled from 1 to n. The first person in the line is holding a pillow initially. Every second, the person holding the pillow passes it to the next person standing in the line. Once the pillow reaches the end of the line, the direction changes, and people continue passing the pillow...
passThePillow(n: int, time: int) -> int
pub fn pass_the_pillow(n: i64, time: i64) -> i64
Aegis.PassThePillow.pass_the_pillow
pub fn pass_the_pillow(n: i64, time: i64) -> i64 { let mut pos: i64 = 1; let mut dir: i64 = 1; let mut step: i64 = 0; while step < time { if dir == 1 { if pos == n { dir = -1; pos = pos - 1; } else { pos = pos + 1; ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [pass_the_pillow]: type definitions module public import Aeneas @[expose] public section 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 -- [pass_the_pillow]: function definitions module public import Aeneas public import Aegis.PassThePillow.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.PassThePillow.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval aegisCa...
[ { "input": "[2, 5]", "output": "2" }, { "input": "[10, 15]", "output": "4" }, { "input": "[500, 750]", "output": "249" }, { "input": "[2, 1]", "output": "2" }, { "input": "[7, 20]", "output": "5" }, { "input": "[8, 20]", "output": "7" }, { ...
94
false
94
verified
10
10
1
449
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.PassThePillow.Code.Funs /-! # Specifications of `Aegis.PassThePillow.pass_the_pillow` LeetCode problem `pass-the-pillow`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.PassThePillow def period (n : Int) : Int := 2 * (n - 1) /--...
11
kth-largest-sum-in-a-binary-tree
2,583
Medium
[ "Tree", "Breadth-First Search", "Binary Tree", "Sorting" ]
You are given the root of a binary tree and a positive integer k. The level sum in the tree is the sum of the values of the nodes that are on the same level. Return the kth largest level sum in the tree (not necessarily distinct). If there are fewer than k levels in the tree, return -1. Note that two nodes are on the s...
kthLargestLevelSum(root: tree, k: int) -> int
pub fn kth_largest_level_sum(root: &Tree, k: i64) -> i64
Aegis.KthLargestLevelSum.kth_largest_level_sum
fn collect_level_sums(t: &Tree, depth: usize, sums: &mut Vec<i64>) { match t { Tree::Null => {} Tree::Node(v, l, r) => { if depth == sums.len() { sums.push(0); } sums[depth] = sums[depth] + *v; collect_level_sums(&**l, depth + 1, sums);...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [kth_largest_level_sum]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [kth_largest_level_sum]: function definitions module public import Aeneas public import Aegis.KthLargestLevelSum.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand fa...
import Aegis.KthLargestLevelSum.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval ae...
[ { "input": "[[1], 1]", "output": "1" }, { "input": "[[5, 2, -3], 1]", "output": "5" }, { "input": "[[1, 3, 2, 5], 2]", "output": "5" }, { "input": "[[1, 3, 2, 15, 20, 7], 2]", "output": "5" }, { "input": "[[1, 3, 2, 5, 6, 7], 3]", "output": "1" }, { "i...
26
false
26
verified
10
10
1
4,060
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.KthLargestLevelSum.Code.Funs /-! # Specifications of `Aegis.KthLargestLevelSum.kth_largest_level_sum` LeetCode problem `kth-largest-sum-in-a-binary-tree`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.KthLargestLevelSum namespace AegisSpec.KthL...
12
split-the-array-to-make-coprime-products
2,584
Hard
[ "Array", "Hash Table", "Math", "Number Theory" ]
You are given a 0-indexed integer array nums of length n. A split at an index i where 0 <= i <= n - 2 is called valid if the product of the first i + 1 elements and the product of the remaining elements are coprime. For example, if nums = [2, 3, 3], then a split at the index i = 0 is valid because 2 and 9 are coprime,...
findValidSplit(nums: list_int) -> int
pub fn find_valid_split(nums: &[i64]) -> i64
Aegis.FindValidSplit.find_valid_split
pub fn find_valid_split(nums: &[i64]) -> i64 { let n = nums.len(); if n < 2 { return -1; } // Build primes up to 1000 using a small sieve. let limit: usize = 1000; let mut is_comp: Vec<i64> = Vec::new(); let mut t: usize = 0; while t <= limit { is_comp.push(0); t...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [find_valid_split]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option lint...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [find_valid_split]: function definitions module public import Aeneas public import Aegis.FindValidSplit.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.FindValidSplit.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval aegisC...
[ { "input": "[[1000000, 1000000]]", "output": "-1" }, { "input": "[[30, 35, 14]]", "output": "-1" }, { "input": "[[60, 45, 10]]", "output": "-1" }, { "input": "[[18, 5, 100]]", "output": "-1" }, { "input": "[[60, 1, 2, 3]]", "output": "-1" }, { "input":...
107
false
107
verified
10
10
2
21,959
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.FindValidSplit.Code.Funs /-! # Specifications of `Aegis.FindValidSplit.find_valid_split` LeetCode problem `split-the-array-to-make-coprime-products`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.FindValidSplit def valAt (nums : S...
10
number-of-ways-to-earn-points
2,585
Hard
[ "Array", "Dynamic Programming" ]
There is a test that has n types of questions. You are given an integer target and a 0-indexed 2D integer array types where types[i] = [counti, marksi] indicates that there are counti questions of the ith type, and each one of them is worth marksi points. Return the number of ways you can earn exactly target points i...
waysToReachTarget(target: int, types: list_list_int) -> int
pub fn ways_to_reach_target(target: i64, types: &[Vec<i64>]) -> i64
Aegis.WaysToReachTarget.ways_to_reach_target
pub fn ways_to_reach_target(target: i64, types: &[Vec<i64>]) -> i64 { let modv: i64 = 1000000007; let target_usize: usize = target as usize; let mut dp: Vec<i64> = Vec::new(); let mut i: usize = 0; while i <= target_usize { dp.push(0); i = i + 1; } dp[0] = 1; let n: usi...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [ways_to_reach_target]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [ways_to_reach_target]: function definitions module public import Aeneas public import Aegis.WaysToReachTarget.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand fals...
import Aegis.WaysToReachTarget.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval aeg...
[ { "input": "[1, [[1, 1]]]", "output": "1" }, { "input": "[10, [[2, 5], [1, 3]]]", "output": "1" }, { "input": "[10, [[10, 1], [5, 2]]]", "output": "6" }, { "input": "[30, [[5, 10], [3, 5], [2, 15]]]", "output": "5" }, { "input": "[750, [[50, 15], [50, 25], [50, 35...
117
false
117
verified
10
10
1
2,823
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.WaysToReachTarget.Code.Funs /-! # Specifications of `Aegis.WaysToReachTarget.ways_to_reach_target` LeetCode problem `number-of-ways-to-earn-points`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.WaysToReachTarget namespace AegisSpec.WaysToR...
14
rearrange-array-to-maximize-prefix-score
2,587
Medium
[ "Greedy", "Array", "Prefix Sum", "Sorting" ]
You are given a 0-indexed integer array nums. You can rearrange the elements of nums to any order (including the given order). Let prefix be the array containing the prefix sums of nums after rearranging it. In other words, prefix[i] is the sum of the elements from 0 to i in nums after rearranging it. The score of nums...
maxScore(nums: list_int) -> int
pub fn max_score(nums: &[i64]) -> i64
Aegis.MaxScore.max_score
pub fn max_score(nums: &[i64]) -> i64 { let n = nums.len(); if n == 0 { return 0; } let mut minv: i64 = nums[0]; let mut maxv: i64 = nums[0]; let mut i: usize = 1; while i < n { let x = nums[i]; if x < minv { minv = x; } if x > maxv { ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [max_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.styl...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [max_score]: function definitions module public import Aeneas public import Aegis.MaxScore.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.MaxScore.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval aegisCase "e...
[ { "input": "[[-1]]", "output": "0" }, { "input": "[[1]]", "output": "1" }, { "input": "[[0]]", "output": "0" }, { "input": "[[-2, -3, 0]]", "output": "0" }, { "input": "[[-1, -2, -3, -4, -5]]", "output": "0" }, { "input": "[[0, 0, 0, 0, 0]]", "outp...
105
false
105
verified_partial
10
7
1
3,274
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MaxScore.Code.Funs /-! # Specifications of `Aegis.MaxScore.max_score` LeetCode problem `rearrange-array-to-maximize-prefix-score`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.MaxScore namespace AegisSpec.MaxScore def vals (nums : Slice Std.I...
15
count-the-number-of-beautiful-subarrays
2,588
Medium
[ "Bit Manipulation", "Array", "Hash Table", "Prefix Sum" ]
You are given a 0-indexed integer array nums. In one operation, you can: Choose two different indices i and j such that 0 <= i, j < nums.length. Choose a non-negative integer k such that the kth bit (0-indexed) in the binary representation of nums[i] and nums[j] is 1. Subtract 2k from nums[i] and nums[j]. A subarray ...
beautifulSubarrays(nums: list_int) -> int
pub fn beautiful_subarrays(nums: &[i64]) -> i64
Aegis.BeautifulSubarrays.beautiful_subarrays
pub fn beautiful_subarrays(nums: &[i64]) -> i64 { let n = nums.len(); let mut max_val: i64 = 0; let mut i: usize = 0; while i < n { if nums[i] > max_val { max_val = nums[i]; } i += 1; } let mut size: i64 = 1; while size <= max_val { size = size *...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [beautiful_subarrays]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option l...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [beautiful_subarrays]: function definitions module public import Aeneas public import Aegis.BeautifulSubarrays.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand fals...
import Aegis.BeautifulSubarrays.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval ae...
[ { "input": "[[1]]", "output": "0" }, { "input": "[[1, 10, 4]]", "output": "0" }, { "input": "[[5, 5, 5, 5]]", "output": "4" }, { "input": "[[0, 0, 0, 0]]", "output": "10" }, { "input": "[[2, 2, 2, 2]]", "output": "4" }, { "input": "[[1, 0, 1, 0, 1]]", ...
121
false
121
verified
10
10
1
6,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.BeautifulSubarrays.Code.Funs /-! # Specifications of `Aegis.BeautifulSubarrays.beautiful_subarrays` LeetCode problem `count-the-number-of-beautiful-subarrays`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.BeautifulSubarrays namespace Aegis...
10
minimum-time-to-complete-all-tasks
2,589
Hard
[ "Stack", "Greedy", "Array", "Binary Search", "Sorting" ]
There is a computer that can run an unlimited number of tasks at the same time. You are given a 2D integer array tasks where tasks[i] = [starti, endi, durationi] indicates that the ith task should run for a total of durationi seconds (not necessarily continuous) within the inclusive time range [starti, endi]. You may t...
findMinimumTime(tasks: list_list_int) -> int
pub fn find_minimum_time(tasks: &[Vec<i64>]) -> i64
Aegis.FindMinimumTime.find_minimum_time
pub fn find_minimum_time(tasks: &[Vec<i64>]) -> i64 { let n = tasks.len(); let mut order: Vec<i64> = Vec::new(); let mut max_end: i64 = 0; let mut i: usize = 0; while i < n { order.push(i as i64); let e = tasks[i][1]; if e > max_end { max_end = e; } ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [find_minimum_time]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option lin...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [find_minimum_time]: function definitions module public import Aeneas public import Aegis.FindMinimumTime.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.FindMinimumTime.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval aegis...
[ { "input": "[[[1, 10, 10]]]", "output": "10" }, { "input": "[[[1, 100, 50], [50, 150, 50], [100, 200, 50]]]", "output": "99" }, { "input": "[[[1, 2, 1], [1, 2, 1], [1, 2, 1]]]", "output": "1" }, { "input": "[[[1, 100, 50], [50, 150, 50], [150, 200, 50]]]", "output": "100"...
112
false
112
verified
10
10
1
11,064
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.FindMinimumTime.Code.Funs /-! # Specifications of `Aegis.FindMinimumTime.find_minimum_time` LeetCode problem `minimum-time-to-complete-all-tasks`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.FindMinimumTime namespace AegisSpec.FindMinimum...
12
distribute-money-to-maximum-children
2,591
Easy
[ "Greedy", "Math" ]
You are given an integer money denoting the amount of money (in dollars) that you have and another integer children denoting the number of children that you must distribute the money to. You have to distribute the money according to the following rules: All money must be distributed. Everyone must receive at least 1 d...
distMoney(money: int, children: int) -> int
pub fn dist_money(money: i64, children: i64) -> i64
Aegis.DistMoney.dist_money
pub fn dist_money(money: i64, children: i64) -> i64 { if money < children { return -1; } let extra: i64 = money - children; let mut ans: i64 = extra / 7; if ans > children { ans = children; } let leftover: i64 = extra - ans * 7; let remaining: i64 = children - ans; ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [dist_money]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter.sty...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [dist_money]: function definitions module public import Aeneas public import Aegis.DistMoney.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.DistMoney.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": "[150, 15]", "output": "14" }, { "input": "[100, 5]", "output": "4" }, { "input": "[15, 3]", "output": "1" }, { "input": "[31, 3]", "output": "2" }, { "input": "[7, 2]", "output": "0" }, { "input": "[25, 4]", "output": "3" }, { "...
47
false
47
verified
10
10
1
5,108
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.DistMoney.Code.Funs /-! # Specifications of `Aegis.DistMoney.dist_money` LeetCode problem `distribute-money-to-maximum-children`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.DistMoney def Admissible (money children : ℤ) (a : List ℤ)...
14
maximize-greatness-of-an-array
2,592
Medium
[ "Greedy", "Array", "Two Pointers", "Sorting" ]
You are given a 0-indexed integer array nums. You are allowed to permute nums into a new array perm of your choosing. We define the greatness of nums be the number of indices 0 <= i < nums.length for which perm[i] > nums[i]. Return the maximum possible greatness you can achieve after permuting nums.   Example 1: Input...
maximizeGreatness(nums: list_int) -> int
pub fn maximize_greatness(nums: &[i64]) -> i64
Aegis.MaximizeGreatness.maximize_greatness
pub fn maximize_greatness(nums: &[i64]) -> i64 { let n = nums.len(); let mut sorted: Vec<i64> = Vec::new(); let mut idx: usize = 0; while idx < n { sorted.push(nums[idx]); idx += 1; } // Bottom-up merge sort. if n >= 2 { let mut tmp: Vec<i64> = Vec::new(); l...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [maximize_greatness]: type definitions module public import Aeneas @[expose] public section 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 -- [maximize_greatness]: function definitions module public import Aeneas public import Aegis.MaximizeGreatness.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false ...
import Aegis.MaximizeGreatness.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval aeg...
[ { "input": "[[1]]", "output": "0" }, { "input": "[[1, 2, 3, 4]]", "output": "3" }, { "input": "[[10000, 1000, 100, 10, 1]]", "output": "4" }, { "input": "[[5, 5, 5, 5, 5]]", "output": "0" }, { "input": "[[0, 0, 0, 0, 0]]", "output": "0" }, { "input": "...
86
false
86
verified
10
10
1
3,754
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MaximizeGreatness.Code.Funs /-! # Specifications of `Aegis.MaximizeGreatness.maximize_greatness` LeetCode problem `maximize-greatness-of-an-array`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.MaximizeGreatness (maximize_greatness) namespace A...
6
find-score-of-an-array-after-marking-all-elements
2,593
Medium
[ "Array", "Hash Table", "Sorting", "Simulation", "Heap (Priority Queue)" ]
You are given an array nums consisting of positive integers. Starting with score = 0, apply the following algorithm: Choose the smallest integer of the array that is not marked. If there is a tie, choose the one with the smallest index. Add the value of the chosen integer to score. Mark the chosen element and its two ...
findScore(nums: list_int) -> int
pub fn find_score(nums: &[i64]) -> i64
Aegis.FindScore.find_score
pub fn find_score(nums: &[i64]) -> i64 { let n = nums.len(); let base = n as i64; let mut keys: Vec<i64> = Vec::new(); let mut i = 0usize; while i < n { let key = nums[i] * base + (i as i64); keys.push(key); i += 1; } // Bottom-up merge sort of encoded (value, index...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [find_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.sty...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [find_score]: function definitions module public import Aeneas public import Aegis.FindScore.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.FindScore.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval aegisCase "...
[ { "input": "[[1]]", "output": "1" }, { "input": "[[1000000]]", "output": "1000000" }, { "input": "[[1, 1000000]]", "output": "1" }, { "input": "[[1000000, 1]]", "output": "1" }, { "input": "[[1000000, 1, 1000000, 1, 1000000]]", "output": "2" }, { "inpu...
112
false
112
verified
10
10
1
6,575
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.FindScore.Code.Funs /-! # Specifications of `Aegis.FindScore.find_score` LeetCode problem `find-score-of-an-array-after-marking-all-elements`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.FindScore namespace AegisSpec.FindScore def valu...
14
number-of-even-and-odd-bits
2,595
Easy
[ "Bit Manipulation" ]
You are given a positive integer n. Let even denote the number of even indices in the binary representation of n with value 1. Let odd denote the number of odd indices in the binary representation of n with value 1. Note that bits are indexed from right to left in the binary representation of a number. Return the array...
evenOddBit(n: int) -> list_int
pub fn even_odd_bit(n: i64) -> Vec<i64>
Aegis.EvenOddBit.even_odd_bit
pub fn even_odd_bit(n: i64) -> Vec<i64> { let mut x = n; let mut idx = 0i64; let mut even = 0i64; let mut odd = 0i64; while x > 0 { if x % 2 == 1 { if idx % 2 == 0 { even += 1; } else { odd += 1; } } x = x /...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [even_odd_bit]: type definitions module public import Aeneas @[expose] public section 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 -- [even_odd_bit]: function definitions module public import Aeneas public import Aegis.EvenOddBit.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.EvenOddBit.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": "[8]", "output": "[0, 1]" }, { "input": "[3]", "output": "[1, 1]" }, { "input": "[1000]", "output": "[2, 4]" }, { "input": "[63]", "output": "[3, 3]" }, { "input": "[255]", "output": "[4, 4]" }, { "input": "[15]", "output": "[2, 2]" },...
62
false
62
verified
10
10
1
350
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.EvenOddBit.Code.Funs /-! # Specifications of `Aegis.EvenOddBit.even_odd_bit` LeetCode problem `number-of-even-and-odd-bits`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.EvenOddBit def bit (n : Int) (i : Nat) : Int := (n / 2 ^ i)...
12
check-knight-tour-configuration
2,596
Medium
[ "Depth-First Search", "Breadth-First Search", "Array", "Matrix", "Simulation" ]
There is a knight on an n x n chessboard. In a valid configuration, the knight starts at the top-left cell of the board and visits every cell on the board exactly once. You are given an n x n integer matrix grid consisting of distinct integers from the range [0, n * n - 1] where grid[row][col] indicates that the cell (...
checkValidGrid(grid: list_list_int) -> bool
pub fn check_valid_grid(grid: &[Vec<i64>]) -> bool
Aegis.CheckValidGrid.check_valid_grid
pub fn check_valid_grid(grid: &[Vec<i64>]) -> bool { let n = grid.len(); let mut ok = true; // Basic shape / start checks (no returns here). if n == 0 || grid[0].len() != n { ok = false; } if ok && grid[0][0] != 0 { ok = false; } let sz = if ok { n * n } else { 0 }; ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [check_valid_grid]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option lint...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [check_valid_grid]: function definitions module public import Aeneas public import Aegis.CheckValidGrid.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.CheckValidGrid.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval aegisC...
[ { "input": "[[[0, 5, 2], [6, 3, 1], [8, 7, 4]]]", "output": "false" }, { "input": "[[[0, 5, 2], [3, 8, 7], [4, 1, 6]]]", "output": "false" }, { "input": "[[[0, 6, 1], [5, 8, 3], [4, 7, 2]]]", "output": "false" }, { "input": "[[[0, 2, 3], [1, 5, 4], [6, 7, 8]]]", "output":...
54
false
54
verified
10
10
3
6,028
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.CheckValidGrid.Code.Funs /-! # Specifications of `Aegis.CheckValidGrid.check_valid_grid` LeetCode problem `check-knight-tour-configuration`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result ControlFlow Error set_option maxHeartbeats 1000000 namespace Ae...
12
smallest-missing-non-negative-integer-after-operations
2,598
Medium
[ "Greedy", "Array", "Hash Table", "Math" ]
You are given a 0-indexed integer array nums and an integer value. In one operation, you can add or subtract value from any element of nums. For example, if nums = [1,2,3] and value = 2, you can choose to subtract value from nums[0] to make nums = [-1,2,3]. The MEX (minimum excluded) of an array is the smallest missi...
findSmallestInteger(nums: list_int, value: int) -> int
pub fn find_smallest_integer(nums: &[i64], value: i64) -> i64
Aegis.FindSmallestInteger.find_smallest_integer
pub fn find_smallest_integer(nums: &[i64], value: i64) -> i64 { let n_usize: usize = nums.len(); let n_i64: i64 = n_usize as i64; if n_usize == 0 { return 0; } // We only ever need residues that can correspond to a target value < n. // Using min(value, n) keeps the table bounded by the...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [find_smallest_integer]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [find_smallest_integer]: function definitions module public import Aeneas public import Aegis.FindSmallestInteger.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand f...
import Aegis.FindSmallestInteger.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": "[[0, 0, 0, 0], 3]", "output": "1" }, { "input": "[[-1, -2, -3, -4], 2]", "output": "4" }, { "input": "[[1000000000, -1000000000, 500000000, -500000000], 1000000000]", "output": "1" }, { "input": "[[10, 20, 30, 40], 10]", "output": "1" }, { "input": "[[...
125
false
125
verified
10
10
2
10,848
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.FindSmallestInteger.Code.Funs /-! # Specifications of `Aegis.FindSmallestInteger.find_smallest_integer` LeetCode problem `smallest-missing-non-negative-integer-after-operations`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.FindSmalle...
14
make-the-prefix-sum-non-negative
2,599
Medium
[ "Greedy", "Array", "Heap (Priority Queue)" ]
You are given a 0-indexed integer array nums. You can apply the following operation any number of times: Pick any element from nums and put it at the end of nums. The prefix sum array of nums is an array prefix of the same length as nums such that prefix[i] is the sum of all the integers nums[j] where j is in the inc...
makePrefSumNonNegative(nums: list_int) -> int
pub fn make_pref_sum_non_negative(nums: &[i64]) -> i64
Aegis.MakePrefSumNonNegative.make_pref_sum_non_negative
pub fn make_pref_sum_non_negative(nums: &[i64]) -> i64 { let n = nums.len(); let mut heap: Vec<i64> = Vec::new(); let mut sum: i64 = 0; let mut ans: i64 = 0; let mut i: usize = 0; while i < n { let x = nums[i]; sum += x; if x < 0 { let mut idx = heap.len(); ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [make_pref_sum_non_negative]: type definitions module public import Aeneas @[expose] public 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 -- [make_pref_sum_non_negative]: function definitions module public import Aeneas public import Aegis.MakePrefSumNonNegative.Code.Types public import Aegis.MakePrefSumNonNegative.Code.FunsExternal @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [make_pref_sum_non_negative]: external functions. -- This is a template file: rename it to "FunsExternal.lean" and fill the holes. module public import Aeneas public import Aegis.MakePrefSumNonNegative.Code.Types @[expose] public section open Aeneas Aeneas.Std Resul...
import Aegis.MakePrefSumNonNegative.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eva...
[ { "input": "[[2, 3, -5, 4]]", "output": "0" }, { "input": "[[3, -5, -2, 6]]", "output": "1" }, { "input": "[[1000000000, -500000000, -500000000, 500000000]]", "output": "0" }, { "input": "[[1000000000, -500000000, -500000000, 1]]", "output": "0" }, { "input": "[[1...
107
false
107
verified
10
10
1
6,566
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MakePrefSumNonNegative.Code.Funs /-! # Specifications of `Aegis.MakePrefSumNonNegative.make_pref_sum_non_negative` LeetCode problem `make-the-prefix-sum-non-negative`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.MakePrefSumNonNegat...
9
k-items-with-the-maximum-sum
2,600
Easy
[ "Greedy", "Math" ]
There is a bag that consists of items, each item has a number 1, 0, or -1 written on it. You are given four non-negative integers numOnes, numZeros, numNegOnes, and k. The bag initially contains: numOnes items with 1s written on them. numZeroes items with 0s written on them. numNegOnes items with -1s written on them. ...
kItemsWithMaximumSum(numOnes: int, numZeros: int, numNegOnes: int, k: int) -> int
pub fn k_items_with_maximum_sum(numOnes: i64, numZeros: i64, numNegOnes: i64, k: i64) -> i64
Aegis.KItemsWithMaximumSum.k_items_with_maximum_sum
pub fn k_items_with_maximum_sum(numOnes: i64, numZeros: i64, numNegOnes: i64, k: i64) -> i64 { let mut remaining = k; let mut total = 0i64; let take_ones = if remaining < numOnes { remaining } else { numOnes }; total += take_ones; remaining -= take_ones; let take_zeros = if remaining < numZero...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [k_items_with_maximum_sum]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_opt...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [k_items_with_maximum_sum]: function definitions module public import Aeneas public import Aegis.KItemsWithMaximumSum.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashComma...
import Aegis.KItemsWithMaximumSum.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": "[25, 25, 0, 50]", "output": "25" }, { "input": "[0, 50, 0, 10]", "output": "0" }, { "input": "[3, 2, 0, 2]", "output": "2" }, { "input": "[20, 20, 10, 50]", "output": "10" }, { "input": "[10, 10, 10, 5]", "output": "5" }, { "input": "[25, 0...
105
false
105
verified
10
10
1
535
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.KItemsWithMaximumSum.Code.Funs /-! # Specifications of `Aegis.KItemsWithMaximumSum.k_items_with_maximum_sum` LeetCode problem `k-items-with-the-maximum-sum`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.KItemsWithMaximumSum /-- T...
8
prime-subtraction-operation
2,601
Medium
[ "Greedy", "Array", "Math", "Binary Search", "Number Theory" ]
You are given a 0-indexed integer array nums of length n. You can perform the following operation as many times as you want: Pick an index i that you haven’t picked before, and pick a prime p strictly less than nums[i], then subtract p from nums[i]. Return true if you can make nums a strictly increasing array using t...
primeSubOperation(nums: list_int) -> bool
pub fn prime_sub_operation(nums: &[i64]) -> bool
Aegis.PrimeSubOperation.prime_sub_operation
fn is_prime(n: i64) -> bool { if n < 2 { return false; } let mut d: i64 = 2; while d * d <= n { if n % d == 0 { return false; } d += 1; } true } pub fn prime_sub_operation(nums: &[i64]) -> bool { let n = nums.len(); let mut prev: i64 = 0; ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [prime_sub_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_option l...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [prime_sub_operation]: function definitions module public import Aeneas public import Aegis.PrimeSubOperation.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false...
import Aegis.PrimeSubOperation.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": "[[5, 8, 3]]", "output": "false" }, { "input": "[[1000, 999, 998]]", "output": "true" }, { "input": "[[2, 3, 5]]", "output": "true" }, { "input": "[[2, 5, 6]]", "output": "true" }, { "input": "[[10, 9, 8]]", "output": "true" }, { "input": "[...
157
false
157
verified
10
10
1
4,844
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.PrimeSubOperation.Code.Funs /-! # Specifications of `Aegis.PrimeSubOperation.prime_sub_operation` LeetCode problem `prime-subtraction-operation`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.PrimeSubOperation namespace AegisSpec.PrimeSubOp...
8
minimum-operations-to-make-all-array-elements-equal
2,602
Medium
[ "Array", "Binary Search", "Prefix Sum", "Sorting" ]
You are given an array nums consisting of positive integers. You are also given an integer array queries of size m. For the ith query, you want to make all of the elements of nums equal to queries[i]. You can perform the following operation on the array any number of times: Increase or decrease an element of the array...
minOperations(nums: list_int, queries: list_int) -> list_int
pub fn min_operations(nums: &[i64], queries: &[i64]) -> Vec<i64>
Aegis.MinOperations.min_operations
fn lower_bound(a: &[i64], x: i64) -> usize { let mut lo: usize = 0; let mut hi: usize = a.len(); while lo < hi { let mid = lo + (hi - lo) / 2; if a[mid] < x { lo = mid + 1; } else { hi = mid; } } lo } fn merge_sort(a: Vec<i64>) -> Vec<i64> {...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [min_operations]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [min_operations]: function definitions module public import Aeneas public import Aegis.MinOperations.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_opti...
import Aegis.MinOperations.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval aegisCa...
[ { "input": "[[1000000000, 1000000000, 1000000000], [1000000000]]", "output": "[0]" }, { "input": "[[1000000000, 999999999, 1000000001], [1000000000]]", "output": "[2]" }, { "input": "[[2, 9, 6, 3], [10]]", "output": "[20]" }, { "input": "[[1, 1, 1, 1], [1]]", "output": "[...
107
false
107
verified
10
10
1
4,882
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": 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-all-array-elements-equal`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.MinOperations def vals (l :...
13
minimum-time-to-eat-all-grains
2,604
Hard
[ "Array", "Two Pointers", "Binary Search", "Sorting" ]
There are n hens and m grains on a line. You are given the initial positions of the hens and the grains in two integer arrays hens and grains of size n and m respectively. Any hen can eat a grain if they are on the same position. The time taken for this is negligible. One hen can also eat multiple grains. In 1 second, ...
minimumTime(hens: list_int, grains: list_int) -> int
pub fn minimum_time(hens: &[i64], grains: &[i64]) -> i64
Aegis.MinimumTime.minimum_time
fn can_eat(hens: &[i64], grains: &[i64], t: i64) -> bool { let n = hens.len(); let m = grains.len(); let mut j: usize = 0; let mut i: usize = 0; while i < n && j < m { let h = hens[i]; let g = grains[j]; if h < g { let reach = h + t; while j < m && g...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [minimum_time]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter.s...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [minimum_time]: function definitions module public import Aeneas public import Aegis.MinimumTime.Code.Types public import Aegis.MinimumTime.Code.FunsExternal @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace fals...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [minimum_time]: external functions. -- This is a template file: rename it to "FunsExternal.lean" and fill the holes. module public import Aeneas public import Aegis.MinimumTime.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_o...
import Aegis.MinimumTime.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval aegisCase...
[ { "input": "[[1000000000], [1000000000]]", "output": "0" }, { "input": "[[0, 1000000000], [500000000, 1500000000]]", "output": "500000000" }, { "input": "[[0, 100], [50, 51, 52]]", "output": "50" }, { "input": "[[100, 200], [50, 150, 250, 350]]", "output": "150" }, { ...
116
false
116
verified
10
10
1
15,082
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MinimumTime.Code.Funs /-! # Specifications of `Aegis.MinimumTime.minimum_time` LeetCode problem `minimum-time-to-eat-all-grains`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.MinimumTime open Aeneas.Std def henVals (hens : Sli...
17
form-smallest-number-from-two-digit-arrays
2,605
Easy
[ "Array", "Hash Table", "Enumeration" ]
Given two arrays of unique digits nums1 and nums2, return the smallest number that contains at least one digit from each array.   Example 1: Input: nums1 = [4,1,3], nums2 = [5,7] Output: 15 Explanation: The number 15 contains the digit 1 from nums1 and the digit 5 from nums2. It can be proven that 15 is the smallest n...
minNumber(nums1: list_int, nums2: list_int) -> int
pub fn min_number(nums1: &[i64], nums2: &[i64]) -> i64
Aegis.MinNumber.min_number
pub fn min_number(nums1: &[i64], nums2: &[i64]) -> i64 { let mut common: i64 = 10; let mut i: usize = 0; while i < nums1.len() { let mut j: usize = 0; while j < nums2.len() { if nums1[i] == nums2[j] { if nums1[i] < common { common = nums1[i]; ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [min_number]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter.sty...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [min_number]: function definitions module public import Aeneas public import Aegis.MinNumber.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.MinNumber.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval aegisCase "...
[ { "input": "[[1], [2]]", "output": "12" }, { "input": "[[2], [3]]", "output": "23" }, { "input": "[[5], [5]]", "output": "5" }, { "input": "[[1], [9]]", "output": "19" }, { "input": "[[9], [1]]", "output": "19" }, { "input": "[[1], [1]]", "output":...
97
false
97
verified
10
10
1
1,158
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MinNumber.Code.Funs /-! # Specifications of `Aegis.MinNumber.min_number` LeetCode problem `form-smallest-number-from-two-digit-arrays`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.MinNumber open Aegis.MinNumber (min_number) def Occ...
13
make-k-subarray-sums-equal
2,607
Medium
[ "Greedy", "Array", "Math", "Number Theory", "Sorting" ]
You are given a 0-indexed integer array arr and an integer k. The array arr is circular. In other words, the first element of the array is the next element of the last element, and the last element of the array is the previous element of the first element. You can do the following operation any number of times: Pick a...
makeSubKSumEqual(arr: list_int, k: int) -> int
pub fn make_sub_k_sum_equal(arr: &[i64], k: i64) -> i64
Aegis.MakeSubKSumEqual.make_sub_k_sum_equal
pub fn make_sub_k_sum_equal(arr: &[i64], k: i64) -> i64 { let n = arr.len(); if n == 0 || k <= 0 { return 0; } let kk = k as usize; // Compute gcd(n, kk). let mut a = n; let mut b = kk; while b != 0 { let r = a % b; a = b; b = r; } let g = a; ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [make_sub_k_sum_equal]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [make_sub_k_sum_equal]: function definitions module public import Aeneas public import Aegis.MakeSubKSumEqual.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false...
import Aegis.MakeSubKSumEqual.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval aegi...
[ { "input": "[[1, 4, 1, 3], 2]", "output": "1" }, { "input": "[[2, 5, 5, 7], 3]", "output": "5" }, { "input": "[[1, 2, 3, 4, 5], 1]", "output": "6" }, { "input": "[[5, 5, 5, 5, 5], 2]", "output": "0" }, { "input": "[[10, 20, 30, 40, 50], 5]", "output": "0" },...
102
false
102
verified
10
10
1
5,377
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MakeSubKSumEqual.Code.Funs /-! # Specifications of `Aegis.MakeSubKSumEqual.make_sub_k_sum_equal` LeetCode problem `make-k-subarray-sums-equal`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.MakeSubKSumEqual def entry (arr : Slice ...
10
find-the-longest-balanced-substring-of-a-binary-string
2,609
Easy
[ "String" ]
You are given a binary string s consisting only of zeroes and ones. A substring of s is considered balanced if all zeroes are before ones and the number of zeroes is equal to the number of ones inside the substring. Notice that the empty substring is considered a balanced substring. Return the length of the longest bal...
findTheLongestBalancedSubstring(s: str) -> int
pub fn find_the_longest_balanced_substring(s: &[u8]) -> i64
Aegis.FindTheLongestBalancedSubstring.find_the_longest_balanced_substring
pub fn find_the_longest_balanced_substring(s: &[u8]) -> i64 { let n = s.len(); let mut best: i64 = 0; let mut i: usize = 0; while i < n { if s[i] == b'0' { let mut zeros: i64 = 0; while i < n && s[i] == b'0' { zeros += 1; i += 1; ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [find_the_longest_balanced_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 fa...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [find_the_longest_balanced_substring]: function definitions module public import Aeneas public import Aegis.FindTheLongestBalancedSubstring.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_o...
import Aegis.FindTheLongestBalancedSubstring.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} {...
[ { "input": "[\"000000111111\"]", "output": "12" }, { "input": "[\"000111000111\"]", "output": "6" }, { "input": "[\"000110\"]", "output": "4" }, { "input": "[\"01\"]", "output": "2" }, { "input": "[\"00111\"]", "output": "4" }, { "input": "[\"000110011...
185
false
185
verified
10
10
1
1,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.FindTheLongestBalancedSubstring.Code.Funs /-! # Specifications of `Aegis.FindTheLongestBalancedSubstring.find_the_longest_balanced_substring` LeetCode problem `find-the-longest-balanced-substring-of-a-binary-string`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std ...
12
convert-an-array-into-a-2d-array-with-conditions
2,610
Medium
[ "Array", "Hash Table" ]
You are given an integer array nums. You need to create a 2D array from nums satisfying the following conditions: The 2D array should contain only the elements of the array nums. Each row in the 2D array contains distinct integers. The number of rows in the 2D array should be minimal. Return the resulting array. If t...
findMatrix(nums: list_int) -> list_list_int
pub fn find_matrix(nums: &[i64]) -> Vec<Vec<i64>>
Aegis.FindMatrix.find_matrix
pub fn find_matrix(nums: &[i64]) -> Vec<Vec<i64>> { let n = nums.len(); let mut maxv: i64 = 0; let mut i = 0usize; while i < n { if nums[i] > maxv { maxv = nums[i]; } i += 1; } let size = (maxv as usize) + 2; let mut freq: Vec<i64> = Vec::new(); let ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [find_matrix]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter.st...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [find_matrix]: function definitions module public import Aeneas public import Aegis.FindMatrix.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.FindMatrix.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval aegisCase ...
[ { "input": "[[1, 2, 3, 4]]", "output": "[[1, 2, 3, 4]]" }, { "input": "[[1, 1, 1, 1]]", "output": "[[1], [1], [1], [1]]" }, { "input": "[[5, 5, 5, 5, 5]]", "output": "[[5], [5], [5], [5], [5]]" }, { "input": "[[1, 2, 1, 3, 4, 2, 3]]", "output": "[[1, 2, 3, 4], [1, 2, 3]]"...
79
false
79
verified
10
10
2
3,581
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.FindMatrix.Code.Funs /-! # Specifications of `Aegis.FindMatrix.find_matrix` LeetCode problem `convert-an-array-into-a-2d-array-with-conditions`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.FindMatrix def rowContents (row : alloc...
13
mice-and-cheese
2,611
Medium
[ "Greedy", "Array", "Sorting", "Heap (Priority Queue)" ]
There are two mice and n different types of cheese, each type of cheese should be eaten by exactly one mouse. A point of the cheese with index i (0-indexed) is: reward1[i] if the first mouse eats it. reward2[i] if the second mouse eats it. You are given a positive integer array reward1, a positive integer array rewar...
miceAndCheese(reward1: list_int, reward2: list_int, k: int) -> int
pub fn mice_and_cheese(reward1: &[i64], reward2: &[i64], k: i64) -> i64
Aegis.MiceAndCheese.mice_and_cheese
pub fn mice_and_cheese(reward1: &[i64], reward2: &[i64], k: i64) -> i64 { let n = reward1.len(); let mut total: i64 = 0; let mut diffs: Vec<i64> = Vec::new(); let mut i: usize = 0; while i < n { total += reward2[i]; diffs.push(reward1[i] - reward2[i]); i += 1; } dif...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [mice_and_cheese]: type definitions module public import Aeneas @[expose] public section 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 -- [mice_and_cheese]: function definitions module public import Aeneas public import Aegis.MiceAndCheese.Code.Types public import Aegis.MiceAndCheese.Code.FunsExternal @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespa...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [mice_and_cheese]: external functions. -- This is a template file: rename it to "FunsExternal.lean" and fill the holes. module public import Aeneas public import Aegis.MiceAndCheese.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error ...
import Aegis.MiceAndCheese.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval aegisCa...
[ { "input": "[[1, 1], [1, 1], 2]", "output": "2" }, { "input": "[[10, 20, 30], [40, 50, 60], 0]", "output": "150" }, { "input": "[[5, 4, 3], [1, 2, 3], 1]", "output": "10" }, { "input": "[[7, 8, 9], [10, 11, 12], 3]", "output": "24" }, { "input": "[[100, 100, 100],...
96
false
96
verified
10
10
1
1,160
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MiceAndCheese.Code.Funs /-! # Specifications of `Aegis.MiceAndCheese.mice_and_cheese` LeetCode problem `mice-and-cheese`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.MiceAndCheese open scoped BigOperators namespace AegisSpec.MiceAndCheese de...
10
beautiful-pairs
2,613
Hard
[ "Geometry", "Array", "Math", "Divide and Conquer", "Ordered Set", "Sorting" ]
You are given two 0-indexed integer arrays nums1 and nums2 of the same length. A pair of indices (i,j) is called beautiful if|nums1[i] - nums1[j]| + |nums2[i] - nums2[j]| is the smallest amongst all possible indices pairs where i < j. Return the beautiful pair. In the case that there are multiple beautiful pairs, retur...
beautifulPair(nums1: list_int, nums2: list_int) -> list_int
pub fn beautiful_pair(nums1: &[i64], nums2: &[i64]) -> Vec<i64>
Aegis.BeautifulPair.beautiful_pair
pub fn beautiful_pair(nums1: &[i64], nums2: &[i64]) -> Vec<i64> { let n = nums1.len(); let mut best_d: i64 = abs_diff(nums1[0], nums1[1]) + abs_diff(nums2[0], nums2[1]); let mut best_i: i64 = 0; let mut best_j: i64 = 1; let mut i = 0; while i < n { let mut j = i + 1; while j < ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [beautiful_pair]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [beautiful_pair]: function definitions module public import Aeneas public import Aegis.BeautifulPair.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.BeautifulPair.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval aegisCa...
[ { "input": "[[0, 0, 0, 0], [0, 0, 0, 0]]", "output": "[0, 1]" }, { "input": "[[5, 5, 5, 5], [5, 5, 5, 5]]", "output": "[0, 1]" }, { "input": "[[10, 20, 30, 40, 50], [50, 40, 30, 20, 10]]", "output": "[0, 1]" }, { "input": "[[5, 3, 1, 2, 4], [4, 2, 3, 1, 5]]", "output": "[...
84
false
84
verified
10
10
2
33,029
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.BeautifulPair.Code.Funs /-! # Specifications of `Aegis.BeautifulPair.beautiful_pair` LeetCode problem `beautiful-pairs`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.BeautifulPair def coord (s : Slice Std.I64) (i : ℤ) : ℤ := ...
2
prime-in-diagonal
2,614
Easy
[ "Array", "Math", "Matrix", "Number Theory" ]
You are given a 0-indexed two-dimensional integer array nums. Return the largest prime number that lies on at least one of the diagonals of nums. In case, no prime is present on any of the diagonals, return 0. Note that: An integer is prime if it is greater than 1 and has no positive integer divisors other than 1 and ...
diagonalPrime(nums: list_list_int) -> int
pub fn diagonal_prime(nums: &[Vec<i64>]) -> i64
Aegis.DiagonalPrime.diagonal_prime
fn is_prime(x: i64) -> bool { if x < 2 { return false; } if x == 2 { return true; } if x % 2 == 0 { return false; } let mut d: i64 = 3; while d * d <= x { if x % d == 0 { return false; } d += 2; } true } pub fn diagona...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [diagonal_prime]: type definitions module public import Aeneas @[expose] public section 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 -- [diagonal_prime]: function definitions module public import Aeneas public import Aegis.DiagonalPrime.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.DiagonalPrime.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": "[[[4, 6, 8], [10, 12, 14], [16, 18, 20]]]", "output": "0" }, { "input": "[[[3, 1, 4], [1, 5, 9], [2, 6, 5]]]", "output": "5" }, { "input": "[[[31, 33, 35], [37, 39, 41], [43, 45, 47]]]", "output": "47" }, { "input": "[[[31, 12, 43], [55, 67, 79], [81, 97, 101]]]",...
73
false
73
verified
10
10
1
874
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.DiagonalPrime.Code.Funs /-! # Specifications of `Aegis.DiagonalPrime.diagonal_prime` LeetCode problem `prime-in-diagonal`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Classical namespace AegisSpec.DiagonalPrime def vecContents (v : alloc.vec.Vec S...
10
sum-of-distances
2,615
Medium
[ "Array", "Hash Table", "Prefix Sum" ]
You are given a 0-indexed integer array nums. There exists an array arr of length nums.length, where arr[i] is the sum of |i - j| over all j such that nums[j] == nums[i] and j != i. If there is no such j, set arr[i] to be 0. Return the array arr.   Example 1: Input: nums = [1,3,1,1,2] Output: [5,0,3,4,0] Explanation: ...
distance(nums: list_int) -> list_int
pub fn distance(nums: &[i64]) -> Vec<i64>
Aegis.Distance.distance
pub fn distance(nums: &[i64]) -> Vec<i64> { let n = nums.len(); let mut ans: Vec<i64> = Vec::new(); let mut i: usize = 0; while i < n { ans.push(0); i += 1; } if n == 0 { return ans; } let base: i64 = n as i64 + 1; let mut order: Vec<i64> = Vec::new(); ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [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.style...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [distance]: function definitions module public import Aeneas public import Aegis.Distance.Code.Types public import Aegis.Distance.Code.FunsExternal @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_opti...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [distance]: external functions. -- This is a template file: rename it to "FunsExternal.lean" and fill the holes. module public import Aeneas public import Aegis.Distance.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option l...
import Aegis.Distance.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval aegisCase "e...
[ { "input": "[[1]]", "output": "[0]" }, { "input": "[[0, 5, 3]]", "output": "[0, 0, 0]" }, { "input": "[[10, 10, 10, 10]]", "output": "[6, 4, 4, 6]" }, { "input": "[[2, 2, 2, 2]]", "output": "[6, 4, 4, 6]" }, { "input": "[[5, 4, 3, 2, 1]]", "output": "[0, 0, 0,...
105
false
105
verified
10
10
1
3,260
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.Distance.Code.Funs /-! # Specifications of `Aegis.Distance.distance` LeetCode problem `sum-of-distances`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.Distance def valAt (l : List Std.I64) (i : ℕ) : ℤ := ((l[i]?).map (fun x => x.val)...
15
minimum-number-of-visited-cells-in-a-grid
2,617
Hard
[ "Stack", "Breadth-First Search", "Union Find", "Array", "Dynamic Programming", "Matrix", "Monotonic Stack", "Heap (Priority Queue)" ]
You are given a 0-indexed m x n integer matrix grid. Your initial position is at the top-left cell (0, 0). Starting from the cell (i, j), you can move to one of the following cells: Cells (i, k) with j < k <= grid[i][j] + j (rightward movement), or Cells (k, j) with i < k <= grid[i][j] + i (downward movement). Return...
minimumVisitedCells(grid: list_list_int) -> int
pub fn minimum_visited_cells(grid: &[Vec<i64>]) -> i64
Aegis.MinimumVisitedCells.minimum_visited_cells
fn find_next(parent: &mut Vec<i64>, base: usize, start: usize) -> usize { let mut v = start; while parent[base + v] != v as i64 { v = parent[base + v] as usize; } let root = v; let mut u = start; while u != root { let nxt = parent[base + u] as usize; parent[base + u] = r...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [minimum_visited_cells]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [minimum_visited_cells]: function definitions module public import Aeneas public import Aegis.MinimumVisitedCells.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand f...
import Aegis.MinimumVisitedCells.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": "[[[0]]]", "output": "1" }, { "input": "[[[0, 0], [0, 0]]]", "output": "-1" }, { "input": "[[[1, 0], [0, 0]]]", "output": "-1" }, { "input": "[[[2, 1, 0], [1, 0, 0]]]", "output": "-1" }, { "input": "[[[2, 0, 0], [1, 3, 1], [0, 1, 0]]]", "output": "5...
103
false
103
verified
10
10
1
17,047
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MinimumVisitedCells.Code.Funs /-! # Specifications of `Aegis.MinimumVisitedCells.minimum_visited_cells` LeetCode problem `minimum-number-of-visited-cells-in-a-grid`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.MinimumVisitedCells ...
8
count-the-number-of-k-free-subsets
2,638
Medium
[ "Array", "Math", "Dynamic Programming", "Combinatorics", "Sorting" ]
You are given an integer array nums, which contains distinct elements and an integer k. A subset is called a k-Free subset if it contains no two elements with an absolute difference equal to k. Notice that the empty set is a k-Free subset. Return the number of k-Free subsets of nums. A subset of an array is a selection...
countTheNumOfKFreeSubsets(nums: list_int, k: int) -> int
pub fn count_the_num_of_k_free_subsets(nums: &[i64], k: i64) -> i64
Aegis.CountTheNumOfKFreeSubsets.count_the_num_of_k_free_subsets
pub fn count_the_num_of_k_free_subsets(nums: &[i64], k: i64) -> i64 { let n = nums.len(); let mut a: Vec<i64> = Vec::new(); let mut i = 0; while i < n { a.push(nums[i]); i += 1; } // Manual insertion sort. let mut i2 = 1; while i2 < n { let key = a[i2]; ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [count_the_num_of_k_free_subsets]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [count_the_num_of_k_free_subsets]: function definitions module public import Aeneas public import Aegis.CountTheNumOfKFreeSubsets.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option lint...
import Aegis.CountTheNumOfKFreeSubsets.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": "[[100, 200, 300], 50]", "output": "8" }, { "input": "[[5, 4, 6], 1]", "output": "5" }, { "input": "[[2, 3, 5, 8], 5]", "output": "12" }, { "input": "[[7, 14, 21, 28], 7]", "output": "8" }, { "input": "[[3, 7, 11, 15], 4]", "output": "8" }, { ...
95
false
95
verified
10
10
1
4,098
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.CountTheNumOfKFreeSubsets.Code.Funs /-! # Specifications of `Aegis.CountTheNumOfKFreeSubsets.count_the_num_of_k_free_subsets` LeetCode problem `count-the-number-of-k-free-subsets`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.CountT...
11
find-the-score-of-all-prefixes-of-an-array
2,640
Medium
[ "Array", "Prefix Sum" ]
We define the conversion array conver of an array arr as follows: conver[i] = arr[i] + max(arr[0..i]) where max(arr[0..i]) is the maximum value of arr[j] over 0 <= j <= i. We also define the score of an array arr as the sum of the values of the conversion array of arr. Given a 0-indexed integer array nums of length n...
findPrefixScore(nums: list_int) -> list_int
pub fn find_prefix_score(nums: &[i64]) -> Vec<i64>
Aegis.FindPrefixScore.find_prefix_score
pub fn find_prefix_score(nums: &[i64]) -> Vec<i64> { let n = nums.len(); let mut ans: Vec<i64> = Vec::new(); let mut cur_max: i64 = 0; let mut sum: i64 = 0; let mut i: usize = 0; while i < n { let v = nums[i]; if i == 0 || v > cur_max { cur_max = v; } ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [find_prefix_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 lin...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [find_prefix_score]: function definitions module public import Aeneas public import Aegis.FindPrefixScore.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.FindPrefixScore.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval aegis...
[ { "input": "[[1]]", "output": "[2]" }, { "input": "[[1000000000]]", "output": "[2000000000]" }, { "input": "[[5, 4, 3, 2, 1]]", "output": "[10, 19, 27, 34, 40]" }, { "input": "[[2, 3, 7, 5, 10]]", "output": "[4, 10, 24, 36, 56]" }, { "input": "[[5, 5, 5, 5, 5]]", ...
94
false
94
verified
10
10
1
349
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.FindPrefixScore.Code.Funs /-! # Specifications of `Aegis.FindPrefixScore.find_prefix_score` LeetCode problem `find-the-score-of-all-prefixes-of-an-array`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.FindPrefixScore def vals (num...
10
cousins-in-binary-tree-ii
2,641
Medium
[ "Tree", "Depth-First Search", "Breadth-First Search", "Hash Table", "Binary Tree" ]
Given the root of a binary tree, replace the value of each node in the tree with the sum of all its cousins' values. Two nodes of a binary tree are cousins if they have the same depth with different parents. Return the root of the modified tree. Note that the depth of a node is the number of edges in the path from the ...
replaceValueInTree(root: tree) -> tree
pub fn replace_value_in_tree(root: &Tree) -> Tree
Aegis.ReplaceValueInTree.replace_value_in_tree
fn collect_depth_sums(t: &Tree, depth: usize, sums: &mut Vec<i64>) { match t { Tree::Null => {} Tree::Node(v, l, r) => { while sums.len() <= depth { sums.push(0); } sums[depth] = sums[depth] + *v; collect_depth_sums(&**l, depth + 1, su...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [replace_value_in_tree]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [replace_value_in_tree]: function definitions module public import Aeneas public import Aegis.ReplaceValueInTree.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand fa...
import Aegis.ReplaceValueInTree.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" deriving...
[ { "input": "[[1]]", "output": "[0]" }, { "input": "[[3, 1, 2]]", "output": "[0, 0, 0]" }, { "input": "[[1, 2, 3, 4, 5, 6, 7]]", "output": "[0, 0, 0, 13, 13, 9, 9]" }, { "input": "[[3, 1, 2, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]]", "output": "[0, 0, 0, 13, 13, 9, 9, 75...
18
false
18
verified
10
10
1
4,623
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.ReplaceValueInTree.Code.Funs /-! # Specifications of `Aegis.ReplaceValueInTree.replace_value_in_tree` LeetCode problem `cousins-in-binary-tree-ii`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.ReplaceValueInTree inductive Dir whe...
14
row-with-maximum-ones
2,643
Easy
[ "Array", "Matrix" ]
Given a m x n binary matrix mat, find the 0-indexed position of the row that contains the maximum count of ones, and the number of ones in that row. In case there are multiple rows that have the maximum count of ones, the row with the smallest row number should be selected. Return an array containing the index of the r...
rowAndMaximumOnes(mat: list_list_int) -> list_int
pub fn row_and_maximum_ones(mat: &[Vec<i64>]) -> Vec<i64>
Aegis.RowAndMaximumOnes.row_and_maximum_ones
pub fn row_and_maximum_ones(mat: &[Vec<i64>]) -> Vec<i64> { let mut best_idx: i64 = 0; let mut best_count: i64 = 0; let mut i: usize = 0; while i < mat.len() { let row = &mat[i]; let mut count: i64 = 0; let mut j: usize = 0; while j < row.len() { if row[j] =...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [row_and_maximum_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 ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [row_and_maximum_ones]: function definitions module public import Aeneas public import Aegis.RowAndMaximumOnes.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand fals...
import Aegis.RowAndMaximumOnes.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": "[[[0, 1], [1, 0]]]", "output": "[0, 1]" }, { "input": "[[[0, 0, 0], [0, 1, 1]]]", "output": "[1, 2]" }, { "input": "[[[0, 0], [1, 1], [0, 0]]]", "output": "[1, 2]" }, { "input": "[[[1, 1, 1], [0, 1, 1], [1, 0, 0]]]", "output": "[0, 3]" }, { "input": "[...
71
false
71
verified
10
10
1
717
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.RowAndMaximumOnes.Code.Funs /-! # Specifications of `Aegis.RowAndMaximumOnes.row_and_maximum_ones` LeetCode problem `row-with-maximum-ones`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.RowAndMaximumOnes namespace AegisSpec.RowAndMaximumOn...
14
find-the-maximum-divisibility-score
2,644
Easy
[ "Array" ]
You are given two integer arrays nums and divisors. The divisibility score of divisors[i] is the number of indices j such that nums[j] is divisible by divisors[i]. Return the integer divisors[i] with the maximum divisibility score. If multiple integers have the maximum score, return the smallest one.   Example 1: Inpu...
maxDivScore(nums: list_int, divisors: list_int) -> int
pub fn max_div_score(nums: &[i64], divisors: &[i64]) -> i64
Aegis.MaxDivScore.max_div_score
pub fn max_div_score(nums: &[i64], divisors: &[i64]) -> i64 { let n = nums.len(); let m = divisors.len(); let mut best_div: i64 = divisors[0]; let mut best_score: i64 = -1; let mut i: usize = 0; while i < m { let d = divisors[i]; let mut score: i64 = 0; let mut j: usiz...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [max_div_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 -- [max_div_score]: function definitions module public import Aeneas public import Aegis.MaxDivScore.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.MaxDivScore.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": "[[100, 200, 300], [10, 20, 50]]", "output": "10" }, { "input": "[[7, 14, 21, 28], [7, 14]]", "output": "7" }, { "input": "[[5, 10, 15, 20, 25], [5]]", "output": "5" }, { "input": "[[1, 1, 1, 1, 1], [1]]", "output": "1" }, { "input": "[[20, 14, 21, 10],...
131
false
131
verified
10
10
1
555
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MaxDivScore.Code.Funs /-! # Specifications of `Aegis.MaxDivScore.max_div_score` LeetCode problem `find-the-maximum-divisibility-score`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.MaxDivScore open Aegis.MaxDivScore (max_div_score) ...
14
minimum-additions-to-make-valid-string
2,645
Medium
[ "Stack", "Greedy", "String", "Dynamic Programming" ]
Given a string word to which you can insert letters "a", "b" or "c" anywhere and any number of times, return the minimum number of letters that must be inserted so that word becomes valid. A string is called valid if it can be formed by concatenating the string "abc" several times.   Example 1: Input: word = "b" Outpu...
addMinimum(word: str) -> int
pub fn add_minimum(word: &[u8]) -> i64
Aegis.AddMinimum.add_minimum
pub fn add_minimum(word: &[u8]) -> i64 { let mut ans: i64 = 0; let mut expected: i64 = 0; // 0 -> 'a', 1 -> 'b', 2 -> 'c' let mut i: usize = 0; while i < word.len() { let target: i64 = if word[i] == b'a' { 0 } else if word[i] == b'b' { 1 } else { ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [add_minimum]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter.st...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [add_minimum]: function definitions module public import Aeneas public import Aegis.AddMinimum.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.AddMinimum.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": "[\"aab\"]", "output": "3" }, { "input": "[\"abc\"]", "output": "0" }, { "input": "[\"bacbac\"]", "output": "6" }, { "input": "[\"aabbcc\"]", "output": "6" }, { "input": "[\"acbac\"]", "output": "4" }, { "input": "[\"aababacaba\"]", "out...
108
false
108
verified
10
10
1
1,599
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.AddMinimum.Code.Funs /-! # Specifications of `Aegis.AddMinimum.add_minimum` LeetCode problem `minimum-additions-to-make-valid-string`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.AddMinimum open Aegis.AddMinimum (add_minimum) ...
13
color-the-triangle-red
2,647
Hard
[ "Array", "Math" ]
You are given an integer n. Consider an equilateral triangle of side length n, broken up into n2 unit equilateral triangles. The triangle has n 1-indexed rows where the ith row has 2i - 1 unit equilateral triangles. The triangles in the ith row are also 1-indexed with coordinates from (i, 1) to (i, 2i - 1). The followi...
colorRed(n: int) -> list_list_int
pub fn color_red(n: i64) -> Vec<Vec<i64>>
Aegis.ColorRed.color_red
pub fn color_red(n: i64) -> Vec<Vec<i64>> { let mut ans: Vec<Vec<i64>> = Vec::new(); let mut first: Vec<i64> = Vec::new(); first.push(1); first.push(1); ans.push(first); if n <= 1 { return ans; } let mut r: i64 = n; while r >= 2 { let d = n - r; if d % 2 =...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [color_red]: type definitions module public import Aeneas @[expose] public section 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 -- [color_red]: function definitions module public import Aeneas public import Aegis.ColorRed.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.ColorRed.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval aegisCase "e...
[ { "input": "[1]", "output": "[[1, 1]]" }, { "input": "[2]", "output": "[[1, 1], [2, 1], [2, 3]]" }, { "input": "[3]", "output": "[[1, 1], [3, 1], [3, 3], [3, 5], [2, 2]]" }, { "input": "[4]", "output": "[[1, 1], [4, 1], [4, 3], [4, 5], [4, 7], [3, 2], [2, 3]]" }, { ...
12
false
12
verified_partial
10
8
1
9,020
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.ColorRed.Code.Funs /-! # Specifications of `Aegis.ColorRed.color_red` LeetCode problem `color-the-triangle-red`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.ColorRed namespace AegisSpec.ColorRed def nNat (n : Std.I64) : Nat := n.val.toNat d...
13
calculate-delayed-arrival-time
2,651
Easy
[ "Math" ]
You are given a positive integer arrivalTime denoting the arrival time of a train in hours, and another positive integer delayedTime denoting the amount of delay in hours. Return the time when the train will arrive at the station. Note that the time in this problem is in 24-hours format.   Example 1: Input: arrivalTim...
findDelayedArrivalTime(arrivalTime: int, delayedTime: int) -> int
pub fn find_delayed_arrival_time(arrivalTime: i64, delayedTime: i64) -> i64
Aegis.FindDelayedArrivalTime.find_delayed_arrival_time
pub fn find_delayed_arrival_time(arrivalTime: i64, delayedTime: i64) -> i64 { (arrivalTime + delayedTime) % 24 }
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [find_delayed_arrival_time]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_op...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [find_delayed_arrival_time]: function definitions module public import Aeneas public import Aegis.FindDelayedArrivalTime.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCo...
import Aegis.FindDelayedArrivalTime.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eva...
[ { "input": "[5, 19]", "output": "0" }, { "input": "[8, 16]", "output": "0" }, { "input": "[13, 11]", "output": "0" }, { "input": "[15, 5]", "output": "20" }, { "input": "[1, 1]", "output": "2" }, { "input": "[12, 12]", "output": "0" }, { "i...
31
false
31
verified
10
10
1
47
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.FindDelayedArrivalTime.Code.Funs /-! # Specifications of `Aegis.FindDelayedArrivalTime.find_delayed_arrival_time` LeetCode problem `calculate-delayed-arrival-time`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.FindDelayedArrivalTime (find_delay...
10
sum-multiples
2,652
Easy
[ "Math" ]
Given a positive integer n, find the sum of all integers in the range [1, n] inclusive that are divisible by 3, 5, or 7. Return an integer denoting the sum of all numbers in the given range satisfying the constraint.   Example 1: Input: n = 7 Output: 21 Explanation: Numbers in the range [1, 7] that are divisible by 3,...
sumOfMultiples(n: int) -> int
pub fn sum_of_multiples(n: i64) -> i64
Aegis.SumOfMultiples.sum_of_multiples
pub fn sum_of_multiples(n: i64) -> i64 { let mut sum: i64 = 0; let mut i: i64 = 1; while i <= n { if i % 3 == 0 || i % 5 == 0 || i % 7 == 0 { sum += i; } i += 1; } sum }
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [sum_of_multiples]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option lint...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [sum_of_multiples]: function definitions module public import Aeneas public import Aegis.SumOfMultiples.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.SumOfMultiples.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval aegisC...
[ { "input": "[9]", "output": "30" }, { "input": "[1]", "output": "0" }, { "input": "[1000]", "output": "272066" }, { "input": "[7]", "output": "21" }, { "input": "[10]", "output": "40" }, { "input": "[210]", "output": "12075" }, { "input": "...
38
false
38
verified
10
10
1
270
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.SumOfMultiples.Code.Funs /-! # Specifications of `Aegis.SumOfMultiples.sum_of_multiples` LeetCode problem `sum-multiples`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.SumOfMultiples def value (k : ℤ) : ℤ := if 3 ∣ k ∨ 5 ∣ k ∨ 7 ∣ k ...
7
sliding-subarray-beauty
2,653
Medium
[ "Array", "Hash Table", "Sliding Window" ]
Given an integer array nums containing n integers, find the beauty of each subarray of size k. The beauty of a subarray is the xth smallest integer in the subarray if it is negative, or 0 if there are fewer than x negative integers. Return an integer array containing n - k + 1 integers, which denote the beauty of the s...
getSubarrayBeauty(nums: list_int, k: int, x: int) -> list_int
pub fn get_subarray_beauty(nums: &[i64], k: i64, x: i64) -> Vec<i64>
Aegis.GetSubarrayBeauty.get_subarray_beauty
pub fn get_subarray_beauty(nums: &[i64], k: i64, x: i64) -> Vec<i64> { let n: usize = nums.len(); let kk: usize = k as usize; let xx: i64 = x; let mut ans: Vec<i64> = Vec::new(); let mut freq: Vec<i64> = Vec::new(); let mut i: usize = 0; while i < 50 { freq.push(0); i += 1;...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [get_subarray_beauty]: type definitions module public import Aeneas @[expose] public section 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 -- [get_subarray_beauty]: function definitions module public import Aeneas public import Aegis.GetSubarrayBeauty.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false...
import Aegis.GetSubarrayBeauty.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": "[[-10, -20, -30, -40, -50], 4, 3]", "output": "[-20, -30]" }, { "input": "[[-10, -20, -30, -40, -50], 4, 2]", "output": "[-30, -40]" }, { "input": "[[5, 6, 7, 8, 9], 3, 2]", "output": "[0, 0, 0]" }, { "input": "[[1, -1, -3, -2, 3], 3, 2]", "output": "[-1, -2, ...
106
false
106
verified
10
10
1
2,172
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.GetSubarrayBeauty.Code.Funs /-! # Specifications of `Aegis.GetSubarrayBeauty.get_subarray_beauty` LeetCode problem `sliding-subarray-beauty`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.GetSubarrayBeauty def sliceVals (nums : Slice ...
10
minimum-number-of-operations-to-make-all-array-elements-equal-to-1
2,654
Medium
[ "Array", "Math", "Number Theory" ]
You are given a 0-indexed array nums consisiting of positive integers. You can do the following operation on the array any number of times: Select an index i such that 0 <= i < n - 1 and replace either of nums[i] or nums[i+1] with their gcd value. Return the minimum number of operations to make all elements of nums e...
minOperations(nums: list_int) -> int
pub fn min_operations(nums: &[i64]) -> i64
Aegis.MinOperations.min_operations
fn gcd(mut a: i64, mut b: i64) -> i64 { while b != 0 { let r: i64 = a % b; a = b; b = r; } a } pub fn min_operations(nums: &[i64]) -> i64 { let n: usize = nums.len(); let n_i: i64 = n as i64; let mut ones: i64 = 0; let mut i: usize = 0; while i < n { if ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [min_operations]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [min_operations]: function definitions module public import Aeneas public import Aegis.MinOperations.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_opti...
import Aegis.MinOperations.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval aegisCa...
[ { "input": "[[10, 15, 25]]", "output": "-1" }, { "input": "[[7, 7, 7, 1]]", "output": "3" }, { "input": "[[100, 200, 300, 400]]", "output": "-1" }, { "input": "[[1, 2, 2, 3]]", "output": "3" }, { "input": "[[1, 1, 1, 1]]", "output": "0" }, { "input": "...
157
false
157
verified
10
10
1
4,456
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MinOperations.Code.Funs /-! # Specifications of `Aegis.MinOperations.min_operations` LeetCode problem `minimum-number-of-operations-to-make-all-array-elements-equal-to-1`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.MinOperations namespace Ae...
16
find-maximal-uncovered-ranges
2,655
Medium
[ "Array", "Sorting" ]
You are given an integer n which is the length of a 0-indexed array nums, and a 0-indexed 2D-array ranges, which is a list of sub-ranges of nums (sub-ranges may overlap). Each row ranges[i] has exactly 2 cells: ranges[i][0], which shows the start of the ith range (inclusive) ranges[i][1], which shows the end of the it...
findMaximalUncoveredRanges(n: int, ranges: list_list_int) -> list_list_int
pub fn find_maximal_uncovered_ranges(n: i64, ranges: &[Vec<i64>]) -> Vec<Vec<i64>>
Aegis.FindMaximalUncoveredRanges.find_maximal_uncovered_ranges
// The append-style test harness compares results with `vec![]` for empty // expected outputs. For a `Vec<Vec<i64>>` return type that is ambiguous under // type inference (`Vec<i64>: PartialEq<Vec<i64> | &[i64] | [i64]>`), so we // provide a test-only `vec!` shadow that pins the empty case to the concrete // result typ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [find_maximal_uncovered_ranges]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false se...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [find_maximal_uncovered_ranges]: function definitions module public import Aeneas public import Aegis.FindMaximalUncoveredRanges.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linte...
import Aegis.FindMaximalUncoveredRanges.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": "[5, []]", "output": "[[0, 4]]" }, { "input": "[5, [[0, 4]]]", "output": "[]" }, { "input": "[100, [[0, 99]]]", "output": "[]" }, { "input": "[1000000000, [[0, 1000000000]]]", "output": "[]" }, { "input": "[3, [[0, 2]]]", "output": "[]" }, { ...
101
false
101
verified
10
10
2
50,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.FindMaximalUncoveredRanges.Code.Funs /-! # Specifications of `Aegis.FindMaximalUncoveredRanges.find_maximal_uncovered_ranges` LeetCode problem `find-maximal-uncovered-ranges`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.FindMaximal...
13
maximum-sum-with-exactly-k-elements
2,656
Easy
[ "Greedy", "Array" ]
You are given a 0-indexed integer array nums and an integer k. Your task is to perform the following operation exactly k times in order to maximize your score: Select an element m from nums. Remove the selected element m from the array. Add a new element with a value of m + 1 to the array. Increase your score by m. R...
maximizeSum(nums: list_int, k: int) -> int
pub fn maximize_sum(nums: &[i64], k: i64) -> i64
Aegis.MaximizeSum.maximize_sum
pub fn maximize_sum(nums: &[i64], k: i64) -> i64 { let mut max_val: i64 = nums[0]; let mut i: usize = 1; while i < nums.len() { if nums[i] > max_val { max_val = nums[i]; } i += 1; } let mut score: i64 = 0; let mut step: i64 = 0; while step < k { s...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [maximize_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 -- [maximize_sum]: function definitions module public import Aeneas public import Aegis.MaximizeSum.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.MaximizeSum.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": "[[100], 1]", "output": "100" }, { "input": "[[100], 100]", "output": "14950" }, { "input": "[[1], 100]", "output": "5050" }, { "input": "[[50], 100]", "output": "9950" }, { "input": "[[42], 100]", "output": "9150" }, { "input": "[[5, 5, 5],...
97
false
97
verified
10
10
1
365
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MaximizeSum.Code.Funs /-! # Specifications of `Aegis.MaximizeSum.maximize_sum` LeetCode problem `maximum-sum-with-exactly-k-elements`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.MaximizeSum def contents (nums : Slice Std.I64) :...
9
maximum-number-of-fish-in-a-grid
2,658
Medium
[ "Depth-First Search", "Breadth-First Search", "Union Find", "Array", "Matrix" ]
You are given a 0-indexed 2D matrix grid of size m x n, where (r, c) represents: A land cell if grid[r][c] = 0, or A water cell containing grid[r][c] fish, if grid[r][c] > 0. A fisher can start at any water cell (r, c) and can do the following operations any number of times: Catch all the fish at cell (r, c), or Mov...
findMaxFish(grid: list_list_int) -> int
pub fn find_max_fish(grid: &[Vec<i64>]) -> i64
Aegis.FindMaxFish.find_max_fish
pub fn find_max_fish(grid: &[Vec<i64>]) -> i64 { let m = grid.len(); if m == 0 { return 0; } let n = grid[0].len(); if n == 0 { return 0; } let mut g: Vec<Vec<i64>> = Vec::new(); let mut i: usize = 0; while i < m { let mut row: Vec<i64> = Vec::new(); ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [find_max_fish]: type definitions module public import Aeneas @[expose] public section 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_max_fish]: function definitions module public import Aeneas public import Aegis.FindMaxFish.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.FindMaxFish.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": "[[[0]]]", "output": "0" }, { "input": "[[[1]]]", "output": "1" }, { "input": "[[[1, 2], [3, 4]]]", "output": "10" }, { "input": "[[[0, 0, 0], [0, 1, 0], [0, 0, 0]]]", "output": "1" }, { "input": "[[[1, 2, 3], [0, 0, 0], [4, 5, 6]]]", "output": "15"...
105
false
105
verified
10
10
1
3,844
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.FindMaxFish.Code.Funs /-! # Specifications of `Aegis.FindMaxFish.find_max_fish` LeetCode problem `maximum-number-of-fish-in-a-grid`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.FindMaxFish def gridVals (grid : Slice (alloc.vec.Vec S...
13
determine-the-winner-of-a-bowling-game
2,660
Easy
[ "Array", "Simulation" ]
You are given two 0-indexed integer arrays player1 and player2, representing the number of pins that player 1 and player 2 hit in a bowling game, respectively. The bowling game consists of n turns, and the number of pins in each turn is exactly 10. Assume a player hits xi pins in the ith turn. The value of the ith turn...
isWinner(player1: list_int, player2: list_int) -> int
pub fn is_winner(player1: &[i64], player2: &[i64]) -> i64
Aegis.IsWinner.is_winner
fn score(player: &[i64]) -> i64 { let n = player.len(); let mut total: i64 = 0; let mut i: usize = 0; while i < n { let mut value: i64 = player[i]; if i >= 1 && player[i - 1] == 10 { value = value * 2; } else if i >= 2 && player[i - 2] == 10 { value = va...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [is_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 linter.styl...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [is_winner]: function definitions module public import Aeneas public import Aegis.IsWinner.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.IsWinner.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval aegisCase "e...
[ { "input": "[[2, 3], [4, 1]]", "output": "0" }, { "input": "[[10, 10, 10], [10, 10, 10]]", "output": "0" }, { "input": "[[5, 10, 3, 2], [6, 5, 7, 3]]", "output": "1" }, { "input": "[[5, 5, 5, 5], [10, 0, 10, 0]]", "output": "2" }, { "input": "[[3, 5, 7, 6], [8, 10...
93
false
93
verified
10
10
1
567
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.IsWinner.Code.Funs /-! # Specifications of `Aegis.IsWinner.is_winner` LeetCode problem `determine-the-winner-of-a-bowling-game`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.IsWinner def weight (xs : List Std.I64) (i : ℕ) : ℤ := if...
7
minimum-cost-of-a-path-with-special-roads
2,662
Medium
[ "Graph", "Array", "Shortest Path", "Heap (Priority Queue)" ]
You are given an array start where start = [startX, startY] represents your initial position (startX, startY) in a 2D space. You are also given the array target where target = [targetX, targetY] represents your target position (targetX, targetY). The cost of going from a position (x1, y1) to any other position in the s...
minimumCost(start: list_int, target: list_int, specialRoads: list_list_int) -> int
pub fn minimum_cost(start: &[i64], target: &[i64], specialRoads: &[Vec<i64>]) -> i64
Aegis.MinimumCost.minimum_cost
fn manhattan(x1: i64, y1: i64, x2: i64, y2: i64) -> i64 { let dx = if x1 >= x2 { x1 - x2 } else { x2 - x1 }; let dy = if y1 >= y2 { y1 - y2 } else { y2 - y1 }; dx + dy } pub fn minimum_cost(start: &[i64], target: &[i64], specialRoads: &[Vec<i64>]) -> i64 { let sx = start[0]; let sy = start[1]; ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [minimum_cost]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter.s...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [minimum_cost]: function definitions module public import Aeneas public import Aegis.MinimumCost.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option l...
import Aegis.MinimumCost.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval aegisCase...
[ { "input": "[[1, 1], [4, 5], [[1, 2, 3, 3, 2], [3, 4, 4, 5, 1]]]", "output": "5" }, { "input": "[[1, 1], [100000, 100000], [[1, 1, 100000, 100000, 50000], [50000, 50000, 75000, 75000, 10000]]]", "output": "50000" }, { "input": "[[10, 10], [100, 100], [[10, 20, 30, 40, 15], [30, 50, 60, 7...
54
false
54
verified
10
10
1
7,236
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MinimumCost.Code.Funs /-! # Specifications of `Aegis.MinimumCost.minimum_cost` LeetCode problem `minimum-cost-of-a-path-with-special-roads`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.MinimumCost namespace AegisSpec.MinimumCost structure P...
14
find-the-distinct-difference-array
2,670
Easy
[ "Array", "Hash Table" ]
You are given a 0-indexed array nums of length n. The distinct difference array of nums is an array diff of length n such that diff[i] is equal to the number of distinct elements in the suffix nums[i + 1, ..., n - 1] subtracted from the number of distinct elements in the prefix nums[0, ..., i]. Return the distinct diff...
distinctDifferenceArray(nums: list_int) -> list_int
pub fn distinct_difference_array(nums: &[i64]) -> Vec<i64>
Aegis.DistinctDifferenceArray.distinct_difference_array
fn count_distinct_range(nums: &[i64], start: usize, end: usize) -> i64 { let mut count: i64 = 0; let mut p: usize = start; while p < end { let mut seen: bool = false; let mut q: usize = start; while q < p { if nums[q] == nums[p] { seen = true; ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [distinct_difference_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_op...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [distinct_difference_array]: function definitions module public import Aeneas public import Aegis.DistinctDifferenceArray.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashC...
import Aegis.DistinctDifferenceArray.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}" #ev...
[ { "input": "[[1]]", "output": "[1]" }, { "input": "[[1, 3, 2, 4, 5]]", "output": "[-3, -1, 1, 3, 5]" }, { "input": "[[10, 20, 10, 20, 10]]", "output": "[-1, 0, 0, 1, 2]" }, { "input": "[[1, 1, 2, 2, 3]]", "output": "[-2, -1, 0, 1, 3]" }, { "input": "[[50, 49, 48, ...
107
false
107
verified
10
10
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.DistinctDifferenceArray.Code.Funs /-! # Specifications of `Aegis.DistinctDifferenceArray.distinct_difference_array` LeetCode problem `find-the-distinct-difference-array`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.DistinctDifferen...
12
number-of-adjacent-elements-with-the-same-color
2,672
Medium
[ "Array" ]
You are given an integer n representing an array colors of length n where all elements are set to 0's meaning uncolored. You are also given a 2D integer array queries where queries[i] = [indexi, colori]. For the ith query: Set colors[indexi] to colori. Count adjacent pairs in colors set to the same color (regardless o...
colorTheArray(n: int, queries: list_list_int) -> list_int
pub fn color_the_array(n: i64, queries: &[Vec<i64>]) -> Vec<i64>
Aegis.ColorTheArray.color_the_array
pub fn color_the_array(n: i64, queries: &[Vec<i64>]) -> Vec<i64> { let n_usize = n as usize; let mut colors: Vec<i64> = Vec::new(); let mut i: usize = 0; while i < n_usize { colors.push(0); i += 1; } let mut answer: Vec<i64> = Vec::new(); let mut count: i64 = 0; let mu...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [color_the_array]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linte...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [color_the_array]: function definitions module public import Aeneas public import Aegis.ColorTheArray.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.ColorTheArray.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval aegisCa...
[ { "input": "[1, [[0, 100000]]]", "output": "[0]" }, { "input": "[3, [[0, 2], [1, 2], [2, 2]]]", "output": "[0, 1, 2]" }, { "input": "[3, [[0, 1], [1, 2], [2, 3]]]", "output": "[0, 0, 0]" }, { "input": "[3, [[0, 1], [1, 2], [2, 1], [1, 1]]]", "output": "[0, 0, 0, 2]" }, ...
74
false
74
verified
10
10
1
1,677
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.ColorTheArray.Code.Funs /-! # Specifications of `Aegis.ColorTheArray.color_the_array` LeetCode problem `number-of-adjacent-elements-with-the-same-color`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.ColorTheArray namespace AegisSpec.Colo...
14
number-of-senior-citizens
2,678
Easy
[ "Array", "String" ]
You are given a 0-indexed array of strings details. Each element of details provides information about a given passenger compressed into a string of length 15. The system is such that: The first ten characters consist of the phone number of passengers. The next character denotes the gender of the person. The following...
countSeniors(details: list_str) -> int
pub fn count_seniors(details: &[Vec<u8>]) -> i64
Aegis.CountSeniors.count_seniors
pub fn count_seniors(details: &[Vec<u8>]) -> i64 { let mut count: i64 = 0; let n = details.len(); let mut i: usize = 0; while i < n { let row = &details[i]; let tens = (row[11] - b'0') as i64; let ones = (row[12] - b'0') as i64; let age = tens * 10 + ones; if a...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [count_seniors]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter....
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [count_seniors]: function definitions module public import Aeneas public import Aegis.CountSeniors.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.CountSeniors.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": "[[\"1234567890M5999\", \"0987654321F6000\"]]", "output": "0" }, { "input": "[[\"1313579440F2036\", \"2921522980M5644\"]]", "output": "0" }, { "input": "[[\"0000000000M5500\", \"1111111111F5999\", \"2222222222O6100\"]]", "output": "1" }, { "input": "[[\"1111111111M...
78
false
78
verified
10
10
1
799
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.CountSeniors.Code.Funs /-! # Specifications of `Aegis.CountSeniors.count_seniors` LeetCode problem `number-of-senior-citizens`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.CountSeniors abbrev Row := Aeneas.Std.alloc.vec.Vec Aene...
8