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 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
count-days-without-meetings | 3,169 | Medium | [
"Array",
"Sorting"
] | You are given a positive integer days representing the total number of days an employee is available for work (starting from day 1). You are also given a 2D array meetings of size n where, meetings[i] = [start_i, end_i] represents the starting and ending days of meeting i (inclusive).
Return the count of days when the ... | countDays(days: int, meetings: list_list_int) -> int | pub fn count_days(days: i64, meetings: &[Vec<i64>]) -> i64 | Aegis.CountDays.count_days | pub fn count_days(days: i64, meetings: &[Vec<i64>]) -> i64 {
let n = meetings.len();
if n == 0 {
return days;
}
let mut arr: Vec<Vec<i64>> = Vec::new();
let mut i = 0;
while i < n {
let m = &meetings[i];
let mut row: Vec<i64> = Vec::new();
row.push(m[0]);
... | -- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS
-- [count_days]: type definitions
module
public import Aeneas
@[expose] public section
open Aeneas Aeneas.Std Result ControlFlow Error
set_option linter.dupNamespace false
set_option linter.hashCommand false
set_option linter.unusedVariables false
set_option linter.sty... | -- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS
-- [count_days]: function definitions
module
public import Aeneas
public import Aegis.CountDays.Code.Types
public import Aegis.CountDays.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_days]: external functions.
-- This is a template file: rename it to "FunsExternal.lean" and fill the holes.
module
public import Aeneas
public import Aegis.CountDays.Code.Types
@[expose] public section
open Aeneas Aeneas.Std Result ControlFlow Error
set_optio... | import Aegis.CountDays.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": "[6, [[1, 6]]]",
"output": "0"
},
{
"input": "[1, [[1, 1]]]",
"output": "0"
},
{
"input": "[1000000, [[1, 1000000]]]",
"output": "0"
},
{
"input": "[100, [[1, 100]]]",
"output": "0"
},
{
"input": "[1000000, [[1, 1000000]]]",
"output": "0"
},
{
... | 90 | false | 90 | verified | 10 | 10 | 1 | 2,008 | [
{
"type": "run_start",
"phase": "",
"model": null,
"messages": null,
"response": null,
"reasoning": null,
"finish_reason": null,
"prompt_tokens": null,
"completion_tokens": null,
"cached_prompt_tokens": null,
"command": null,
"exit_code": null,
"timed_out": null,
... | import Aegis.CountDays.Code.Funs
/-!
# Specifications of `Aegis.CountDays.count_days`
LeetCode problem `count-days-without-meetings`. Each `spec_<n>` theorem states one property of the function.
-/
open Aeneas Aeneas.Std Result
namespace AegisSpec.CountDays
def meetingVal (v : alloc.vec.Vec Aeneas.Std.I64) : List ... | 10 |
bitwise-or-of-adjacent-elements | 3,173 | Easy | [
"Bit Manipulation",
"Array"
] | Given an array nums of length n, return an array answer of length n - 1 such that answer[i] = nums[i] | nums[i + 1] where | is the bitwise OR operation.
Example 1:
Input: nums = [1,3,7,15]
Output: [3,7,15]
Example 2:
Input: nums = [8,4,2]
Output: [12,6]
Example 3:
Input: nums = [5,4,9,11]
Output: [5,13,11]
Co... | orArray(nums: list_int) -> list_int | pub fn or_array(nums: &[i64]) -> Vec<i64> | Aegis.OrArray.or_array | pub fn or_array(nums: &[i64]) -> Vec<i64> {
let n = nums.len();
let mut out: Vec<i64> = Vec::new();
if n < 2 {
return out;
}
let mut i: usize = 0;
while i + 1 < n {
out.push(nums[i] | nums[i + 1]);
i += 1;
}
out
}
| -- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS
-- [or_array]: type definitions
module
public import Aeneas
@[expose] public section
open Aeneas Aeneas.Std Result ControlFlow Error
set_option linter.dupNamespace false
set_option linter.hashCommand false
set_option linter.unusedVariables false
set_option linter.style... | -- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS
-- [or_array]: function definitions
module
public import Aeneas
public import Aegis.OrArray.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.OrArray.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": "[[8, 4, 2]]",
"output": "[12, 6]"
},
{
"input": "[[1, 1, 1, 1]]",
"output": "[1, 1, 1]"
},
{
"input": "[[5, 4, 9, 11]]",
"output": "[5, 13, 11]"
},
{
"input": "[[100, 50, 25, 12]]",
"output": "[118, 59, 29]"
},
{
"input": "[[1, 3, 7, 15]]",
"output... | 104 | false | 104 | verified | 10 | 10 | 1 | 141 | [
{
"type": "run_start",
"phase": "",
"model": null,
"messages": null,
"response": null,
"reasoning": null,
"finish_reason": null,
"prompt_tokens": null,
"completion_tokens": null,
"cached_prompt_tokens": null,
"command": null,
"exit_code": null,
"timed_out": null,
... | import Aegis.OrArray.Code.Funs
/-!
# Specifications of `Aegis.OrArray.or_array`
LeetCode problem `bitwise-or-of-adjacent-elements`. Each `spec_<n>` theorem states one property of the function.
-/
open Aeneas Aeneas.Std Result
open Aegis.OrArray
namespace AegisSpec.OrArray
/-- The function returns a result r and le... | 10 | |
find-the-maximum-length-of-a-good-subsequence-i | 3,176 | Medium | [
"Array",
"Hash Table",
"Dynamic Programming"
] | You are given an integer array nums and a non-negative integer k. A sequence of integers seq is called good if there are at most k indices i in the range [0, seq.length - 2] such that seq[i] != seq[i + 1].
Return the maximum possible length of a good subsequence of nums.
Example 1:
Input: nums = [1,2,1,1,3], k = 2
O... | maximumLength(nums: list_int, k: int) -> int | pub fn maximum_length(nums: &[i64], k: i64) -> i64 | Aegis.MaximumLength.maximum_length | pub fn maximum_length(nums: &[i64], k: i64) -> i64 {
let n = nums.len();
if n == 0 {
return 0;
}
let mut kcap = k;
let max_changes = n as i64 - 1;
if kcap > max_changes {
kcap = max_changes;
}
if kcap < 0 {
kcap = 0;
}
let cols = (kcap + 1) as usize;
... | -- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS
-- [maximum_length]: type definitions
module
public import Aeneas
@[expose] public section
open Aeneas Aeneas.Std Result ControlFlow Error
set_option linter.dupNamespace false
set_option linter.hashCommand false
set_option linter.unusedVariables false
set_option linter... | -- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS
-- [maximum_length]: function definitions
module
public import Aeneas
public import Aegis.MaximumLength.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.MaximumLength.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]",
"output": "1"
},
{
"input": "[[1, 2], 1]",
"output": "2"
},
{
"input": "[[1, 1, 1, 1, 1], 3]",
"output": "5"
},
{
"input": "[[1, 2, 3, 2, 1], 1]",
"output": "3"
},
{
"input": "[[1, 2, 1, 1, 3], 2]",
"output": "4"
},
{
"input": "[... | 109 | false | 109 | verified | 10 | 10 | 1 | 3,886 | [
{
"type": "run_start",
"phase": "",
"model": null,
"messages": null,
"response": null,
"reasoning": null,
"finish_reason": null,
"prompt_tokens": null,
"completion_tokens": null,
"cached_prompt_tokens": null,
"command": null,
"exit_code": null,
"timed_out": null,
... | import Aegis.MaximumLength.Code.Funs
/-!
# Specifications of `Aegis.MaximumLength.maximum_length`
LeetCode problem `find-the-maximum-length-of-a-good-subsequence-i`. Each `spec_<n>` theorem states one property of the function.
-/
open Aeneas Aeneas.Std Result
open Aegis.MaximumLength
namespace AegisSpec.Maximu... | 14 | |
find-the-maximum-length-of-a-good-subsequence-ii | 3,177 | Hard | [
"Array",
"Hash Table",
"Dynamic Programming"
] | You are given an integer array nums and a non-negative integer k. A sequence of integers seq is called good if there are at most k indices i in the range [0, seq.length - 2] such that seq[i] != seq[i + 1].
Return the maximum possible length of a good subsequence of nums.
Example 1:
Input: nums = [1,2,1,1,3], k = 2
O... | maximumLength(nums: list_int, k: int) -> int | pub fn maximum_length(nums: &[i64], k: i64) -> i64 | Aegis.MaximumLength.maximum_length | pub fn maximum_length(nums: &[i64], k: i64) -> i64 {
let n: usize = nums.len();
let kk: usize = k as usize;
let mut best: Vec<i64> = Vec::new();
let mut t: usize = 0;
while t <= kk {
best.push(0);
t += 1;
}
let mut vals: Vec<i64> = Vec::new();
let mut best_val: Vec<Vec<... | -- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS
-- [maximum_length]: type definitions
module
public import Aeneas
@[expose] public section
open Aeneas Aeneas.Std Result ControlFlow Error
set_option linter.dupNamespace false
set_option linter.hashCommand false
set_option linter.unusedVariables false
set_option linter... | -- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS
-- [maximum_length]: function definitions
module
public import Aeneas
public import Aegis.MaximumLength.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.MaximumLength.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]",
"output": "1"
},
{
"input": "[[5, 5, 5, 5, 5], 5]",
"output": "5"
},
{
"input": "[[1, 1, 1, 1, 1], 3]",
"output": "5"
},
{
"input": "[[1, 2, 3, 2, 1], 1]",
"output": "3"
},
{
"input": "[[1, 2, 1, 1, 3], 2]",
"output": "4"
},
{
"i... | 107 | false | 107 | verified | 10 | 10 | 1 | 8,655 | [
{
"type": "run_start",
"phase": "",
"model": null,
"messages": null,
"response": null,
"reasoning": null,
"finish_reason": null,
"prompt_tokens": null,
"completion_tokens": null,
"cached_prompt_tokens": null,
"command": null,
"exit_code": null,
"timed_out": null,
... | import Aegis.MaximumLength.Code.Funs
/-!
# Specifications of `Aegis.MaximumLength.maximum_length`
LeetCode problem `find-the-maximum-length-of-a-good-subsequence-ii`. Each `spec_<n>` theorem states one property of the function.
-/
open Aeneas Aeneas.Std Result
open Aegis.MaximumLength
namespace AegisSpec.Maximu... | 13 | |
find-the-child-who-has-the-ball-after-k-seconds | 3,178 | Easy | [
"Math",
"Simulation"
] | You are given two positive integers n and k. There are n children numbered from 0 to n - 1 standing in a queue in order from left to right.
Initially, child 0 holds a ball and the direction of passing the ball is towards the right direction. After each second, the child holding the ball passes it to the child next to t... | numberOfChild(n: int, k: int) -> int | pub fn number_of_child(n: i64, k: i64) -> i64 | Aegis.NumberOfChild.number_of_child | pub fn number_of_child(n: i64, k: i64) -> i64 {
let period = 2 * (n - 1);
let t = k % period;
if t < n {
t
} else {
period - t
}
}
| -- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS
-- [number_of_child]: type definitions
module
public import Aeneas
@[expose] public section
open Aeneas Aeneas.Std Result ControlFlow Error
set_option linter.dupNamespace false
set_option linter.hashCommand false
set_option linter.unusedVariables false
set_option linte... | -- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS
-- [number_of_child]: function definitions
module
public import Aeneas
public import Aegis.NumberOfChild.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.NumberOfChild.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": "[50, 50]",
"output": "48"
},
{
"input": "[3, 5]",
"output": "1"
},
{
"input": "[2, 1]",
"output": "1"
},
{
"input": "[40, 20]",
"output": "20"
},
{
"input": "[5, 6]",
"output": "2"
},
{
"input": "[10, 15]",
"output": "3"
},
{
"i... | 82 | false | 82 | verified | 10 | 10 | 1 | 388 | [
{
"type": "run_start",
"phase": "",
"model": null,
"messages": null,
"response": null,
"reasoning": null,
"finish_reason": null,
"prompt_tokens": null,
"completion_tokens": null,
"cached_prompt_tokens": null,
"command": null,
"exit_code": null,
"timed_out": null,
... | import Aegis.NumberOfChild.Code.Funs
/-!
# Specifications of `Aegis.NumberOfChild.number_of_child`
LeetCode problem `find-the-child-who-has-the-ball-after-k-seconds`. Each `spec_<n>` theorem states one property of the function.
-/
open Aeneas Aeneas.Std Result
open Aegis.NumberOfChild
namespace AegisSpec.Number... | 14 | |
find-the-n-th-value-after-k-seconds | 3,179 | Medium | [
"Array",
"Math",
"Combinatorics",
"Prefix Sum",
"Simulation"
] | You are given two integers n and k.
Initially, you start with an array a of n integers where a[i] = 1 for all 0 <= i <= n - 1. After each second, you simultaneously update each element to be the sum of all its preceding elements plus the element itself. For example, after one second, a[0] remains the same, a[1] becomes... | valueAfterKSeconds(n: int, k: int) -> int | pub fn value_after_k_seconds(n: i64, k: i64) -> i64 | Aegis.ValueAfterKSeconds.value_after_k_seconds | pub fn value_after_k_seconds(n: i64, k: i64) -> i64 {
let modulo: i64 = 1_000_000_007;
let n_usize: usize = n as usize;
let k_usize: usize = k as usize;
let mut a: Vec<i64> = Vec::new();
let mut i: usize = 0;
while i < n_usize {
a.push(1);
i += 1;
}
let mut sec: usize =... | -- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS
-- [value_after_k_seconds]: type definitions
module
public import Aeneas
@[expose] public section
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
-- [value_after_k_seconds]: function definitions
module
public import Aeneas
public import Aegis.ValueAfterKSeconds.Code.Types
public import Aegis.ValueAfterKSeconds.Code.FunsExternal
@[expose] public section
open Aeneas Aeneas.Std Result ControlFlow Error
set_option l... | -- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS
-- [value_after_k_seconds]: external functions.
-- This is a template file: rename it to "FunsExternal.lean" and fill the holes.
module
public import Aeneas
public import Aegis.ValueAfterKSeconds.Code.Types
@[expose] public section
open Aeneas Aeneas.Std Result Control... | import Aegis.ValueAfterKSeconds.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": "[7, 4]",
"output": "210"
},
{
"input": "[2, 4]",
"output": "5"
},
{
"input": "[2, 5]",
"output": "6"
},
{
"input": "[8, 4]",
"output": "330"
},
{
"input": "[2, 1]",
"output": "2"
},
{
"input": "[1, 1]",
"output": "1"
},
{
"input... | 63 | false | 63 | verified | 10 | 10 | 1 | 1,494 | [
{
"type": "run_start",
"phase": "",
"model": null,
"messages": null,
"response": null,
"reasoning": null,
"finish_reason": null,
"prompt_tokens": null,
"completion_tokens": null,
"cached_prompt_tokens": null,
"command": null,
"exit_code": null,
"timed_out": null,
... | import Aegis.ValueAfterKSeconds.Code.Funs
/-!
# Specifications of `Aegis.ValueAfterKSeconds.value_after_k_seconds`
LeetCode problem `find-the-n-th-value-after-k-seconds`. Each `spec_<n>` theorem states one property of the function.
-/
open Aeneas Aeneas.Std Result
open Aegis.ValueAfterKSeconds
namespace AegisSp... | 10 |
maximum-total-reward-using-operations-i | 3,180 | Medium | [
"Array",
"Dynamic Programming"
] | You are given an integer array rewardValues of length n, representing the values of rewards.
Initially, your total reward x is 0, and all indices are unmarked. You are allowed to perform the following operation any number of times:
Choose an unmarked index i from the range [0, n - 1].
If rewardValues[i] is greater tha... | maxTotalReward(rewardValues: list_int) -> int | pub fn max_total_reward(rewardValues: &[i64]) -> i64 | Aegis.MaxTotalReward.max_total_reward | pub fn max_total_reward(rewardValues: &[i64]) -> i64 {
let n = rewardValues.len();
if n == 0 {
return 0;
}
let mut vals: Vec<i64> = Vec::new();
let mut i: usize = 0;
let mut max_val: i64 = 0;
while i < n {
let v = rewardValues[i];
vals.push(v);
if v > max_va... | -- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS
-- [max_total_reward]: type definitions
module
public import Aeneas
@[expose] public section
open Aeneas Aeneas.Std Result ControlFlow Error
set_option linter.dupNamespace false
set_option linter.hashCommand false
set_option linter.unusedVariables false
set_option lint... | -- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS
-- [max_total_reward]: function definitions
module
public import Aeneas
public import Aegis.MaxTotalReward.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.MaxTotalReward.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": "[[1]]",
"output": "1"
},
{
"input": "[[2000, 1]]",
"output": "2001"
},
{
"input": "[[1, 2000]]",
"output": "2001"
},
{
"input": "[[1000, 1000, 1000]]",
"output": "1000"
},
{
"input": "[[1, 1, 3, 3]]",
"output": "4"
},
{
"input": "[[1, 6, 4,... | 104 | false | 104 | verified | 10 | 10 | 1 | 6,213 | [
{
"type": "run_start",
"phase": "",
"model": null,
"messages": null,
"response": null,
"reasoning": null,
"finish_reason": null,
"prompt_tokens": null,
"completion_tokens": null,
"cached_prompt_tokens": null,
"command": null,
"exit_code": null,
"timed_out": null,
... | import Aegis.MaxTotalReward.Code.Funs
/-!
# Specifications of `Aegis.MaxTotalReward.max_total_reward`
LeetCode problem `maximum-total-reward-using-operations-i`. Each `spec_<n>` theorem states one property of the function.
-/
open Aeneas Aeneas.Std Result
namespace AegisSpec.MaxTotalReward
def rv (a : Slice St... | 14 | |
maximum-total-reward-using-operations-ii | 3,181 | Hard | [
"Bit Manipulation",
"Array",
"Dynamic Programming"
] | You are given an integer array rewardValues of length n, representing the values of rewards.
Initially, your total reward x is 0, and all indices are unmarked. You are allowed to perform the following operation any number of times:
Choose an unmarked index i from the range [0, n - 1].
If rewardValues[i] is greater tha... | maxTotalReward(rewardValues: list_int) -> int | pub fn max_total_reward(rewardValues: &[i64]) -> i64 | Aegis.MaxTotalReward.max_total_reward | pub fn max_total_reward(rewardValues: &[i64]) -> i64 {
let n = rewardValues.len();
if n == 0 {
return 0;
}
let mut maxv: i64 = 0;
let mut i: usize = 0;
while i < n {
let x = rewardValues[i];
if x > maxv {
maxv = x;
}
i += 1;
}
let see... | -- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS
-- [max_total_reward]: type definitions
module
public import Aeneas
@[expose] public section
open Aeneas Aeneas.Std Result ControlFlow Error
set_option linter.dupNamespace false
set_option linter.hashCommand false
set_option linter.unusedVariables false
set_option lint... | -- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS
-- [max_total_reward]: function definitions
module
public import Aeneas
public import Aegis.MaxTotalReward.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.MaxTotalReward.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": "[[1]]",
"output": "1"
},
{
"input": "[[1, 1, 3, 3]]",
"output": "4"
},
{
"input": "[[1, 2, 3, 4, 5]]",
"output": "9"
},
{
"input": "[[50000, 40000, 30000, 20000, 10000]]",
"output": "90000"
},
{
"input": "[[1, 6, 4, 3, 2]]",
"output": "11"
},
{... | 87 | false | 87 | verified_partial | 10 | 3 | 2 | 21,452 | [
{
"type": "run_start",
"phase": "",
"model": null,
"messages": null,
"response": null,
"reasoning": null,
"finish_reason": null,
"prompt_tokens": null,
"completion_tokens": null,
"cached_prompt_tokens": null,
"command": null,
"exit_code": null,
"timed_out": null,
... | import Aegis.MaxTotalReward.Code.Funs
/-!
# Specifications of `Aegis.MaxTotalReward.max_total_reward`
LeetCode problem `maximum-total-reward-using-operations-ii`. Each `spec_<n>` theorem states one property of the function.
-/
open Aeneas Aeneas.Std Result
open Aegis.MaxTotalReward
namespace AegisSpec.MaxTotalRewar... | 14 | |
the-number-of-ways-to-make-the-sum | 3,183 | Medium | [
"Array",
"Dynamic Programming"
] | You have an infinite number of coins with values 1, 2, and 6, and only 2 coins with value 4.
Given an integer n, return the number of ways to make the sum of n with the coins you have.
Since the answer may be very large, return it modulo 109 + 7.
Note that the order of the coins doesn't matter and [2, 2, 3] is the same... | numberOfWays(n: int) -> int | pub fn number_of_ways(n: i64) -> i64 | Aegis.NumberOfWays.number_of_ways | fn ways_for_sum(m: i64) -> i64 {
let k: i64 = m / 6 + 1;
let parity: i64 = m % 2;
let half_plus_one: i64 = (m - parity) / 2 + 1;
let first: i64 = k * half_plus_one;
let second: i64 = 3 * k * (k - 1) / 2;
first - second
}
pub fn number_of_ways(n: i64) -> i64 {
let modulo: i64 = 1_000_000_007... | -- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS
-- [number_of_ways]: type definitions
module
public import Aeneas
@[expose] public section
open Aeneas Aeneas.Std Result ControlFlow Error
set_option linter.dupNamespace false
set_option linter.hashCommand false
set_option linter.unusedVariables false
set_option linter... | -- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS
-- [number_of_ways]: function definitions
module
public import Aeneas
public import Aegis.NumberOfWays.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.NumberOfWays.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": "2"
},
{
"input": "[100000]",
"output": "250024994"
},
{
"input": "[100]",
"output": "1276"
},
{
"input": "[30]",
"output": "121"
},
{
"input": "[4]",
"output": "4"
},
{
"input": "[12]",
"output": "22"
},
{
"inpu... | 56 | false | 56 | verified | 10 | 10 | 2 | 7,985 | [
{
"type": "run_start",
"phase": "",
"model": null,
"messages": null,
"response": null,
"reasoning": null,
"finish_reason": null,
"prompt_tokens": null,
"completion_tokens": null,
"cached_prompt_tokens": null,
"command": null,
"exit_code": null,
"timed_out": null,
... | import Aegis.NumberOfWays.Code.Funs
import Mathlib.RingTheory.PowerSeries.Basic
import Mathlib.RingTheory.PowerSeries.Inverse
import Mathlib.Data.Int.ModEq
/-!
# Specifications of `Aegis.NumberOfWays.number_of_ways`
LeetCode problem `the-number-of-ways-to-make-the-sum`. Each `spec_<n>` theorem states one property of ... | 13 | |
count-pairs-that-form-a-complete-day-i | 3,184 | Easy | [
"Array",
"Hash Table",
"Counting"
] | Given an integer array hours representing times in hours, return an integer denoting the number of pairs i, j where i < j and hours[i] + hours[j] forms a complete day.
A complete day is defined as a time duration that is an exact multiple of 24 hours.
For example, 1 day is 24 hours, 2 days is 48 hours, 3 days is 72 hou... | countCompleteDayPairs(hours: list_int) -> int | pub fn count_complete_day_pairs(hours: &[i64]) -> i64 | Aegis.CountCompleteDayPairs.count_complete_day_pairs | pub fn count_complete_day_pairs(hours: &[i64]) -> i64 {
let n = hours.len();
let mut count: i64 = 0;
let mut i: usize = 0;
while i < n {
let mut j: usize = i + 1;
while j < n {
if (hours[i] % 24 + hours[j] % 24) % 24 == 0 {
count += 1;
}
... | -- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS
-- [count_complete_day_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_opt... | -- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS
-- [count_complete_day_pairs]: function definitions
module
public import Aeneas
public import Aegis.CountCompleteDayPairs.Code.Types
@[expose] public section
open Aeneas Aeneas.Std Result ControlFlow Error
set_option linter.dupNamespace false
set_option linter.hashComm... | import Aegis.CountCompleteDayPairs.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": "[[1000000000, 1000000000, 1000000000, 1000000000]]",
"output": "0"
},
{
"input": "[[24, 48, 72, 96]]",
"output": "6"
},
{
"input": "[[1, 2, 3, 23]]",
"output": "1"
},
{
"input": "[[24, 24, 24, 24]]",
"output": "6"
},
{
"input": "[[72, 48, 24, 3]]",
... | 83 | false | 83 | verified | 10 | 10 | 1 | 214 | [
{
"type": "run_start",
"phase": "",
"model": null,
"messages": null,
"response": null,
"reasoning": null,
"finish_reason": null,
"prompt_tokens": null,
"completion_tokens": null,
"cached_prompt_tokens": null,
"command": null,
"exit_code": null,
"timed_out": null,
... | import Aegis.CountCompleteDayPairs.Code.Funs
/-!
# Specifications of `Aegis.CountCompleteDayPairs.count_complete_day_pairs`
LeetCode problem `count-pairs-that-form-a-complete-day-i`. Each `spec_<n>` theorem states one property of the function.
-/
open Aeneas Aeneas.Std Result
open Aegis.CountCompleteDayPairs
na... | 8 | |
count-pairs-that-form-a-complete-day-ii | 3,185 | Medium | [
"Array",
"Hash Table",
"Counting"
] | Given an integer array hours representing times in hours, return an integer denoting the number of pairs i, j where i < j and hours[i] + hours[j] forms a complete day.
A complete day is defined as a time duration that is an exact multiple of 24 hours.
For example, 1 day is 24 hours, 2 days is 48 hours, 3 days is 72 hou... | countCompleteDayPairs(hours: list_int) -> int | pub fn count_complete_day_pairs(hours: &[i64]) -> i64 | Aegis.CountCompleteDayPairs.count_complete_day_pairs | pub fn count_complete_day_pairs(hours: &[i64]) -> i64 {
let mut counts: Vec<i64> = Vec::new();
let mut k: usize = 0;
while k < 24 {
counts.push(0);
k += 1;
}
let mut ans: i64 = 0;
let mut i: usize = 0;
while i < hours.len() {
let r: i64 = hours[i] % 24;
let... | -- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS
-- [count_complete_day_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_opt... | -- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS
-- [count_complete_day_pairs]: function definitions
module
public import Aeneas
public import Aegis.CountCompleteDayPairs.Code.Types
@[expose] public section
open Aeneas Aeneas.Std Result ControlFlow Error
set_option linter.dupNamespace false
set_option linter.hashComm... | import Aegis.CountCompleteDayPairs.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": "[[24]]",
"output": "0"
},
{
"input": "[[72, 48, 24, 3]]",
"output": "3"
},
{
"input": "[[24, 48, 72, 96]]",
"output": "6"
},
{
"input": "[[24, 48, 72, 96, 120]]",
"output": "10"
},
{
"input": "[[12, 12, 30, 24, 24]]",
"output": "2"
},
{
"in... | 73 | false | 73 | verified | 10 | 10 | 1 | 533 | [
{
"type": "run_start",
"phase": "",
"model": null,
"messages": null,
"response": null,
"reasoning": null,
"finish_reason": null,
"prompt_tokens": null,
"completion_tokens": null,
"cached_prompt_tokens": null,
"command": null,
"exit_code": null,
"timed_out": null,
... | import Aegis.CountCompleteDayPairs.Code.Funs
/-!
# Specifications of `Aegis.CountCompleteDayPairs.count_complete_day_pairs`
LeetCode problem `count-pairs-that-form-a-complete-day-ii`. Each `spec_<n>` theorem states one property of the function.
-/
open Aeneas Aeneas.Std Result
namespace AegisSpec.CountCompleteDay... | 11 | |
maximum-total-damage-with-spell-casting | 3,186 | Medium | [
"Array",
"Hash Table",
"Two Pointers",
"Binary Search",
"Dynamic Programming",
"Counting",
"Sorting"
] | A magician has various spells.
You are given an array power, where each element represents the damage of a spell. Multiple spells can have the same damage value.
It is a known fact that if a magician decides to cast a spell with a damage of power[i], they cannot cast any spell with a damage of power[i] - 2, power[i] - ... | maximumTotalDamage(power: list_int) -> int | pub fn maximum_total_damage(power: &[i64]) -> i64 | Aegis.MaximumTotalDamage.maximum_total_damage | fn sorted_copy(power: &[i64]) -> Vec<i64> {
let n = power.len();
let mut a: Vec<i64> = Vec::new();
let mut idx = 0;
while idx < n {
a.push(power[idx]);
idx += 1;
}
if n <= 1 {
return a;
}
// Iterative bottom-up merge sort (no recursion, no std sort).
let mut w... | -- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS
-- [maximum_total_damage]: type definitions
module
public import Aeneas
@[expose] public section
open Aeneas Aeneas.Std Result ControlFlow Error
set_option linter.dupNamespace false
set_option linter.hashCommand false
set_option linter.unusedVariables false
set_option ... | -- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS
-- [maximum_total_damage]: function definitions
module
public import Aeneas
public import Aegis.MaximumTotalDamage.Code.Types
@[expose] public section
open Aeneas Aeneas.Std Result ControlFlow Error
set_option linter.dupNamespace false
set_option linter.hashCommand fal... | import Aegis.MaximumTotalDamage.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, 3, 4]]",
"output": "6"
},
{
"input": "[[7, 1, 6, 6]]",
"output": "13"
},
{
"input": "[[5, 5, 5, 5]]",
"output": "20"
},
{
"input": "[[1000000000, 1000000000, 1000000000, 1000000000]]",
"output": "4000000000"
},
{
"input": "[[5, 5, 5, 5, 5]]",
... | 99 | false | 99 | verified | 10 | 10 | 1 | 7,804 | [
{
"type": "run_start",
"phase": "",
"model": null,
"messages": null,
"response": null,
"reasoning": null,
"finish_reason": null,
"prompt_tokens": null,
"completion_tokens": null,
"cached_prompt_tokens": null,
"command": null,
"exit_code": null,
"timed_out": null,
... | import Aegis.MaximumTotalDamage.Code.Funs
/-!
# Specifications of `Aegis.MaximumTotalDamage.maximum_total_damage`
LeetCode problem `maximum-total-damage-with-spell-casting`. Each `spec_<n>` theorem states one property of the function.
-/
open Aeneas Aeneas.Std Result
namespace AegisSpec.MaximumTotalDamage
open Aeg... | 11 | |
peaks-in-array | 3,187 | Hard | [
"Binary Indexed Tree",
"Segment Tree",
"Array"
] | A peak in an array arr is an element that is greater than its previous and next element in arr.
You are given an integer array nums and a 2D integer array queries.
You have to process queries of two types:
queries[i] = [1, li, ri], determine the count of peak elements in the subarray nums[li..ri].
queries[i] = [2, ind... | countOfPeaks(nums: list_int, queries: list_list_int) -> list_int | pub fn count_of_peaks(nums: &[i64], queries: &[Vec<i64>]) -> Vec<i64> | Aegis.CountOfPeaks.count_of_peaks | fn is_peak(a: &[i64], i: usize) -> bool {
let n = a.len();
if i == 0 || i + 1 >= n {
false
} else {
a[i] > a[i - 1] && a[i] > a[i + 1]
}
}
fn seg_query(tree: &[i64], size: usize, mut l: usize, mut r: usize) -> i64 {
l += size;
r += size;
let mut res = 0;
while l < r {
... | -- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS
-- [count_of_peaks]: type definitions
module
public import Aeneas
@[expose] public section
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_of_peaks]: function definitions
module
public import Aeneas
public import Aegis.CountOfPeaks.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.CountOfPeaks.Code.Funs
open Aeneas Aeneas.Std Result
set_option maxHeartbeats 4000000
set_option maxRecDepth 4096
def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do
let h ← IO.FS.Handle.mk path .append
h.putStrLn s!"CASE {i} {b}"
h.flush
IO.println s!"CASE {i} {b}"
#eval aegisCas... | [
{
"input": "[[3, 1, 4, 2, 5], [[2, 3, 4], [1, 0, 4]]]",
"output": "[0]"
},
{
"input": "[[4, 1, 4, 2, 1, 5], [[2, 2, 4], [1, 0, 2], [1, 0, 4]]]",
"output": "[0, 1]"
},
{
"input": "[[9, 8, 7, 6, 5, 4, 3, 2, 1], [[1, 0, 8], [2, 4, 10], [1, 0, 8]]]",
"output": "[0, 1]"
},
{
"inpu... | 86 | false | 86 | verified | 10 | 10 | 1 | 23,175 | [
{
"type": "run_start",
"phase": "",
"model": null,
"messages": null,
"response": null,
"reasoning": null,
"finish_reason": null,
"prompt_tokens": null,
"completion_tokens": null,
"cached_prompt_tokens": null,
"command": null,
"exit_code": null,
"timed_out": null,
... | import Aegis.CountOfPeaks.Code.Funs
/-!
# Specifications of `Aegis.CountOfPeaks.count_of_peaks`
LeetCode problem `peaks-in-array`. Each `spec_<n>` theorem states one property of the function.
-/
open Aeneas Aeneas.Std Result
namespace AegisSpec.CountOfPeaks
def numsOf (nums : Slice Std.I64) : List ℤ := nums.val.ma... | 9 | |
minimum-moves-to-get-a-peaceful-board | 3,189 | Medium | [
"Greedy",
"Array",
"Counting Sort",
"Sorting"
] | Given a 2D array rooks of length n, where rooks[i] = [xi, yi] indicates the position of a rook on an n x n chess board. Your task is to move the rooks 1 cell at a time vertically or horizontally (to an adjacent cell) such that the board becomes peaceful.
A board is peaceful if there is exactly one rook in each row and ... | minMoves(rooks: list_list_int) -> int | pub fn min_moves(rooks: &[Vec<i64>]) -> i64 | Aegis.MinMoves.min_moves | pub fn min_moves(rooks: &[Vec<i64>]) -> i64 {
let n: usize = rooks.len();
let mut xs: Vec<i64> = Vec::new();
let mut ys: Vec<i64> = Vec::new();
let mut i: usize = 0;
while i < n {
xs.push(rooks[i][0]);
ys.push(rooks[i][1]);
i = i + 1;
}
sort_i64(&mut xs);
sort_i... | -- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS
-- [min_moves]: type definitions
module
public import Aeneas
@[expose] public section
open Aeneas Aeneas.Std Result ControlFlow Error
set_option linter.dupNamespace false
set_option linter.hashCommand false
set_option linter.unusedVariables false
set_option linter.styl... | -- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS
-- [min_moves]: function definitions
module
public import Aeneas
public import Aegis.MinMoves.Code.Types
@[expose] public section
open Aeneas Aeneas.Std Result ControlFlow Error
set_option linter.dupNamespace false
set_option linter.hashCommand false
set_option linter.... | import Aegis.MinMoves.Code.Funs
open Aeneas Aeneas.Std Result
set_option maxHeartbeats 4000000
set_option maxRecDepth 4096
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], [1, 0], [1, 1]]]",
"output": "3"
},
{
"input": "[[[0, 0], [1, 1], [2, 2], [3, 3]]]",
"output": "0"
},
{
"input": "[[[0, 0], [1, 2], [2, 1], [3, 3]]]",
"output": "0"
},
{
"input": "[[[0, 3], [1, 0], [2, 1], [3, 2]]]",
"output": "0"
},
{
"input... | 103 | false | 103 | verified | 10 | 10 | 1 | 3,139 | [
{
"type": "run_start",
"phase": "",
"model": null,
"messages": null,
"response": null,
"reasoning": null,
"finish_reason": null,
"prompt_tokens": null,
"completion_tokens": null,
"cached_prompt_tokens": null,
"command": null,
"exit_code": null,
"timed_out": null,
... | import Aegis.MinMoves.Code.Funs
/-!
# Specifications of `Aegis.MinMoves.min_moves`
LeetCode problem `minimum-moves-to-get-a-peaceful-board`. Each `spec_<n>` theorem states one property of the function.
-/
open Aeneas Aeneas.Std Result
open Aegis.MinMoves
namespace AegisSpec.MinMoves
def xAt (rooks : Slice (a... | 9 | |
find-minimum-operations-to-make-all-elements-divisible-by-three | 3,190 | Easy | [
"Array",
"Math"
] | You are given an integer array nums. In one operation, you can add or subtract 1 from any element of nums.
Return the minimum number of operations to make all elements of nums divisible by 3.
Example 1:
Input: nums = [1,2,3,4]
Output: 3
Explanation:
All array elements can be made divisible by 3 using 3 operations:
... | minimumOperations(nums: list_int) -> int | pub fn minimum_operations(nums: &[i64]) -> i64 | Aegis.MinimumOperations.minimum_operations | pub fn minimum_operations(nums: &[i64]) -> i64 {
let mut ans: i64 = 0;
let mut i: usize = 0;
while i < nums.len() {
if nums[i] % 3 != 0 {
ans += 1;
}
i += 1;
}
ans
}
| -- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS
-- [minimum_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 li... | -- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS
-- [minimum_operations]: function definitions
module
public import Aeneas
public import Aegis.MinimumOperations.Code.Types
@[expose] public section
open Aeneas Aeneas.Std Result ControlFlow Error
set_option linter.dupNamespace false
set_option linter.hashCommand false
... | import Aegis.MinimumOperations.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": "[[47, 49, 50]]",
"output": "3"
},
{
"input": "[[1, 2, 5]]",
"output": "3"
},
{
"input": "[[1, 5, 7]]",
"output": "3"
},
{
"input": "[[3, 6, 9]]",
"output": "0"
},
{
"input": "[[1, 2, 4, 5]]",
"output": "4"
},
{
"input": "[[1, 1, 1, 1]]",
... | 117 | false | 117 | verified | 10 | 10 | 1 | 376 | [
{
"type": "run_start",
"phase": "",
"model": null,
"messages": null,
"response": null,
"reasoning": null,
"finish_reason": null,
"prompt_tokens": null,
"completion_tokens": null,
"cached_prompt_tokens": null,
"command": null,
"exit_code": null,
"timed_out": null,
... | import Aegis.MinimumOperations.Code.Funs
/-!
# Specifications of `Aegis.MinimumOperations.minimum_operations`
LeetCode problem `find-minimum-operations-to-make-all-elements-divisible-by-three`. Each `spec_<n>` theorem states one property of the function.
-/
open Aeneas Aeneas.Std Result
open Aegis.MinimumOperations ... | 6 | |
minimum-operations-to-make-binary-array-elements-equal-to-one-i | 3,191 | Medium | [
"Bit Manipulation",
"Queue",
"Array",
"Prefix Sum",
"Sliding Window"
] | You are given a binary array nums.
You can do the following operation on the array any number of times (possibly zero):
Choose any 3 consecutive elements from the array and flip all of them.
Flipping an element means changing its value from 0 to 1, and from 1 to 0.
Return the minimum number of operations required to ... | minOperations(nums: list_int) -> int | pub fn min_operations(nums: &[i64]) -> i64 | Aegis.MinOperations.min_operations | pub fn min_operations(nums: &[i64]) -> i64 {
let n = nums.len();
let mut a: Vec<i64> = Vec::new();
let mut i = 0;
while i < n {
a.push(nums[i]);
i += 1;
}
let mut operations: i64 = 0;
i = 0;
while i + 2 < n {
if a[i] == 0 {
operations += 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": "[[0, 0, 0]]",
"output": "1"
},
{
"input": "[[0, 1, 1, 1]]",
"output": "-1"
},
{
"input": "[[0, 1, 0, 1, 0, 1]]",
"output": "3"
},
{
"input": "[[1, 0, 0, 1, 0, 0]]",
"output": "2"
},
{
"input": "[[1, 0, 1, 0, 1, 0]]",
"output": "3"
},
{
"inp... | 109 | false | 109 | verified | 10 | 10 | 1 | 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.MinOperations.Code.Funs
/-!
# Specifications of `Aegis.MinOperations.min_operations`
LeetCode problem `minimum-operations-to-make-binary-array-elements-equal-to-one-i`. Each `spec_<n>` theorem states one property of the function.
-/
open Aeneas Aeneas.Std Result
open Aegis.MinOperations
namespace A... | 12 | |
minimum-operations-to-make-binary-array-elements-equal-to-one-ii | 3,192 | Medium | [
"Greedy",
"Array",
"Dynamic Programming"
] | You are given a binary array nums.
You can do the following operation on the array any number of times (possibly zero):
Choose any index i from the array and flip all the elements from index i to the end of the array.
Flipping an element means changing its value from 0 to 1, and from 1 to 0.
Return the minimum number... | minOperations(nums: list_int) -> int | pub fn min_operations(nums: &[i64]) -> i64 | Aegis.MinOperations.min_operations | pub fn min_operations(nums: &[i64]) -> i64 {
let n: usize = nums.len();
let mut ops: i64 = 0;
let mut state: i64 = 0;
let mut i: usize = 0;
while i < n {
let cur: i64 = nums[i];
let mut eff: i64 = cur;
if state == 1 {
eff = 1 - cur;
}
if eff == 0 ... | -- 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": "[[1]]",
"output": "0"
},
{
"input": "[[0]]",
"output": "1"
},
{
"input": "[[1, 0, 0, 0]]",
"output": "1"
},
{
"input": "[[1, 0, 1, 0, 1]]",
"output": "4"
},
{
"input": "[[0, 1, 0, 1, 0]]",
"output": "5"
},
{
"input": "[[0, 0, 0, 0, 0]]",
... | 68 | false | 68 | verified | 10 | 10 | 3 | 2,949 | [
{
"type": "run_start",
"phase": "",
"model": null,
"messages": null,
"response": null,
"reasoning": 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-binary-array-elements-equal-to-one-ii`. Each `spec_<n>` theorem states one property of the function.
-/
open Aeneas Aeneas.Std Result
namespace AegisSpec.MinOperations
... | 11 | |
count-the-number-of-inversions | 3,193 | Hard | [
"Array",
"Dynamic Programming"
] | You are given an integer n and a 2D array requirements, where requirements[i] = [endi, cnti] represents the end index and the inversion count of each requirement.
A pair of indices (i, j) from an integer array nums is called an inversion if:
i < j and nums[i] > nums[j]
Return the number of permutations perm of [0, 1,... | numberOfPermutations(n: int, requirements: list_list_int) -> int | pub fn number_of_permutations(n: i64, requirements: &[Vec<i64>]) -> i64 | Aegis.NumberOfPermutations.number_of_permutations | pub fn number_of_permutations(n: i64, requirements: &[Vec<i64>]) -> i64 {
let modulo: i64 = 1000000007;
let n_usize: usize = n as usize;
let mut req: Vec<i64> = Vec::new();
let mut i: usize = 0;
while i < n_usize {
req.push(-1);
i += 1;
}
let mut max_cnt: i64 = 0;
i = 0... | -- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS
-- [number_of_permutations]: type definitions
module
public import Aeneas
@[expose] public section
open Aeneas Aeneas.Std Result ControlFlow Error
set_option linter.dupNamespace false
set_option linter.hashCommand false
set_option linter.unusedVariables false
set_optio... | -- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS
-- [number_of_permutations]: function definitions
module
public import Aeneas
public import Aegis.NumberOfPermutations.Code.Types
@[expose] public section
open Aeneas Aeneas.Std Result ControlFlow Error
set_option linter.dupNamespace false
set_option linter.hashCommand... | import Aegis.NumberOfPermutations.Code.Funs
open Aeneas Aeneas.Std Result
set_option maxHeartbeats 4000000
set_option maxRecDepth 4096
def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do
let h ← IO.FS.Handle.mk path .append
h.putStrLn s!"CASE {i} {b}"
h.flush
IO.println s!"CASE {i} {b}"
#eval ... | [
{
"input": "[2, [[0, 0], [1, 0]]]",
"output": "1"
},
{
"input": "[3, [[2, 2], [0, 0]]]",
"output": "2"
},
{
"input": "[3, [[2, 2], [1, 1], [0, 0]]]",
"output": "1"
},
{
"input": "[5, [[4, 5], [2, 2], [0, 0]]]",
"output": "8"
},
{
"input": "[4, [[3, 3], [1, 1], [2,... | 84 | false | 84 | verified | 10 | 10 | 1 | 7,418 | [
{
"type": "run_start",
"phase": "",
"model": null,
"messages": null,
"response": null,
"reasoning": null,
"finish_reason": null,
"prompt_tokens": null,
"completion_tokens": null,
"cached_prompt_tokens": null,
"command": null,
"exit_code": null,
"timed_out": null,
... | import Aegis.NumberOfPermutations.Code.Funs
/-!
# Specifications of `Aegis.NumberOfPermutations.number_of_permutations`
LeetCode problem `count-the-number-of-inversions`. Each `spec_<n>` theorem states one property of the function.
-/
open Aeneas Aeneas.Std Result
namespace AegisSpec.NumberOfPermutations
open ... | 12 | |
find-the-minimum-area-to-cover-all-ones-i | 3,195 | Medium | [
"Array",
"Matrix"
] | You are given a 2D binary array grid. Find a rectangle with horizontal and vertical sides with the smallest area, such that all the 1's in grid lie inside this rectangle.
Return the minimum possible area of the rectangle.
Example 1:
Input: grid = [[0,1,0],[1,0,1]]
Output: 6
Explanation:
The smallest rectangle has a... | minimumArea(grid: list_list_int) -> int | pub fn minimum_area(grid: &[Vec<i64>]) -> i64 | Aegis.MinimumArea.minimum_area | pub fn minimum_area(grid: &[Vec<i64>]) -> i64 {
let rows = grid.len();
if rows == 0 {
return 0;
}
// Smallest row index that contains a 1.
let mut min_r: i64 = rows as i64;
for i in 0..rows {
let len = grid[i].len();
for j in 0..len {
if grid[i][j] == 1 {
... | -- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS
-- [minimum_area]: type definitions
module
public import Aeneas
@[expose] public section
open Aeneas Aeneas.Std Result ControlFlow Error
set_option linter.dupNamespace false
set_option linter.hashCommand false
set_option linter.unusedVariables false
set_option linter.s... | -- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS
-- [minimum_area]: function definitions
module
public import Aeneas
public import Aegis.MinimumArea.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.MinimumArea.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": "[[[0], [1], [0]]]",
"output": "1"
},
{
"input": "[[[1, 0], [0, 0]]]",
"output": "1"
},
{
"input": "[[[1, 1], [1, 1]]]",
"output": "4"
},
{
"input": "[[[1, 0, 1, 0, 1]]]",
"output": "5"
},
{
"input": "[... | 76 | false | 76 | verified | 10 | 10 | 2 | 20,271 | [
{
"type": "run_start",
"phase": "",
"model": null,
"messages": null,
"response": null,
"reasoning": null,
"finish_reason": null,
"prompt_tokens": null,
"completion_tokens": null,
"cached_prompt_tokens": null,
"command": null,
"exit_code": null,
"timed_out": null,
... | import Aegis.MinimumArea.Code.Funs
/-!
# Specifications of `Aegis.MinimumArea.minimum_area`
LeetCode problem `find-the-minimum-area-to-cover-all-ones-i`. Each `spec_<n>` theorem states one property of the function.
-/
open Aeneas Aeneas.Std Result
namespace AegisSpec.MinimumArea
def cell (grid : Slice (alloc.vec.V... | 13 | |
maximize-total-cost-of-alternating-subarrays | 3,196 | Medium | [
"Array",
"Dynamic Programming"
] | You are given an integer array nums with length n.
The cost of a subarray nums[l..r], where 0 <= l <= r < n, is defined as:
cost(l, r) = nums[l] - nums[l + 1] + ... + nums[r] * (−1)r − l
Your task is to split nums into subarrays such that the total cost of the subarrays is maximized, ensuring each element belongs to ex... | maximumTotalCost(nums: list_int) -> int | pub fn maximum_total_cost(nums: &[i64]) -> i64 | Aegis.MaximumTotalCost.maximum_total_cost | pub fn maximum_total_cost(nums: &[i64]) -> i64 {
let n = nums.len();
if n == 0 {
return 0;
}
let mut pos: i64 = nums[0];
let mut neg: i64 = -1000000000000000000;
let mut i: usize = 1;
while i < n {
let x = nums[i];
let best = if pos > neg { pos } else { neg };
... | -- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS
-- [maximum_total_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 li... | -- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS
-- [maximum_total_cost]: function definitions
module
public import Aeneas
public import Aegis.MaximumTotalCost.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.MaximumTotalCost.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]]",
"output": "1"
},
{
"input": "[[0]]",
"output": "0"
},
{
"input": "[[1, -1]]",
"output": "2"
},
{
"input": "[[1, 2]]",
"output": "3"
},
{
"input": "[[1, -1, 1, -1]]",
"output": "4"
},
{
"input": "[[1, -2, 3, 4]]",
"output": "10"
... | 105 | false | 105 | verified | 10 | 10 | 1 | 2,493 | [
{
"type": "run_start",
"phase": "",
"model": null,
"messages": null,
"response": null,
"reasoning": null,
"finish_reason": null,
"prompt_tokens": null,
"completion_tokens": null,
"cached_prompt_tokens": null,
"command": null,
"exit_code": null,
"timed_out": null,
... | import Aegis.MaximumTotalCost.Code.Funs
/-!
# Specifications of `Aegis.MaximumTotalCost.maximum_total_cost`
LeetCode problem `maximize-total-cost-of-alternating-subarrays`. Each `spec_<n>` theorem states one property of the function.
-/
open Aeneas Aeneas.Std Result
namespace AegisSpec.MaximumTotalCost
open Aegis.... | 17 | |
find-the-minimum-area-to-cover-all-ones-ii | 3,197 | Hard | [
"Array",
"Enumeration",
"Matrix"
] | You are given a 2D binary array grid. You need to find 3 non-overlapping rectangles having non-zero areas with horizontal and vertical sides such that all the 1's in grid lie inside these rectangles.
Return the minimum possible sum of the area of these rectangles.
Note that the rectangles are allowed to touch.
Exampl... | minimumSum(grid: list_list_int) -> int | pub fn minimum_sum(grid: &[Vec<i64>]) -> i64 | Aegis.MinimumSum.minimum_sum | fn area(
grid: &[Vec<i64>],
r1: usize,
r2: usize,
c1: usize,
c2: usize,
) -> usize {
if r1 >= r2 {
return 0;
}
if c1 >= c2 {
return 0;
}
let mut found = false;
let mut min_r: usize = 0;
let mut max_r: usize = 0;
let mut min_c: usize = 0;
let mut m... | -- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS
-- [minimum_sum]: type definitions
module
public import Aeneas
@[expose] public section
open Aeneas Aeneas.Std Result ControlFlow Error
set_option linter.dupNamespace false
set_option linter.hashCommand false
set_option linter.unusedVariables false
set_option linter.st... | -- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS
-- [minimum_sum]: function definitions
module
public import Aeneas
public import Aegis.MinimumSum.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.MinimumSum.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, 0, 1], [1, 1, 1]]]",
"output": "5"
},
{
"input": "[[[1, 0, 1, 0], [0, 1, 0, 1]]]",
"output": "5"
},
{
"input": "[[[1, 0, 0, 1], [0, 1, 1, 0], [0, 1, 1, 0], [1, 0, 0, 1]]]",
"output": "12"
},
{
"input": "[[[1, 1, 0, 0, 1], [1, 1, 0, 0, 1], [0, 0, 1, 1, 0], [0... | 62 | false | 62 | verified | 10 | 10 | 1 | 17,840 | [
{
"type": "run_start",
"phase": "",
"model": null,
"messages": null,
"response": null,
"reasoning": null,
"finish_reason": null,
"prompt_tokens": null,
"completion_tokens": null,
"cached_prompt_tokens": null,
"command": null,
"exit_code": null,
"timed_out": null,
... | import Aegis.MinimumSum.Code.Funs
/-!
# Specifications of `Aegis.MinimumSum.minimum_sum`
LeetCode problem `find-the-minimum-area-to-cover-all-ones-ii`. Each `spec_<n>` theorem states one property of the function.
-/
open Aeneas Aeneas.Std Result
namespace AegisSpec.MinimumSum
abbrev Grid := Slice (alloc.vec.Ve... | 16 | |
count-triplets-with-even-xor-set-bits-i | 3,199 | Easy | [
"Bit Manipulation",
"Array"
] | Given three integer arrays a, b, and c, return the number of triplets (a[i], b[j], c[k]), such that the bitwise XOR of the elements of each triplet has an even number of set bits.
Example 1:
Input: a = [1], b = [2], c = [3]
Output: 1
Explanation:
The only triplet is (a[0], b[0], c[0]) and their XOR is: 1 XOR 2 XOR 3... | tripletCount(a: list_int, b: list_int, c: list_int) -> int | pub fn triplet_count(a: &[i64], b: &[i64], c: &[i64]) -> i64 | Aegis.TripletCount.triplet_count | pub fn triplet_count(a: &[i64], b: &[i64], c: &[i64]) -> i64 {
let mut even_a: i64 = 0;
let mut odd_a: i64 = 0;
let mut even_b: i64 = 0;
let mut odd_b: i64 = 0;
let mut even_c: i64 = 0;
let mut odd_c: i64 = 0;
let mut i: usize = 0;
while i < a.len() {
if set_bits_parity(a[i]) ==... | -- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS
-- [triplet_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
-- [triplet_count]: function definitions
module
public import Aeneas
public import Aegis.TripletCount.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.TripletCount.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], [2], [3]]",
"output": "1"
},
{
"input": "[[0], [0], [0]]",
"output": "1"
},
{
"input": "[[0, 1], [0, 1], [0, 1]]",
"output": "4"
},
{
"input": "[[1, 1], [2, 3], [1, 5]]",
"output": "4"
},
{
"input": "[[0, 1, 2], [0, 1, 2], [0, 1, 2]]",
"outpu... | 77 | false | 77 | verified | 10 | 10 | 1 | 1,042 | [
{
"type": "run_start",
"phase": "",
"model": null,
"messages": null,
"response": null,
"reasoning": null,
"finish_reason": null,
"prompt_tokens": null,
"completion_tokens": null,
"cached_prompt_tokens": null,
"command": null,
"exit_code": null,
"timed_out": null,
... | import Aegis.TripletCount.Code.Funs
/-!
# Specifications of `Aegis.TripletCount.triplet_count`
LeetCode problem `count-triplets-with-even-xor-set-bits-i`. Each `spec_<n>` theorem states one property of the function.
-/
open Aeneas Aeneas.Std Result
namespace AegisSpec.TripletCount
open Aeneas.Std
open Aegis.Triple... | 12 | |
maximum-height-of-a-triangle | 3,200 | Easy | [
"Array",
"Enumeration"
] | You are given two integers red and blue representing the count of red and blue colored balls. You have to arrange these balls to form a triangle such that the 1st row will have 1 ball, the 2nd row will have 2 balls, the 3rd row will have 3 balls, and so on.
All the balls in a particular row should be the same color, an... | maxHeightOfTriangle(red: int, blue: int) -> int | pub fn max_height_of_triangle(red: i64, blue: i64) -> i64 | Aegis.MaxHeightOfTriangle.max_height_of_triangle | pub fn max_height_of_triangle(red: i64, blue: i64) -> i64 {
let mut best: i64 = 0;
let mut scenario: i64 = 0;
while scenario < 2 {
let mut r: i64 = red;
let mut b: i64 = blue;
let mut height: i64 = 0;
let mut need_red: bool = scenario == 0;
let mut size: i64 = 1;
... | -- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS
-- [max_height_of_triangle]: type definitions
module
public import Aeneas
@[expose] public section
open Aeneas Aeneas.Std Result ControlFlow Error
set_option linter.dupNamespace false
set_option linter.hashCommand false
set_option linter.unusedVariables false
set_optio... | -- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS
-- [max_height_of_triangle]: function definitions
module
public import Aeneas
public import Aegis.MaxHeightOfTriangle.Code.Types
@[expose] public section
open Aeneas Aeneas.Std Result ControlFlow Error
set_option linter.dupNamespace false
set_option linter.hashCommand ... | import Aegis.MaxHeightOfTriangle.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": "[100, 1]",
"output": "2"
},
{
"input": "[3, 7]",
"output": "3"
},
{
"input": "[50, 50]",
"output": "13"
},
{
"input": "[5, 5]",
"output": "3"
},
{
"input": "[1, 1]",
"output": "1"
},
{
"input": "[10, 1]",
"output": "2"
},
{
"inp... | 67 | false | 67 | verified | 10 | 10 | 1 | 1,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.MaxHeightOfTriangle.Code.Funs
/-!
# Specifications of `Aegis.MaxHeightOfTriangle.max_height_of_triangle`
LeetCode problem `maximum-height-of-a-triangle`. Each `spec_<n>` theorem states one property of the function.
-/
open Aeneas Aeneas.Std Result
open Aegis.MaxHeightOfTriangle
namespace AegisSpec.MaxH... | 13 | |
find-the-maximum-length-of-valid-subsequence-i | 3,201 | Medium | [
"Array",
"Dynamic Programming"
] | You are given an integer array nums.
A subsequence sub of nums with length x is called valid if it satisfies:
(sub[0] + sub[1]) % 2 == (sub[1] + sub[2]) % 2 == ... == (sub[x - 2] + sub[x - 1]) % 2.
Return the length of the longest valid subsequence of nums.
A subsequence is an array that can be derived from another a... | maximumLength(nums: list_int) -> int | pub fn maximum_length(nums: &[i64]) -> i64 | Aegis.MaximumLength.maximum_length | pub fn maximum_length(nums: &[i64]) -> i64 {
let n = nums.len();
if n == 0 {
return 0;
}
let mut even: i64 = 0;
let mut odd: i64 = 0;
let mut i: usize = 0;
while i < n {
if nums[i] % 2 == 0 {
even += 1;
} else {
odd += 1;
}
i ... | -- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS
-- [maximum_length]: type definitions
module
public import Aeneas
@[expose] public section
open Aeneas Aeneas.Std Result ControlFlow Error
set_option linter.dupNamespace false
set_option linter.hashCommand false
set_option linter.unusedVariables false
set_option linter... | -- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS
-- [maximum_length]: function definitions
module
public import Aeneas
public import Aegis.MaximumLength.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.MaximumLength.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, 3]]",
"output": "2"
},
{
"input": "[[1, 1, 1, 1]]",
"output": "4"
},
{
"input": "[[1, 2, 3, 4]]",
"output": "4"
},
{
"input": "[[2, 2, 2, 2]]",
"output": "4"
},
{
"input": "[[10000000, 1, 10000000, 1]]",
"output": "4"
},
{
"input": "[[... | 115 | false | 115 | verified | 10 | 10 | 1 | 1,554 | [
{
"type": "run_start",
"phase": "",
"model": null,
"messages": null,
"response": null,
"reasoning": null,
"finish_reason": null,
"prompt_tokens": null,
"completion_tokens": null,
"cached_prompt_tokens": null,
"command": null,
"exit_code": null,
"timed_out": null,
... | import Aegis.MaximumLength.Code.Funs
/-!
# Specifications of `Aegis.MaximumLength.maximum_length`
LeetCode problem `find-the-maximum-length-of-valid-subsequence-i`. Each `spec_<n>` theorem states one property of the function.
-/
open Aeneas Aeneas.Std Result ControlFlow Error
set_option autoImplicit false
namespac... | 13 | |
find-the-maximum-length-of-valid-subsequence-ii | 3,202 | Medium | [
"Array",
"Dynamic Programming"
] | You are given an integer array nums and a positive integer k.
A subsequence sub of nums with length x is called valid if it satisfies:
(sub[0] + sub[1]) % k == (sub[1] + sub[2]) % k == ... == (sub[x - 2] + sub[x - 1]) % k.
Return the length of the longest valid subsequence of nums.
Example 1:
Input: nums = [1,2,3,... | maximumLength(nums: list_int, k: int) -> int | pub fn maximum_length(nums: &[i64], k: i64) -> i64 | Aegis.MaximumLength.maximum_length | pub fn maximum_length(nums: &[i64], k: i64) -> i64 {
let k_usize = k as usize;
let n = nums.len();
let mut ans: i64 = 0;
let mut target: usize = 0;
while target < k_usize {
let target_i64 = target as i64;
let mut dp: Vec<i64> = Vec::new();
let mut i: usize = 0;
whil... | -- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS
-- [maximum_length]: type definitions
module
public import Aeneas
@[expose] public section
open Aeneas Aeneas.Std Result ControlFlow Error
set_option linter.dupNamespace false
set_option linter.hashCommand false
set_option linter.unusedVariables false
set_option linter... | -- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS
-- [maximum_length]: function definitions
module
public import Aeneas
public import Aegis.MaximumLength.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.MaximumLength.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, 6, 8, 10], 4]",
"output": "3"
},
{
"input": "[[5, 5, 5, 5, 5], 5]",
"output": "5"
},
{
"input": "[[5, 10, 15, 20, 25], 5]",
"output": "5"
},
{
"input": "[[2, 4, 6, 8, 10], 4]",
"output": "5"
},
{
"input": "[[1, 2, 3, 4, 5], 2]",
"output": "5"
... | 125 | false | 125 | verified | 10 | 10 | 1 | 2,906 | [
{
"type": "run_start",
"phase": "",
"model": null,
"messages": null,
"response": null,
"reasoning": null,
"finish_reason": null,
"prompt_tokens": null,
"completion_tokens": null,
"cached_prompt_tokens": null,
"command": null,
"exit_code": null,
"timed_out": null,
... | import Aegis.MaximumLength.Code.Funs
/-!
# Specifications of `Aegis.MaximumLength.maximum_length`
LeetCode problem `find-the-maximum-length-of-valid-subsequence-ii`. Each `spec_<n>` theorem states one property of the function.
-/
open Aeneas Aeneas.Std Result
open Aegis.MaximumLength
namespace AegisSpec.MaximumLeng... | 11 | |
maximum-array-hopping-score-i | 3,205 | Medium | [
"Stack",
"Greedy",
"Array",
"Dynamic Programming",
"Monotonic Stack"
] | Given an array nums, you have to get the maximum score starting from index 0 and hopping until you reach the last element of the array.
In each hop, you can jump from index i to an index j > i, and you get a score of (j - i) * nums[j].
Return the maximum score you can get.
Example 1:
Input: nums = [1,5,8]
Output: 16... | 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();
let mut dp: Vec<i64> = Vec::new();
dp.push(0);
let mut j: usize = 1;
let mut j_dist: i64 = 1;
while j < n {
let mut i: usize = 0;
let mut dist: i64 = j_dist;
let mut best: i64 = 0;
while i < j {
... | -- 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, 5, 8]]",
"output": "16"
},
{
"input": "[[5, 4, 3, 2, 1]]",
"output": "10"
},
{
"input": "[[3, 4, 5, 6, 7]]",
"output": "28"
},
{
"input": "[[3, 2, 1, 4, 5]]",
"output": "20"
},
{
"input": "[[2, 3, 4, 5, 6]]",
"output": "24"
},
{
"input... | 105 | false | 105 | verified | 10 | 10 | 1 | 2,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.MaxScore.Code.Funs
/-!
# Specifications of `Aegis.MaxScore.max_score`
LeetCode problem `maximum-array-hopping-score-i`. Each `spec_<n>` theorem states one property of the function.
-/
open Aeneas Aeneas.Std Result
namespace AegisSpec.MaxScore
open Aegis.MaxScore
def len (nums : Slice Std.I64) : Nat :... | 13 | |
alternating-groups-i | 3,206 | Easy | [
"Array",
"Sliding Window"
] | There is a circle of red and blue tiles. You are given an array of integers colors. The color of tile i is represented by colors[i]:
colors[i] == 0 means that tile i is red.
colors[i] == 1 means that tile i is blue.
Every 3 contiguous tiles in the circle with alternating colors (the middle tile has a different color ... | numberOfAlternatingGroups(colors: list_int) -> int | pub fn number_of_alternating_groups(colors: &[i64]) -> i64 | Aegis.NumberOfAlternatingGroups.number_of_alternating_groups | pub fn number_of_alternating_groups(colors: &[i64]) -> i64 {
let n: usize = colors.len();
let mut count: i64 = 0;
let mut i: usize = 0;
while i < n {
let left_index: usize = if i == 0 { n - 1 } else { i - 1 };
let right_index: usize = if i + 1 == n { 0 } else { i + 1 };
let lef... | -- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS
-- [number_of_alternating_groups]: type definitions
module
public import Aeneas
@[expose] public section
open Aeneas Aeneas.Std Result ControlFlow Error
set_option linter.dupNamespace false
set_option linter.hashCommand false
set_option linter.unusedVariables false
set... | -- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS
-- [number_of_alternating_groups]: function definitions
module
public import Aeneas
public import Aegis.NumberOfAlternatingGroups.Code.Types
@[expose] public section
open Aeneas Aeneas.Std Result ControlFlow Error
set_option linter.dupNamespace false
set_option linter.... | import Aegis.NumberOfAlternatingGroups.Code.Funs
open Aeneas Aeneas.Std Result
set_option maxHeartbeats 4000000
set_option maxRecDepth 4096
def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do
let h ← IO.FS.Handle.mk path .append
h.putStrLn s!"CASE {i} {b}"
h.flush
IO.println s!"CASE {i} {b}"
#... | [
{
"input": "[[1, 1, 1]]",
"output": "0"
},
{
"input": "[[0, 1, 0, 1, 0]]",
"output": "3"
},
{
"input": "[[1, 0, 1, 0, 1]]",
"output": "3"
},
{
"input": "[[0, 1, 0, 0, 1]]",
"output": "3"
},
{
"input": "[[0, 1, 1, 0, 0, 1]]",
"output": "2"
},
{
"input":... | 131 | false | 131 | verified | 10 | 10 | 1 | 866 | [
{
"type": "run_start",
"phase": "",
"model": null,
"messages": null,
"response": null,
"reasoning": null,
"finish_reason": null,
"prompt_tokens": null,
"completion_tokens": null,
"cached_prompt_tokens": null,
"command": null,
"exit_code": null,
"timed_out": null,
... | import Aegis.NumberOfAlternatingGroups.Code.Funs
/-!
# Specifications of `Aegis.NumberOfAlternatingGroups.number_of_alternating_groups`
LeetCode problem `alternating-groups-i`. Each `spec_<n>` theorem states one property of the function.
-/
open Aeneas Aeneas.Std Result
namespace AegisSpec.NumberOfAlternatingGrou... | 11 | |
maximum-points-after-enemy-battles | 3,207 | Medium | [
"Greedy",
"Array"
] | You are given an integer array enemyEnergies denoting the energy values of various enemies.
You are also given an integer currentEnergy denoting the amount of energy you have initially.
You start with 0 points, and all the enemies are unmarked initially.
You can perform either of the following operations zero or multip... | maximumPoints(enemyEnergies: list_int, currentEnergy: int) -> int | pub fn maximum_points(enemyEnergies: &[i64], currentEnergy: i64) -> i64 | Aegis.MaximumPoints.maximum_points | pub fn maximum_points(enemyEnergies: &[i64], currentEnergy: i64) -> i64 {
let n = enemyEnergies.len();
if n == 0 {
return 0;
}
let mut min_energy = enemyEnergies[0];
let mut sum_energy: i64 = 0;
let mut i: usize = 0;
while i < n {
let energy = enemyEnergies[i];
sum_... | -- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS
-- [maximum_points]: type definitions
module
public import Aeneas
@[expose] public section
open Aeneas Aeneas.Std Result ControlFlow Error
set_option linter.dupNamespace false
set_option linter.hashCommand false
set_option linter.unusedVariables false
set_option linter... | -- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS
-- [maximum_points]: function definitions
module
public import Aeneas
public import Aegis.MaximumPoints.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.MaximumPoints.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], 10]",
"output": "5"
},
{
"input": "[[1], 0]",
"output": "0"
},
{
"input": "[[1000000000], 1000000000]",
"output": "1"
},
{
"input": "[[1, 1000000000, 1], 1000000001]",
"output": "2000000002"
},
{
"input": "[[3, 2, 2], 2]",
"output": "3"
},
... | 104 | false | 104 | verified | 10 | 10 | 1 | 868 | [
{
"type": "run_start",
"phase": "",
"model": null,
"messages": null,
"response": null,
"reasoning": null,
"finish_reason": null,
"prompt_tokens": null,
"completion_tokens": null,
"cached_prompt_tokens": null,
"command": null,
"exit_code": null,
"timed_out": null,
... | import Aegis.MaximumPoints.Code.Funs
/-!
# Specifications of `Aegis.MaximumPoints.maximum_points`
LeetCode problem `maximum-points-after-enemy-battles`. Each `spec_<n>` theorem states one property of the function.
-/
open Aeneas Aeneas.Std Result
namespace AegisSpec.MaximumPoints
def energies (enemyEnergies : Slic... | 8 | |
alternating-groups-ii | 3,208 | Medium | [
"Array",
"Sliding Window"
] | There is a circle of red and blue tiles. You are given an array of integers colors and an integer k. The color of tile i is represented by colors[i]:
colors[i] == 0 means that tile i is red.
colors[i] == 1 means that tile i is blue.
An alternating group is every k contiguous tiles in the circle with alternating color... | numberOfAlternatingGroups(colors: list_int, k: int) -> int | pub fn number_of_alternating_groups(colors: &[i64], k: i64) -> i64 | Aegis.NumberOfAlternatingGroups.number_of_alternating_groups | pub fn number_of_alternating_groups(colors: &[i64], k: i64) -> i64 {
let n = colors.len();
let m = (k - 1) as usize;
let mut edges: Vec<i64> = Vec::new();
let mut i: usize = 0;
while i < n {
let next = if i + 1 < n { i + 1 } else { 0 };
if colors[i] != colors[next] {
edg... | -- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS
-- [number_of_alternating_groups]: type definitions
module
public import Aeneas
@[expose] public section
open Aeneas Aeneas.Std Result ControlFlow Error
set_option linter.dupNamespace false
set_option linter.hashCommand false
set_option linter.unusedVariables false
set... | -- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS
-- [number_of_alternating_groups]: function definitions
module
public import Aeneas
public import Aegis.NumberOfAlternatingGroups.Code.Types
@[expose] public section
open Aeneas Aeneas.Std Result ControlFlow Error
set_option linter.dupNamespace false
set_option linter.... | import Aegis.NumberOfAlternatingGroups.Code.Funs
open Aeneas Aeneas.Std Result
set_option maxHeartbeats 4000000
set_option maxRecDepth 4096
def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do
let h ← IO.FS.Handle.mk path .append
h.putStrLn s!"CASE {i} {b}"
h.flush
IO.println s!"CASE {i} {b}"
#... | [
{
"input": "[[1, 1, 0, 1], 4]",
"output": "0"
},
{
"input": "[[0, 1, 0, 1, 0], 3]",
"output": "3"
},
{
"input": "[[0, 1, 0, 0, 1, 0, 1], 6]",
"output": "2"
},
{
"input": "[[1, 0, 1, 0, 1, 0, 1, 0], 3]",
"output": "8"
},
{
"input": "[[0, 0, 1, 1, 0, 0, 1, 1], 4]",
... | 103 | false | 103 | verified | 10 | 10 | 1 | 4,671 | [
{
"type": "run_start",
"phase": "",
"model": null,
"messages": null,
"response": null,
"reasoning": null,
"finish_reason": null,
"prompt_tokens": null,
"completion_tokens": null,
"cached_prompt_tokens": null,
"command": null,
"exit_code": null,
"timed_out": null,
... | import Aegis.NumberOfAlternatingGroups.Code.Funs
/-!
# Specifications of `Aegis.NumberOfAlternatingGroups.number_of_alternating_groups`
LeetCode problem `alternating-groups-ii`. Each `spec_<n>` theorem states one property of the function.
-/
open Aeneas Aeneas.Std Result
namespace AegisSpec.NumberOfAlternatingGro... | 14 | |
number-of-subarrays-with-and-value-of-k | 3,209 | Hard | [
"Bit Manipulation",
"Segment Tree",
"Array",
"Binary Search"
] | Given an array of integers nums and an integer k, return the number of subarrays of nums where the bitwise AND of the elements of the subarray equals k.
Example 1:
Input: nums = [1,1,1], k = 1
Output: 6
Explanation:
All subarrays contain only 1's.
Example 2:
Input: nums = [1,1,2], k = 1
Output: 3
Explanation:
Suba... | countSubarrays(nums: list_int, k: int) -> int | pub fn count_subarrays(nums: &[i64], k: i64) -> i64 | Aegis.CountSubarrays.count_subarrays | pub fn count_subarrays(nums: &[i64], k: i64) -> i64 {
let mut prev_vals: Vec<i64> = Vec::new();
let mut prev_counts: Vec<i64> = Vec::new();
let mut ans: i64 = 0;
let n = nums.len();
let mut i: usize = 0;
while i < n {
let x = nums[i];
let mut curr_vals: Vec<i64> = Vec::new();
... | -- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS
-- [count_subarrays]: type definitions
module
public import Aeneas
@[expose] public section
open Aeneas Aeneas.Std Result ControlFlow Error
set_option linter.dupNamespace false
set_option linter.hashCommand false
set_option linter.unusedVariables false
set_option linte... | -- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS
-- [count_subarrays]: function definitions
module
public import Aeneas
public import Aegis.CountSubarrays.Code.Types
@[expose] public section
open Aeneas Aeneas.Std Result ControlFlow Error
set_option linter.dupNamespace false
set_option linter.hashCommand false
set_op... | import Aegis.CountSubarrays.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": "[[1, 2, 3], 2]",
"output": "2"
},
{
"input": "[[1000000000, 1000000000, 1000000000], 1000000000]",
"output": "6"
},
{
"input": "[[1, 1, 1], 1]",
"output": "6"
},
{
"input": "[[1, 1, 2], 1]",
"output": "3"
},
{
"input": "[[0, 0, 0], 0]",
"output": "... | 127 | false | 127 | verified | 10 | 10 | 1 | 3,586 | [
{
"type": "run_start",
"phase": "",
"model": null,
"messages": null,
"response": null,
"reasoning": null,
"finish_reason": null,
"prompt_tokens": null,
"completion_tokens": null,
"cached_prompt_tokens": null,
"command": null,
"exit_code": null,
"timed_out": null,
... | import Aegis.CountSubarrays.Code.Funs
/-!
# Specifications of `Aegis.CountSubarrays.count_subarrays`
LeetCode problem `number-of-subarrays-with-and-value-of-k`. Each `spec_<n>` theorem states one property of the function.
-/
open Aeneas Aeneas.Std Result
namespace AegisSpec.CountSubarrays
open Aegis.CountSubarrays... | 11 | |
generate-binary-strings-without-adjacent-zeros | 3,211 | Medium | [
"Bit Manipulation",
"String",
"Backtracking"
] | You are given a positive integer n.
A binary string x is valid if all substrings of x of length 2 contain at least one "1".
Return all valid strings with length n, in any order.
Example 1:
Input: n = 3
Output: ["010","011","101","110","111"]
Explanation:
The valid strings of length 3 are: "010", "011", "101", "110",... | validStrings(n: int) -> list_str | pub fn valid_strings(n: i64) -> Vec<Vec<u8>> | Aegis.ValidStrings.valid_strings | pub fn valid_strings(n: i64) -> Vec<Vec<u8>> {
let mut cur: Vec<Vec<u8>> = Vec::new();
let empty: Vec<u8> = Vec::new();
cur.push(empty);
let mut pos: i64 = 0;
while pos < n {
let mut next: Vec<Vec<u8>> = Vec::new();
let count = cur.len();
let mut i: usize = 0;
while... | -- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS
-- [valid_strings]: type definitions
module
public import Aeneas
@[expose] public section
open Aeneas Aeneas.Std Result ControlFlow Error
set_option linter.dupNamespace false
set_option linter.hashCommand false
set_option linter.unusedVariables false
set_option linter.... | -- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS
-- [valid_strings]: function definitions
module
public import Aeneas
public import Aegis.ValidStrings.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.ValidStrings.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\", \"1\"]"
},
{
"input": "[2]",
"output": "[\"01\", \"10\", \"11\"]"
},
{
"input": "[3]",
"output": "[\"010\", \"011\", \"101\", \"110\", \"111\"]"
},
{
"input": "[4]",
"output": "[\"0101\", \"0110\", \"0111\", \"1010\", \"1011\", \"1101\... | 11 | true | 11 | verified_partial | 10 | 7 | 1 | 2,342 | [
{
"type": "run_start",
"phase": "",
"model": null,
"messages": null,
"response": null,
"reasoning": null,
"finish_reason": null,
"prompt_tokens": null,
"completion_tokens": null,
"cached_prompt_tokens": null,
"command": null,
"exit_code": null,
"timed_out": null,
... | import Aegis.ValidStrings.Code.Funs
/-!
# Specifications of `Aegis.ValidStrings.valid_strings`
LeetCode problem `generate-binary-strings-without-adjacent-zeros`. Each `spec_<n>` theorem states one property of the function.
-/
open Aeneas Aeneas.Std Result ControlFlow Error
namespace AegisSpec.ValidStrings
def IsBi... | 9 | |
count-triplets-with-even-xor-set-bits-ii | 3,215 | Medium | [
"Bit Manipulation",
"Array"
] | Given three integer arrays a, b, and c, return the number of triplets (a[i], b[j], c[k]), such that the bitwise XOR between the elements of each triplet has an even number of set bits.
Example 1:
Input: a = [1], b = [2], c = [3]
Output: 1
Explanation:
The only triplet is (a[0], b[0], c[0]) and their XOR is: 1 XOR 2 ... | tripletCount(a: list_int, b: list_int, c: list_int) -> int | pub fn triplet_count(a: &[i64], b: &[i64], c: &[i64]) -> i64 | Aegis.TripletCount.triplet_count | fn odd_popcount(mut x: i64) -> bool {
let mut odd = false;
while x != 0 {
odd = !odd;
x = x & (x - 1);
}
odd
}
pub fn triplet_count(a: &[i64], b: &[i64], c: &[i64]) -> i64 {
let mut a_even: i64 = 0;
let mut a_odd: i64 = 0;
let mut b_even: i64 = 0;
let mut b_odd: i64 = 0;... | -- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS
-- [triplet_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
-- [triplet_count]: function definitions
module
public import Aeneas
public import Aegis.TripletCount.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.TripletCount.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": "[[1000000000], [1000000000], [1000000000]]",
"output": "0"
},
{
"input": "[[1], [2], [3]]",
"output": "1"
},
{
"input": "[[1, 1], [2, 3], [1, 5]]",
"output": "4"
},
{
"input": "[[10, 20, 30], [15, 25, 35], [5, 10, 15]]",
"output": "9"
},
{
"input": "[[... | 73 | false | 73 | verified | 10 | 10 | 1 | 2,329 | [
{
"type": "run_start",
"phase": "",
"model": null,
"messages": null,
"response": null,
"reasoning": null,
"finish_reason": null,
"prompt_tokens": null,
"completion_tokens": null,
"cached_prompt_tokens": null,
"command": null,
"exit_code": null,
"timed_out": null,
... | import Aegis.TripletCount.Code.Funs
/-!
# Specifications of `Aegis.TripletCount.triplet_count`
LeetCode problem `count-triplets-with-even-xor-set-bits-ii`. Each `spec_<n>` theorem states one property of the function.
-/
open Aeneas Aeneas.Std Result
open Aegis.TripletCount (triplet_count)
namespace AegisSpec.Triple... | 14 | |
delete-nodes-from-linked-list-present-in-array | 3,217 | Medium | [
"Array",
"Hash Table",
"Linked List"
] | You are given an array of integers nums and the head of a linked list. Return the head of the modified linked list after removing all nodes from the linked list that have a value that exists in nums.
Example 1:
Input: nums = [1,2,3], head = [1,2,3,4,5]
Output: [4,5]
Explanation:
Remove the nodes with values 1, 2, a... | modifiedList(nums: list_int, head: linkedlist) -> linkedlist | pub fn modified_list(nums: &[i64], head: &List) -> List | Aegis.ModifiedList.modified_list | pub fn modified_list(nums: &[i64], head: &List) -> List {
let mut sorted: Vec<i64> = Vec::new();
let mut idx: usize = 0;
while idx < nums.len() {
sorted.push(nums[idx]);
idx += 1;
}
let n: usize = sorted.len();
if n > 1 {
let mut tmp: Vec<i64> = Vec::new();
let ... | -- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS
-- [modified_list]: type definitions
module
public import Aeneas
@[expose] public section
open Aeneas Aeneas.Std Result ControlFlow Error
set_option linter.dupNamespace false
set_option linter.hashCommand false
set_option linter.unusedVariables false
set_option linter.... | -- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS
-- [modified_list]: function definitions
module
public import Aeneas
public import Aegis.ModifiedList.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.ModifiedList.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 insta... | [
{
"input": "[[100000], [99999, 100000, 100001]]",
"output": "[99999, 100001]"
},
{
"input": "[[10], [1, 10, 100, 1000]]",
"output": "[1, 100, 1000]"
},
{
"input": "[[100000], [50000, 100000, 150000, 200000]]",
"output": "[50000, 150000, 200000]"
},
{
"input": "[[5], [1, 2, 3,... | 86 | false | 86 | verified | 10 | 10 | 2 | 15,671 | [
{
"type": "run_start",
"phase": "",
"model": null,
"messages": null,
"response": null,
"reasoning": null,
"finish_reason": null,
"prompt_tokens": null,
"completion_tokens": null,
"cached_prompt_tokens": null,
"command": null,
"exit_code": null,
"timed_out": null,
... | import Aegis.ModifiedList.Code.Funs
/-!
# Specifications of `Aegis.ModifiedList.modified_list`
LeetCode problem `delete-nodes-from-linked-list-present-in-array`. Each `spec_<n>` theorem states one property of the function.
-/
open Aeneas Aeneas.Std Result
namespace AegisSpec.ModifiedList
def vals : Aegis.Modif... | 12 | |
minimum-cost-for-cutting-cake-ii | 3,219 | Hard | [
"Greedy",
"Array",
"Sorting"
] | There is an m x n cake that needs to be cut into 1 x 1 pieces.
You are given integers m, n, and two arrays:
horizontalCut of size m - 1, where horizontalCut[i] represents the cost to cut along the horizontal line i.
verticalCut of size n - 1, where verticalCut[j] represents the cost to cut along the vertical line j.
... | minimumCost(m: int, n: int, horizontalCut: list_int, verticalCut: list_int) -> int | pub fn minimum_cost(m: i64, n: i64, horizontalCut: &[i64], verticalCut: &[i64]) -> i64 | Aegis.MinimumCost.minimum_cost | fn sort_asc(mut a: Vec<i64>) -> Vec<i64> {
let n = a.len();
if n <= 1 {
return a;
}
let mut b: Vec<i64> = Vec::new();
let mut t: usize = 0;
while t < n {
b.push(0);
t += 1;
}
let mut width: usize = 1;
while width < n {
let mut l: usize = 0;
w... | -- 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": "[2, 2, [7], [4]]",
"output": "15"
},
{
"input": "[3, 2, [1, 3], [5]]",
"output": "13"
},
{
"input": "[3, 3, [1, 2], [1, 2]]",
"output": "11"
},
{
"input": "[4, 3, [1, 2, 3], [1, 2]]",
"output": "17"
},
{
"input": "[4, 3, [2, 4, 6], [1, 3, 5]]",
"ou... | 27 | false | 27 | verified | 10 | 10 | 2 | 21,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.MinimumCost.Code.Funs
/-!
# Specifications of `Aegis.MinimumCost.minimum_cost`
LeetCode problem `minimum-cost-for-cutting-cake-ii`. Each `spec_<n>` theorem states one property of the function.
-/
open Aeneas Aeneas.Std Result
open Aegis.MinimumCost
namespace AegisSpec.MinimumCost
def values (l : List ... | 17 | |
maximum-array-hopping-score-ii | 3,221 | Medium | [
"Stack",
"Greedy",
"Array",
"Monotonic Stack"
] | Given an array nums, you have to get the maximum score starting from index 0 and hopping until you reach the last element of the array.
In each hop, you can jump from index i to an index j > i, and you get a score of (j - i) * nums[j].
Return the maximum score you can get.
Example 1:
Input: nums = [1,5,8]
Output: 16... | 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();
let mut maxv: i64 = nums[n - 1];
let mut ans: i64 = 0;
let mut i: usize = n - 1;
while i > 0 {
if nums[i] > maxv {
maxv = nums[i];
}
ans = ans + maxv;
i = i - 1;
}
ans
}
| -- 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, 5, 8]]",
"output": "16"
},
{
"input": "[[2, 3, 1, 4]]",
"output": "12"
},
{
"input": "[[5, 4, 3, 2, 1]]",
"output": "10"
},
{
"input": "[[2, 3, 7, 8, 4]]",
"output": "28"
},
{
"input": "[[1, 1, 1, 1, 1]]",
"output": "4"
},
{
"input": "... | 109 | false | 109 | verified | 10 | 10 | 1 | 6,893 | [
{
"type": "run_start",
"phase": "",
"model": null,
"messages": null,
"response": null,
"reasoning": 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-array-hopping-score-ii`. Each `spec_<n>` theorem states one property of the function.
-/
open Aeneas Aeneas.Std Result ControlFlow Error
open Aeneas.Std.Result
namespace AegisSpec.MaxScore
def numLen ... | 13 | |
minimum-length-of-string-after-operations | 3,223 | Medium | [
"Hash Table",
"String",
"Counting"
] | You are given a string s.
You can perform the following process on s any number of times:
Choose an index i in the string such that there is at least one character to the left of index i that is equal to s[i], and at least one character to the right that is also equal to s[i].
Delete the closest occurrence of s[i] loc... | minimumLength(s: str) -> int | pub fn minimum_length(s: &[u8]) -> i64 | Aegis.MinimumLength.minimum_length | pub fn minimum_length(s: &[u8]) -> i64 {
let mut counts: Vec<i64> = Vec::new();
let mut k: usize = 0;
while k < 26 {
counts.push(0);
k += 1;
}
let n: usize = s.len();
let mut i: usize = 0;
while i < n {
let idx: usize = (s[i] - b'a') as usize;
counts[idx] = c... | -- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS
-- [minimum_length]: type definitions
module
public import Aeneas
@[expose] public section
open Aeneas Aeneas.Std Result ControlFlow Error
set_option linter.dupNamespace false
set_option linter.hashCommand false
set_option linter.unusedVariables false
set_option linter... | -- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS
-- [minimum_length]: function definitions
module
public import Aeneas
public import Aegis.MinimumLength.Code.Types
@[expose] public section
open Aeneas Aeneas.Std Result ControlFlow Error
set_option linter.dupNamespace false
set_option linter.hashCommand false
set_opti... | import Aegis.MinimumLength.Code.Funs
open Aeneas Aeneas.Std Result
set_option maxHeartbeats 4000000
set_option maxRecDepth 4096
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": "[\"zzzzyzyzyyzzyzz\"]",
"output": "3"
},
{
"input": "[\"abcba\"]",
"output": "5"
},
{
"input": "[\"abcdefghijklmnopqrstuvwxyz\"]",
"output": "26"
},
{
"input": "[\"abaacbcbb\"]",
"output": "5"
},
{
"input": "[\"aabbaa\"]",
"output": "4"
},
{
... | 47 | false | 47 | verified | 10 | 10 | 1 | 1,168 | [
{
"type": "run_start",
"phase": "",
"model": null,
"messages": null,
"response": null,
"reasoning": null,
"finish_reason": null,
"prompt_tokens": null,
"completion_tokens": null,
"cached_prompt_tokens": null,
"command": null,
"exit_code": null,
"timed_out": null,
... | import Aegis.MinimumLength.Code.Funs
/-!
# Specifications of `Aegis.MinimumLength.minimum_length`
LeetCode problem `minimum-length-of-string-after-operations`. Each `spec_<n>` theorem states one property of the function.
-/
open Aeneas Aeneas.Std Result
namespace AegisSpec.MinimumLength
def isLowerByte (b : Ae... | 9 | |
minimum-array-changes-to-make-differences-equal | 3,224 | Medium | [
"Array",
"Hash Table",
"Prefix Sum"
] | You are given an integer array nums of size n where n is even, and an integer k.
You can perform some changes on the array, where in one change you can replace any element in the array with any integer in the range from 0 to k.
You need to perform some changes (possibly none) such that the final array satisfies the fol... | minChanges(nums: list_int, k: int) -> int | pub fn min_changes(nums: &[i64], k: i64) -> i64 | Aegis.MinChanges.min_changes | pub fn min_changes(nums: &[i64], k: i64) -> i64 {
let n: usize = nums.len();
let m: usize = n / 2;
let mut diffs: Vec<i64> = Vec::new();
let mut thresh: Vec<i64> = Vec::new();
let mut p: usize = 0;
while p < m {
let a: i64 = nums[p];
let b: i64 = nums[n - p - 1];
let m... | -- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS
-- [min_changes]: type definitions
module
public import Aeneas
@[expose] public section
open Aeneas Aeneas.Std Result ControlFlow Error
set_option linter.dupNamespace false
set_option linter.hashCommand false
set_option linter.unusedVariables false
set_option linter.st... | -- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS
-- [min_changes]: function definitions
module
public import Aeneas
public import Aegis.MinChanges.Code.Types
public import Aegis.MinChanges.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
-- [min_changes]: external functions.
-- This is a template file: rename it to "FunsExternal.lean" and fill the holes.
module
public import Aeneas
public import Aegis.MinChanges.Code.Types
@[expose] public section
open Aeneas Aeneas.Std Result ControlFlow Error
set_opt... | import Aegis.MinChanges.Code.Funs
open Aeneas Aeneas.Std Result
set_option maxHeartbeats 4000000
set_option maxRecDepth 4096
def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do
let h ← IO.FS.Handle.mk path .append
h.putStrLn s!"CASE {i} {b}"
h.flush
IO.println s!"CASE {i} {b}"
#eval aegisCase ... | [
{
"input": "[[5, 5, 5, 5], 5]",
"output": "0"
},
{
"input": "[[100000, 99999, 99998, 99997, 99996, 99995], 100000]",
"output": "2"
},
{
"input": "[[10, 9, 8, 7, 6, 5], 10]",
"output": "2"
},
{
"input": "[[1, 0, 1, 2, 4, 3], 4]",
"output": "2"
},
{
"input": "[[0, 2... | 101 | false | 101 | verified | 10 | 10 | 2 | 22,492 | [
{
"type": "run_start",
"phase": "",
"model": null,
"messages": null,
"response": null,
"reasoning": null,
"finish_reason": null,
"prompt_tokens": null,
"completion_tokens": null,
"cached_prompt_tokens": null,
"command": null,
"exit_code": null,
"timed_out": null,
... | import Aegis.MinChanges.Code.Funs
/-!
# Specifications of `Aegis.MinChanges.min_changes`
LeetCode problem `minimum-array-changes-to-make-differences-equal`. Each `spec_<n>` theorem states one property of the function.
-/
open Aeneas Aeneas.Std Result
namespace AegisSpec.MinChanges
def ivs (s : Slice I64) : List ℤ ... | 14 |
maximum-score-from-grid-operations | 3,225 | Hard | [
"Array",
"Dynamic Programming",
"Matrix",
"Prefix Sum"
] | You are given a 2D matrix grid of size n x n. Initially, all cells of the grid are colored white. In one operation, you can select any cell of indices (i, j), and color black all the cells of the jth column starting from the top row down to the ith row.
The grid score is the sum of all grid[i][j] such that cell (i, j) ... | maximumScore(grid: list_list_int) -> int | pub fn maximum_score(grid: &[Vec<i64>]) -> i64 | Aegis.MaximumScore.maximum_score | pub fn maximum_score(grid: &[Vec<i64>]) -> i64 {
let n = grid.len();
if n == 0 {
return 0;
}
let m = n + 1;
let neg: i64 = -1000000000000000000;
let valid_cut: i64 = -500000000000000000;
// Column-major prefix sums:
// pref[col * m + t] = sum of grid[0..t-1][col].
let mut p... | -- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS
-- [maximum_score]: type definitions
module
public import Aeneas
@[expose] public section
open Aeneas Aeneas.Std Result ControlFlow Error
set_option linter.dupNamespace false
set_option linter.hashCommand false
set_option linter.unusedVariables false
set_option linter.... | -- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS
-- [maximum_score]: function definitions
module
public import Aeneas
public import Aegis.MaximumScore.Code.Types
@[expose] public section
open Aeneas Aeneas.Std Result ControlFlow Error
set_option linter.dupNamespace false
set_option linter.hashCommand false
set_option... | import Aegis.MaximumScore.Code.Funs
open Aeneas Aeneas.Std Result
set_option maxHeartbeats 4000000
set_option maxRecDepth 4096
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, 0], [0, 0]]]",
"output": "0"
},
{
"input": "[[[5, 5, 5], [5, 5, 5], [5, 5, 5]]]",
"output": "30"
},
{
"input": "[[[1, 2, 3], [4, 5, 6], [7, 8, 9]]]",
"output": "30"
},
{
"input": "[[[1, 0, 0], [0, 1, 0], [0, 0, 1]]]",
"output": "2"
},
{
"input": ... | 75 | false | 75 | verified | 10 | 10 | 1 | 19,798 | [
{
"type": "run_start",
"phase": "",
"model": null,
"messages": null,
"response": null,
"reasoning": null,
"finish_reason": null,
"prompt_tokens": null,
"completion_tokens": null,
"cached_prompt_tokens": null,
"command": null,
"exit_code": null,
"timed_out": null,
... | import Aegis.MaximumScore.Code.Funs
/-!
# Specifications of `Aegis.MaximumScore.maximum_score`
LeetCode problem `maximum-score-from-grid-operations`. Each `spec_<n>` theorem states one property of the function.
-/
open Aeneas Aeneas.Std Result
namespace AegisSpec.MaximumScore
def entries (grid : Slice (alloc.vec.V... | 10 | |
number-of-bit-changes-to-make-two-integers-equal | 3,226 | Easy | [
"Bit Manipulation"
] | You are given two positive integers n and k.
You can choose any bit in the binary representation of n that is equal to 1 and change it to 0.
Return the number of changes needed to make n equal to k. If it is impossible, return -1.
Example 1:
Input: n = 13, k = 4
Output: 2
Explanation:
Initially, the binary represent... | minChanges(n: int, k: int) -> int | pub fn min_changes(n: i64, k: i64) -> i64 | Aegis.MinChanges.min_changes | pub fn min_changes(n: i64, k: i64) -> i64 {
let mut a = n;
let mut b = k;
let mut count: i64 = 0;
while a > 0 || b > 0 {
let abit = a % 2;
let bbit = b % 2;
if bbit == 1 && abit == 0 {
return -1;
}
if abit == 1 && bbit == 0 {
count += 1;... | -- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS
-- [min_changes]: type definitions
module
public import Aeneas
@[expose] public section
open Aeneas Aeneas.Std Result ControlFlow Error
set_option linter.dupNamespace false
set_option linter.hashCommand false
set_option linter.unusedVariables false
set_option linter.st... | -- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS
-- [min_changes]: function definitions
module
public import Aeneas
public import Aegis.MinChanges.Code.Types
@[expose] public section
open Aeneas Aeneas.Std Result ControlFlow Error
set_option linter.dupNamespace false
set_option linter.hashCommand false
set_option lin... | import Aegis.MinChanges.Code.Funs
open Aeneas Aeneas.Std Result
set_option maxHeartbeats 4000000
set_option maxRecDepth 4096
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": "-1"
},
{
"input": "[31, 1]",
"output": "4"
},
{
"input": "[15, 9]",
"output": "2"
},
{
"input": "[8, 8]",
"output": "0"
},
{
"input": "[1000000, 999999]",
"output": "-1"
},
{
"input": "[7, 11]",
"output": "-1"
},
... | 91 | false | 91 | verified | 10 | 10 | 1 | 904 | [
{
"type": "run_start",
"phase": "",
"model": null,
"messages": null,
"response": null,
"reasoning": null,
"finish_reason": null,
"prompt_tokens": null,
"completion_tokens": null,
"cached_prompt_tokens": null,
"command": null,
"exit_code": null,
"timed_out": null,
... | import Aegis.MinChanges.Code.Funs
/-!
# Specifications of `Aegis.MinChanges.min_changes`
LeetCode problem `number-of-bit-changes-to-make-two-integers-equal`. Each `spec_<n>` theorem states one property of the function.
-/
open Aeneas Aeneas.Std Result
open Aegis.MinChanges
namespace AegisSpec.MinChanges
def bit (x... | 11 | |
vowels-game-in-a-string | 3,227 | Medium | [
"Brainteaser",
"Math",
"String",
"Game Theory"
] | Alice and Bob are playing a game on a string.
You are given a string s, Alice and Bob will take turns playing the following game where Alice starts first:
On Alice's turn, she has to remove any non-empty substring from s that contains an odd number of vowels.
On Bob's turn, he has to remove any non-empty substring fro... | doesAliceWin(s: str) -> bool | pub fn does_alice_win(s: &[u8]) -> bool | Aegis.DoesAliceWin.does_alice_win | pub fn does_alice_win(s: &[u8]) -> bool {
let mut i: usize = 0;
while i < s.len() {
let c = s[i];
if c == b'a' || c == b'e' || c == b'i' || c == b'o' || c == b'u' {
return true;
}
i += 1;
}
false
}
| -- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS
-- [does_alice_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... | -- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS
-- [does_alice_win]: function definitions
module
public import Aeneas
public import Aegis.DoesAliceWin.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.DoesAliceWin.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": "[\"b\"]",
"output": "false"
},
{
"input": "[\"bcbcbc\"]",
"output": "false"
},
{
"input": "[\"leetcodeisfun\"]",
"output": "true"
},
{
"input": "[\"abcdefghijklmnopqrstuvwxyz\"]",
"output": "true"
},
{
"input": "[\"uoiea\"]",
"output": "true"
},
... | 121 | false | 121 | verified | 10 | 10 | 1 | 411 | [
{
"type": "run_start",
"phase": "",
"model": null,
"messages": null,
"response": null,
"reasoning": null,
"finish_reason": null,
"prompt_tokens": null,
"completion_tokens": null,
"cached_prompt_tokens": null,
"command": null,
"exit_code": null,
"timed_out": null,
... | import Aegis.DoesAliceWin.Code.Funs
/-!
# Specifications of `Aegis.DoesAliceWin.does_alice_win`
LeetCode problem `vowels-game-in-a-string`. Each `spec_<n>` theorem states one property of the function.
-/
open Aeneas Aeneas.Std Result
namespace AegisSpec.DoesAliceWin
def Vowel (c : Std.U8) : Prop :=
c.val =... | 3 | |
maximum-number-of-operations-to-move-ones-to-the-end | 3,228 | Medium | [
"Greedy",
"String",
"Counting"
] | You are given a binary string s.
You can perform the following operation on the string any number of times:
Choose any index i from the string where i + 1 < s.length such that s[i] == '1' and s[i + 1] == '0'.
Move the character s[i] to the right until it reaches the end of the string or another '1'. For example, for s... | maxOperations(s: str) -> int | pub fn max_operations(s: &[u8]) -> i64 | Aegis.MaxOperations.max_operations | pub fn max_operations(s: &[u8]) -> i64 {
let mut ans: i64 = 0;
let mut ones: i64 = 0;
let n: usize = s.len();
let mut i: usize = 0;
while i < n {
if s[i] == b'1' {
ones += 1;
} else {
if i != 0 {
if s[i - 1] == b'1' {
ans +... | -- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS
-- [max_operations]: type definitions
module
public import Aeneas
@[expose] public section
open Aeneas Aeneas.Std Result ControlFlow Error
set_option linter.dupNamespace false
set_option linter.hashCommand false
set_option linter.unusedVariables false
set_option linter... | -- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS
-- [max_operations]: function definitions
module
public import Aeneas
public import Aegis.MaxOperations.Code.Types
@[expose] public section
open Aeneas Aeneas.Std Result ControlFlow Error
set_option linter.dupNamespace false
set_option linter.hashCommand false
set_opti... | import Aegis.MaxOperations.Code.Funs
open Aeneas Aeneas.Std Result
set_option maxHeartbeats 4000000
set_option maxRecDepth 4096
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": "[\"00111\"]",
"output": "0"
},
{
"input": "[\"101100110\"]",
"output": "9"
},
{
"input": "[\"000111000\"]",
"output": "3"
},
{
"input": "[\"11110000\"]",
"output": "4"
},
{
"input": "[\"010101010\"]",
"output": "10"
},
{
"input": "[\"100100... | 107 | false | 107 | verified | 10 | 10 | 1 | 2,441 | [
{
"type": "run_start",
"phase": "",
"model": null,
"messages": null,
"response": null,
"reasoning": null,
"finish_reason": null,
"prompt_tokens": null,
"completion_tokens": null,
"cached_prompt_tokens": null,
"command": null,
"exit_code": null,
"timed_out": null,
... | import Aegis.MaxOperations.Code.Funs
/-!
# Specifications of `Aegis.MaxOperations.max_operations`
LeetCode problem `maximum-number-of-operations-to-move-ones-to-the-end`. Each `spec_<n>` theorem states one property of the function.
-/
open Aeneas Aeneas.Std Result
namespace AegisSpec.MaxOperations
abbrev byteZero ... | 12 | |
minimum-operations-to-make-array-equal-to-target | 3,229 | Hard | [
"Stack",
"Greedy",
"Array",
"Dynamic Programming",
"Monotonic Stack"
] | You are given two positive integer arrays nums and target, of the same length.
In a single operation, you can select any subarray of nums and increment each element within that subarray by 1 or decrement each element within that subarray by 1.
Return the minimum number of operations required to make nums equal to the a... | minimumOperations(nums: list_int, target: list_int) -> int | pub fn minimum_operations(nums: &[i64], target: &[i64]) -> i64 | Aegis.MinimumOperations.minimum_operations | pub fn minimum_operations(nums: &[i64], target: &[i64]) -> i64 {
let n = nums.len();
let mut ans: i64 = 0;
let mut prev_pos: i64 = 0;
let mut prev_neg: i64 = 0;
let mut i: usize = 0;
while i < n {
let d = target[i] - nums[i];
let pos = if d > 0 { d } else { 0 };
let ne... | -- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS
-- [minimum_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 li... | -- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS
-- [minimum_operations]: function definitions
module
public import Aeneas
public import Aegis.MinimumOperations.Code.Types
@[expose] public section
open Aeneas Aeneas.Std Result ControlFlow Error
set_option linter.dupNamespace false
set_option linter.hashCommand false
... | import Aegis.MinimumOperations.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": "[[100000000], [100000000]]",
"output": "0"
},
{
"input": "[[100000000, 100000000], [1, 1]]",
"output": "99999999"
},
{
"input": "[[1, 100000000, 1], [100000000, 1, 100000000]]",
"output": "299999997"
},
{
"input": "[[1, 3, 2], [2, 1, 4]]",
"output": "5"
},
... | 117 | false | 117 | verified | 10 | 10 | 1 | 2,663 | [
{
"type": "run_start",
"phase": "",
"model": null,
"messages": null,
"response": null,
"reasoning": null,
"finish_reason": null,
"prompt_tokens": null,
"completion_tokens": null,
"cached_prompt_tokens": null,
"command": null,
"exit_code": null,
"timed_out": null,
... | import Aegis.MinimumOperations.Code.Funs
/-!
# Specifications of `Aegis.MinimumOperations.minimum_operations`
LeetCode problem `minimum-operations-to-make-array-equal-to-target`. Each `spec_<n>` theorem states one property of the function.
-/
open Aeneas Aeneas.Std Result
namespace AegisSpec.MinimumOperations
... | 11 | |
minimum-number-of-increasing-subsequence-to-be-removed | 3,231 | Hard | [
"Array",
"Binary Search"
] | Given an array of integers nums, you are allowed to perform the following operation any number of times:
Remove a strictly increasing subsequence from the array.
Your task is to find the minimum number of operations required to make the array empty.
Example 1:
Input: nums = [5,3,1,4,2]
Output: 3
Explanation:
We re... | minOperations(nums: list_int) -> int | pub fn min_operations(nums: &[i64]) -> i64 | Aegis.MinOperations.min_operations | pub fn min_operations(nums: &[i64]) -> i64 {
let n = nums.len();
let mut tails: Vec<i64> = Vec::new();
let mut i: usize = 0;
while i < n {
let x = nums[i];
// Find the first position where tails[pos] < x.
// tails is maintained in non-increasing order.
let mut lo: usize... | -- 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": "[[1]]",
"output": "1"
},
{
"input": "[[1, 2]]",
"output": "1"
},
{
"input": "[[1, 2, 3]]",
"output": "1"
},
{
"input": "[[1, 2, 3, 4, 5]]",
"output": "1"
},
{
"input": "[[1, 1, 1, 1, 1]]",
"output": "5"
},
{
"input": "[[5, 4, 3, 2, 1]]",
... | 119 | false | 119 | verified | 10 | 10 | 1 | 2,887 | [
{
"type": "run_start",
"phase": "",
"model": null,
"messages": null,
"response": null,
"reasoning": 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-increasing-subsequence-to-be-removed`. Each `spec_<n>` theorem states one property of the function.
-/
open Aeneas Aeneas.Std Result
namespace AegisSpec.MinOperations
def getInt... | 14 | |
find-if-digit-game-can-be-won | 3,232 | Easy | [
"Array",
"Math"
] | You are given an array of positive integers nums.
Alice and Bob are playing a game. In the game, Alice can choose either all single-digit numbers or all double-digit numbers from nums, and the rest of the numbers are given to Bob. Alice wins if the sum of her numbers is strictly greater than the sum of Bob's numbers.
R... | canAliceWin(nums: list_int) -> bool | pub fn can_alice_win(nums: &[i64]) -> bool | Aegis.CanAliceWin.can_alice_win | pub fn can_alice_win(nums: &[i64]) -> bool {
let mut single_sum: i64 = 0;
let mut double_sum: i64 = 0;
let mut i: usize = 0;
while i < nums.len() {
if nums[i] < 10 {
single_sum += nums[i];
} else {
double_sum += nums[i];
}
i += 1;
}
singl... | -- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS
-- [can_alice_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.... | -- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS
-- [can_alice_win]: function definitions
module
public import Aeneas
public import Aegis.CanAliceWin.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.CanAliceWin.Code.Funs
open Aeneas Aeneas.Std Result
set_option maxHeartbeats 4000000
set_option maxRecDepth 4096
def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do
let h ← IO.FS.Handle.mk path .append
h.putStrLn s!"CASE {i} {b}"
h.flush
IO.println s!"CASE {i} {b}"
#eval aegisCase... | [
{
"input": "[[5, 5, 5, 25]]",
"output": "true"
},
{
"input": "[[10, 20, 30, 40]]",
"output": "true"
},
{
"input": "[[9, 9, 9, 10, 10]]",
"output": "true"
},
{
"input": "[[1, 11, 111, 1111, 11111]]",
"output": "true"
},
{
"input": "[[1, 2, 3, 4, 10]]",
"output"... | 121 | false | 121 | verified | 10 | 10 | 1 | 1,235 | [
{
"type": "run_start",
"phase": "",
"model": null,
"messages": null,
"response": null,
"reasoning": null,
"finish_reason": null,
"prompt_tokens": null,
"completion_tokens": null,
"cached_prompt_tokens": null,
"command": null,
"exit_code": null,
"timed_out": null,
... | import Aegis.CanAliceWin.Code.Funs
/-!
# Specifications of `Aegis.CanAliceWin.can_alice_win`
LeetCode problem `find-if-digit-game-can-be-won`. Each `spec_<n>` theorem states one property of the function.
-/
open Aeneas Aeneas.Std Result
namespace AegisSpec.CanAliceWin
def Constraints (nums : Slice Std.I64) : Prop ... | 8 | |
find-the-count-of-numbers-which-are-not-special | 3,233 | Medium | [
"Array",
"Math",
"Number Theory"
] | You are given 2 positive integers l and r. For any number x, all positive divisors of x except x are called the proper divisors of x.
A number is called special if it has exactly 2 proper divisors. For example:
The number 4 is special because it has proper divisors 1 and 2.
The number 6 is not special because it has p... | nonSpecialCount(l: int, r: int) -> int | pub fn non_special_count(l: i64, r: i64) -> i64 | Aegis.NonSpecialCount.non_special_count | 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 non_special_count(l: i64, r: i64) -> i64 {
let total = r - l + 1;
let mut special: i64 = ... | -- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS
-- [non_special_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 lin... | -- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS
-- [non_special_count]: function definitions
module
public import Aeneas
public import Aegis.NonSpecialCount.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.NonSpecialCount.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, 200]",
"output": "99"
},
{
"input": "[5, 7]",
"output": "3"
},
{
"input": "[20, 50]",
"output": "29"
},
{
"input": "[1, 10]",
"output": "8"
},
{
"input": "[100, 150]",
"output": "50"
},
{
"input": "[4, 16]",
"output": "11"
},
... | 77 | false | 77 | verified | 10 | 10 | 1 | 1,586 | [
{
"type": "run_start",
"phase": "",
"model": null,
"messages": null,
"response": null,
"reasoning": null,
"finish_reason": null,
"prompt_tokens": null,
"completion_tokens": null,
"cached_prompt_tokens": null,
"command": null,
"exit_code": null,
"timed_out": null,
... | import Aegis.NonSpecialCount.Code.Funs
/-!
# Specifications of `Aegis.NonSpecialCount.non_special_count`
LeetCode problem `find-the-count-of-numbers-which-are-not-special`. Each `spec_<n>` theorem states one property of the function.
-/
open Aeneas Aeneas.Std Result
namespace AegisSpec.NonSpecialCount
def IsSpecia... | 12 | |
count-the-number-of-substrings-with-dominant-ones | 3,234 | Medium | [
"String",
"Enumeration",
"Sliding Window"
] | You are given a binary string s.
Return the number of substrings with dominant ones.
A string has dominant ones if the number of ones in the string is greater than or equal to the square of the number of zeros in the string.
Example 1:
Input: s = "00011"
Output: 5
Explanation:
The substrings with dominant ones are s... | numberOfSubstrings(s: str) -> int | pub fn number_of_substrings(s: &[u8]) -> i64 | Aegis.NumberOfSubstrings.number_of_substrings | pub fn number_of_substrings(s: &[u8]) -> i64 {
let n_usize: usize = s.len();
let n: i64 = n_usize as i64;
let mut zeros: Vec<i64> = Vec::new();
let mut i_usize: usize = 0;
while i_usize < n_usize {
if s[i_usize] == b'0' {
zeros.push(i_usize as i64);
}
i_usize += ... | -- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS
-- [number_of_substrings]: type definitions
module
public import Aeneas
@[expose] public section
open Aeneas Aeneas.Std Result ControlFlow Error
set_option linter.dupNamespace false
set_option linter.hashCommand false
set_option linter.unusedVariables false
set_option ... | -- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS
-- [number_of_substrings]: function definitions
module
public import Aeneas
public import Aegis.NumberOfSubstrings.Code.Types
@[expose] public section
open Aeneas Aeneas.Std Result ControlFlow Error
set_option linter.dupNamespace false
set_option linter.hashCommand fal... | import Aegis.NumberOfSubstrings.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": "[\"1111\"]",
"output": "10"
},
{
"input": "[\"100100100\"]",
"output": "8"
},
{
"input": "[\"1111010101\"]",
"output": "33"
},
{
"input": "[\"000111000\"]",
"output": "12"
},
{
"input": "[\"11110000\"]",
"output": "15"
},
{
"input": "[\"000... | 165 | false | 165 | verified | 10 | 10 | 1 | 10,000 | [
{
"type": "run_start",
"phase": "",
"model": null,
"messages": null,
"response": null,
"reasoning": null,
"finish_reason": null,
"prompt_tokens": null,
"completion_tokens": null,
"cached_prompt_tokens": null,
"command": null,
"exit_code": null,
"timed_out": null,
... | import Aegis.NumberOfSubstrings.Code.Funs
/-!
# Specifications of `Aegis.NumberOfSubstrings.number_of_substrings`
LeetCode problem `count-the-number-of-substrings-with-dominant-ones`. Each `spec_<n>` theorem states one property of the function.
-/
open Aeneas Aeneas.Std Result
open Aegis.NumberOfSubstrings
name... | 10 | |
check-if-the-rectangle-corner-is-reachable | 3,235 | Hard | [
"Depth-First Search",
"Breadth-First Search",
"Union Find",
"Geometry",
"Array",
"Math"
] | You are given two positive integers xCorner and yCorner, and a 2D array circles, where circles[i] = [xi, yi, ri] denotes a circle with center at (xi, yi) and radius ri.
There is a rectangle in the coordinate plane with its bottom left corner at the origin and top right corner at the coordinate (xCorner, yCorner). You n... | canReachCorner(xCorner: int, yCorner: int, circles: list_list_int) -> bool | pub fn can_reach_corner(xCorner: i64, yCorner: i64, circles: &[Vec<i64>]) -> bool | Aegis.CanReachCorner.can_reach_corner | fn find(parent: &Vec<usize>, mut x: usize) -> usize {
while parent[x] != x {
x = parent[x];
}
x
}
fn link(parent: &Vec<usize>, child: usize, par: usize) -> Vec<usize> {
let mut out: Vec<usize> = Vec::new();
let mut i: usize = 0;
while i < parent.len() {
if i == child {
... | -- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS
-- [can_reach_corner]: type definitions
module
public import Aeneas
@[expose] public section
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
-- [can_reach_corner]: function definitions
module
public import Aeneas
public import Aegis.CanReachCorner.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.CanReachCorner.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, 499999999]]]",
"output": "true"
},
{
"input": "[1000000000, 1000000000, [[500000000, 500000000, 100000000]]]",
"output": "true"
},
{
"input": "[1000000000, 1000000000, [[500000000, 500000000, 500000000]]]",
"output": "false... | 104 | false | 104 | verified | 10 | 10 | 6 | 175,808 | [
{
"type": "run_start",
"phase": "",
"model": null,
"messages": null,
"response": null,
"reasoning": null,
"finish_reason": null,
"prompt_tokens": null,
"completion_tokens": null,
"cached_prompt_tokens": null,
"command": null,
"exit_code": null,
"timed_out": null,
... | import Aegis.CanReachCorner.Code.Funs
import Mathlib.Data.Real.Basic
import Mathlib.Topology.Basic
import Mathlib.Topology.UniformSpace.Real
/-!
# Specifications of `Aegis.CanReachCorner.can_reach_corner`
LeetCode problem `check-if-the-rectangle-corner-is-reachable`. Each `spec_<n>` theorem states one property of the... | 14 | |
find-the-number-of-winning-players | 3,238 | Easy | [
"Array",
"Hash Table",
"Counting"
] | You are given an integer n representing the number of players in a game and a 2D array pick where pick[i] = [xi, yi] represents that the player xi picked a ball of color yi.
Player i wins the game if they pick strictly more than i balls of the same color. In other words,
Player 0 wins if they pick any ball.
Player 1 w... | winningPlayerCount(n: int, pick: list_list_int) -> int | pub fn winning_player_count(n: i64, pick: &[Vec<i64>]) -> i64 | Aegis.WinningPlayerCount.winning_player_count | pub fn winning_player_count(n: i64, pick: &[Vec<i64>]) -> i64 {
let n_usize = n as usize;
let colors = 11usize;
let mut counts: Vec<Vec<i64>> = Vec::new();
let mut i = 0usize;
while i < n_usize {
let mut row: Vec<i64> = Vec::new();
let mut c = 0usize;
while c < colors {
... | -- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS
-- [winning_player_count]: type definitions
module
public import Aeneas
@[expose] public section
open Aeneas Aeneas.Std Result ControlFlow Error
set_option linter.dupNamespace false
set_option linter.hashCommand false
set_option linter.unusedVariables false
set_option ... | -- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS
-- [winning_player_count]: function definitions
module
public import Aeneas
public import Aegis.WinningPlayerCount.Code.Types
@[expose] public section
open Aeneas Aeneas.Std Result ControlFlow Error
set_option linter.dupNamespace false
set_option linter.hashCommand fal... | import Aegis.WinningPlayerCount.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, [[0, 0], [1, 1], [1, 1]]]",
"output": "2"
},
{
"input": "[3, [[0, 0], [1, 0], [1, 0], [1, 0]]]",
"output": "2"
},
{
"input": "[5, [[1, 1], [2, 4], [2, 4], [2, 4]]]",
"output": "1"
},
{
"input": "[5, [[1, 1], [1, 2], [1, 3], [1, 4]]]",
"output": "0"
},
... | 69 | false | 69 | verified | 10 | 10 | 1 | 1,126 | [
{
"type": "run_start",
"phase": "",
"model": null,
"messages": null,
"response": null,
"reasoning": null,
"finish_reason": null,
"prompt_tokens": null,
"completion_tokens": null,
"cached_prompt_tokens": null,
"command": null,
"exit_code": null,
"timed_out": null,
... | import Aegis.WinningPlayerCount.Code.Funs
/-!
# Specifications of `Aegis.WinningPlayerCount.winning_player_count`
LeetCode problem `find-the-number-of-winning-players`. Each `spec_<n>` theorem states one property of the function.
-/
open Aeneas Aeneas.Std Result
namespace AegisSpec.WinningPlayerCount
def rowValue ... | 13 | |
minimum-number-of-flips-to-make-binary-grid-palindromic-i | 3,239 | Medium | [
"Array",
"Two Pointers",
"Matrix"
] | You are given an m x n binary matrix grid.
A row or column is considered palindromic if its values read the same forward and backward.
You can flip any number of cells in grid from 0 to 1, or from 1 to 0.
Return the minimum number of cells that need to be flipped to make either all rows palindromic or all columns palin... | minFlips(grid: list_list_int) -> int | pub fn min_flips(grid: &[Vec<i64>]) -> i64 | Aegis.MinFlips.min_flips | pub fn min_flips(grid: &[Vec<i64>]) -> i64 {
let m = grid.len();
if m == 0 {
return 0;
}
let n = grid[0].len();
let mut row_cost: i64 = 0;
let mut i: usize = 0;
while i < m {
let row = &grid[i];
let mut j: usize = 0;
while j < n / 2 {
if row[j] !=... | -- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS
-- [min_flips]: type definitions
module
public import Aeneas
@[expose] public section
open Aeneas Aeneas.Std Result ControlFlow Error
set_option linter.dupNamespace false
set_option linter.hashCommand false
set_option linter.unusedVariables false
set_option linter.styl... | -- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS
-- [min_flips]: function definitions
module
public import Aeneas
public import Aegis.MinFlips.Code.Types
@[expose] public section
open Aeneas Aeneas.Std Result ControlFlow Error
set_option linter.dupNamespace false
set_option linter.hashCommand false
set_option linter.... | import Aegis.MinFlips.Code.Funs
open Aeneas Aeneas.Std Result
set_option maxHeartbeats 4000000
set_option maxRecDepth 4096
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], [0]]]",
"output": "0"
},
{
"input": "[[[0, 1], [0, 1], [0, 0]]]",
"output": "1"
},
{
"input": "[[[1, 1, 0], [0, 1, 0], [0, 1, 1]]]",
"output": "2"
},
{
"input": "[[[1, 1, 1], [1, 0, 1], [1, 1, 1]]]",
"output": "0"
},
{
"input": "[[[1, 0, 0], [0,... | 77 | false | 77 | verified | 10 | 10 | 1 | 1,127 | [
{
"type": "run_start",
"phase": "",
"model": null,
"messages": null,
"response": null,
"reasoning": null,
"finish_reason": null,
"prompt_tokens": null,
"completion_tokens": null,
"cached_prompt_tokens": null,
"command": null,
"exit_code": null,
"timed_out": null,
... | import Aegis.MinFlips.Code.Funs
/-!
# Specifications of `Aegis.MinFlips.min_flips`
LeetCode problem `minimum-number-of-flips-to-make-binary-grid-palindromic-i`. Each `spec_<n>` theorem states one property of the function.
-/
open Aeneas Aeneas.Std Result
open Aegis.MinFlips
namespace AegisSpec.MinFlips
def n... | 12 | |
minimum-number-of-flips-to-make-binary-grid-palindromic-ii | 3,240 | Medium | [
"Array",
"Two Pointers",
"Matrix"
] | You are given an m x n binary matrix grid.
A row or column is considered palindromic if its values read the same forward and backward.
You can flip any number of cells in grid from 0 to 1, or from 1 to 0.
Return the minimum number of cells that need to be flipped to make all rows and columns palindromic, and the total ... | minFlips(grid: list_list_int) -> int | pub fn min_flips(grid: &[Vec<i64>]) -> i64 | Aegis.MinFlips.min_flips | fn update_dp(dp: &[i64], cost0: i64, add0: usize, cost1: i64, add1: usize) -> Vec<i64> {
let inf: i64 = 1000000000000000000;
let mut ndp: Vec<i64> = Vec::new();
ndp.push(inf);
ndp.push(inf);
ndp.push(inf);
ndp.push(inf);
let mut r: usize = 0;
while r < 4 {
let cur = dp[r];
... | -- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS
-- [min_flips]: type definitions
module
public import Aeneas
@[expose] public section
open Aeneas Aeneas.Std Result ControlFlow Error
set_option linter.dupNamespace false
set_option linter.hashCommand false
set_option linter.unusedVariables false
set_option linter.styl... | -- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS
-- [min_flips]: function definitions
module
public import Aeneas
public import Aegis.MinFlips.Code.Types
@[expose] public section
open Aeneas Aeneas.Std Result ControlFlow Error
set_option linter.dupNamespace false
set_option linter.hashCommand false
set_option linter.... | import Aegis.MinFlips.Code.Funs
open Aeneas Aeneas.Std Result
set_option maxHeartbeats 4000000
set_option maxRecDepth 4096
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], [1]]]",
"output": "2"
},
{
"input": "[[[0, 1], [0, 1], [0, 0]]]",
"output": "2"
},
{
"input": "[[[1, 0], [0, 1], [1, 0]]]",
"output": "3"
},
{
"input": "[[[1, 0], [0, 1], [1, 0], [0, 1]]]",
"output": "4"
},
{
"input": "[[[1, 0, 0], [0, 1, 0], [0... | 88 | false | 88 | verified | 10 | 10 | 1 | 10,710 | [
{
"type": "run_start",
"phase": "",
"model": null,
"messages": null,
"response": null,
"reasoning": null,
"finish_reason": null,
"prompt_tokens": null,
"completion_tokens": null,
"cached_prompt_tokens": null,
"command": null,
"exit_code": null,
"timed_out": null,
... | import Aegis.MinFlips.Code.Funs
/-!
# Specifications of `Aegis.MinFlips.min_flips`
LeetCode problem `minimum-number-of-flips-to-make-binary-grid-palindromic-ii`. Each `spec_<n>` theorem states one property of the function.
-/
open Aeneas Aeneas.Std Result
open Aegis.MinFlips (min_flips)
namespace AegisSpec.MinF... | 15 | |
time-taken-to-mark-all-nodes | 3,241 | Hard | [
"Tree",
"Depth-First Search",
"Graph",
"Dynamic Programming"
] | There exists an undirected tree with n nodes numbered 0 to n - 1. You are given a 2D integer array edges of length n - 1, where edges[i] = [ui, vi] indicates that there is an edge between nodes ui and vi in the tree.
Initially, all nodes are unmarked. For each node i:
If i is odd, the node will get marked at time x if... | timeTaken(edges: list_list_int) -> list_int | pub fn time_taken(edges: &[Vec<i64>]) -> Vec<i64> | Aegis.TimeTaken.time_taken | pub fn time_taken(edges: &[Vec<i64>]) -> Vec<i64> {
let n = edges.len() + 1;
let mut adj: Vec<Vec<i64>> = Vec::new();
let mut i = 0usize;
while i < n {
adj.push(Vec::new());
i += 1;
}
i = 0usize;
while i < edges.len() {
let u_i = edges[i][0];
let v_i = edges... | -- 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, 1]]]",
"output": "[1, 2]"
},
{
"input": "[[[0, 1], [0, 2]]]",
"output": "[2, 4, 3]"
},
{
"input": "[[[3, 1], [3, 0], [1, 2]]]",
"output": "[4, 3, 4, 3]"
},
{
"input": "[[[3, 1], [3, 2], [3, 0]]]",
"output": "[3, 3, 3, 2]"
},
{
"input": "[[[0, 3],... | 54 | false | 54 | verified | 10 | 10 | 1 | 10,571 | [
{
"type": "run_start",
"phase": "",
"model": null,
"messages": null,
"response": null,
"reasoning": 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-mark-all-nodes`. Each `spec_<n>` theorem states one property of the function.
-/
open Aeneas Aeneas.Std Result
open Aegis.TimeTaken
namespace AegisSpec.TimeTaken
def Delta (v : Nat) : Nat :=... | 11 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.