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-vowel-substrings-of-a-string
2,062
Easy
[ "Hash Table", "String" ]
A substring is a contiguous (non-empty) sequence of characters within a string. A vowel substring is a substring that only consists of vowels ('a', 'e', 'i', 'o', and 'u') and has all five vowels present in it. Given a string word, return the number of vowel substrings in word.   Example 1: Input: word = "aeiouu" Outp...
countVowelSubstrings(word: str) -> int
pub fn count_vowel_substrings(word: &[u8]) -> i64
Aegis.CountVowelSubstrings.count_vowel_substrings
fn is_vowel(c: u8) -> bool { c == b'a' || c == b'e' || c == b'i' || c == b'o' || c == b'u' } pub fn count_vowel_substrings(word: &[u8]) -> i64 { let n: usize = word.len(); let mut ans: i64 = 0; let mut i: usize = 0; while i < n { if is_vowel(word[i]) { let mut has_a: bool = fal...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [count_vowel_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_optio...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [count_vowel_substrings]: function definitions module public import Aeneas public import Aegis.CountVowelSubstrings.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand...
import Aegis.CountVowelSubstrings.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": "[\"aeiou\"]", "output": "1" }, { "input": "[\"aeiofvuaeiou\"]", "output": "3" }, { "input": "[\"uoiea\"]", "output": "1" }, { "input": "[\"aeiouxaeeiaouoieua\"]", "output": "28" }, { "input": "[\"aeiaaioaaaaeiiiiouuuooaauuaeiu\"]", "output": "175" ...
110
false
110
verified
10
10
1
1,987
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.CountVowelSubstrings.Code.Funs /-! # Specifications of `Aegis.CountVowelSubstrings.count_vowel_substrings` LeetCode problem `count-vowel-substrings-of-a-string`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.CountVowelSubstrings def b...
12
vowels-of-all-substrings
2,063
Medium
[ "Math", "String", "Dynamic Programming", "Combinatorics" ]
Given a string word, return the sum of the number of vowels ('a', 'e', 'i', 'o', and 'u') in every substring of word. A substring is a contiguous (non-empty) sequence of characters within a string. Note: Due to the large constraints, the answer may not fit in a signed 32-bit integer. Please be careful during the calcul...
countVowels(word: str) -> int
pub fn count_vowels(word: &[u8]) -> i64
Aegis.CountVowels.count_vowels
pub fn count_vowels(word: &[u8]) -> i64 { let n: usize = word.len(); let mut total: i64 = 0; let mut i: usize = 0; while i < n { let c: u8 = word[i]; if c == b'a' || c == b'e' || c == b'i' || c == b'o' || c == b'u' { let left: i64 = (i as i64) + 1; let right: i64...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [count_vowels]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter.s...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [count_vowels]: function definitions module public import Aeneas public import Aegis.CountVowels.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.CountVowels.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": "[\"e\"]", "output": "1" }, { "input": "[\"aeiou\"]", "output": "35" }, { "input": "[\"abc\"]", "output": "3" }, { "input": "[\"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\"]", "output": "0" }, { "input": "[\"aeiaaioaaaaeiiiiouuuooaauuaeiuiauuu...
80
false
80
verified
10
10
1
739
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.CountVowels.Code.Funs /-! # Specifications of `Aegis.CountVowels.count_vowels` LeetCode problem `vowels-of-all-substrings`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.CountVowels def IsLower (c : U8) : Prop := 97 ≤ c.val ∧ c.val ≤ ...
10
number-of-equal-count-substrings
2,067
Medium
[ "Hash Table", "String", "Counting", "Sliding Window" ]
You are given a 0-indexed string s consisting of only lowercase English letters, and an integer count. A substring of s is said to be an equal count substring if, for each unique letter in the substring, it appears exactly count times in the substring. Return the number of equal count substrings in s. A substring is a ...
equalCountSubstrings(s: str, count: int) -> int
pub fn equal_count_substrings(s: &[u8], count: i64) -> i64
Aegis.EqualCountSubstrings.equal_count_substrings
pub fn equal_count_substrings(s: &[u8], count: i64) -> i64 { let n: usize = s.len(); if n == 0 || count <= 0 { return 0; } let c: usize = count as usize; if c > n { return 0; } let mut max_k: usize = n / c; if max_k > 26 { max_k = 26; } let mut ans: i6...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [equal_count_substrings]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_optio...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [equal_count_substrings]: function definitions module public import Aeneas public import Aegis.EqualCountSubstrings.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand...
import Aegis.EqualCountSubstrings.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": "[\"a\", 5]", "output": "0" }, { "input": "[\"abcdefg\", 3]", "output": "0" }, { "input": "[\"abcabcabc\", 3]", "output": "1" }, { "input": "[\"abccbaabc\", 3]", "output": "1" }, { "input": "[\"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\", 2]"...
97
false
97
verified
10
10
1
6,702
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.EqualCountSubstrings.Code.Funs /-! # Specifications of `Aegis.EqualCountSubstrings.equal_count_substrings` LeetCode problem `number-of-equal-count-substrings`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.EqualCountSubstrings namespace AegisSp...
13
most-beautiful-item-for-each-query
2,070
Medium
[ "Array", "Binary Search", "Sorting" ]
You are given a 2D integer array items where items[i] = [pricei, beautyi] denotes the price and beauty of an item respectively. You are also given a 0-indexed integer array queries. For each queries[j], you want to determine the maximum beauty of an item whose price is less than or equal to queries[j]. If no such item ...
maximumBeauty(items: list_list_int, queries: list_int) -> list_int
pub fn maximum_beauty(items: &[Vec<i64>], queries: &[i64]) -> Vec<i64>
Aegis.MaximumBeauty.maximum_beauty
pub fn maximum_beauty(items: &[Vec<i64>], queries: &[i64]) -> Vec<i64> { let n = items.len(); let mut prices: Vec<i64> = Vec::new(); let mut beauties: Vec<i64> = Vec::new(); let mut i = 0; while i < n { prices.push(items[i][0]); beauties.push(items[i][1]); i += 1; } ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [maximum_beauty]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [maximum_beauty]: function definitions module public import Aeneas public import Aegis.MaximumBeauty.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.MaximumBeauty.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval aegisCa...
[ { "input": "[[[10, 1000]], [5]]", "output": "[0]" }, { "input": "[[[1000000000, 1000000000]], [500000000, 1000000000, 1500000000]]", "output": "[0, 1000000000, 1000000000]" }, { "input": "[[[1, 1000000000], [1000000000, 1]], [500000000, 1000000000]]", "output": "[1000000000, 10000000...
106
false
106
verified
10
10
1
3,182
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MaximumBeauty.Code.Funs /-! # Specifications of `Aegis.MaximumBeauty.maximum_beauty` LeetCode problem `most-beautiful-item-for-each-query`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.MaximumBeauty open Aegis.MaximumBeauty (maximum_...
14
maximum-number-of-tasks-you-can-assign
2,071
Hard
[ "Greedy", "Queue", "Array", "Binary Search", "Sorting", "Monotonic Queue" ]
You have n tasks and m workers. Each task has a strength requirement stored in a 0-indexed integer array tasks, with the ith task requiring tasks[i] strength to complete. The strength of each worker is stored in a 0-indexed integer array workers, with the jth worker having workers[j] strength. Each worker can only be a...
maxTaskAssign(tasks: list_int, workers: list_int, pills: int, strength: int) -> int
pub fn max_task_assign(tasks: &[i64], workers: &[i64], pills: i64, strength: i64) -> i64
Aegis.MaxTaskAssign.max_task_assign
fn st_add(tree: &mut [i64], size: usize, pos: usize, delta: i64) { let mut p = pos + size; tree[p] = tree[p] + delta; p = p / 2; while p > 0 { tree[p] = tree[2 * p] + tree[2 * p + 1]; p = p / 2; } } fn st_prefix(tree: &[i64], size: usize, end: usize) -> i64 { let mut l = size; ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [max_task_assign]: type definitions module public import Aeneas @[expose] public section 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 -- [max_task_assign]: function definitions module public import Aeneas public import Aegis.MaxTaskAssign.Code.Types public import Aegis.MaxTaskAssign.Code.FunsExternal @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespa...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [max_task_assign]: external functions. -- This is a template file: rename it to "FunsExternal.lean" and fill the holes. module public import Aeneas public import Aegis.MaxTaskAssign.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error ...
import Aegis.MaxTaskAssign.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval aegisCa...
[ { "input": "[[1000000000], [999999999], 1, 1]", "output": "1" }, { "input": "[[1000000000], [1000000000], 0, 0]", "output": "1" }, { "input": "[[1000000000], [1000000000], 1, 0]", "output": "1" }, { "input": "[[1000000000, 1000000000], [1000000000, 1000000000], 1, 0]", "o...
119
false
119
verified
10
10
1
18,293
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MaxTaskAssign.Code.Funs /-! # Specifications of `Aegis.MaxTaskAssign.max_task_assign` LeetCode problem `maximum-number-of-tasks-you-can-assign`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.MaxTaskAssign def taskVals (tasks : Sli...
13
time-needed-to-buy-tickets
2,073
Easy
[ "Queue", "Array", "Simulation" ]
There are n people in a line queuing to buy tickets, where the 0th person is at the front of the line and the (n - 1)th person is at the back of the line. You are given a 0-indexed integer array tickets of length n where the number of tickets that the ith person would like to buy is tickets[i]. Each person takes exactl...
timeRequiredToBuy(tickets: list_int, k: int) -> int
pub fn time_required_to_buy(tickets: &[i64], k: i64) -> i64
Aegis.TimeRequiredToBuy.time_required_to_buy
pub fn time_required_to_buy(tickets: &[i64], k: i64) -> i64 { let n: usize = tickets.len(); let kk: usize = k as usize; let target: i64 = tickets[kk]; let mut total: i64 = 0; let mut i: usize = 0; while i < n { if i <= kk { if tickets[i] < target { total += ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [time_required_to_buy]: type definitions module public import Aeneas @[expose] public section 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 -- [time_required_to_buy]: function definitions module public import Aeneas public import Aegis.TimeRequiredToBuy.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand fals...
import Aegis.TimeRequiredToBuy.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval aeg...
[ { "input": "[[1], 0]", "output": "1" }, { "input": "[[100, 100, 100], 1]", "output": "299" }, { "input": "[[10, 10, 10], 2]", "output": "30" }, { "input": "[[10, 10, 10], 0]", "output": "28" }, { "input": "[[10, 10, 10], 1]", "output": "29" }, { "input...
99
false
99
verified
10
10
1
440
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.TimeRequiredToBuy.Code.Funs /-! # Specifications of `Aegis.TimeRequiredToBuy.time_required_to_buy` LeetCode problem `time-needed-to-buy-tickets`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.TimeRequiredToBuy open Aeneas Aeneas.Std R...
12
reverse-nodes-in-even-length-groups
2,074
Medium
[ "Linked List" ]
You are given the head of a linked list. The nodes in the linked list are sequentially assigned to non-empty groups whose lengths form the sequence of the natural numbers (1, 2, 3, 4, ...). The length of a group is the number of nodes assigned to it. In other words, The 1st node is assigned to the first group. The 2nd...
reverseEvenLengthGroups(head: linkedlist) -> linkedlist
pub fn reverse_even_length_groups(head: &List) -> List
Aegis.ReverseEvenLengthGroups.reverse_even_length_groups
fn collect(l: &List, acc: Vec<i64>) -> Vec<i64> { match l { List::Nil => acc, List::Cons(v, next) => { let mut a: Vec<i64> = acc; a.push(*v); collect(&**next, a) } } } // Emits v[0], v[1], ..., v[i-1] in forward order using an accumulator. fn build(v:...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [reverse_even_length_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_o...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [reverse_even_length_groups]: function definitions module public import Aeneas public import Aegis.ReverseEvenLengthGroups.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hash...
import Aegis.ReverseEvenLengthGroups.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}" der...
[ { "input": "[[1]]", "output": "[1]" }, { "input": "[[0]]", "output": "[0]" }, { "input": "[[1, 2]]", "output": "[1, 2]" }, { "input": "[[1, 2, 3]]", "output": "[1, 3, 2]" }, { "input": "[[2, 4, 3]]", "output": "[2, 3, 4]" }, { "input": "[[1, 2, 3, 4]]"...
98
false
98
verified
10
10
6
55,811
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.ReverseEvenLengthGroups.Code.Funs /-! # Specifications of `Aegis.ReverseEvenLengthGroups.reverse_even_length_groups` LeetCode problem `reverse-nodes-in-even-length-groups`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace Aegis.ReverseEvenLengthGro...
8
process-restricted-friend-requests
2,076
Hard
[ "Union Find", "Graph" ]
You are given an integer n indicating the number of people in a network. Each person is labeled from 0 to n - 1. You are also given a 0-indexed 2D integer array restrictions, where restrictions[i] = [xi, yi] means that person xi and person yi cannot become friends, either directly or indirectly through other people. In...
friendRequests(n: int, restrictions: list_list_int, requests: list_list_int) -> list_bool
pub fn friend_requests(n: i64, restrictions: &[Vec<i64>], requests: &[Vec<i64>]) -> Vec<bool>
Aegis.FriendRequests.friend_requests
fn find(parent: &mut Vec<i64>, x: i64) -> i64 { let mut root = x; while parent[root as usize] != root { root = parent[root as usize]; } let mut cur = x; while parent[cur as usize] != root { let next = parent[cur as usize]; parent[cur as usize] = root; cur = next; ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [friend_requests]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linte...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [friend_requests]: function definitions module public import Aeneas public import Aegis.FriendRequests.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.FriendRequests.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval aegisC...
[ { "input": "[3, [[0, 1]], [[1, 2], [0, 2]]]", "output": "[true, false]" }, { "input": "[3, [[0, 1]], [[0, 2], [2, 1]]]", "output": "[true, false]" }, { "input": "[4, [], [[0, 1], [1, 2], [2, 3], [3, 0]]]", "output": "[true, true, true, true]" }, { "input": "[4, [[0, 2], [1, 3...
72
false
72
verified
10
10
1
2,443
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.FriendRequests.Code.Funs /-! # Specifications of `Aegis.FriendRequests.friend_requests` LeetCode problem `process-restricted-friend-requests`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.FriendRequests open Classical def vecI...
11
two-furthest-houses-with-different-colors
2,078
Easy
[ "Greedy", "Array" ]
There are n houses evenly lined up on the street, and each house is beautifully painted. You are given a 0-indexed integer array colors of length n, where colors[i] represents the color of the ith house. Return the maximum distance between two houses with different colors. The distance between the ith and jth houses is...
maxDistance(colors: list_int) -> int
pub fn max_distance(colors: &[i64]) -> i64
Aegis.MaxDistance.max_distance
pub fn max_distance(colors: &[i64]) -> i64 { let n = colors.len(); let ni = n as i64; let mut best: i64 = 0; let mut i: i64 = 0; while i < ni { let mut j: i64 = i + 1; while j < ni { if colors[i as usize] != colors[j as usize] { let d: i64 = j - i; ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [max_distance]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter.s...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [max_distance]: function definitions module public import Aeneas public import Aegis.MaxDistance.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.MaxDistance.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" }, { "input": "[[10, 20, 10, 10, 10]]", "output": "3" }, { "input": "[[10, 20, 30, 40, 50]]", "output": "4" }, { "input": "[[3, 1, 3, 3, 3]]", "output": "3" }, { "input": "[[1, 2, 3, 4, 5]]", "output": "4" }, { "inp...
90
false
90
verified
10
10
1
898
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MaxDistance.Code.Funs /-! # Specifications of `Aegis.MaxDistance.max_distance` LeetCode problem `two-furthest-houses-with-different-colors`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.MaxDistance def colAt (colors : Slice Std.I...
11
watering-plants
2,079
Medium
[ "Array", "Simulation" ]
You want to water n plants in your garden with a watering can. The plants are arranged in a row and are labeled from 0 to n - 1 from left to right where the ith plant is located at x = i. There is a river at x = -1 that you can refill your watering can at. Each plant needs a specific amount of water. You will water the...
wateringPlants(plants: list_int, capacity: int) -> int
pub fn watering_plants(plants: &[i64], capacity: i64) -> i64
Aegis.WateringPlants.watering_plants
pub fn watering_plants(plants: &[i64], capacity: i64) -> i64 { let n = plants.len(); let mut steps: i64 = 0; let mut water: i64 = capacity; let mut i: usize = 0; let mut pos: i64 = 0; while i < n { if water < plants[i] { steps = steps + 2 * pos; water = capacity;...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [watering_plants]: type definitions module public import Aeneas @[expose] public section 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 -- [watering_plants]: function definitions module public import Aeneas public import Aegis.WateringPlants.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.WateringPlants.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval aegisC...
[ { "input": "[[1000000], 1000000]", "output": "1" }, { "input": "[[10], 10]", "output": "1" }, { "input": "[[10, 10, 10], 10]", "output": "9" }, { "input": "[[1, 2, 3], 6]", "output": "3" }, { "input": "[[5, 8, 6], 10]", "output": "9" }, { "input": "[[1...
84
false
84
verified
10
10
1
1,846
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.WateringPlants.Code.Funs /-! # Specifications of `Aegis.WateringPlants.watering_plants` LeetCode problem `watering-plants`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.WateringPlants open Aeneas Aeneas.Std Result def heights ...
9
sum-of-k-mirror-numbers
2,081
Hard
[ "Math", "Enumeration" ]
A k-mirror number is a positive integer without leading zeros that reads the same both forward and backward in base-10 as well as in base-k. For example, 9 is a 2-mirror number. The representation of 9 in base-10 and base-2 are 9 and 1001 respectively, which read the same both forward and backward. On the contrary, 4 ...
kMirror(k: int, n: int) -> int
pub fn k_mirror(k: i64, n: i64) -> i64
Aegis.KMirror.k_mirror
fn is_pal_base(x: i64, k: i64) -> bool { let mut y = x; let mut rev: i64 = 0; while y > 0 { rev = rev * k + (y % k); y = y / k; } rev == x } pub fn k_mirror(k: i64, n: i64) -> i64 { let mut sum: i64 = 0; let mut count: i64 = 0; let mut len: i64 = 1; let mut start:...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [k_mirror]: type definitions module public import Aeneas @[expose] public section 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 -- [k_mirror]: function definitions module public import Aeneas public import Aegis.KMirror.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.KMirror.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": "[2, 1]", "output": "1" }, { "input": "[5, 8]", "output": "638" }, { "input": "[8, 15]", "output": "5818" }, { "input": "[9, 5]", "output": "15" }, { "input": "[9, 6]", "output": "21" }, { "input": "[8, 9]", "output": "158" }, { ...
59
false
59
verified
10
10
2
14,612
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.KMirror.Code.Funs /-! # Specifications of `Aegis.KMirror.k_mirror` LeetCode problem `sum-of-k-mirror-numbers`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.KMirror def baseDigits (b : Nat) (x : Nat) : List Nat := if _ : b < 2...
8
substrings-that-begin-and-end-with-the-same-letter
2,083
Medium
[ "Hash Table", "Math", "String", "Counting", "Prefix Sum" ]
You are given a 0-indexed string s consisting of only lowercase English letters. Return the number of substrings in s that begin and end with the same character. A substring is a contiguous non-empty sequence of characters within a string.   Example 1: Input: s = "abcba" Output: 7 Explanation: The substrings of length...
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 mut counts: Vec<i64> = Vec::new(); let mut j: usize = 0; while j < 26 { counts.push(0); j += 1; } let mut ans: i64 = 0; let mut i: usize = 0; let n: usize = s.len(); while i < n { let idx: usize = (s[i] - b'a') ...
-- 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": "[\"zxyxzyxzyxz\"]", "output": "26" }, { "input": "[\"abcba\"]", "output": "7" }, { "input": "[\"abcdefghijklmnopqrstuvwxyz\"]", "output": "26" }, { "input": "[\"abaacababa\"]", "output": "28" }, { "input": "[\"abababab\"]", "output": "20" }, { ...
78
false
78
verified
10
10
1
801
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": 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 `substrings-that-begin-and-end-with-the-same-letter`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.NumberOfSubstri...
15
count-common-words-with-one-occurrence
2,085
Easy
[ "Array", "Hash Table", "String", "Counting" ]
Given two string arrays words1 and words2, return the number of strings that appear exactly once in each of the two arrays.   Example 1: Input: words1 = ["leetcode","is","amazing","as","is"], words2 = ["amazing","leetcode","is"] Output: 2 Explanation: - "leetcode" appears exactly once in each of the two arrays. We cou...
countWords(words1: list_str, words2: list_str) -> int
pub fn count_words(words1: &[Vec<u8>], words2: &[Vec<u8>]) -> i64
Aegis.CountWords.count_words
pub fn count_words(words1: &[Vec<u8>], words2: &[Vec<u8>]) -> i64 { let n1 = words1.len(); let n2 = words2.len(); let mut ans: i64 = 0; let mut i: usize = 0; while i < n1 { let mut count1: i64 = 0; let mut j: usize = 0; while j < n1 { let mut equal: bool = true;...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [count_words]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter.st...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [count_words]: function definitions module public import Aeneas public import Aegis.CountWords.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.CountWords.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": "[[\"one\"], [\"two\"]]", "output": "0" }, { "input": "[[\"unique\"], [\"unique\"]]", "output": "1" }, { "input": "[[\"single\"], [\"single\"]]", "output": "1" }, { "input": "[[\"distinct\"], [\"distinct\", \"distinct\"]]", "output": "0" }, { "input": "...
103
false
103
verified
10
10
1
2,440
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.CountWords.Code.Funs /-! # Specifications of `Aegis.CountWords.count_words` LeetCode problem `count-common-words-with-one-occurrence`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.CountWords def isAsciiLower (b : U8) : Prop := 97...
12
minimum-number-of-food-buckets-to-feed-the-hamsters
2,086
Medium
[ "Greedy", "String", "Dynamic Programming" ]
You are given a 0-indexed string hamsters where hamsters[i] is either: 'H' indicating that there is a hamster at index i, or '.' indicating that index i is empty. You will add some number of food buckets at the empty indices in order to feed the hamsters. A hamster can be fed if there is at least one food bucket to i...
minimumBuckets(hamsters: str) -> int
pub fn minimum_buckets(hamsters: &[u8]) -> i64
Aegis.MinimumBuckets.minimum_buckets
pub fn minimum_buckets(hamsters: &[u8]) -> i64 { let n = hamsters.len(); let mut ans: i64 = 0; let mut i: usize = 0; while i < n { if hamsters[i] == b'H' { if i + 1 < n && hamsters[i + 1] == b'.' { ans += 1; i += 3; } else if i > 0 && hams...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [minimum_buckets]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linte...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [minimum_buckets]: function definitions module public import Aeneas public import Aegis.MinimumBuckets.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.MinimumBuckets.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": "[\"H\"]", "output": "-1" }, { "input": "[\"H.H.H.H.H.H\"]", "output": "3" }, { "input": "[\"HH.H.H.H.H.H.H.H.H.H.H.H.H.H\"]", "output": "-1" }, { "input": "[\"H.H.H.H.H.H.H.H.H.H\"]", "output": "5" }, { "input": "[\".....\"]", "output": "0" }, ...
91
false
91
verified
10
10
1
12,413
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MinimumBuckets.Code.Funs /-! # Specifications of `Aegis.MinimumBuckets.minimum_buckets` LeetCode problem `minimum-number-of-food-buckets-to-feed-the-hamsters`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.MinimumBuckets def byteAt (s...
12
count-fertile-pyramids-in-a-land
2,088
Hard
[ "Array", "Dynamic Programming", "Matrix" ]
A farmer has a rectangular grid of land with m rows and n columns that can be divided into unit cells. Each cell is either fertile (represented by a 1) or barren (represented by a 0). All cells outside the grid are considered barren. A pyramidal plot of land can be defined as a set of cells with the following criteria:...
countPyramids(grid: list_list_int) -> int
pub fn count_pyramids(grid: &[Vec<i64>]) -> i64
Aegis.CountPyramids.count_pyramids
pub fn count_pyramids(grid: &[Vec<i64>]) -> i64 { let m = grid.len(); if m == 0 { return 0; } let n = grid[0].len(); if n == 0 { return 0; } let mut dp: Vec<Vec<i64>> = Vec::new(); let mut i = 0; while i < m { let mut row: Vec<i64> = Vec::new(); let m...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [count_pyramids]: type definitions module public import Aeneas @[expose] public section 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_pyramids]: function definitions module public import Aeneas public import Aegis.CountPyramids.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.CountPyramids.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": "[[[1, 1], [1, 1]]]", "output": "0" }, { "input": "[[[1, 1, 1], [1, 1, 1]]]", "output": "2" }, { "input": "[[[0, 1, 1, 0], [1, 1, 1, 1]]]", "output": "2" }, { "input": "[[[0, 0, 0], [0, 1, 0], [0, 0, 0]]]", "ou...
74
false
74
verified
10
10
1
4,017
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.CountPyramids.Code.Funs /-! # Specifications of `Aegis.CountPyramids.count_pyramids` LeetCode problem `count-fertile-pyramids-in-a-land`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open scoped Classical namespace AegisSpec.CountPyramids open Aeg...
10
find-target-indices-after-sorting-array
2,089
Easy
[ "Array", "Binary Search", "Sorting" ]
You are given a 0-indexed integer array nums and a target element target. A target index is an index i such that nums[i] == target. Return a list of the target indices of nums after sorting nums in non-decreasing order. If there are no target indices, return an empty list. The returned list must be sorted in increasing...
targetIndices(nums: list_int, target: int) -> list_int
pub fn target_indices(nums: &[i64], target: i64) -> Vec<i64>
Aegis.TargetIndices.target_indices
pub fn target_indices(nums: &[i64], target: i64) -> Vec<i64> { let mut less: i64 = 0; let mut equal: i64 = 0; let mut i: usize = 0; while i < nums.len() { if nums[i] < target { less += 1; } else if nums[i] == target { equal += 1; } i += 1; } ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [target_indices]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [target_indices]: function definitions module public import Aeneas public import Aegis.TargetIndices.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.TargetIndices.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], 2]", "output": "[]" }, { "input": "[[7, 7, 7, 7, 7], 8]", "output": "[]" }, { "input": "[[10, 20, 30, 40, 50], 25]", "output": "[]" }, { "input": "[[1, 3, 5, 7, 9], 0]", "output": "[]" }, { "input": "[[50, 40, 30, 20, 10], 15]", "output": "[]...
118
false
118
verified
10
10
1
473
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.TargetIndices.Code.Funs /-! # Specifications of `Aegis.TargetIndices.target_indices` LeetCode problem `find-target-indices-after-sorting-array`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.TargetIndices open Aeneas Aeneas.Std Re...
12
k-radius-subarray-averages
2,090
Medium
[ "Array", "Sliding Window" ]
You are given a 0-indexed array nums of n integers, and an integer k. The k-radius average for a subarray of nums centered at some index i with the radius k is the average of all elements in nums between the indices i - k and i + k (inclusive). If there are less than k elements before or after the index i, then the k-r...
getAverages(nums: list_int, k: int) -> list_int
pub fn get_averages(nums: &[i64], k: i64) -> Vec<i64>
Aegis.GetAverages.get_averages
pub fn get_averages(nums: &[i64], k: i64) -> Vec<i64> { let n = nums.len(); let mut res: Vec<i64> = Vec::new(); let mut idx: usize = 0; while idx < n { res.push(-1); idx += 1; } if k < 0 { return res; } let ku = k as usize; let win = 2 * ku + 1; if n <...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [get_averages]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter.s...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [get_averages]: function definitions module public import Aeneas public import Aegis.GetAverages.Code.Types public import Aegis.GetAverages.Code.FunsExternal @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace fals...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [get_averages]: external functions. -- This is a template file: rename it to "FunsExternal.lean" and fill the holes. module public import Aeneas public import Aegis.GetAverages.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_o...
import Aegis.GetAverages.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval aegisCase...
[ { "input": "[[100000], 0]", "output": "[100000]" }, { "input": "[[8], 100000]", "output": "[-1]" }, { "input": "[[5], 0]", "output": "[5]" }, { "input": "[[0, 0, 0, 0, 0], 2]", "output": "[-1, -1, 0, -1, -1]" }, { "input": "[[1, 2, 3, 4, 5], 2]", "output": "[-...
94
false
94
verified
10
10
1
2,594
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.GetAverages.Code.Funs /-! # Specifications of `Aegis.GetAverages.get_averages` LeetCode problem `k-radius-subarray-averages`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.GetAverages open Aegis.GetAverages def intAt (xs : List Std.I...
12
removing-minimum-and-maximum-from-array
2,091
Medium
[ "Greedy", "Array" ]
You are given a 0-indexed array of distinct integers nums. There is an element in nums that has the lowest value and an element that has the highest value. We call them the minimum and maximum respectively. Your goal is to remove both these elements from the array. A deletion is defined as either removing an element fr...
minimumDeletions(nums: list_int) -> int
pub fn minimum_deletions(nums: &[i64]) -> i64
Aegis.MinimumDeletions.minimum_deletions
pub fn minimum_deletions(nums: &[i64]) -> i64 { let n = nums.len(); if n == 0 { return 0; } let mut min_idx: usize = 0; let mut max_idx: usize = 0; let mut i: usize = 1; while i < n { if nums[i] < nums[min_idx] { min_idx = i; } if nums[i] > nums[...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [minimum_deletions]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option lin...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [minimum_deletions]: function definitions module public import Aeneas public import Aegis.MinimumDeletions.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false se...
import Aegis.MinimumDeletions.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 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": "[[101]]", "output": "1" }, { "input": "[[3, 1]]", "output": "2" }, { "input": "[[-1, 1]]", "output": "2" }, { "input": "[[1, 3, 2]]", "output": "2" }, { "input": "[[3, 2, 1]]", "output": "2" }, { "input": "[[3, 1, 2]]", "output": "2" ...
101
false
101
verified
10
10
1
1,509
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MinimumDeletions.Code.Funs /-! # Specifications of `Aegis.MinimumDeletions.minimum_deletions` LeetCode problem `removing-minimum-and-maximum-from-array`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.MinimumDeletions def IsMinIndex (l...
11
find-all-people-with-secret
2,092
Hard
[ "Depth-First Search", "Breadth-First Search", "Union Find", "Graph", "Sorting" ]
You are given an integer n indicating there are n people numbered from 0 to n - 1. You are also given a 0-indexed 2D integer array meetings where meetings[i] = [xi, yi, timei] indicates that person xi and person yi have a meeting at timei. A person may attend multiple meetings at the same time. Finally, you are given a...
findAllPeople(n: int, meetings: list_list_int, firstPerson: int) -> list_int
pub fn find_all_people(n: i64, meetings: &[Vec<i64>], firstPerson: i64) -> Vec<i64>
Aegis.FindAllPeople.find_all_people
fn dsu_find(parent: &Vec<i64>, x: i64) -> i64 { let mut r = x; while parent[r as usize] != r { r = parent[r as usize]; } r } fn dsu_union(parent: &mut Vec<i64>, rank: &mut Vec<i64>, a: i64, b: i64) { let ra = dsu_find(&*parent, a); let rb = dsu_find(&*parent, b); if ra == rb { ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [find_all_people]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linte...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [find_all_people]: function definitions module public import Aeneas public import Aegis.FindAllPeople.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.FindAllPeople.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval aegisCa...
[ { "input": "[3, [[0, 1, 10], [1, 2, 20]], 1]", "output": "[0, 1, 2]" }, { "input": "[3, [[0, 1, 1], [1, 2, 2], [0, 2, 3]], 2]", "output": "[0, 1, 2]" }, { "input": "[4, [[3, 1, 3], [1, 2, 2], [0, 3, 3]], 3]", "output": "[0, 1, 3]" }, { "input": "[3, [[0, 1, 10], [1, 2, 20], [...
84
true
84
verified
10
10
1
9,131
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.FindAllPeople.Code.Funs /-! # Specifications of `Aegis.FindAllPeople.find_all_people` LeetCode problem `find-all-people-with-secret`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.FindAllPeople def triples (meetings : Slice (alloc.vec...
13
minimum-cost-to-reach-city-with-discounts
2,093
Medium
[ "Graph", "Shortest Path", "Heap (Priority Queue)" ]
A series of highways connect n cities numbered from 0 to n - 1. You are given a 2D integer array highways where highways[i] = [city1i, city2i, tolli] indicates that there is a highway that connects city1i and city2i, allowing a car to go from city1i to city2i and vice versa for a cost of tolli. You are also given an in...
minimumCost(n: int, highways: list_list_int, discounts: int) -> int
pub fn minimum_cost(n: i64, highways: &[Vec<i64>], discounts: i64) -> i64
Aegis.MinimumCost.minimum_cost
pub fn minimum_cost(n: i64, highways: &[Vec<i64>], discounts: i64) -> i64 { let n_usize = n as usize; let mut max_disc = discounts; let n_minus_one = n - 1; if max_disc > n_minus_one { max_disc = n_minus_one; } if max_disc < 0 { max_disc = 0; } let d_usize = max_disc as...
-- 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": "[3, [[0, 1, 10], [1, 2, 10]], 1]", "output": "15" }, { "input": "[4, [[0, 1, 3], [2, 3, 2]], 0]", "output": "-1" }, { "input": "[5, [[0, 1, 4], [2, 1, 3], [1, 4, 11], [3, 2, 3], [3, 4, 2]], 1]", "output": "9" }, { "input": "[4, [[1, 3, 17], [1, 2, 7], [3, 2, 5], [...
84
false
84
verified
10
10
1
18,243
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MinimumCost.Code.Funs /-! # Specifications of `Aegis.MinimumCost.minimum_cost` LeetCode problem `minimum-cost-to-reach-city-with-discounts`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.MinimumCost def hwInts (h : alloc.vec.Vec Std.I...
11
finding-3-digit-even-numbers
2,094
Easy
[ "Array", "Hash Table", "Enumeration", "Sorting" ]
You are given an integer array digits, where each element is a digit. The array may contain duplicates. You need to find all the unique integers that follow the given requirements: The integer consists of the concatenation of three elements from digits in any arbitrary order. The integer does not have leading zeros. T...
findEvenNumbers(digits: list_int) -> list_int
pub fn find_even_numbers(digits: &[i64]) -> Vec<i64>
Aegis.FindEvenNumbers.find_even_numbers
pub fn find_even_numbers(digits: &[i64]) -> Vec<i64> { let mut counts: Vec<i64> = Vec::new(); let mut k: usize = 0; while k < 10 { counts.push(0); k += 1; } let mut i: usize = 0; while i < digits.len() { let d = digits[i] as usize; counts[d] = counts[d] + 1; ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [find_even_numbers]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option lin...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [find_even_numbers]: function definitions module public import Aeneas public import Aegis.FindEvenNumbers.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.FindEvenNumbers.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": "[[3, 7, 5]]", "output": "[]" }, { "input": "[[0, 0, 0]]", "output": "[]" }, { "input": "[[1, 0, 0, 0]]", "output": "[100]" }, { "input": "[[1, 3, 5, 7, 9]]", "output": "[]" }, { "input": "[[1, 1, 1, 1, 1, 1]]", "output": "[]" }, { "input": ...
91
false
91
verified
10
10
1
2,714
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.FindEvenNumbers.Code.Funs /-! # Specifications of `Aegis.FindEvenNumbers.find_even_numbers` LeetCode problem `finding-3-digit-even-numbers`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.FindEvenNumbers def HasValueAt (l : List St...
2
delete-the-middle-node-of-a-linked-list
2,095
Medium
[ "Linked List", "Two Pointers" ]
You are given the head of a linked list. Delete the middle node, and return the head of the modified linked list. The middle node of a linked list of size n is the ⌊n / 2⌋th node from the start using 0-based indexing, where ⌊x⌋ denotes the largest integer less than or equal to x. For n = 1, 2, 3, 4, and 5, the middle ...
deleteMiddle(head: linkedlist) -> linkedlist
pub fn delete_middle(head: &List) -> List
Aegis.DeleteMiddle.delete_middle
fn is_nil(l: &List) -> bool { match l { List::Nil => true, List::Cons(_, _) => false, } } pub fn delete_middle(head: &List) -> List { let mut vals: Vec<i64> = Vec::new(); let mut cur: &List = head; while !is_nil(cur) { match cur { List::Nil => {} Lis...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [delete_middle]: type definitions module public import Aeneas @[expose] public section 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 -- [delete_middle]: function definitions module public import Aeneas public import Aegis.DeleteMiddle.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.DeleteMiddle.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": "[[2, 1]]", "output": "[2]" }, { "input": "[[1, 2]]", "output": "[1]" }, { "input": "[[1, 2, 3]]", "output": "[1, 3]" }, { "input": "[[1, 2, 3, 4]]", "output": "[1, 2, 4]" }, { "input": "[[1, 2, 2, 1]]", "output": "[1, 2, 1]" }, { "input": "...
56
false
56
verified
10
10
1
6,967
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.DeleteMiddle.Code.Funs /-! # Specifications of `Aegis.DeleteMiddle.delete_middle` LeetCode problem `delete-the-middle-node-of-a-linked-list`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.DeleteMiddle def vals : Aegis.DeleteMiddle.Lis...
8
valid-arrangement-of-pairs
2,097
Hard
[ "Depth-First Search", "Graph", "Eulerian Circuit" ]
You are given a 0-indexed 2D integer array pairs where pairs[i] = [starti, endi]. An arrangement of pairs is valid if for every index i where 1 <= i < pairs.length, we have endi-1 == starti. Return any valid arrangement of pairs. Note: The inputs will be generated such that there exists a valid arrangement of pairs.   ...
validArrangement(pairs: list_list_int) -> list_list_int
pub fn valid_arrangement(pairs: &[Vec<i64>]) -> Vec<Vec<i64>>
Aegis.ValidArrangement.valid_arrangement
fn sort_i64(mut a: Vec<i64>) -> Vec<i64> { let n = a.len(); if n <= 1 { return a; } let mut tmp: Vec<i64> = Vec::new(); let mut i = 0usize; while i < n { tmp.push(0); i += 1; } let mut width = 1usize; while width < n { let mut lo = 0usize; wh...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [valid_arrangement]: type definitions module public import Aeneas @[expose] public section 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 -- [valid_arrangement]: function definitions module public import Aeneas public import Aegis.ValidArrangement.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false se...
import Aegis.ValidArrangement.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval aegi...
[ { "input": "[[[1, 2], [1, 3], [2, 1]]]", "output": "[[1, 2], [2, 1], [1, 3]]" }, { "input": "[[[1, 3], [3, 2], [2, 1]]]", "output": "[[1, 3], [3, 2], [2, 1]]" }, { "input": "[[[100, 200], [200, 300], [300, 100]]]", "output": "[[100, 200], [200, 300], [300, 100]]" }, { "input"...
79
false
79
verified
10
10
1
18,150
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.ValidArrangement.Code.Funs /-! # Specifications of `Aegis.ValidArrangement.valid_arrangement` LeetCode problem `valid-arrangement-of-pairs`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.ValidArrangement def rowFst (v : alloc.vec....
5
subsequence-of-size-k-with-the-largest-even-sum
2,098
Medium
[ "Greedy", "Array", "Sorting" ]
You are given an integer array nums and an integer k. Find the largest even sum of any subsequence of nums that has a length of k. Return this sum, or -1 if such a sum does not exist. A subsequence is an array that can be derived from another array by deleting some or no elements without changing the order of the remai...
largestEvenSum(nums: list_int, k: int) -> int
pub fn largest_even_sum(nums: &[i64], k: i64) -> i64
Aegis.LargestEvenSum.largest_even_sum
fn median3(x: i64, y: i64, z: i64) -> i64 { if x < y { if y < z { return y; } if x < z { return z; } return x; } else { if x < z { return x; } if y < z { return z; } return y; } } ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [largest_even_sum]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option lint...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [largest_even_sum]: function definitions module public import Aeneas public import Aegis.LargestEvenSum.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.LargestEvenSum.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], 1]", "output": "-1" }, { "input": "[[2], 1]", "output": "2" }, { "input": "[[4, 6, 2], 3]", "output": "12" }, { "input": "[[1, 3, 5], 1]", "output": "-1" }, { "input": "[[1, 3, 5], 3]", "output": "-1" }, { "input": "[[2, 4, 6], 1]", ...
123
false
123
verified
10
10
2
31,232
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.LargestEvenSum.Code.Funs /-! # Specifications of `Aegis.LargestEvenSum.largest_even_sum` LeetCode problem `subsequence-of-size-k-with-the-largest-even-sum`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.LargestEvenSum def IsSubseq...
4
find-subsequence-of-length-k-with-the-largest-sum
2,099
Easy
[ "Array", "Hash Table", "Sorting", "Heap (Priority Queue)" ]
You are given an integer array nums and an integer k. You want to find a subsequence of nums of length k that has the largest sum. Return any such subsequence as an integer array of length k. A subsequence is an array that can be derived from another array by deleting some or no elements without changing the order of t...
maxSubsequence(nums: list_int, k: int) -> list_int
pub fn max_subsequence(nums: &[i64], k: i64) -> Vec<i64>
Aegis.MaxSubsequence.max_subsequence
pub fn max_subsequence(nums: &[i64], k: i64) -> Vec<i64> { let n: usize = nums.len(); let ni: i64 = n as i64; // Phase 1: find min and max value (running extremes). let mut min_v: i64 = nums[0]; let mut max_v: i64 = nums[0]; let mut i: usize = 0; while i < n { if nums[i] < min_v { ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [max_subsequence]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linte...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [max_subsequence]: function definitions module public import Aeneas public import Aegis.MaxSubsequence.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.MaxSubsequence.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], 1]", "output": "[1]" }, { "input": "[[0, 0, 0, 0], 2]", "output": "[0, 0]" }, { "input": "[[-1, -2, -3, -4], 2]", "output": "[-1, -2]" }, { "input": "[[2, 1, 3, 3], 2]", "output": "[3, 3]" }, { "input": "[[-10, -20, -30, -40], 2]", "output": ...
99
false
99
verified_partial
10
5
3
35,036
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MaxSubsequence.Code.Funs /-! # Specifications of `Aegis.MaxSubsequence.max_subsequence` LeetCode problem `find-subsequence-of-length-k-with-the-largest-sum`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.MaxSubsequence def toInts (l :...
14
find-good-days-to-rob-the-bank
2,100
Medium
[ "Array", "Dynamic Programming", "Prefix Sum" ]
You and a gang of thieves are planning on robbing a bank. You are given a 0-indexed integer array security, where security[i] is the number of guards on duty on the ith day. The days are numbered starting from 0. You are also given an integer time. The ith day is a good day to rob the bank if: There are at least time ...
goodDaysToRobBank(security: list_int, time: int) -> list_int
pub fn good_days_to_rob_bank(security: &[i64], time: i64) -> Vec<i64>
Aegis.GoodDaysToRobBank.good_days_to_rob_bank
pub fn good_days_to_rob_bank(security: &[i64], time: i64) -> Vec<i64> { let n: usize = security.len(); let mut left: Vec<i64> = Vec::new(); let mut i: usize = 0; while i < n { if i == 0 { left.push(0); } else if security[i - 1] >= security[i] { let prev: i64 = le...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [good_days_to_rob_bank]: type definitions module public import Aeneas @[expose] public section 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 -- [good_days_to_rob_bank]: function definitions module public import Aeneas public import Aegis.GoodDaysToRobBank.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand fal...
import Aegis.GoodDaysToRobBank.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval aeg...
[ { "input": "[[1], 0]", "output": "[0]" }, { "input": "[[1, 2], 1]", "output": "[]" }, { "input": "[[2, 1], 1]", "output": "[]" }, { "input": "[[6, 5, 4, 3, 2, 1], 2]", "output": "[]" }, { "input": "[[1, 2, 3, 4, 5, 6], 2]", "output": "[]" }, { "input":...
123
false
123
verified
10
10
1
4,966
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.GoodDaysToRobBank.Code.Funs /-! # Specifications of `Aegis.GoodDaysToRobBank.good_days_to_rob_bank` LeetCode problem `find-good-days-to-rob-the-bank`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.GoodDaysToRobBank def valAt (secu...
9
detonate-the-maximum-bombs
2,101
Medium
[ "Depth-First Search", "Breadth-First Search", "Graph", "Geometry", "Array", "Math" ]
You are given a list of bombs. The range of a bomb is defined as the area where its effect can be felt. This area is in the shape of a circle with the center as the location of the bomb. The bombs are represented by a 0-indexed 2D integer array bombs where bombs[i] = [xi, yi, ri]. xi and yi denote the X-coordinate and ...
maximumDetonation(bombs: list_list_int) -> int
pub fn maximum_detonation(bombs: &[Vec<i64>]) -> i64
Aegis.MaximumDetonation.maximum_detonation
pub fn maximum_detonation(bombs: &[Vec<i64>]) -> i64 { let n: usize = bombs.len(); if n == 0 { return 0; } let mut best: i64 = 0; let mut start: usize = 0; while start < n { let mut visited: Vec<bool> = Vec::new(); let mut k: usize = 0; while k < n { ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [maximum_detonation]: type definitions module public import Aeneas @[expose] public section 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_detonation]: function definitions module public import Aeneas public import Aegis.MaximumDetonation.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false ...
import Aegis.MaximumDetonation.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval aeg...
[ { "input": "[[[1, 1, 5], [10, 10, 5]]]", "output": "1" }, { "input": "[[[2, 1, 3], [6, 1, 4]]]", "output": "2" }, { "input": "[[[10, 10, 5], [15, 15, 5], [20, 20, 5]]]", "output": "1" }, { "input": "[[[1, 1, 1], [2, 2, 1], [3, 3, 1]]]", "output": "1" }, { "input":...
113
false
113
verified
10
10
1
2,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.MaximumDetonation.Code.Funs /-! # Specifications of `Aegis.MaximumDetonation.maximum_detonation` LeetCode problem `detonate-the-maximum-bombs`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.MaximumDetonation open Aegis.MaximumDeto...
14
rings-and-rods
2,103
Easy
[ "Hash Table", "String" ]
There are n rings and each ring is either red, green, or blue. The rings are distributed across ten rods labeled from 0 to 9. You are given a string rings of length 2n that describes the n rings that are placed onto the rods. Every two characters in rings forms a color-position pair that is used to describe each ring w...
countPoints(rings: str) -> int
pub fn count_points(rings: &[u8]) -> i64
Aegis.CountPoints.count_points
pub fn count_points(rings: &[u8]) -> i64 { let mut masks: Vec<i64> = Vec::new(); let mut k: usize = 0; while k < 10 { masks.push(0); k += 1; } let mut i: usize = 0; while i + 1 < rings.len() { let color = rings[i]; let rod = (rings[i + 1] - b'0') as usize; ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [count_points]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter.s...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [count_points]: function definitions module public import Aeneas public import Aegis.CountPoints.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option l...
import Aegis.CountPoints.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 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": "[\"R0G0B0R1G1B1R2G2B2\"]", "output": "3" }, { "input": "[\"R9G9B9R9G9B9R9G9B9\"]", "output": "1" }, { "input": "[\"G4\"]", "output": "0" }, { "input": "[\"R0G0R0G0R0G0\"]", "output": "0" }, { "input": "[\"G0G1G2G3G4G5G6G7G8G9\"]", "output": "0" }...
99
false
99
verified
10
10
1
616
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.CountPoints.Code.Funs /-! # Specifications of `Aegis.CountPoints.count_points` LeetCode problem `rings-and-rods`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.CountPoints namespace AegisSpec.CountPoints def byteAt? (rings : Slice U8) (i : Nat...
11
sum-of-subarray-ranges
2,104
Medium
[ "Stack", "Array", "Monotonic Stack" ]
You are given an integer array nums. The range of a subarray of nums is the difference between the largest and smallest element in the subarray. Return the sum of all subarray ranges of nums. A subarray is a contiguous non-empty sequence of elements within an array.   Example 1: Input: nums = [1,2,3] Output: 4 Explana...
subArrayRanges(nums: list_int) -> int
pub fn sub_array_ranges(nums: &[i64]) -> i64
Aegis.SubArrayRanges.sub_array_ranges
pub fn sub_array_ranges(nums: &[i64]) -> i64 { let n: usize = nums.len(); let mut total: i64 = 0; let mut i: usize = 0; while i < n { let mut min_val: i64 = nums[i]; let mut max_val: i64 = nums[i]; let mut j: usize = i; while j < n { let x: i64 = nums[j]; ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [sub_array_ranges]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option lint...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [sub_array_ranges]: function definitions module public import Aeneas public import Aegis.SubArrayRanges.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.SubArrayRanges.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": "[[5]]", "output": "0" }, { "input": "[[1, 3, 3]]", "output": "4" }, { "input": "[[1, 2, 3]]", "output": "4" }, { "input": "[[-1, -2, -3, -4]]", "output": "10" }, { "input": "[[0, 0, 0, 0]]", "output": "0" }, { "input": "[[100, 100, 100, 100...
127
false
127
verified
10
10
1
612
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.SubArrayRanges.Code.Funs /-! # Specifications of `Aegis.SubArrayRanges.sub_array_ranges` LeetCode problem `sum-of-subarray-ranges`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.SubArrayRanges namespace AegisSpec.SubArrayRanges def ints (nums ...
14
watering-plants-ii
2,105
Medium
[ "Array", "Two Pointers", "Simulation" ]
Alice and Bob want to water n plants in their garden. The plants are arranged in a row and are labeled from 0 to n - 1 from left to right where the ith plant is located at x = i. Each plant needs a specific amount of water. Alice and Bob have a watering can each, initially full. They water the plants in the following w...
minimumRefill(plants: list_int, capacityA: int, capacityB: int) -> int
pub fn minimum_refill(plants: &[i64], capacityA: i64, capacityB: i64) -> i64
Aegis.MinimumRefill.minimum_refill
pub fn minimum_refill(plants: &[i64], capacityA: i64, capacityB: i64) -> i64 { let n = plants.len(); let mut left: usize = 0; let mut right: usize = n - 1; let mut water_a = capacityA; let mut water_b = capacityB; let mut refills: i64 = 0; while left < right { if water_a < plants[le...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [minimum_refill]: type definitions module public import Aeneas @[expose] public section 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_refill]: function definitions module public import Aeneas public import Aegis.MinimumRefill.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.MinimumRefill.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": "[[5], 10, 8]", "output": "0" }, { "input": "[[1000000], 1000000, 1000000]", "output": "0" }, { "input": "[[1000000, 1000000, 1000000], 1000000, 1000000]", "output": "1" }, { "input": "[[5, 8, 6], 10, 10]", "output": "1" }, { "input": "[[2, 2, 3, 3], 5,...
104
false
104
verified
10
10
1
718
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MinimumRefill.Code.Funs /-! # Specifications of `Aegis.MinimumRefill.minimum_refill` LeetCode problem `watering-plants-ii`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.MinimumRefill namespace AegisSpec.MinimumRefill def amounts (plants...
11
maximum-fruits-harvested-after-at-most-k-steps
2,106
Hard
[ "Array", "Binary Search", "Prefix Sum", "Sliding Window" ]
Fruits are available at some positions on an infinite x-axis. You are given a 2D integer array fruits where fruits[i] = [positioni, amounti] depicts amounti fruits at the position positioni. fruits is already sorted by positioni in ascending order, and each positioni is unique. You are also given an integer startPos an...
maxTotalFruits(fruits: list_list_int, startPos: int, k: int) -> int
pub fn max_total_fruits(fruits: &[Vec<i64>], startPos: i64, k: i64) -> i64
Aegis.MaxTotalFruits.max_total_fruits
pub fn max_total_fruits(fruits: &[Vec<i64>], startPos: i64, k: i64) -> i64 { let n = fruits.len(); if n == 0 { return 0; } // Extract positions and amounts. let mut pos: Vec<i64> = Vec::new(); let mut amt: Vec<i64> = Vec::new(); let mut i: usize = 0; while i < n { pos.pu...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [max_total_fruits]: type definitions module public import Aeneas @[expose] public section 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_fruits]: function definitions module public import Aeneas public import Aegis.MaxTotalFruits.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.MaxTotalFruits.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": "[[[100000, 10000]], 90000, 20000]", "output": "10000" }, { "input": "[[[1, 10000], [20000, 10000]], 10000, 10000]", "output": "10000" }, { "input": "[[[1, 100], [50, 100], [100, 100]], 75, 25]", "output": "100" }, { "input": "[[[1, 10], [2, 10], [3, 10]], 1, 5]", ...
114
false
114
verified
10
10
1
5,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.MaxTotalFruits.Code.Funs /-! # Specifications of `Aegis.MaxTotalFruits.max_total_fruits` LeetCode problem `maximum-fruits-harvested-after-at-most-k-steps`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.MaxTotalFruits abbrev Fruits : T...
13
number-of-unique-flavors-after-sharing-k-candies
2,107
Medium
[ "Array", "Hash Table", "Sliding Window" ]
You are given a 0-indexed integer array candies, where candies[i] represents the flavor of the ith candy. Your mom wants you to share these candies with your little sister by giving her k consecutive candies, but you want to keep as many flavors of candies as possible. Return the maximum number of unique flavors of can...
shareCandies(candies: list_int, k: int) -> int
pub fn share_candies(candies: &[i64], k: i64) -> i64
Aegis.ShareCandies.share_candies
pub fn share_candies(candies: &[i64], k: i64) -> i64 { let n = candies.len(); if n == 0 { return 0; } let kk = k as usize; let mut max_value: i64 = 0; let mut i: usize = 0; while i < n { if candies[i] > max_value { max_value = candies[i]; } i += ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [share_candies]: type definitions module public import Aeneas @[expose] public section 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 -- [share_candies]: function definitions module public import Aeneas public import Aegis.ShareCandies.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.ShareCandies.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]", "output": "0" }, { "input": "[[1], 1]", "output": "0" }, { "input": "[[1, 2, 3], 3]", "output": "0" }, { "input": "[[2, 4, 5], 0]", "output": "3" }, { "input": "[[100000, 100000, 100000], 1]", "output": "1" }, { "input": "[[100000...
109
false
109
verified_partial
10
4
1
2,603
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.ShareCandies.Code.Funs /-! # Specifications of `Aegis.ShareCandies.share_candies` LeetCode problem `number-of-unique-flavors-after-sharing-k-candies`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.ShareCandies namespace AegisSpec.ShareCandi...
17
number-of-smooth-descent-periods-of-a-stock
2,110
Medium
[ "Array", "Math", "Dynamic Programming" ]
You are given an integer array prices representing the daily price history of a stock, where prices[i] is the stock price on the ith day. A smooth descent period of a stock consists of one or more contiguous days such that the price on each day is lower than the price on the preceding day by exactly 1. The first day of...
getDescentPeriods(prices: list_int) -> int
pub fn get_descent_periods(prices: &[i64]) -> i64
Aegis.GetDescentPeriods.get_descent_periods
pub fn get_descent_periods(prices: &[i64]) -> i64 { let n = prices.len(); if n == 0 { return 0; } let mut total: i64 = 1; let mut run: i64 = 1; let mut i: usize = 1; while i < n { if prices[i - 1] - prices[i] == 1 { run += 1; } else { run = 1; ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [get_descent_periods]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option l...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [get_descent_periods]: function definitions module public import Aeneas public import Aegis.GetDescentPeriods.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false...
import Aegis.GetDescentPeriods.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval aeg...
[ { "input": "[[1]]", "output": "1" }, { "input": "[[5]]", "output": "1" }, { "input": "[[8, 6, 7, 7]]", "output": "4" }, { "input": "[[3, 2, 1, 4]]", "output": "7" }, { "input": "[[3, 3, 3, 3, 3]]", "output": "5" }, { "input": "[[5, 4, 3, 2, 1]]", "...
116
false
116
verified
10
10
1
412
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.GetDescentPeriods.Code.Funs /-! # Specifications of `Aegis.GetDescentPeriods.get_descent_periods` LeetCode problem `number-of-smooth-descent-periods-of-a-stock`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.GetDescentPeriods (get_descent_peri...
10
minimum-operations-to-make-the-array-k-increasing
2,111
Hard
[ "Array", "Binary Search" ]
You are given a 0-indexed array arr consisting of n positive integers, and a positive integer k. The array arr is called K-increasing if arr[i-k] <= arr[i] holds for every index i, where k <= i <= n-1. For example, arr = [4, 1, 5, 2, 6, 2] is K-increasing for k = 2 because: arr[0] <= arr[2] (4 <= 5) arr[1] <= arr[3...
kIncreasing(arr: list_int, k: int) -> int
pub fn k_increasing(arr: &[i64], k: i64) -> i64
Aegis.KIncreasing.k_increasing
fn lnds_len(seq: &[i64]) -> i64 { let mut tails: Vec<i64> = Vec::new(); let n = seq.len(); let mut i: usize = 0; while i < n { let x = seq[i]; let mut lo: usize = 0; let mut hi: usize = tails.len(); while lo < hi { let mid = lo + (hi - lo) / 2; ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [k_increasing]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter.s...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [k_increasing]: function definitions module public import Aeneas public import Aegis.KIncreasing.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.KIncreasing.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, 2, 2, 2], 1]", "output": "0" }, { "input": "[[1, 5, 9, 13, 17], 4]", "output": "0" }, { "input": "[[5, 4, 3, 2, 1], 1]", "output": "4" }, { "input": "[[9, 7, 5, 3, 1], 2]", "output": "3" }, { "input": "[[5, 5, 5, 5, 5], 5]", "output": "0" ...
133
false
133
verified
10
10
1
2,639
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.KIncreasing.Code.Funs /-! # Specifications of `Aegis.KIncreasing.k_increasing` LeetCode problem `minimum-operations-to-make-the-array-k-increasing`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.KIncreasing def vals (arr : Slice I...
10
elements-in-array-after-removing-and-replacing-elements
2,113
Medium
[ "Array" ]
You are given a 0-indexed integer array nums. Initially on minute 0, the array is unchanged. Every minute, the leftmost element in nums is removed until no elements remain. Then, every minute, one element is appended to the end of nums, in the order they were removed in, until the original array is restored. This proce...
elementInNums(nums: list_int, queries: list_list_int) -> list_int
pub fn element_in_nums(nums: &[i64], queries: &[Vec<i64>]) -> Vec<i64>
Aegis.ElementInNums.element_in_nums
pub fn element_in_nums(nums: &[i64], queries: &[Vec<i64>]) -> Vec<i64> { let n_usize = nums.len(); let n = n_usize as i64; let period = n + n; let mut ans: Vec<i64> = Vec::new(); let mut qi: usize = 0; while qi < queries.len() { let q = &queries[qi]; let t = q[0]; let i...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [element_in_nums]: type definitions module public import Aeneas @[expose] public section 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 -- [element_in_nums]: function definitions module public import Aeneas public import Aegis.ElementInNums.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.ElementInNums.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], [[0, 0], [1, 0], [2, 0], [3, 0]]]", "output": "[2, -1, 2, -1]" }, { "input": "[[0, 1, 2], [[0, 2], [2, 0], [3, 2], [5, 0]]]", "output": "[2, 2, -1, 0]" }, { "input": "[[3, 5, 7, 9], [[0, 3], [4, 0], [7, 2], [10, 1]]]", "output": "[9, -1, 7, 9]" }, { "input":...
87
false
87
verified
10
10
1
3,288
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.ElementInNums.Code.Funs /-! # Specifications of `Aegis.ElementInNums.element_in_nums` LeetCode problem `elements-in-array-after-removing-and-replacing-elements`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.ElementInNums namespace AegisSpe...
12
maximum-number-of-words-found-in-sentences
2,114
Easy
[ "Array", "String" ]
A sentence is a list of words that are separated by a single space with no leading or trailing spaces. You are given an array of strings sentences, where each sentences[i] represents a single sentence. Return the maximum number of words that appear in a single sentence.   Example 1: Input: sentences = ["alice and bob ...
mostWordsFound(sentences: list_str) -> int
pub fn most_words_found(sentences: &[Vec<u8>]) -> i64
Aegis.MostWordsFound.most_words_found
pub fn most_words_found(sentences: &[Vec<u8>]) -> i64 { let mut max_words: i64 = 0; let mut i: usize = 0; while i < sentences.len() { let sentence = &sentences[i]; let mut words: i64 = 1; let mut j: usize = 0; while j < sentence.len() { if sentence[j] == b' ' { ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [most_words_found]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option lint...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [most_words_found]: function definitions module public import Aeneas public import Aegis.MostWordsFound.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.MostWordsFound.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": "[[\"one\"]]", "output": "1" }, { "input": "[[\"one two three four five six seven eight nine ten\"]]", "output": "10" }, { "input": "[[\"a b c d e f g h i j k l m n o p q r s t u v w x y z\"]]", "output": "26" }, { "input": "[[\"the longest sentence in this list is...
78
false
78
verified
10
10
1
487
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MostWordsFound.Code.Funs /-! # Specifications of `Aegis.MostWordsFound.most_words_found` LeetCode problem `maximum-number-of-words-found-in-sentences`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.MostWordsFound abbrev Sentence :...
8
check-if-a-parentheses-string-can-be-valid
2,116
Medium
[ "Stack", "Greedy", "String" ]
A parentheses string is a non-empty string consisting only of '(' and ')'. It is valid if any of the following conditions is true: It is (). It can be written as AB (A concatenated with B), where A and B are valid parentheses strings. It can be written as (A), where A is a valid parentheses string. You are given a pa...
canBeValid(s: str, locked: str) -> bool
pub fn can_be_valid(s: &[u8], locked: &[u8]) -> bool
Aegis.CanBeValid.can_be_valid
pub fn can_be_valid(s: &[u8], locked: &[u8]) -> bool { let n = s.len(); if n == 0 || n % 2 != 0 { return false; } let nl = locked.len(); let mut ok: bool = true; let mut balance: i64 = 0; let mut i: usize = 0; // Left-to-right pass: treat every changeable position as '('. ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [can_be_valid]: type definitions module public import Aeneas @[expose] public section 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 -- [can_be_valid]: function definitions module public import Aeneas public import Aegis.CanBeValid.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option li...
import Aegis.CanBeValid.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": "[\"(((())(((())\", \"111111010111\"]", "output": "true" }, { "input": "[\"()))()\", \"010100\"]", "output": "true" }, { "input": "[\"()()\", \"0000\"]", "output": "true" }, { "input": "[\")\", \"0\"]", "output": "false" }, { "input": "[\"()()()()()()()...
81
false
81
verified
10
10
3
9,881
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.CanBeValid.Code.Funs /-! # Specifications of `Aegis.CanBeValid.can_be_valid` LeetCode problem `check-if-a-parentheses-string-can-be-valid`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.CanBeValid namespace AegisSpec.CanBeValid def cLPar...
12
a-number-after-a-double-reversal
2,119
Easy
[ "Math" ]
Reversing an integer means to reverse all its digits. For example, reversing 2021 gives 1202. Reversing 12300 gives 321 as the leading zeros are not retained. Given an integer num, reverse num to get reversed1, then reverse reversed1 to get reversed2. Return true if reversed2 equals num. Otherwise return false.   Exa...
isSameAfterReversals(num: int) -> bool
pub fn is_same_after_reversals(num: i64) -> bool
Aegis.IsSameAfterReversals.is_same_after_reversals
pub fn is_same_after_reversals(num: i64) -> bool { if num == 0 { return true; } num % 10 != 0 }
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [is_same_after_reversals]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_opti...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [is_same_after_reversals]: function definitions module public import Aeneas public import Aegis.IsSameAfterReversals.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashComman...
import Aegis.IsSameAfterReversals.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": "[987654321]", "output": "true" }, { "input": "[1001]", "output": "true" }, { "input": "[1000000]", "output": "false" }, { "input": "[999999]", "output": "true" }, { "input": "[1200]", "output": "false" }, { "input": "[0]", "output": "tr...
66
false
66
verified
10
10
1
146
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.IsSameAfterReversals.Code.Funs /-! # Specifications of `Aegis.IsSameAfterReversals.is_same_after_reversals` LeetCode problem `a-number-after-a-double-reversal`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result set_option autoImplicit false namespace AegisSp...
8
execution-of-all-suffix-instructions-staying-in-a-grid
2,120
Medium
[ "String", "Simulation" ]
There is an n x n grid, with the top-left cell at (0, 0) and the bottom-right cell at (n - 1, n - 1). You are given the integer n and an integer array startPos where startPos = [startrow, startcol] indicates that a robot is initially at cell (startrow, startcol). You are also given a 0-indexed string s of length m wher...
executeInstructions(n: int, startPos: list_int, s: str) -> list_int
pub fn execute_instructions(n: i64, startPos: &[i64], s: &[u8]) -> Vec<i64>
Aegis.ExecuteInstructions.execute_instructions
pub fn execute_instructions(n: i64, startPos: &[i64], s: &[u8]) -> Vec<i64> { let m: usize = s.len(); let mut answer: Vec<i64> = Vec::new(); let mut i: usize = 0; while i < m { let mut row: i64 = startPos[0]; let mut col: i64 = startPos[1]; let mut count: i64 = 0; let mu...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [execute_instructions]: type definitions module public import Aeneas @[expose] public section 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 -- [execute_instructions]: function definitions module public import Aeneas public import Aegis.ExecuteInstructions.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand fa...
import Aegis.ExecuteInstructions.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval a...
[ { "input": "[3, [2, 0], \"RRU\"]", "output": "[3, 2, 1]" }, { "input": "[3, [0, 2], \"LLD\"]", "output": "[3, 2, 1]" }, { "input": "[1, [0, 0], \"LRUD\"]", "output": "[0, 0, 0, 0]" }, { "input": "[4, [2, 2], \"DDDD\"]", "output": "[1, 1, 1, 1]" }, { "input": "[4, ...
89
false
89
verified
10
10
1
1,307
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.ExecuteInstructions.Code.Funs /-! # Specifications of `Aegis.ExecuteInstructions.execute_instructions` LeetCode problem `execution-of-all-suffix-instructions-staying-in-a-grid`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.ExecuteInst...
10
intervals-between-identical-elements
2,121
Medium
[ "Array", "Hash Table", "Prefix Sum" ]
You are given a 0-indexed array of n integers arr. The interval between two elements in arr is defined as the absolute difference between their indices. More formally, the interval between arr[i] and arr[j] is |i - j|. Return an array intervals of length n where intervals[i] is the sum of intervals between arr[i] and e...
getDistances(arr: list_int) -> list_int
pub fn get_distances(arr: &[i64]) -> Vec<i64>
Aegis.GetDistances.get_distances
pub fn get_distances(arr: &[i64]) -> Vec<i64> { let n = arr.len(); if n == 0 { return Vec::new(); } // Find the maximum value to size the counting array. let mut max_val = arr[0]; let mut i = 1; while i < n { if arr[i] > max_val { max_val = arr[i]; } ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [get_distances]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter....
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [get_distances]: function definitions module public import Aeneas public import Aegis.GetDistances.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.GetDistances.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": "[[10, 5, 10, 10]]", "output": "[5, 0, 3, 4]" }, { "input": "[[5, 4, 3, 2, 1]]", "output": "[0, 0, 0, 0, 0]" }, { "input": "[[1, 2, 3, 4, 5]]", "output": "[0, 0, 0, 0, 0]" }, { "input": "[[5, 5, 5, 5, 5]]", "output": "[10, 7, 6, 7, 10]" }, { "input": "[...
89
false
89
verified_partial
10
8
1
9,381
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.GetDistances.Code.Funs /-! # Specifications of `Aegis.GetDistances.get_distances` LeetCode problem `intervals-between-identical-elements`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.GetDistances def rev (arr : Slice I64) : Slice I6...
9
minimum-operations-to-remove-adjacent-ones-in-matrix
2,123
Hard
[ "Graph", "Array", "Matrix" ]
You are given a 0-indexed binary matrix grid. In one operation, you can flip any 1 in grid to be 0. A binary matrix is well-isolated if there is no 1 in the matrix that is 4-directionally connected (i.e., horizontal and vertical) to another 1. Return the minimum number of operations to make grid well-isolated.   Exampl...
minimumOperations(grid: list_list_int) -> int
pub fn minimum_operations(grid: &[Vec<i64>]) -> i64
Aegis.MinimumOperations.minimum_operations
fn neighbor(u: i64, dir: i64, m: i64, n: i64, grid: &[Vec<i64>]) -> i64 { let i = u / n; let j = u % n; let mut r = -1; if dir == 0 { if i > 0 && grid[(i - 1) as usize][j as usize] == 1 { r = (i - 1) * n + j; } } else if dir == 1 { if i + 1 < m && grid[(i + 1) as ...
-- 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": "[[[0, 1], [1, 0]]]", "output": "0" }, { "input": "[[[1, 1, 1], [1, 1, 1], [1, 1, 1]]]", "output": "4" }, { "input": "[[[1, 1, 1], [1, 0, 1], [1, 1, 1]]]", "output": "4" }, { "input": "[[[0, 0, 0], [0, 0, 0], [0, 0, 0]]]", "output": "0" }, { "input": "[...
74
false
74
verified
10
10
2
30,575
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MinimumOperations.Code.Funs /-! # Specifications of `Aegis.MinimumOperations.minimum_operations` LeetCode problem `minimum-operations-to-remove-adjacent-ones-in-matrix`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.MinimumOperations (minimum_op...
13
check-if-all-as-appears-before-all-bs
2,124
Easy
[ "String" ]
Given a string s consisting of only the characters 'a' and 'b', return true if every 'a' appears before every 'b' in the string. Otherwise, return false.   Example 1: Input: s = "aaabbb" Output: true Explanation: The 'a's are at indices 0, 1, and 2, while the 'b's are at indices 3, 4, and 5. Hence, every 'a' appears b...
checkString(s: str) -> bool
pub fn check_string(s: &[u8]) -> bool
Aegis.CheckString.check_string
pub fn check_string(s: &[u8]) -> bool { let mut i: usize = 0; let mut seen_b: bool = false; while i < s.len() { if s[i] == b'b' { seen_b = true; } else if s[i] == b'a' && seen_b { return false; } i += 1; } true }
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [check_string]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter.s...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [check_string]: function definitions module public import Aeneas public import Aegis.CheckString.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.CheckString.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": "[\"b\"]", "output": "true" }, { "input": "[\"aaaaabbbbb\"]", "output": "true" }, { "input": "[\"bbb\"]", "output": "true" }, { "input": "[\"ab\"]", "output": "true" }, { "input": "[\"aabbaa\"]", "output": "false" }, { "input": "[\"ba\"]", ...
152
false
152
verified
10
10
1
256
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.CheckString.Code.Funs /-! # Specifications of `Aegis.CheckString.check_string` LeetCode problem `check-if-all-as-appears-before-all-bs`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.CheckString def lastA (s : Slice Std.U8) : Int ...
8
number-of-laser-beams-in-a-bank
2,125
Medium
[ "Array", "Math", "String", "Matrix" ]
Anti-theft security devices are activated inside a bank. You are given a 0-indexed binary string array bank representing the floor plan of the bank, which is an m x n 2D matrix. bank[i] represents the ith row, consisting of '0's and '1's. '0' means the cell is empty, while'1' means the cell has a security device. There...
numberOfBeams(bank: list_str) -> int
pub fn number_of_beams(bank: &[Vec<u8>]) -> i64
Aegis.NumberOfBeams.number_of_beams
pub fn number_of_beams(bank: &[Vec<u8>]) -> i64 { let m = bank.len(); let mut total: i64 = 0; let mut prev: i64 = 0; let mut i: usize = 0; while i < m { let row = &bank[i]; let n = row.len(); let mut count: i64 = 0; let mut j: usize = 0; while j < n { ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [number_of_beams]: type definitions module public import Aeneas @[expose] public section 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_beams]: function definitions module public import Aeneas public import Aegis.NumberOfBeams.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.NumberOfBeams.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": "[[\"111\", \"000\", \"111\"]]", "output": "9" }, { "input": "[[\"11111\", \"11111\", \"11111\"]]", "output": "50" }, { "input": "[[\"000\", \"000\", \"000\"]]", "output": "0" }, { "input": "[[\"000\", \"111\", \"000\"]]", "output": "0" }, { "input": "[...
117
false
117
verified
10
10
1
662
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.NumberOfBeams.Code.Funs /-! # Specifications of `Aegis.NumberOfBeams.number_of_beams` LeetCode problem `number-of-laser-beams-in-a-bank`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.NumberOfBeams def row (bank : Slice (alloc.vec.Vec...
12
destroying-asteroids
2,126
Medium
[ "Greedy", "Array", "Sorting" ]
You are given an integer mass, which represents the original mass of a planet. You are further given an integer array asteroids, where asteroids[i] is the mass of the ith asteroid. You can arrange for the planet to collide with the asteroids in any arbitrary order. If the mass of the planet is greater than or equal to ...
asteroidsDestroyed(mass: int, asteroids: list_int) -> bool
pub fn asteroids_destroyed(mass: i64, asteroids: &[i64]) -> bool
Aegis.AsteroidsDestroyed.asteroids_destroyed
pub fn asteroids_destroyed(mass: i64, asteroids: &[i64]) -> bool { let n: usize = asteroids.len(); if n == 0 { return true; } let mut a: Vec<i64> = Vec::new(); let mut b: Vec<i64> = Vec::new(); let mut i: usize = 0; let mut minv: i64 = asteroids[0]; let mut maxv: i64 = asteroids...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [asteroids_destroyed]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option l...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [asteroids_destroyed]: function definitions module public import Aeneas public import Aegis.AsteroidsDestroyed.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand fals...
import Aegis.AsteroidsDestroyed.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, [100000]]", "output": "false" }, { "input": "[100000, [100000]]", "output": "true" }, { "input": "[25, [5, 10, 15]]", "output": "true" }, { "input": "[5, [4, 9, 23, 4]]", "output": "false" }, { "input": "[1, [1, 1, 1, 1]]", "output": "true" }...
88
false
88
verified
10
10
2
20,152
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.AsteroidsDestroyed.Code.Funs /-! # Specifications of `Aegis.AsteroidsDestroyed.asteroids_destroyed` LeetCode problem `destroying-asteroids`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.AsteroidsDestroyed namespace AegisSpec.AsteroidsDestroyed...
15
maximum-employees-to-be-invited-to-a-meeting
2,127
Hard
[ "Depth-First Search", "Graph", "Topological Sort" ]
A company is organizing a meeting and has a list of n employees, waiting to be invited. They have arranged for a large circular table, capable of seating any number of employees. The employees are numbered from 0 to n - 1. Each employee has a favorite person and they will attend the meeting only if they can sit next to...
maximumInvitations(favorite: list_int) -> int
pub fn maximum_invitations(favorite: &[i64]) -> i64
Aegis.MaximumInvitations.maximum_invitations
pub fn maximum_invitations(favorite: &[i64]) -> i64 { let n = favorite.len(); let mut indeg: Vec<i64> = Vec::new(); let mut depth: Vec<i64> = Vec::new(); let mut visited: Vec<bool> = Vec::new(); let mut i: usize = 0; while i < n { indeg.push(0); depth.push(0); visited.p...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [maximum_invitations]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option l...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [maximum_invitations]: function definitions module public import Aeneas public import Aegis.MaximumInvitations.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand fals...
import Aegis.MaximumInvitations.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 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, 2, 0]]", "output": "3" }, { "input": "[[1, 0, 0, 2]]", "output": "4" }, { "input": "[[1, 0, 3, 2]]", "output": "4" }, { "input": "[[3, 3, 0, 2]]", "output": "3" }, { "input": "[[2, 2, 1, 2]]", "output": "3" }, { "input": "[[0, 1, 2, 3,...
127
false
127
verified
10
10
1
11,496
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MaximumInvitations.Code.Funs /-! # Specifications of `Aegis.MaximumInvitations.maximum_invitations` LeetCode problem `maximum-employees-to-be-invited-to-a-meeting`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.MaximumInvitations ...
12
remove-all-ones-with-row-and-column-flips
2,128
Medium
[ "Bit Manipulation", "Array", "Math", "Matrix" ]
You are given an m x n binary matrix grid. In one operation, you can choose any row or column and flip each value in that row or column (i.e., changing all 0's to 1's, and all 1's to 0's). Return true if it is possible to remove all 1's from grid using any number of operations or false otherwise.   Example 1: Input: ...
removeOnes(grid: list_list_int) -> bool
pub fn remove_ones(grid: &[Vec<i64>]) -> bool
Aegis.RemoveOnes.remove_ones
pub fn remove_ones(grid: &[Vec<i64>]) -> bool { let m = grid.len(); if m == 0 { return true; } let n = grid[0].len(); let mut i = 1; while i < m { let mut all_same = true; let mut all_flipped = true; let mut j = 0; while j < n { if grid[i][j...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [remove_ones]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter.st...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [remove_ones]: function definitions module public import Aeneas public import Aegis.RemoveOnes.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.RemoveOnes.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval aegisCase ...
[ { "input": "[[[0]]]", "output": "true" }, { "input": "[[[1], [1]]]", "output": "true" }, { "input": "[[[0, 0], [0, 0]]]", "output": "true" }, { "input": "[[[1, 0], [0, 1]]]", "output": "true" }, { "input": "[[[0, 0], [1, 1]]]", "output": "true" }, { "i...
82
false
82
verified
10
10
1
1,037
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.RemoveOnes.Code.Funs /-! # Specifications of `Aegis.RemoveOnes.remove_ones` LeetCode problem `remove-all-ones-with-row-and-column-flips`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.RemoveOnes namespace AegisSpec.RemoveOnes abbrev Grid : Ty...
15
maximum-twin-sum-of-a-linked-list
2,130
Medium
[ "Stack", "Linked List", "Two Pointers" ]
In a linked list of size n, where n is even, the ith node (0-indexed) of the linked list is known as the twin of the (n-1-i)th node, if 0 <= i <= (n / 2) - 1. For example, if n = 4, then node 0 is the twin of node 3, and node 1 is the twin of node 2. These are the only nodes with twins for n = 4. The twin sum is defi...
pairSum(head: linkedlist) -> int
pub fn pair_sum(head: &List) -> i64
Aegis.PairSum.pair_sum
pub fn pair_sum(head: &List) -> i64 { let mut vals: Vec<i64> = Vec::new(); let mut cur: &List = head; let mut done: bool = false; while !done { match cur { List::Nil => { done = true; } List::Cons(v, next) => { vals.push(*v); ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [pair_sum]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter.style...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [pair_sum]: function definitions module public import Aeneas public import Aegis.PairSum.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.PairSum.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval aegisCase "ev...
[ { "input": "[[1, 100000]]", "output": "100001" }, { "input": "[[4, 2, 2, 3]]", "output": "7" }, { "input": "[[99999, 99999, 99999, 99999]]", "output": "199998" }, { "input": "[[100000, 1, 100000, 1]]", "output": "100001" }, { "input": "[[5, 4, 2, 1]]", "output...
89
false
89
verified
10
10
1
6,391
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.PairSum.Code.Funs /-! # Specifications of `Aegis.PairSum.pair_sum` LeetCode problem `maximum-twin-sum-of-a-linked-list`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.PairSum def vals (head : Aegis.PairSum.List) : List ℤ := match he...
9
longest-palindrome-by-concatenating-two-letter-words
2,131
Medium
[ "Greedy", "Array", "Hash Table", "String", "Counting" ]
You are given an array of strings words. Each element of words consists of two lowercase English letters. Create the longest possible palindrome by selecting some elements from words and concatenating them in any order. Each element can be selected at most once. Return the length of the longest palindrome that you can ...
longestPalindrome(words: list_str) -> int
pub fn longest_palindrome(words: &[Vec<u8>]) -> i64
Aegis.LongestPalindrome.longest_palindrome
pub fn longest_palindrome(words: &[Vec<u8>]) -> i64 { let mut counts: Vec<i64> = Vec::new(); let mut k: usize = 0; while k < 676 { counts.push(0); k += 1; } let mut i: usize = 0; while i < words.len() { let w = &words[i]; let a: usize = (w[0] as usize) - 97; ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [longest_palindrome]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option li...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [longest_palindrome]: function definitions module public import Aeneas public import Aegis.LongestPalindrome.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false ...
import Aegis.LongestPalindrome.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 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": "[[\"cc\", \"ll\", \"xx\"]]", "output": "2" }, { "input": "[[\"lc\", \"cl\", \"gg\"]]", "output": "6" }, { "input": "[[\"aa\", \"aa\", \"aa\", \"aa\"]]", "output": "8" }, { "input": "[[\"aa\", \"bb\", \"cc\", \"dd\", \"ee\"]]", "output": "2" }, { "input...
52
false
52
verified
10
10
1
2,695
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.LongestPalindrome.Code.Funs /-! # Specifications of `Aegis.LongestPalindrome.longest_palindrome` LeetCode problem `longest-palindrome-by-concatenating-two-letter-words`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.LongestPalindrome (longest_pa...
14
stamping-the-grid
2,132
Hard
[ "Greedy", "Array", "Matrix", "Prefix Sum" ]
You are given an m x n binary matrix grid where each cell is either 0 (empty) or 1 (occupied). You are then given stamps of size stampHeight x stampWidth. We want to fit the stamps such that they follow the given restrictions and requirements: Cover all the empty cells. Do not cover any of the occupied cells. We can p...
possibleToStamp(grid: list_list_int, stampHeight: int, stampWidth: int) -> bool
pub fn possible_to_stamp(grid: &[Vec<i64>], stampHeight: i64, stampWidth: i64) -> bool
Aegis.PossibleToStamp.possible_to_stamp
pub fn possible_to_stamp(grid: &[Vec<i64>], stampHeight: i64, stampWidth: i64) -> bool { let m = grid.len(); let n = grid[0].len(); let sh = stampHeight as usize; let sw = stampWidth as usize; // Prefix sum of the grid, size (m+1) x (n+1) let mut pref: Vec<Vec<i64>> = Vec::new(); let mut i...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [possible_to_stamp]: type definitions module public import Aeneas @[expose] public section 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 -- [possible_to_stamp]: function definitions module public import Aeneas public import Aegis.PossibleToStamp.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.PossibleToStamp.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval aegis...
[ { "input": "[[[0, 0], [0, 0]], 1, 1]", "output": "true" }, { "input": "[[[0, 0, 0], [0, 0, 0], [0, 0, 0]], 1, 1]", "output": "true" }, { "input": "[[[1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1]], 2, 2]", "output": "true" }, { "input": "[[[1, 0, 0, 0], [0, 1, 0, 0], ...
81
false
81
verified
10
10
2
6,799
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.PossibleToStamp.Code.Funs /-! # Specifications of `Aegis.PossibleToStamp.possible_to_stamp` LeetCode problem `stamping-the-grid`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.PossibleToStamp abbrev Grid := Slice (alloc.vec.Vec I6...
12
minimum-swaps-to-group-all-1s-together-ii
2,134
Medium
[ "Array", "Sliding Window" ]
A swap is defined as taking two distinct positions in an array and swapping the values in them. A circular array is defined as an array where we consider the first element and the last element to be adjacent. Given a binary circular array nums, return the minimum number of swaps required to group all 1's present in the...
minSwaps(nums: list_int) -> int
pub fn min_swaps(nums: &[i64]) -> i64
Aegis.MinSwaps.min_swaps
pub fn min_swaps(nums: &[i64]) -> i64 { let n = nums.len(); let mut ones: usize = 0; let mut i: usize = 0; while i < n { if nums[i] == 1 { ones += 1; } i += 1; } if ones <= 1 { return 0; } let k = ones; let mut cur: i64 = 0; let mut...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [min_swaps]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter.styl...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [min_swaps]: function definitions module public import Aeneas public import Aegis.MinSwaps.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter....
import Aegis.MinSwaps.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval aegisCase "e...
[ { "input": "[[0, 0, 0, 0, 0]]", "output": "0" }, { "input": "[[1, 1, 0, 0, 1]]", "output": "0" }, { "input": "[[1, 1, 1, 1, 1]]", "output": "0" }, { "input": "[[1, 0, 0, 1, 0, 1]]", "output": "1" }, { "input": "[[0, 1, 0, 1, 1, 0, 0]]", "output": "1" }, { ...
117
false
117
verified
10
10
1
3,154
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MinSwaps.Code.Funs /-! # Specifications of `Aegis.MinSwaps.min_swaps` LeetCode problem `minimum-swaps-to-group-all-1s-together-ii`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.MinSwaps namespace AegisSpec.MinSwaps def vals (nums : Slice Std....
11
earliest-possible-day-of-full-bloom
2,136
Hard
[ "Greedy", "Array", "Sorting" ]
You have n flower seeds. Every seed must be planted first before it can begin to grow, then bloom. Planting a seed takes time and so does the growth of a seed. You are given two 0-indexed integer arrays plantTime and growTime, of length n each: plantTime[i] is the number of full days it takes you to plant the ith seed...
earliestFullBloom(plantTime: list_int, growTime: list_int) -> int
pub fn earliest_full_bloom(plantTime: &[i64], growTime: &[i64]) -> i64
Aegis.EarliestFullBloom.earliest_full_bloom
pub fn earliest_full_bloom(plantTime: &[i64], growTime: &[i64]) -> i64 { let n = plantTime.len(); let mut order: Vec<i64> = Vec::new(); let mut i: usize = 0; while i < n { order.push(i as i64); i += 1; } let mut temp: Vec<i64> = Vec::new(); i = 0; while i < n { ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [earliest_full_bloom]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option l...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [earliest_full_bloom]: function definitions module public import Aeneas public import Aegis.EarliestFullBloom.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false...
import Aegis.EarliestFullBloom.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval aeg...
[ { "input": "[[1], [1]]", "output": "2" }, { "input": "[[10000, 10000], [10000, 10000]]", "output": "30000" }, { "input": "[[10000, 10000], [1, 1]]", "output": "20001" }, { "input": "[[2, 2, 2], [3, 3, 3]]", "output": "9" }, { "input": "[[2, 2, 2], [3, 2, 1]]", ...
102
false
102
verified
10
10
1
4,406
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.EarliestFullBloom.Code.Funs /-! # Specifications of `Aegis.EarliestFullBloom.earliest_full_bloom` LeetCode problem `earliest-possible-day-of-full-bloom`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.EarliestFullBloom namespace AegisSpec.Earlie...
13
minimum-moves-to-reach-target-score
2,139
Medium
[ "Greedy", "Math" ]
You are playing a game with integers. You start with the integer 1 and you want to reach the integer target. In one move, you can either: Increment the current integer by one (i.e., x = x + 1). Double the current integer (i.e., x = 2 * x). You can use the increment operation any number of times, however, you can only...
minMoves(target: int, maxDoubles: int) -> int
pub fn min_moves(target: i64, maxDoubles: i64) -> i64
Aegis.MinMoves.min_moves
pub fn min_moves(target: i64, maxDoubles: i64) -> i64 { let mut x = target; let mut doubles = maxDoubles; let mut moves = 0i64; while x > 1 && doubles > 0 { if x % 2 == 1 { x -= 1; moves += 1; } if x > 1 && doubles > 0 { x /= 2; m...
-- 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": "[2, 1]", "output": "1" }, { "input": "[6, 0]", "output": "5" }, { "input": "[1000000000, 100]", "output": "41" }, { "input": "[8, 3]", "output": "3" }, { "input": "[100, 10]", "output": "8" }, { "input": "[256, 8]", "output": "8" }, ...
140
false
140
verified
10
10
1
1,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-reach-target-score`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.MinMoves open Aegis.MinMoves (min_moves) inductive Move where...
12
solving-questions-with-brainpower
2,140
Medium
[ "Array", "Dynamic Programming" ]
You are given a 0-indexed 2D integer array questions where questions[i] = [pointsi, brainpoweri]. The array describes the questions of an exam, where you have to process the questions in order (i.e., starting from question 0) and make a decision whether to solve or skip each question. Solving question i will earn you p...
mostPoints(questions: list_list_int) -> int
pub fn most_points(questions: &[Vec<i64>]) -> i64
Aegis.MostPoints.most_points
pub fn most_points(questions: &[Vec<i64>]) -> i64 { let n = questions.len(); let mut dp: Vec<i64> = Vec::new(); let mut k = 0usize; while k <= n { dp.push(0); k += 1; } let mut i = n; while i > 0 { i -= 1; let points = questions[i][0]; let brainpowe...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [most_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.st...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [most_points]: function definitions module public import Aeneas public import Aegis.MostPoints.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.MostPoints.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, 10], [10, 5], [15, 1]]]", "output": "15" }, { "input": "[[[5, 1], [2, 2], [1, 1]]]", "output": "6" }, { "input": "[[[1, 5], [2, 3], [3, 2], [4, 1]]]", "output": "4" }, { "input": "[[[3, 2], [4, 3], [4, 4], [2, 5]]]", "output": "5" }, { "input": "...
108
false
108
verified
10
10
1
1,212
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MostPoints.Code.Funs /-! # Specifications of `Aegis.MostPoints.most_points` LeetCode problem `solving-questions-with-brainpower`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.MostPoints (most_points) namespace AegisSpec.MostPoints open Classi...
14
maximum-running-time-of-n-computers
2,141
Hard
[ "Greedy", "Array", "Binary Search", "Sorting" ]
You have n computers. You are given the integer n and a 0-indexed integer array batteries where the ith battery can run a computer for batteries[i] minutes. You are interested in running all n computers simultaneously using the given batteries. Initially, you can insert at most one battery into each computer. After tha...
maxRunTime(n: int, batteries: list_int) -> int
pub fn max_run_time(n: i64, batteries: &[i64]) -> i64
Aegis.MaxRunTime.max_run_time
fn can_run(n: i64, batteries: &[i64], t: i64) -> bool { let mut total: i64 = 0; let len = batteries.len(); let mut i: usize = 0; while i < len { if batteries[i] < t { total += batteries[i]; } else { total += t; } i += 1; } total >= n * t ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [max_run_time]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter.s...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [max_run_time]: function definitions module public import Aeneas public import Aegis.MaxRunTime.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option li...
import Aegis.MaxRunTime.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval aegisCase ...
[ { "input": "[1, [5]]", "output": "5" }, { "input": "[1, [100]]", "output": "100" }, { "input": "[1, [10]]", "output": "10" }, { "input": "[1, [1000000000]]", "output": "1000000000" }, { "input": "[2, [1000000000, 1000000000]]", "output": "1000000000" }, { ...
114
false
114
verified
10
10
1
1,047
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MaxRunTime.Code.Funs /-! # Specifications of `Aegis.MaxRunTime.max_run_time` LeetCode problem `maximum-running-time-of-n-computers`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.MaxRunTime def sliceSum (batteries : Slice Std.I64)...
16
choose-numbers-from-two-arrays-in-range
2,143
Hard
[ "Array", "Dynamic Programming" ]
You are given two 0-indexed integer arrays nums1 and nums2 of length n. A range [l, r] (inclusive) where 0 <= l <= r < n is balanced if: For every i in the range [l, r], you pick either nums1[i] or nums2[i]. The sum of the numbers you pick from nums1 equals to the sum of the numbers you pick from nums2 (the sum is con...
countSubranges(nums1: list_int, nums2: list_int) -> int
pub fn count_subranges(nums1: &[i64], nums2: &[i64]) -> i64
Aegis.CountSubranges.count_subranges
const MOD: i64 = 1_000_000_007; fn add_mod(a: i64, b: i64) -> i64 { let s = a + b; if s >= MOD { s - MOD } else { s } } pub fn count_subranges(nums1: &[i64], nums2: &[i64]) -> i64 { let n = nums1.len(); let mut dp: Vec<i64> = Vec::new(); dp.push(1); let mut zero_idx: ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [count_subranges]: type definitions module public import Aeneas @[expose] public section 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_subranges]: function definitions module public import Aeneas public import Aegis.CountSubranges.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.CountSubranges.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval aegisC...
[ { "input": "[[0, 100], [100, 0]]", "output": "4" }, { "input": "[[50, 50], [50, 50]]", "output": "2" }, { "input": "[[0, 1], [1, 0]]", "output": "4" }, { "input": "[[0, 100, 0], [100, 0, 0]]", "output": "12" }, { "input": "[[5, 10, 15], [15, 10, 5]]", "output"...
90
false
90
verified
10
10
2
30,219
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.CountSubranges.Code.Funs /-! # Specifications of `Aegis.CountSubranges.count_subranges` LeetCode problem `choose-numbers-from-two-arrays-in-range`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.CountSubranges namespace AegisSpec.CountSubran...
14
minimum-cost-of-buying-candies-with-discount
2,144
Easy
[ "Greedy", "Array", "Sorting" ]
A shop is selling candies at a discount. For every two candies sold, the shop gives a third candy for free. The customer can choose any candy to take away for free as long as the cost of the chosen candy is less than or equal to the minimum cost of the two candies bought. For example, if there are 4 candies with costs...
minimumCost(cost: list_int) -> int
pub fn minimum_cost(cost: &[i64]) -> i64
Aegis.MinimumCost.minimum_cost
pub fn minimum_cost(cost: &[i64]) -> i64 { let n = cost.len(); if n == 0 { return 0; } let mut v: Vec<i64> = Vec::new(); let mut i = 0; while i < n { v.push(cost[i]); i += 1; } // Sort in descending order using selection sort. let mut a = 0; while a < n ...
-- 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": "[[100]]", "output": "100" }, { "input": "[[1]]", "output": "1" }, { "input": "[[10, 20]]", "output": "30" }, { "input": "[[5, 5]]", "output": "10" }, { "input": "[[1, 2]]", "output": "3" }, { "input": "[[3, 2, 1]]", "output": "5" }, ...
96
false
96
verified
10
10
1
984
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MinimumCost.Code.Funs /-! # Specifications of `Aegis.MinimumCost.minimum_cost` LeetCode problem `minimum-cost-of-buying-candies-with-discount`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result ControlFlow Error namespace AegisSpec.MinimumCost def costAt (co...
10
count-the-hidden-sequences
2,145
Medium
[ "Array", "Prefix Sum" ]
You are given a 0-indexed array of n integers differences, which describes the differences between each pair of consecutive integers of a hidden sequence of length (n + 1). More formally, call the hidden sequence hidden, then we have that differences[i] = hidden[i + 1] - hidden[i]. You are further given two integers lo...
numberOfArrays(differences: list_int, lower: int, upper: int) -> int
pub fn number_of_arrays(differences: &[i64], lower: i64, upper: i64) -> i64
Aegis.NumberOfArrays.number_of_arrays
pub fn number_of_arrays(differences: &[i64], lower: i64, upper: i64) -> i64 { let mut prefix: i64 = 0; let mut min_prefix: i64 = 0; let mut max_prefix: i64 = 0; let mut i: usize = 0; while i < differences.len() { prefix = prefix + differences[i]; if prefix < min_prefix { ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [number_of_arrays]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option lint...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [number_of_arrays]: function definitions module public import Aeneas public import Aegis.NumberOfArrays.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.NumberOfArrays.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, -1]", "output": "1" }, { "input": "[[1], 1, 2]", "output": "1" }, { "input": "[[100000, -100000], -100000, 100000]", "output": "100001" }, { "input": "[[0, 0, 0], 1, 1]", "output": "1" }, { "input": "[[1, -3, 4], 1, 6]", "output": "2" ...
123
false
123
verified
10
10
1
1,120
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.NumberOfArrays.Code.Funs /-! # Specifications of `Aegis.NumberOfArrays.number_of_arrays` LeetCode problem `count-the-hidden-sequences`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.NumberOfArrays open Aegis.NumberOfArrays (number_of_...
8
k-highest-ranked-items-within-a-price-range
2,146
Medium
[ "Breadth-First Search", "Array", "Matrix", "Sorting", "Heap (Priority Queue)" ]
You are given a 0-indexed 2D integer array grid of size m x n that represents a map of the items in a shop. The integers in the grid represent the following: 0 represents a wall that you cannot pass through. 1 represents an empty cell that you can freely move to and from. All other positive integers represent the pric...
highestRankedKItems(grid: list_list_int, pricing: list_int, start: list_int, k: int) -> list_list_int
pub fn highest_ranked_k_items(grid: &[Vec<i64>], pricing: &[i64], start: &[i64], k: i64) -> Vec<Vec<i64>>
Aegis.HighestRankedKItems.highest_ranked_k_items
#[derive(Debug)] pub struct RankedItems(pub Vec<Vec<i64>>); impl RankedItems { pub fn len(&self) -> usize { self.0.len() } } impl core::ops::Index<usize> for RankedItems { type Output = Vec<i64>; fn index(&self, index: usize) -> &Vec<i64> { &self.0[index] } } impl PartialEq<Vec<Ve...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [highest_ranked_k_items]: type definitions module public import Aeneas @[expose] public 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 -- [highest_ranked_k_items]: function definitions module public import Aeneas public import Aegis.HighestRankedKItems.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand ...
import Aegis.HighestRankedKItems.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval a...
[ { "input": "[[[1, 1, 1], [0, 0, 1], [2, 3, 4]], [2, 3], [0, 0], 3]", "output": "[[2, 1], [2, 0]]" }, { "input": "[[[1, 2, 0, 1], [1, 3, 3, 1], [0, 2, 5, 1]], [2, 3], [2, 3], 2]", "output": "[[2, 1], [1, 2]]" }, { "input": "[[[1, 2, 0, 1], [1, 3, 0, 1], [0, 2, 5, 1]], [2, 5], [0, 0], 3]",...
79
false
79
verified
10
10
6
108,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.HighestRankedKItems.Code.Funs /-! # Specifications of `Aegis.HighestRankedKItems.highest_ranked_k_items` LeetCode problem `k-highest-ranked-items-within-a-price-range`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.HighestRankedKItems ...
10
number-of-ways-to-divide-a-long-corridor
2,147
Hard
[ "Math", "String", "Dynamic Programming" ]
Along a long library corridor, there is a line of seats and decorative plants. You are given a 0-indexed string corridor of length n consisting of letters 'S' and 'P' where each 'S' represents a seat and each 'P' represents a plant. One room divider has already been installed to the left of index 0, and another to the ...
numberOfWays(corridor: str) -> int
pub fn number_of_ways(corridor: &[u8]) -> i64
Aegis.NumberOfWays.number_of_ways
pub fn number_of_ways(corridor: &[u8]) -> i64 { let n: usize = corridor.len(); let mut total_seats: i64 = 0; let mut i: usize = 0; while i < n { if corridor[i] == b'S' { total_seats += 1; } i += 1; } if total_seats == 0 { return 0; } if tota...
-- 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": "[\"PPPPSSPPPPSSPPPP\"]", "output": "5" }, { "input": "[\"SSSSSSSSSS\"]", "output": "1" }, { "input": "[\"SPSPSPSP\"]", "output": "2" }, { "input": "[\"SSSPPSS\"]", "output": "0" }, { "input": "[\"PSSPSPSPPS\"]", "output": "0" }, { "input": ...
145
false
145
verified
10
10
1
1,906
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.NumberOfWays.Code.Funs /-! # Specifications of `Aegis.NumberOfWays.number_of_ways` LeetCode problem `number-of-ways-to-divide-a-long-corridor`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aeneas.Std.Result namespace AegisSpec.NumberOfWays ab...
9
count-elements-with-strictly-smaller-and-greater-elements
2,148
Easy
[ "Array", "Counting", "Sorting" ]
Given an integer array nums, return the number of elements that have both a strictly smaller and a strictly greater element appear in nums.   Example 1: Input: nums = [11,7,2,15] Output: 2 Explanation: The element 7 has the element 2 strictly smaller than it and the element 11 strictly greater than it. Element 11 has ...
countElements(nums: list_int) -> int
pub fn count_elements(nums: &[i64]) -> i64
Aegis.CountElements.count_elements
pub fn count_elements(nums: &[i64]) -> i64 { let n = nums.len(); if n == 0 { return 0; } let mut min_val = nums[0]; let mut max_val = nums[0]; let mut i = 1; while i < n { let x = nums[i]; if x < min_val { min_val = x; } if x > max_val { ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [count_elements]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [count_elements]: function definitions module public import Aeneas public import Aegis.CountElements.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.CountElements.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": "0" }, { "input": "[[-100000, 100000]]", "output": "0" }, { "input": "[[1, 2]]", "output": "0" }, { "input": "[[-1, 0, 1]]", "output": "1" }, { "input": "[[11, 7, 2, 15]]", "output"...
120
false
120
verified
10
10
1
500
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.CountElements.Code.Funs /-! # Specifications of `Aegis.CountElements.count_elements` LeetCode problem `count-elements-with-strictly-smaller-and-greater-elements`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.CountElements namespace AegisSp...
10
find-all-lonely-numbers-in-the-array
2,150
Medium
[ "Array", "Hash Table", "Counting" ]
You are given an integer array nums. A number x is lonely when it appears only once, and no adjacent numbers (i.e. x + 1 and x - 1) appear in the array. Return all lonely numbers in nums. You may return the answer in any order.   Example 1: Input: nums = [10,6,5,8] Output: [10,8] Explanation: - 10 is a lonely number ...
findLonely(nums: list_int) -> list_int
pub fn find_lonely(nums: &[i64]) -> Vec<i64>
Aegis.FindLonely.find_lonely
fn table_contains(keys: &[i64], m: usize, x: i64) -> bool { let mut idx: usize = (x as usize) % m; let mut steps: usize = 0; while steps < m { let k = keys[idx]; if k == -1 { return false; } if k == x { return true; } idx += 1; ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [find_lonely]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter.st...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [find_lonely]: function definitions module public import Aeneas public import Aegis.FindLonely.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.FindLonely.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval aegisCase ...
[ { "input": "[[2]]", "output": "[2]" }, { "input": "[[1000000]]", "output": "[1000000]" }, { "input": "[[5]]", "output": "[5]" }, { "input": "[[5, 5, 5, 5, 5]]", "output": "[]" }, { "input": "[[0, 0, 0, 0, 0]]", "output": "[]" }, { "input": "[[1, 2, 3, ...
148
true
148
verified
10
10
2
22,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.FindLonely.Code.Funs /-! # Specifications of `Aegis.FindLonely.find_lonely` LeetCode problem `find-all-lonely-numbers-in-the-array`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.FindLonely namespace AegisSpec.FindLonely def nth (l : Lis...
12
maximum-good-people-based-on-statements
2,151
Hard
[ "Bit Manipulation", "Array", "Backtracking", "Enumeration" ]
There are two types of persons: The good person: The person who always tells the truth. The bad person: The person who might tell the truth and might lie. You are given a 0-indexed 2D integer array statements of size n x n that represents the statements made by n people about each other. More specifically, statements...
maximumGood(statements: list_list_int) -> int
pub fn maximum_good(statements: &[Vec<i64>]) -> i64
Aegis.MaximumGood.maximum_good
pub fn maximum_good(statements: &[Vec<i64>]) -> i64 { let n: usize = statements.len(); let limit: i64 = 1i64 << n; let mut best: i64 = 0; let mut mask: i64 = 0; while mask < limit { let mut ok: bool = true; let mut i: usize = 0; while i < n { if ((mask >> i) & ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [maximum_good]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter.s...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [maximum_good]: function definitions module public import Aeneas public import Aegis.MaximumGood.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.MaximumGood.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], [2, 2]]]", "output": "2" }, { "input": "[[[2, 1], [0, 2]]]", "output": "1" }, { "input": "[[[2, 0], [0, 2]]]", "output": "1" }, { "input": "[[[2, 1, 2], [1, 2, 2], [2, 0, 2]]]", "output": "2" }, { "input": "[[[2, 1, 0], [1, 2, 1], [0, 1, 0]]]...
75
false
75
verified
10
10
1
1,491
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MaximumGood.Code.Funs /-! # Specifications of `Aegis.MaximumGood.maximum_good` LeetCode problem `maximum-good-people-based-on-statements`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.MaximumGood (maximum_good) namespace AegisSpec.MaximumGood ...
12
minimum-number-of-lines-to-cover-points
2,152
Medium
[ "Bit Manipulation", "Geometry", "Array", "Hash Table", "Math", "Dynamic Programming", "Backtracking", "Bitmask" ]
You are given an array points where points[i] = [xi, yi] represents a point on an X-Y plane. Straight lines are going to be added to the X-Y plane, such that every point is covered by at least one line. Return the minimum number of straight lines needed to cover all the points.   Example 1: Input: points = [[0,1],[2,...
minimumLines(points: list_list_int) -> int
pub fn minimum_lines(points: &[Vec<i64>]) -> i64
Aegis.MinimumLines.minimum_lines
pub fn minimum_lines(points: &[Vec<i64>]) -> i64 { let n = points.len(); let total: usize = 1usize << n; let mut dp: Vec<i64> = Vec::new(); let mut m: usize = 0; while m < total { dp.push(0); m += 1; } m = 1; while m < total { let mut best: i64 = 100; l...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [minimum_lines]: type definitions module public import Aeneas @[expose] public section 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_lines]: function definitions module public import Aeneas public import Aegis.MinimumLines.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.MinimumLines.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, 2], [-2, -2], [1, 4]]]", "output": "1" }, { "input": "[[[1, 1], [2, 2], [3, 3]]]", "output": "1" }, { "input": "[[[-100, 100], [100, -100], [0, 0]]]", "output": "1" }, { "input": "[[[-1, 1], [0, 0], [1, -1]]]", "output": "1" }, { "input": "[[[0, ...
107
false
107
verified
10
10
1
9,915
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MinimumLines.Code.Funs /-! # Specifications of `Aegis.MinimumLines.minimum_lines` LeetCode problem `minimum-number-of-lines-to-cover-points`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.MinimumLines abbrev Point := Int × Int def Pt...
13
keep-multiplying-found-values-by-two
2,154
Easy
[ "Array", "Hash Table", "Sorting", "Simulation" ]
You are given an array of integers nums. You are also given an integer original which is the first number that needs to be searched for in nums. You then do the following steps: If original is found in nums, multiply it by two (i.e., set original = 2 * original). Otherwise, stop the process. Repeat this process with t...
findFinalValue(nums: list_int, original: int) -> int
pub fn find_final_value(nums: &[i64], original: i64) -> i64
Aegis.FindFinalValue.find_final_value
pub fn find_final_value(nums: &[i64], original: i64) -> i64 { let mut current: i64 = original; loop { let mut found: bool = false; let mut i: usize = 0; while i < nums.len() { if nums[i] == current { found = true; } i += 1; } ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [find_final_value]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option lint...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [find_final_value]: function definitions module public import Aeneas public import Aegis.FindFinalValue.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.FindFinalValue.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": "[[2, 7, 9], 4]", "output": "4" }, { "input": "[[1, 2, 4, 8], 1]", "output": "16" }, { "input": "[[1000, 500, 250, 125], 125]", "output": "2000" }, { "input": "[[10, 20, 30, 40, 50], 5]", "output": "5" }, { "input": "[[1000, 500, 250, 125, 625], 5]", ...
115
false
115
verified
10
10
1
367
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.FindFinalValue.Code.Funs /-! # Specifications of `Aegis.FindFinalValue.find_final_value` LeetCode problem `keep-multiplying-found-values-by-two`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.FindFinalValue def occurs (nums : Slic...
12
all-divisions-with-the-highest-score-of-a-binary-array
2,155
Medium
[ "Array" ]
You are given a 0-indexed binary array nums of length n. nums can be divided at index i (where 0 <= i <= n) into two arrays (possibly empty) numsleft and numsright: numsleft has all the elements of nums between index 0 and i - 1 (inclusive), while numsright has all the elements of nums between index i and n - 1 (inclu...
maxScoreIndices(nums: list_int) -> list_int
pub fn max_score_indices(nums: &[i64]) -> Vec<i64>
Aegis.MaxScoreIndices.max_score_indices
pub fn max_score_indices(nums: &[i64]) -> Vec<i64> { let n = nums.len(); let mut total_ones: i64 = 0; let mut k: usize = 0; while k < n { if nums[k] == 1 { total_ones += 1; } k += 1; } let mut best: i64 = -1; let mut zeros_left: i64 = 0; let mut one...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [max_score_indices]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option lin...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [max_score_indices]: function definitions module public import Aeneas public import Aegis.MaxScoreIndices.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.MaxScoreIndices.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval aegis...
[ { "input": "[[1, 1]]", "output": "[0]" }, { "input": "[[0, 0, 0]]", "output": "[3]" }, { "input": "[[0, 0, 1, 0]]", "output": "[2, 4]" }, { "input": "[[1, 0, 0, 0, 1, 1, 1]]", "output": "[4]" }, { "input": "[[1, 0, 1, 0, 1]]", "output": "[0, 2, 4]" }, { ...
98
true
98
verified
10
10
1
891
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MaxScoreIndices.Code.Funs /-! # Specifications of `Aegis.MaxScoreIndices.max_score_indices` LeetCode problem `all-divisions-with-the-highest-score-of-a-binary-array`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.MaxScoreIndices def i...
2
groups-of-strings
2,157
Hard
[ "Bit Manipulation", "Union Find", "String" ]
You are given a 0-indexed array of strings words. Each string consists of lowercase English letters only. No letter occurs more than once in any string of words. Two strings s1 and s2 are said to be connected if the set of letters of s2 can be obtained from the set of letters of s1 by any one of the following operation...
groupStrings(words: list_str) -> list_int
pub fn group_strings(words: &[Vec<u8>]) -> Vec<i64>
Aegis.GroupStrings.group_strings
fn dsu_find(parent: &mut Vec<i64>, x: i64) -> i64 { let mut r = x; while parent[r as usize] != r { r = parent[r as usize]; } r } fn dsu_union(parent: &mut Vec<i64>, weight: &mut Vec<i64>, a: i64, b: i64) { let mut ra = dsu_find(parent, a); let mut rb = dsu_find(parent, b); if ra ==...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [group_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 -- [group_strings]: function definitions module public import Aeneas public import Aegis.GroupStrings.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.GroupStrings.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": "[[\"a\", \"ab\", \"abc\"]]", "output": "[1, 3]" }, { "input": "[[\"abc\", \"bcd\", \"ace\", \"bce\"]]", "output": "[1, 4]" }, { "input": "[[\"a\", \"b\", \"ab\", \"cde\"]]", "output": "[2, 3]" }, { "input": "[[\"abc\", \"bcd\", \"ace\", \"xyz\"]]", "output": "...
70
false
70
verified
10
10
2
42,157
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.GroupStrings.Code.Funs /-! # Specifications of `Aegis.GroupStrings.group_strings` LeetCode problem `groups-of-strings`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.GroupStrings def letterSet (w : alloc.vec.Vec Std.U8) : Finset ℕ := ...
11
minimum-sum-of-four-digit-number-after-splitting-digits
2,160
Easy
[ "Greedy", "Math", "Sorting" ]
You are given a positive integer num consisting of exactly four digits. Split num into two new integers new1 and new2 by using the digits found in num. Leading zeros are allowed in new1 and new2, and all the digits found in num must be used. For example, given num = 2932, you have the following digits: two 2's, one 9 ...
minimumSum(num: int) -> int
pub fn minimum_sum(num: i64) -> i64
Aegis.MinimumSum.minimum_sum
pub fn minimum_sum(num: i64) -> i64 { let mut d0: i64 = num / 1000; let mut d1: i64 = (num / 100) % 10; let mut d2: i64 = (num / 10) % 10; let mut d3: i64 = num % 10; if d0 > d1 { let t = d0; d0 = d1; d1 = t; } if d2 > d3 { let t = d2; d2 = d3; ...
-- 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": "[8765]", "output": "125" }, { "input": "[2309]", "output": "32" }, { "input": "[5678]", "output": "125" }, { "input": "[1098]", "output": "27" }, { "input": "[1111]", "output": "22" }, { "input": "[3333]", "output": "66" }, { "i...
83
false
83
verified
10
10
1
1,526
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MinimumSum.Code.Funs /-! # Specifications of `Aegis.MinimumSum.minimum_sum` LeetCode problem `minimum-sum-of-four-digit-number-after-splitting-digits`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.MinimumSum def digits (n : Int) : Li...
11
partition-array-according-to-given-pivot
2,161
Medium
[ "Array", "Two Pointers", "Simulation" ]
You are given a 0-indexed integer array nums and an integer pivot. Rearrange nums such that the following conditions are satisfied: Every element less than pivot appears before every element greater than pivot. Every element equal to pivot appears in between the elements less than and greater than pivot. The relative ...
pivotArray(nums: list_int, pivot: int) -> list_int
pub fn pivot_array(nums: &[i64], pivot: i64) -> Vec<i64>
Aegis.PivotArray.pivot_array
pub fn pivot_array(nums: &[i64], pivot: i64) -> Vec<i64> { let n = nums.len(); let mut less: Vec<i64> = Vec::new(); let mut equal: Vec<i64> = Vec::new(); let mut greater: Vec<i64> = Vec::new(); let mut i: usize = 0; while i < n { let x = nums[i]; if x < pivot { less...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [pivot_array]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter.st...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [pivot_array]: function definitions module public import Aeneas public import Aegis.PivotArray.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.PivotArray.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, -10, 4], 5]", "output": "[-10, 4, 5]" }, { "input": "[[10, 10, 10, 10], 10]", "output": "[10, 10, 10, 10]" }, { "input": "[[-3, 4, 3, 2], 2]", "output": "[-3, 2, 4, 3]" }, { "input": "[[1, 1, 1, 1, 1], 1]", "output": "[1, 1, 1, 1, 1]" }, { "input"...
105
false
105
verified
10
10
1
646
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.PivotArray.Code.Funs /-! # Specifications of `Aegis.PivotArray.pivot_array` LeetCode problem `partition-array-according-to-given-pivot`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.PivotArray def lessElems (l : List I64) (p : I64) :...
10
minimum-cost-to-set-cooking-time
2,162
Medium
[ "Math", "Enumeration" ]
A generic microwave supports cooking times for: at least 1 second. at most 99 minutes and 99 seconds. To set the cooking time, you push at most four digits. The microwave normalizes what you push as four digits by prepending zeroes. It interprets the first two digits as the minutes and the last two digits as the seco...
minCostSetTime(startAt: int, moveCost: int, pushCost: int, targetSeconds: int) -> int
pub fn min_cost_set_time(startAt: i64, moveCost: i64, pushCost: i64, targetSeconds: i64) -> i64
Aegis.MinCostSetTime.min_cost_set_time
pub fn min_cost_set_time(startAt: i64, moveCost: i64, pushCost: i64, targetSeconds: i64) -> i64 { let mut best: i64 = 1000000000; let mut minutes: i64 = 0; while minutes < 100 { let seconds: i64 = targetSeconds - minutes * 60; if seconds >= 0 && seconds <= 99 { let cost = digit...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [min_cost_set_time]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option lin...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [min_cost_set_time]: function definitions module public import Aeneas public import Aegis.MinCostSetTime.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.MinCostSetTime.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, 1, 600]", "output": "6" }, { "input": "[0, 1, 2, 76]", "output": "6" }, { "input": "[2, 2, 3, 599]", "output": "15" }, { "input": "[6, 3, 2, 3599]", "output": "20" }, { "input": "[9, 5, 10, 99]", "output": "20" }, { "input": "[5, 1, ...
116
false
116
verified
10
10
1
5,605
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MinCostSetTime.Code.Funs /-! # Specifications of `Aegis.MinCostSetTime.min_cost_set_time` LeetCode problem `minimum-cost-to-set-cooking-time`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.MinCostSetTime def IsDigitSeq (P : List I...
11
minimum-difference-in-sums-after-removal-of-elements
2,163
Hard
[ "Array", "Dynamic Programming", "Heap (Priority Queue)" ]
You are given a 0-indexed integer array nums consisting of 3 * n elements. You are allowed to remove any subsequence of elements of size exactly n from nums. The remaining 2 * n elements will be divided into two equal parts: The first n elements belonging to the first part and their sum is sumfirst. The next n element...
minimumDifference(nums: list_int) -> int
pub fn minimum_difference(nums: &[i64]) -> i64
Aegis.MinimumDifference.minimum_difference
fn heap_push_max(h: &mut Vec<i64>, x: i64) { h.push(x); let mut i = h.len() - 1; let mut running = true; while running && i > 0 { let p = (i - 1) / 2; if h[i] > h[p] { let tmp = h[i]; h[i] = h[p]; h[p] = tmp; i = p; } else { ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [minimum_difference]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option li...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [minimum_difference]: function definitions module public import Aeneas public import Aegis.MinimumDifference.Code.Types public import Aegis.MinimumDifference.Code.FunsExternal @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [minimum_difference]: external functions. -- This is a template file: rename it to "FunsExternal.lean" and fill the holes. module public import Aeneas public import Aegis.MinimumDifference.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow...
import Aegis.MinimumDifference.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval aeg...
[ { "input": "[[3, 1, 2]]", "output": "-1" }, { "input": "[[5, 5, 5, 5, 5, 5]]", "output": "0" }, { "input": "[[10, 20, 30, 40, 50, 60]]", "output": "-80" }, { "input": "[[1, 2, 3, 100, 100, 100]]", "output": "-197" }, { "input": "[[1, 2, 3, 4, 5, 6]]", "output"...
117
false
117
verified
10
10
1
8,060
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MinimumDifference.Code.Funs /-! # Specifications of `Aegis.MinimumDifference.minimum_difference` LeetCode problem `minimum-difference-in-sums-after-removal-of-elements`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.MinimumDifference namespace ...
11
sort-even-and-odd-indices-independently
2,164
Easy
[ "Array", "Sorting" ]
You are given a 0-indexed integer array nums. Rearrange the values of nums according to the following rules: Sort the values at odd indices of nums in non-increasing order. For example, if nums = [4,1,2,3] before this step, it becomes [4,3,2,1] after. The values at odd indices 1 and 3 are sorted in non-increasing o...
sortEvenOdd(nums: list_int) -> list_int
pub fn sort_even_odd(nums: &[i64]) -> Vec<i64>
Aegis.SortEvenOdd.sort_even_odd
pub fn sort_even_odd(nums: &[i64]) -> Vec<i64> { let n = nums.len(); let mut evens: Vec<i64> = Vec::new(); let mut odds: Vec<i64> = Vec::new(); let mut i: usize = 0; while i < n { if i % 2 == 0 { evens.push(nums[i]); } else { odds.push(nums[i]); } ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [sort_even_odd]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter....
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [sort_even_odd]: function definitions module public import Aeneas public import Aegis.SortEvenOdd.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.SortEvenOdd.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": "[[2, 1]]", "output": "[2, 1]" }, { "input": "[[4, 1, 2, 3]]", "output": "[2, 3, 4, 1]" }, { "input": "[[10, 20, 30, 40, 50]]", "output": "[10, 40, 30, 20, 50]" }, { "input": "[[5, 6, 3, 4, 7]]", "output": "[3,...
107
false
107
verified
10
10
1
1,032
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.SortEvenOdd.Code.Funs /-! # Specifications of `Aegis.SortEvenOdd.sort_even_odd` LeetCode problem `sort-even-and-odd-indices-independently`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.SortEvenOdd def getI (xs : List Aeneas.Std.I...
12
smallest-value-of-the-rearranged-number
2,165
Medium
[ "Math", "Sorting" ]
You are given an integer num. Rearrange the digits of num such that its value is minimized and it does not contain any leading zeros. Return the rearranged number with minimal value. Note that the sign of the number does not change after rearranging the digits.   Example 1: Input: num = 310 Output: 103 Explanation: Th...
smallestNumber(num: int) -> int
pub fn smallest_number(num: i64) -> i64
Aegis.SmallestNumber.smallest_number
pub fn smallest_number(num: i64) -> i64 { if num == 0 { return 0; } let is_negative: bool = num < 0; let mut x: i64 = num; if is_negative { x = -x; } let mut counts: Vec<i64> = Vec::new(); let mut k: i64 = 0; while k < 10 { counts.push(0); k += 1; ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [smallest_number]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linte...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [smallest_number]: function definitions module public import Aeneas public import Aegis.SmallestNumber.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.SmallestNumber.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": "[2020]", "output": "2002" }, { "input": "[10]", "output": "10" }, { "input": "[-10000000000]", "output": "-10000000000" }, { "input": "[10000000000]", "output": "10000000000" }, { "input": "[10001]", "output": "10001" }, { "input": "[123456...
120
false
120
verified
10
10
1
3,844
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.SmallestNumber.Code.Funs /-! # Specifications of `Aegis.SmallestNumber.smallest_number` LeetCode problem `smallest-value-of-the-rearranged-number`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.SmallestNumber def bound : Int := 10...
15
minimum-time-to-remove-all-cars-containing-illegal-goods
2,167
Hard
[ "String", "Dynamic Programming" ]
You are given a 0-indexed binary string s which represents a sequence of train cars. s[i] = '0' denotes that the ith car does not contain illegal goods and s[i] = '1' denotes that the ith car does contain illegal goods. As the train conductor, you would like to get rid of all the cars containing illegal goods. You can ...
minimumTime(s: str) -> int
pub fn minimum_time(s: &[u8]) -> i64
Aegis.MinimumTime.minimum_time
pub fn minimum_time(s: &[u8]) -> i64 { let len: usize = s.len(); let mut n: i64 = 0; let mut k: usize = 0; while k < len { n = n + 1; k = k + 1; } let mut ans: i64 = n; let mut prefix_ones: i64 = 0; let mut min_left: i64 = 0; let mut i: usize = 0; let mut b: i6...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [minimum_time]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter.s...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [minimum_time]: function definitions module public import Aeneas public import Aegis.MinimumTime.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option l...
import Aegis.MinimumTime.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval aegisCase...
[ { "input": "[\"100100100100\"]", "output": "7" }, { "input": "[\"110110110110110110110110110110110110110110110110\"]", "output": "47" }, { "input": "[\"1100101\"]", "output": "5" }, { "input": "[\"1001001001\"]", "output": "6" }, { "input": "[\"11111\"]", "out...
101
false
101
verified
10
10
1
9,623
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MinimumTime.Code.Funs /-! # Specifications of `Aegis.MinimumTime.minimum_time` LeetCode problem `minimum-time-to-remove-all-cars-containing-illegal-goods`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.MinimumTime def byteAt (s : ...
15
unique-substrings-with-equal-digit-frequency
2,168
Medium
[ "Hash Table", "String", "Counting", "Hash Function", "Rolling Hash" ]
Given a digit string s, return the number of unique substrings of s where every digit appears the same number of times.   Example 1: Input: s = "1212" Output: 5 Explanation: The substrings that meet the requirements are "1", "2", "12", "21", "1212". Note that although the substring "12" appears twice, it is only count...
equalDigitFrequency(s: str) -> int
pub fn equal_digit_frequency(s: &[u8]) -> i64
Aegis.EqualDigitFrequency.equal_digit_frequency
pub fn equal_digit_frequency(s: &[u8]) -> i64 { let n: usize = s.len(); // Trie of all suffixes, stored as a flat array of child indices. // Each node has 10 possible digit children; -1 means absent. let mut children: Vec<i64> = Vec::new(); let mut i: usize = 0; while i < 10 { children....
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [equal_digit_frequency]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [equal_digit_frequency]: function definitions module public import Aeneas public import Aegis.EqualDigitFrequency.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand f...
import Aegis.EqualDigitFrequency.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": "[\"9876543210\"]", "output": "55" }, { "input": "[\"111222333\"]", "output": "16" }, { "input": "[\"12211221\"]", "output": "13" }, { "input": "[\"1221\"]", "output": "6" }, { "input": "[\"1221122\"]", "output": "11" }, { "input": "[\"111\"...
125
false
125
verified
10
10
1
9,345
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.EqualDigitFrequency.Code.Funs /-! # Specifications of `Aegis.EqualDigitFrequency.equal_digit_frequency` LeetCode problem `unique-substrings-with-equal-digit-frequency`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.EqualDigitFrequenc...
13
count-operations-to-obtain-zero
2,169
Easy
[ "Math", "Simulation" ]
You are given two non-negative integers num1 and num2. In one operation, if num1 >= num2, you must subtract num2 from num1, otherwise subtract num1 from num2. For example, if num1 = 5 and num2 = 4, subtract num2 from num1, thus obtaining num1 = 1 and num2 = 4. However, if num1 = 4 and num2 = 5, after one operation, nu...
countOperations(num1: int, num2: int) -> int
pub fn count_operations(num1: i64, num2: i64) -> i64
Aegis.CountOperations.count_operations
pub fn count_operations(num1: i64, num2: i64) -> i64 { let mut a = num1; let mut b = num2; let mut count = 0i64; while a > 0 && b > 0 { if a >= b { a = a - b; } else { b = b - a; } count = count + 1; } count }
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [count_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 lint...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [count_operations]: function definitions module public import Aeneas public import Aegis.CountOperations.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.CountOperations.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval aegis...
[ { "input": "[0, 5]", "output": "0" }, { "input": "[100, 1]", "output": "100" }, { "input": "[123, 456]", "output": "12" }, { "input": "[8, 12]", "output": "3" }, { "input": "[1, 1]", "output": "1" }, { "input": "[100000, 100000]", "output": "1" }...
78
false
78
verified
10
10
1
330
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.CountOperations.Code.Funs /-! # Specifications of `Aegis.CountOperations.count_operations` LeetCode problem `count-operations-to-obtain-zero`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.CountOperations namespace AegisSpec.CountOperations...
13
minimum-operations-to-make-the-array-alternating
2,170
Medium
[ "Greedy", "Array", "Hash Table", "Counting" ]
You are given a 0-indexed array nums consisting of n positive integers. The array nums is called alternating if: nums[i - 2] == nums[i], where 2 <= i <= n - 1. nums[i - 1] != nums[i], where 1 <= i <= n - 1. In one operation, you can choose an index i and change nums[i] into any positive integer. Return the minimum nu...
minimumOperations(nums: list_int) -> int
pub fn minimum_operations(nums: &[i64]) -> i64
Aegis.MinimumOperations.minimum_operations
pub fn minimum_operations(nums: &[i64]) -> i64 { let n = nums.len(); if n == 0 { return 0; } let mut max_v: i64 = nums[0]; let mut i: usize = 1; while i < n { if nums[i] > max_v { max_v = nums[i]; } i += 1; } let size: usize = (max_v + 1) as ...
-- 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": "[[1]]", "output": "0" }, { "input": "[[1, 2, 3, 4, 5]]", "output": "3" }, { "input": "[[1, 1, 1, 1, 1]]", "output": "2" }, { "input": "[[1, 2, 2, 2, 2]]", "output": "2" }, { "input": "[[100000, 99999, 100000, 99999, 100000]]", "output": "0" }, ...
135
false
135
verified_partial
10
4
1
9,050
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": 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-the-array-alternating`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.MinimumOperations ...
15
removing-minimum-number-of-magic-beans
2,171
Medium
[ "Greedy", "Array", "Enumeration", "Prefix Sum", "Sorting" ]
You are given an array of positive integers beans, where each integer represents the number of magic beans found in a particular magic bag. Remove any number of beans (possibly none) from each bag such that the number of beans in each remaining non-empty bag (still containing at least one bean) is equal. Once a bean ha...
minimumRemoval(beans: list_int) -> int
pub fn minimum_removal(beans: &[i64]) -> i64
Aegis.MinimumRemoval.minimum_removal
pub fn minimum_removal(beans: &[i64]) -> i64 { let n = beans.len(); if n == 0 { return 0; } let mut v: Vec<i64> = Vec::new(); let mut total: i64 = 0; let mut i: usize = 0; while i < n { let x = beans[i]; v.push(x); total += x; i += 1; } let m...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [minimum_removal]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linte...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [minimum_removal]: function definitions module public import Aeneas public import Aegis.MinimumRemoval.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.MinimumRemoval.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": "0" }, { "input": "[[100000]]", "output": "0" }, { "input": "[[4, 1, 6, 5]]", "output": "4" }, { "input": "[[5, 5, 5, 5]]", "output": "0" }, { "input": "[[10, 10, 10, 10]]", "output": "0" }, { "input": "[[2, 10, 3, 2]]", ...
107
false
107
verified
10
10
2
23,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.MinimumRemoval.Code.Funs /-! # Specifications of `Aegis.MinimumRemoval.minimum_removal` LeetCode problem `removing-minimum-number-of-magic-beans`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.MinimumRemoval abbrev Beans : Type := Aen...
12
count-equal-and-divisible-pairs-in-an-array
2,176
Easy
[ "Array" ]
Given a 0-indexed integer array nums of length n and an integer k, return the number of pairs (i, j) where 0 <= i < j < n, such that nums[i] == nums[j] and (i * j) is divisible by k.   Example 1: Input: nums = [3,1,2,2,2,1,3], k = 2 Output: 4 Explanation: There are 4 pairs that meet all the requirements: - nums[0] == ...
countPairs(nums: list_int, k: int) -> int
pub fn count_pairs(nums: &[i64], k: i64) -> i64
Aegis.CountPairs.count_pairs
pub fn count_pairs(nums: &[i64], k: i64) -> i64 { let n = nums.len(); let mut ans: i64 = 0; for i in 0..n { for j in (i + 1)..n { if nums[i] == nums[j] { let product = (i as i64) * (j as i64); if product % k == 0 { ans += 1; ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [count_pairs]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter.st...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [count_pairs]: function definitions module public import Aeneas public import Aegis.CountPairs.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option lin...
import Aegis.CountPairs.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval aegisCase ...
[ { "input": "[[9, 9, 9], 9]", "output": "2" }, { "input": "[[100, 100, 100], 3]", "output": "2" }, { "input": "[[6, 6, 6, 6], 2]", "output": "5" }, { "input": "[[1, 1, 1, 1], 1]", "output": "6" }, { "input": "[[1, 2, 3, 4], 1]", "output": "0" }, { "inpu...
89
false
89
verified
10
10
1
344
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.CountPairs.Code.Funs /-! # Specifications of `Aegis.CountPairs.count_pairs` LeetCode problem `count-equal-and-divisible-pairs-in-an-array`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.CountPairs def valAt (nums : Slice Std.I64) (i :...
15
find-three-consecutive-integers-that-sum-to-a-given-number
2,177
Medium
[ "Math", "Simulation" ]
Given an integer num, return three consecutive integers (as a sorted array) that sum to num. If num cannot be expressed as the sum of three consecutive integers, return an empty array.   Example 1: Input: num = 33 Output: [10,11,12] Explanation: 33 can be expressed as 10 + 11 + 12 = 33. 10, 11, 12 are 3 consecutive in...
sumOfThree(num: int) -> list_int
pub fn sum_of_three(num: i64) -> Vec<i64>
Aegis.SumOfThree.sum_of_three
pub fn sum_of_three(num: i64) -> Vec<i64> { if num % 3 != 0 { return Vec::new(); } let mid = num / 3; let mut result: Vec<i64> = Vec::new(); result.push(mid - 1); result.push(mid); result.push(mid + 1); result }
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [sum_of_three]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter.s...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [sum_of_three]: function definitions module public import Aeneas public import Aegis.SumOfThree.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option li...
import Aegis.SumOfThree.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": "[1000000000001]", "output": "[]" }, { "input": "[4]", "output": "[]" }, { "input": "[1000000000000]", "output": "[]" }, { "input": "[100000000000000]", "output": "[]" }, { "input": "[1000000000003]", "output": "[]" }, { "input": "[123456789...
52
false
52
verified
10
10
1
1,325
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.SumOfThree.Code.Funs /-! # Specifications of `Aegis.SumOfThree.sum_of_three` LeetCode problem `find-three-consecutive-integers-that-sum-to-a-given-number`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.SumOfThree /-- The function ...
12
maximum-split-of-positive-even-integers
2,178
Medium
[ "Greedy", "Math", "Backtracking" ]
You are given an integer finalSum. Split it into a sum of a maximum number of unique positive even integers. For example, given finalSum = 12, the following splits are valid (unique positive even integers summing up to finalSum): (12), (2 + 10), (2 + 4 + 6), and (4 + 8). Among them, (2 + 4 + 6) contains the maximum nu...
maximumEvenSplit(finalSum: int) -> list_int
pub fn maximum_even_split(finalSum: i64) -> Vec<i64>
Aegis.MaximumEvenSplit.maximum_even_split
pub fn maximum_even_split(finalSum: i64) -> Vec<i64> { let mut ans: Vec<i64> = Vec::new(); if finalSum <= 0 { return ans; } if finalSum % 2 != 0 { return ans; } let n: i64 = finalSum / 2; let mut sum: i64 = 0; let mut next: i64 = 1; let mut m: i64 = 0; while s...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [maximum_even_split]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option li...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [maximum_even_split]: function definitions module public import Aeneas public import Aegis.MaximumEvenSplit.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.MaximumEvenSplit.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": "[7]", "output": "[]" }, { "input": "[101]", "output": "[]" }, { "input": "[123456789]", "output": "[]" }, { "input": "[9999999999]", "output": "[]" }, { "input": "[3]", "output": "[]" }, { "input": "[1111111111]", "output": "[]" }, ...
49
true
49
verified
10
10
1
8,062
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MaximumEvenSplit.Code.Funs /-! # Specifications of `Aegis.MaximumEvenSplit.maximum_even_split` LeetCode problem `maximum-split-of-positive-even-integers`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.MaximumEvenSplit def IsEvenIn...
13
count-good-triplets-in-an-array
2,179
Hard
[ "Binary Indexed Tree", "Segment Tree", "Array", "Binary Search", "Divide and Conquer", "Ordered Set", "Merge Sort" ]
You are given two 0-indexed arrays nums1 and nums2 of length n, both of which are permutations of [0, 1, ..., n - 1]. A good triplet is a set of 3 distinct values which are present in increasing order by position both in nums1 and nums2. In other words, if we consider pos1v as the index of the value v in nums1 and pos2...
goodTriplets(nums1: list_int, nums2: list_int) -> int
pub fn good_triplets(nums1: &[i64], nums2: &[i64]) -> i64
Aegis.GoodTriplets.good_triplets
fn lowbit(x: usize) -> usize { let mut val = x; let mut lb: usize = 1; while val > 0 && val % 2 == 0 { lb *= 2; val /= 2; } lb } pub fn good_triplets(nums1: &[i64], nums2: &[i64]) -> i64 { let n = nums1.len(); let mut pos2: Vec<i64> = Vec::new(); let mut i = 0; whil...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [good_triplets]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter....
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [good_triplets]: function definitions module public import Aeneas public import Aegis.GoodTriplets.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.GoodTriplets.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval aegisCas...
[ { "input": "[[0, 1, 2], [2, 1, 0]]", "output": "0" }, { "input": "[[0, 1, 2, 3], [3, 2, 1, 0]]", "output": "0" }, { "input": "[[1, 0, 3, 2], [2, 3, 0, 1]]", "output": "0" }, { "input": "[[2, 0, 1, 3], [0, 1, 2, 3]]", "output": "1" }, { "input": "[[3, 2, 1, 0], [3,...
100
false
100
verified
10
10
1
5,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.GoodTriplets.Code.Funs /-! # Specifications of `Aegis.GoodTriplets.good_triplets` LeetCode problem `count-good-triplets-in-an-array`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.GoodTriplets def ivals (s : Slice Std.I64) : List ...
10
count-integers-with-even-digit-sum
2,180
Easy
[ "Math", "Simulation" ]
Given a positive integer num, return the number of positive integers less than or equal to num whose digit sums are even. The digit sum of a positive integer is the sum of all its digits.   Example 1: Input: num = 4 Output: 2 Explanation: The only integers less than or equal to 4 whose digit sums are even are 2 and 4....
countEven(num: int) -> int
pub fn count_even(num: i64) -> i64
Aegis.CountEven.count_even
pub fn count_even(num: i64) -> i64 { let mut count: i64 = 0; let mut value: i64 = 1; while value <= num { let mut x: i64 = value; let mut digit_sum: i64 = 0; while x > 0 { digit_sum += x % 10; x /= 10; } if digit_sum % 2 == 0 { c...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [count_even]: type definitions module public import Aeneas @[expose] public section 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_even]: function definitions module public import Aeneas public import Aegis.CountEven.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.CountEven.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": "[30]", "output": "14" }, { "input": "[10]", "output": "4" }, { "input": "[999]", "output": "499" }, { "input": "[500]", "output": "249" }, { "input": "[4]", "output": "2" }, { "input": "[2]", "output": "1" }, { "input": "[1]", ...
34
false
34
verified
10
10
1
412
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.CountEven.Code.Funs /-! # Specifications of `Aegis.CountEven.count_even` LeetCode problem `count-integers-with-even-digit-sum`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.CountEven def digitSum (n : ℕ) : ℕ := if h : n = 0 t...
13
merge-nodes-in-between-zeros
2,181
Medium
[ "Linked List", "Simulation" ]
You are given the head of a linked list, which contains a series of integers separated by 0's. The beginning and end of the linked list will have Node.val == 0. For every two consecutive 0's, merge all the nodes lying in between them into a single node whose value is the sum of all the merged nodes. The modified list s...
mergeNodes(head: linkedlist) -> linkedlist
pub fn merge_nodes(head: &List) -> List
Aegis.MergeNodes.merge_nodes
fn merge_nodes_go(l: &List, started: bool, sum: i64) -> List { match l { List::Nil => List::Nil, List::Cons(v, next) => { if *v == 0 { if started { List::Cons(sum, Box::new(merge_nodes_go(&**next, true, 0))) } else { ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [merge_nodes]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter.st...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [merge_nodes]: function definitions module public import Aeneas public import Aegis.MergeNodes.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.MergeNodes.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 instanc...
[ { "input": "[[0, 0]]", "output": "[0]" }, { "input": "[[0, 10, 0]]", "output": "[10]" }, { "input": "[[0, 1000, 0]]", "output": "[1000]" }, { "input": "[[0, 999, 999, 999, 0]]", "output": "[2997]" }, { "input": "[[0, 1000, 0, 1000, 1000, 0]]", "output": "[1000...
93
false
93
verified
10
10
1
2,856
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MergeNodes.Code.Funs /-! # Specifications of `Aegis.MergeNodes.merge_nodes` LeetCode problem `merge-nodes-in-between-zeros`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.MergeNodes def values : Aegis.MergeNodes.List → List Int | .N...
14
count-array-pairs-divisible-by-k
2,183
Hard
[ "Array", "Math", "Number Theory" ]
Given a 0-indexed integer array nums of length n and an integer k, return the number of pairs (i, j) such that: 0 <= i < j <= n - 1 and nums[i] * nums[j] is divisible by k.   Example 1: Input: nums = [1,2,3,4,5], k = 2 Output: 7 Explanation: The 7 pairs of indices whose corresponding products are divisible by 2 are...
countPairs(nums: list_int, k: int) -> int
pub fn count_pairs(nums: &[i64], k: i64) -> i64
Aegis.CountPairs.count_pairs
fn gcd_i64(mut a: i64, mut b: i64) -> i64 { while b != 0 { let t = a % b; a = b; b = t; } a } pub fn count_pairs(nums: &[i64], k: i64) -> i64 { let n = nums.len(); if n < 2 { return 0; } let mut divisors: Vec<i64> = Vec::new(); let mut d: i64 = 1; wh...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [count_pairs]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter.st...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [count_pairs]: function definitions module public import Aeneas public import Aegis.CountPairs.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option lin...
import Aegis.CountPairs.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval aegisCase ...
[ { "input": "[[5, 5, 5, 5], 5]", "output": "6" }, { "input": "[[6, 12, 18, 24], 12]", "output": "6" }, { "input": "[[10, 20, 30, 40], 10]", "output": "6" }, { "input": "[[7, 14, 21, 28], 7]", "output": "6" }, { "input": "[[1, 2, 3, 4], 5]", "output": "0" }, ...
102
false
102
verified
10
10
1
4,774
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.CountPairs.Code.Funs /-! # Specifications of `Aegis.CountPairs.count_pairs` LeetCode problem `count-array-pairs-divisible-by-k`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result ControlFlow Error open Aegis.CountPairs namespace AegisSpec.CountPairs def Divi...
11
counting-words-with-a-given-prefix
2,185
Easy
[ "Array", "String", "String Matching" ]
You are given an array of strings words and a string pref. Return the number of strings in words that contain pref as a prefix. A prefix of a string s is any leading contiguous substring of s.   Example 1: Input: words = ["pay","attention","practice","attend"], pref = "at" Output: 2 Explanation: The 2 strings that con...
prefixCount(words: list_str, pref: str) -> int
pub fn prefix_count(words: &[Vec<u8>], pref: &[u8]) -> i64
Aegis.PrefixCount.prefix_count
pub fn prefix_count(words: &[Vec<u8>], pref: &[u8]) -> i64 { let mut count: i64 = 0; let n = words.len(); let m = pref.len(); let mut i: usize = 0; while i < n { let w = &words[i]; let mut ok: bool = true; if w.len() < m { ok = false; } else { ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [prefix_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.s...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [prefix_count]: function definitions module public import Aeneas public import Aegis.PrefixCount.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.PrefixCount.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": "[[\"hello\", \"world\"], \"hi\"]", "output": "0" }, { "input": "[[\"abc\", \"bcd\", \"cde\"], \"a\"]", "output": "1" }, { "input": "[[\"hello\", \"hell\", \"helper\"], \"hel\"]", "output": "3" }, { "input": "[[\"apple\", \"apricot\", \"application\"], \"app\"]", ...
153
false
153
verified
10
10
1
980
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.PrefixCount.Code.Funs /-! # Specifications of `Aegis.PrefixCount.prefix_count` LeetCode problem `counting-words-with-a-given-prefix`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.PrefixCount def IsLowercaseByte (b : Std.U8) : Prop :=...
13
minimum-time-to-complete-trips
2,187
Medium
[ "Array", "Binary Search" ]
You are given an array time where time[i] denotes the time taken by the ith bus to complete one trip. Each bus can make multiple trips successively; that is, the next trip can start immediately after completing the current trip. Also, each bus operates independently; that is, the trips of one bus do not influence the t...
minimumTime(time: list_int, totalTrips: int) -> int
pub fn minimum_time(time: &[i64], totalTrips: i64) -> i64
Aegis.MinimumTime.minimum_time
pub fn minimum_time(time: &[i64], totalTrips: i64) -> i64 { let n = time.len(); let mut min_time = time[0]; let mut i = 1; while i < n { if time[i] < min_time { min_time = time[i]; } i += 1; } let mut lo: i64 = 0; let mut hi: i64 = min_time * totalTrips;...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [minimum_time]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter.s...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [minimum_time]: function definitions module public import Aeneas public import Aegis.MinimumTime.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option l...
import Aegis.MinimumTime.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval aegisCase...
[ { "input": "[[10000000], 10000000]", "output": "100000000000000" }, { "input": "[[2], 1]", "output": "2" }, { "input": "[[1, 2, 3], 5]", "output": "3" }, { "input": "[[10, 20, 30], 100]", "output": "550" }, { "input": "[[5, 10, 15], 9]", "output": "30" }, ...
103
false
103
verified
10
10
1
1,193
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MinimumTime.Code.Funs /-! # Specifications of `Aegis.MinimumTime.minimum_time` LeetCode problem `minimum-time-to-complete-trips`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.MinimumTime def tripCount (time : Slice Std.I64) (T : Int)...
13
minimum-time-to-finish-the-race
2,188
Hard
[ "Array", "Dynamic Programming" ]
You are given a 0-indexed 2D integer array tires where tires[i] = [fi, ri] indicates that the ith tire can finish its xth successive lap in fi * ri(x-1) seconds. For example, if fi = 3 and ri = 2, then the tire would finish its 1st lap in 3 seconds, its 2nd lap in 3 * 2 = 6 seconds, its 3rd lap in 3 * 22 = 12 seconds,...
minimumFinishTime(tires: list_list_int, changeTime: int, numLaps: int) -> int
pub fn minimum_finish_time(tires: &[Vec<i64>], changeTime: i64, numLaps: i64) -> i64
Aegis.MinimumFinishTime.minimum_finish_time
pub fn minimum_finish_time(tires: &[Vec<i64>], changeTime: i64, numLaps: i64) -> i64 { let n: usize = numLaps as usize; let inf: i64 = 1_000_000_000_000_000_000; // Smallest first-lap time among all tires (used to bound useful run lengths). let mut min_first: i64 = tires[0][0]; let mut ti: usize = ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [minimum_finish_time]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option l...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [minimum_finish_time]: function definitions module public import Aeneas public import Aegis.MinimumFinishTime.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false...
import Aegis.MinimumFinishTime.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": "[[[100000, 2]], 100000, 1000]", "output": "199900000" }, { "input": "[[[5, 2]], 3, 3]", "output": "21" }, { "input": "[[[1, 2]], 3, 1]", "output": "1" }, { "input": "[[[5, 2]], 3, 2]", "output": "13" }, { "input": "[[[1, 2]], 3, 10]", "output": "27...
100
false
100
verified
10
10
2
11,627
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MinimumFinishTime.Code.Funs /-! # Specifications of `Aegis.MinimumFinishTime.minimum_finish_time` LeetCode problem `minimum-time-to-finish-the-race`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.MinimumFinishTime namespace AegisSpec.Minimu...
15
number-of-ways-to-build-house-of-cards
2,189
Medium
[ "Math", "Dynamic Programming" ]
You are given an integer n representing the number of playing cards you have. A house of cards meets the following conditions: A house of cards consists of one or more rows of triangles and horizontal cards. Triangles are created by leaning two cards against each other. One card must be placed horizontally between all...
houseOfCards(n: int) -> int
pub fn house_of_cards(n: i64) -> i64
Aegis.HouseOfCards.house_of_cards
pub fn house_of_cards(n: i64) -> i64 { let n_usize = n as usize; let mut dp: Vec<i64> = Vec::new(); let mut i: usize = 0; while i <= n_usize { dp.push(0); i += 1; } dp[0] = 1; let mut cards: i64 = 2; while cards <= n { let c = cards as usize; let mut tot...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [house_of_cards]: type definitions module public import Aeneas @[expose] public section 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 -- [house_of_cards]: function definitions module public import Aeneas public import Aegis.HouseOfCards.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.HouseOfCards.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": "0" }, { "input": "[11]", "output": "1" }, { "input": "[30]", "output": "5" }, { "input": "[1]", "output": "0" }, { "input": "[4]", "output": "0" }, { "input": "[16]", "output": "2" }, { "input": "[2]", "outp...
89
false
89
verified
10
10
1
3,716
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.HouseOfCards.Code.Funs /-! # Specifications of `Aegis.HouseOfCards.house_of_cards` LeetCode problem `number-of-ways-to-build-house-of-cards`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.HouseOfCards namespace AegisSpec.HouseOfCards def...
9
sort-the-jumbled-numbers
2,191
Medium
[ "Array", "Sorting" ]
You are given a 0-indexed integer array mapping which represents the mapping rule of a shuffled decimal system. mapping[i] = j means digit i should be mapped to digit j in this system. The mapped value of an integer is the new integer obtained by replacing each occurrence of digit i in the integer with mapping[i] for a...
sortJumbled(mapping: list_int, nums: list_int) -> list_int
pub fn sort_jumbled(mapping: &[i64], nums: &[i64]) -> Vec<i64>
Aegis.SortJumbled.sort_jumbled
fn mapped_value(mapping: &[i64], x0: i64) -> i64 { if x0 == 0 { return mapping[0]; } let mut x = x0; let mut res: i64 = 0; let mut place: i64 = 1; while x > 0 { let d = (x % 10) as usize; res = res + mapping[d] * place; place = place * 10; x = x / 10; ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [sort_jumbled]: type definitions module public import Aeneas @[expose] public section 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 -- [sort_jumbled]: function definitions module public import Aeneas public import Aegis.SortJumbled.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.SortJumbled.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, 2, 1, 3, 4, 5, 6, 7, 8, 9], [987654321, 123456789]]", "output": "[123456789, 987654321]" }, { "input": "[[5, 8, 9, 2, 1, 6, 7, 0, 3, 4], [345, 123, 678]]", "output": "[345, 678, 123]" }, { "input": "[[1, 2, 3, 4, 5, 6, 7, 8, 9, 0], [90, 12, 34]]", "output": "[90, 12,...
109
false
109
verified
10
10
1
4,405
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.SortJumbled.Code.Funs /-! # Specifications of `Aegis.SortJumbled.sort_jumbled` LeetCode problem `sort-the-jumbled-numbers`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.SortJumbled def decimalDigits (n : Nat) : List Nat := if n < 1...
12
append-k-integers-with-minimal-sum
2,195
Medium
[ "Greedy", "Array", "Math", "Sorting" ]
You are given an integer array nums and an integer k. Append k unique positive integers that do not appear in nums to nums such that the resulting total sum is minimum. Return the sum of the k integers appended to nums.   Example 1: Input: nums = [1,4,25,10,25], k = 2 Output: 5 Explanation: The two unique positive int...
minimalKSum(nums: list_int, k: int) -> int
pub fn minimal_k_sum(nums: &[i64], k: i64) -> i64
Aegis.MinimalKSum.minimal_k_sum
pub fn minimal_k_sum(nums: &[i64], k: i64) -> i64 { let mut v: Vec<i64> = Vec::new(); let n = nums.len(); let mut i = 0usize; while i < n { v.push(nums[i]); i += 1; } v.sort(); let m = v.len(); let mut ans: i64 = 0; let mut need: i64 = k; let mut cur: i64 = 1; ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [minimal_k_sum]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter....
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [minimal_k_sum]: function definitions module public import Aeneas public import Aegis.MinimalKSum.Code.Types public import Aegis.MinimalKSum.Code.FunsExternal @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace fal...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [minimal_k_sum]: external functions. -- This is a template file: rename it to "FunsExternal.lean" and fill the holes. module public import Aeneas public import Aegis.MinimalKSum.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_...
import Aegis.MinimalKSum.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval aegisCase...
[ { "input": "[[1000000000], 100000]", "output": "5000050000" }, { "input": "[[1000000000], 1]", "output": "1" }, { "input": "[[1], 1]", "output": "2" }, { "input": "[[1000000000], 100000000]", "output": "5000000050000000" }, { "input": "[[1], 1000000]", "output...
111
false
111
verified
10
10
1
3,001
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MinimalKSum.Code.Funs /-! # Specifications of `Aegis.MinimalKSum.minimal_k_sum` LeetCode problem `append-k-integers-with-minimal-sum`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.MinimalKSum namespace AegisSpec.MinimalKSum def entries ...
11
create-binary-tree-from-descriptions
2,196
Medium
[ "Tree", "Array", "Hash Table", "Binary Tree" ]
You are given a 2D integer array descriptions where descriptions[i] = [parenti, childi, isLefti] indicates that parenti is the parent of childi in a binary tree of unique values. Furthermore, If isLefti == 1, then childi is the left child of parenti. If isLefti == 0, then childi is the right child of parenti. Constru...
createBinaryTree(descriptions: list_list_int) -> tree
pub fn create_binary_tree(descriptions: &[Vec<i64>]) -> Tree
Aegis.CreateBinaryTree.create_binary_tree
fn pop_tree(stack: &mut Vec<Tree>) -> Tree { match stack.pop() { Some(t) => t, None => Tree::Null, } } pub fn create_binary_tree(descriptions: &[Vec<i64>]) -> Tree { let m = descriptions.len(); if m == 0 { return Tree::Null; } let mut max_val: i64 = 0; let mut i = 0...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [create_binary_tree]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option li...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [create_binary_tree]: function definitions module public import Aeneas public import Aegis.CreateBinaryTree.Code.Types public import Aegis.CreateBinaryTree.Code.FunsExternal @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.d...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [create_binary_tree]: external functions. -- This is a template file: rename it to "FunsExternal.lean" and fill the holes. module public import Aeneas public import Aegis.CreateBinaryTree.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow ...
import Aegis.CreateBinaryTree.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 i...
[ { "input": "[[[1, 2, 1], [2, 3, 0], [3, 4, 1]]]", "output": "[1, 2, null, null, 3, 4]" }, { "input": "[[[20, 15, 1], [20, 17, 0], [50, 20, 1], [50, 80, 0], [80, 19, 1]]]", "output": "[50, 20, 80, 15, 17, 19]" }, { "input": "[[[100, 50, 1], [100, 150, 0], [50, 25, 1], [50, 75, 0], [150, 1...
48
false
48
verified
10
10
1
11,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.CreateBinaryTree.Code.Funs /-! # Specifications of `Aegis.CreateBinaryTree.create_binary_tree` LeetCode problem `create-binary-tree-from-descriptions`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.CreateBinaryTree noncomputable section namesp...
11
replace-non-coprime-numbers-in-array
2,197
Hard
[ "Stack", "Array", "Math", "Number Theory" ]
You are given an array of integers nums. Perform the following steps: Find any two adjacent numbers in nums that are non-coprime. If no such numbers are found, stop the process. Otherwise, delete the two numbers and replace them with their LCM (Least Common Multiple). Repeat this process as long as you keep finding tw...
replaceNonCoprimes(nums: list_int) -> list_int
pub fn replace_non_coprimes(nums: &[i64]) -> Vec<i64>
Aegis.ReplaceNonCoprimes.replace_non_coprimes
fn gcd(mut a: i64, mut b: i64) -> i64 { while b != 0 { let r = a % b; a = b; b = r; } a } pub fn replace_non_coprimes(nums: &[i64]) -> Vec<i64> { let mut stack: Vec<i64> = Vec::new(); let mut i: usize = 0; while i < nums.len() { let mut x: i64 = nums[i]; ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [replace_non_coprimes]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [replace_non_coprimes]: function definitions module public import Aeneas public import Aegis.ReplaceNonCoprimes.Code.Types public import Aegis.ReplaceNonCoprimes.Code.FunsExternal @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option li...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [replace_non_coprimes]: external functions. -- This is a template file: rename it to "FunsExternal.lean" and fill the holes. module public import Aeneas public import Aegis.ReplaceNonCoprimes.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlF...
import Aegis.ReplaceNonCoprimes.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": "[[100000, 100000, 100000, 100000]]", "output": "[100000]" }, { "input": "[[5, 10, 15, 20]]", "output": "[60]" }, { "input": "[[4, 6, 8, 10, 12]]", "output": "[120]" }, { "input": "[[9, 27, 81, 243, 729]]", "output": "[729]" }, { "input": "[[42, 56, 70,...
133
false
133
verified
10
10
1
2,390
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.ReplaceNonCoprimes.Code.Funs /-! # Specifications of `Aegis.ReplaceNonCoprimes.replace_non_coprimes` LeetCode problem `replace-non-coprime-numbers-in-array`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.ReplaceNonCoprimes abbrev Ar...
14
find-all-k-distant-indices-in-an-array
2,200
Easy
[ "Array", "Two Pointers" ]
You are given a 0-indexed integer array nums and two integers key and k. A k-distant index is an index i of nums for which there exists at least one index j such that |i - j| <= k and nums[j] == key. Return a list of all k-distant indices sorted in increasing order.   Example 1: Input: nums = [3,4,9,1,3,9,5], key = 9,...
findKDistantIndices(nums: list_int, key: int, k: int) -> list_int
pub fn find_k_distant_indices(nums: &[i64], key: i64, k: i64) -> Vec<i64>
Aegis.FindKDistantIndices.find_k_distant_indices
pub fn find_k_distant_indices(nums: &[i64], key: i64, k: i64) -> Vec<i64> { let n = nums.len(); let mut result: Vec<i64> = Vec::new(); let mut i: usize = 0; while i < n { let mut j: usize = 0; let mut found: bool = false; while j < n { if nums[j] == key { ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [find_k_distant_indices]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_optio...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [find_k_distant_indices]: function definitions module public import Aeneas public import Aegis.FindKDistantIndices.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand ...
import Aegis.FindKDistantIndices.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": "[[10, 20, 30, 40, 50], 40, 0]", "output": "[3]" }, { "input": "[[1, 3, 5, 7, 9], 5, 0]", "output": "[2]" }, { "input": "[[1, 2, 3, 4, 5], 3, 0]", "output": "[2]" }, { "input": "[[5, 4, 3, 2, 1], 1, 1]", "output": "[3, 4]" }, { "input": "[[1, 2, 3, 4, 5...
107
false
107
verified
10
10
1
931
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.FindKDistantIndices.Code.Funs /-! # Specifications of `Aegis.FindKDistantIndices.find_k_distant_indices` LeetCode problem `find-all-k-distant-indices-in-an-array`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.FindKDistantIndices ...
11
maximize-the-topmost-element-after-k-moves
2,202
Medium
[ "Greedy", "Array" ]
You are given a 0-indexed integer array nums representing the contents of a pile, where nums[0] is the topmost element of the pile. In one move, you can perform either of the following: If the pile is not empty, remove the topmost element of the pile. If there are one or more removed elements, add any one of them back...
maximumTop(nums: list_int, k: int) -> int
pub fn maximum_top(nums: &[i64], k: i64) -> i64
Aegis.MaximumTop.maximum_top
pub fn maximum_top(nums: &[i64], k: i64) -> i64 { let n = nums.len(); if n == 0 { return -1; } if n == 1 { if k % 2 == 1 { return -1; } return nums[0]; } let nm = n as i64; let mut ans: i64 = -1; // Elements that can be removed and then pla...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [maximum_top]: type definitions module public import Aeneas @[expose] public section 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 -- [maximum_top]: function definitions module public import Aeneas public import Aegis.MaximumTop.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.MaximumTop.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval aegisCase ...
[ { "input": "[[10], 2]", "output": "10" }, { "input": "[[1000000000], 0]", "output": "1000000000" }, { "input": "[[1], 2]", "output": "1" }, { "input": "[[2], 1]", "output": "-1" }, { "input": "[[10], 0]", "output": "10" }, { "input": "[[9], 0]", "o...
148
false
148
verified
10
10
1
5,047
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MaximumTop.Code.Funs /-! # Specifications of `Aegis.MaximumTop.maximum_top` LeetCode problem `maximize-the-topmost-element-after-k-moves`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.MaximumTop namespace AegisSpec.MaximumTop def valAt (nums ...
8
minimum-weighted-subgraph-with-the-required-paths
2,203
Hard
[ "Graph", "Shortest Path" ]
You are given an integer n denoting the number of nodes of a weighted directed graph. The nodes are numbered from 0 to n - 1. You are also given a 2D integer array edges where edges[i] = [fromi, toi, weighti] denotes that there exists a directed edge from fromi to toi with weight weighti. Lastly, you are given three di...
minimumWeight(n: int, edges: list_list_int, src1: int, src2: int, dest: int) -> int
pub fn minimum_weight(n: i64, edges: &[Vec<i64>], src1: i64, src2: i64, dest: i64) -> i64
Aegis.MinimumWeight.minimum_weight
fn dijkstra( n: i64, head: &[i64], to: &[i64], wt: &[i64], next: &[i64], source: i64, ) -> Vec<i64> { let inf: i64 = 1_000_000_000_000_000_000; let n_usize = n as usize; let mut dist: Vec<i64> = Vec::new(); let mut i: i64 = 0; while i < n { dist.push(inf); i ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [minimum_weight]: type definitions module public import Aeneas @[expose] public section 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_weight]: function definitions module public import Aeneas public import Aegis.MinimumWeight.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.MinimumWeight.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval aegisCa...
[ { "input": "[3, [[0, 1, 1], [2, 1, 1]], 0, 1, 2]", "output": "-1" }, { "input": "[4, [[0, 1, 2], [0, 2, 2], [1, 3, 1], [2, 3, 1]], 0, 1, 3]", "output": "3" }, { "input": "[4, [[0, 1, 1], [1, 2, 2], [2, 3, 3], [3, 1, 4]], 0, 2, 3]", "output": "6" }, { "input": "[4, [[0, 1, 2],...
58
false
58
verified
10
10
1
12,269
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MinimumWeight.Code.Funs /-! # Specifications of `Aegis.MinimumWeight.minimum_weight` LeetCode problem `minimum-weighted-subgraph-with-the-required-paths`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.MinimumWeight namespace AegisSpec.MinimumWe...
12
distance-to-a-cycle-in-undirected-graph
2,204
Hard
[ "Depth-First Search", "Breadth-First Search", "Union Find", "Graph" ]
You are given a positive integer n representing the number of nodes in a connected undirected graph containing exactly one cycle. The nodes are numbered from 0 to n - 1 (inclusive). You are also given a 2D integer array edges, where edges[i] = [node1i, node2i] denotes that there is a bidirectional edge connecting node1...
distanceToCycle(n: int, edges: list_list_int) -> list_int
pub fn distance_to_cycle(n: i64, edges: &[Vec<i64>]) -> Vec<i64>
Aegis.DistanceToCycle.distance_to_cycle
pub fn distance_to_cycle(n: i64, edges: &[Vec<i64>]) -> Vec<i64> { let n_us = n as usize; // Build adjacency list. let mut adj: Vec<Vec<i64>> = Vec::new(); let mut i: usize = 0; while i < n_us { adj.push(Vec::new()); i += 1; } let mut e: usize = 0; while e < edges.len()...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [distance_to_cycle]: type definitions module public import Aeneas @[expose] public section 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 -- [distance_to_cycle]: function definitions module public import Aeneas public import Aegis.DistanceToCycle.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.DistanceToCycle.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": "[4, [[0, 1], [1, 2], [2, 3], [3, 0]]]", "output": "[0, 0, 0, 0]" }, { "input": "[5, [[0, 1], [1, 2], [2, 3], [3, 4], [4, 0]]]", "output": "[0, 0, 0, 0, 0]" }, { "input": "[6, [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 1]]]", "output": "[1, 0, 0, 0, 0, 0]" }, { "...
48
false
48
verified
10
10
1
4,504
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.DistanceToCycle.Code.Funs /-! # Specifications of `Aegis.DistanceToCycle.distance_to_cycle` LeetCode problem `distance-to-a-cycle-in-undirected-graph`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.DistanceToCycle def vals (v : al...
13
maximize-number-of-subsequences-in-a-string
2,207
Medium
[ "Greedy", "String", "Prefix Sum" ]
You are given a 0-indexed string text and another 0-indexed string pattern of length 2, both of which consist of only lowercase English letters. You can add either pattern[0] or pattern[1] anywhere in text exactly once. Note that the character can be added even at the beginning or at the end of text. Return the maximum...
maximumSubsequenceCount(text: str, pattern: str) -> int
pub fn maximum_subsequence_count(text: &[u8], pattern: &[u8]) -> i64
Aegis.MaximumSubsequenceCount.maximum_subsequence_count
pub fn maximum_subsequence_count(text: &[u8], pattern: &[u8]) -> i64 { let a = pattern[0]; let b = pattern[1]; if a == b { let mut count: i64 = 0; let mut i: usize = 0; while i < text.len() { if text[i] == a { count += 1; } i += 1;...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [maximum_subsequence_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_op...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [maximum_subsequence_count]: function definitions module public import Aeneas public import Aegis.MaximumSubsequenceCount.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashC...
import Aegis.MaximumSubsequenceCount.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #ev...
[ { "input": "[\"bbbb\", \"bb\"]", "output": "10" }, { "input": "[\"aaaaa\", \"aa\"]", "output": "15" }, { "input": "[\"zzzz\", \"zz\"]", "output": "10" }, { "input": "[\"abdcdbc\", \"ac\"]", "output": "4" }, { "input": "[\"abc\", \"ca\"]", "output": "1" }, ...
138
false
138
verified
10
10
1
901
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MaximumSubsequenceCount.Code.Funs /-! # Specifications of `Aegis.MaximumSubsequenceCount.maximum_subsequence_count` LeetCode problem `maximize-number-of-subsequences-in-a-string`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.MaximumSubsequenc...
10
minimum-operations-to-halve-array-sum
2,208
Medium
[ "Greedy", "Array", "Heap (Priority Queue)" ]
You are given an array nums of positive integers. In one operation, you can choose any number from nums and reduce it to exactly half the number. (Note that you may choose this reduced number in future operations.) Return the minimum number of operations to reduce the sum of nums by at least half.   Example 1: Input: ...
halveArray(nums: list_int) -> int
pub fn halve_array(nums: &[i64]) -> i64
Aegis.HalveArray.halve_array
pub fn halve_array(nums: &[i64]) -> i64 { let n = nums.len(); if n == 0 { return 0; } let mut total: i64 = 0; let mut i: usize = 0; while i < n { total += nums[i]; i += 1; } // We compare reductions using denominator 2^24. // A reduction of S/2 corresponds t...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [halve_array]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter.st...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [halve_array]: function definitions module public import Aeneas public import Aegis.HalveArray.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.HalveArray.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval aegisCase ...
[ { "input": "[[10000000]]", "output": "1" }, { "input": "[[3, 8, 20]]", "output": "3" }, { "input": "[[10, 10, 10, 10]]", "output": "4" }, { "input": "[[100, 100, 100, 100]]", "output": "4" }, { "input": "[[5, 19, 8, 1]]", "output": "3" }, { "input": "[...
78
false
78
verified
10
10
1
18,707
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.HalveArray.Code.Funs /-! # Specifications of `Aegis.HalveArray.halve_array` LeetCode problem `minimum-operations-to-halve-array-sum`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.HalveArray (halve_array) namespace AegisSpec.HalveArray def val...
11
minimum-white-tiles-after-covering-with-carpets
2,209
Hard
[ "String", "Dynamic Programming", "Prefix Sum" ]
You are given a 0-indexed binary string floor, which represents the colors of tiles on a floor: floor[i] = '0' denotes that the ith tile of the floor is colored black. On the other hand, floor[i] = '1' denotes that the ith tile of the floor is colored white. You are also given numCarpets and carpetLen. You have numCa...
minimumWhiteTiles(floor: str, numCarpets: int, carpetLen: int) -> int
pub fn minimum_white_tiles(floor: &[u8], numCarpets: i64, carpetLen: i64) -> i64
Aegis.MinimumWhiteTiles.minimum_white_tiles
pub fn minimum_white_tiles(floor: &[u8], numCarpets: i64, carpetLen: i64) -> i64 { let n: usize = floor.len(); let mut k: usize = numCarpets as usize; if k > n { k = n; } let l: usize = carpetLen as usize; let width: usize = k + 1; let total: usize = (n + 1) * width; let mut dp...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [minimum_white_tiles]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option l...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [minimum_white_tiles]: function definitions module public import Aeneas public import Aegis.MinimumWhiteTiles.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false...
import Aegis.MinimumWhiteTiles.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": "[\"111100001111\", 4, 4]", "output": "0" }, { "input": "[\"110011\", 3, 2]", "output": "0" }, { "input": "[\"11111\", 2, 3]", "output": "0" }, { "input": "[\"1010101010\", 5, 1]", "output": "0" }, { "input": "[\"11001100\", 3, 2]", "output": "0" ...
110
false
110
verified
10
10
1
9,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.MinimumWhiteTiles.Code.Funs /-! # Specifications of `Aegis.MinimumWhiteTiles.minimum_white_tiles` LeetCode problem `minimum-white-tiles-after-covering-with-carpets`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.MinimumWhiteTiles namespace Aegi...
13
count-hills-and-valleys-in-an-array
2,210
Easy
[ "Array" ]
You are given a 0-indexed integer array nums. An index i is part of a hill in nums if the closest non-equal neighbors of i are smaller than nums[i]. Similarly, an index i is part of a valley in nums if the closest non-equal neighbors of i are larger than nums[i]. Adjacent indices i and j are part of the same hill or va...
countHillValley(nums: list_int) -> int
pub fn count_hill_valley(nums: &[i64]) -> i64
Aegis.CountHillValley.count_hill_valley
pub fn count_hill_valley(nums: &[i64]) -> i64 { let n = nums.len(); let mut count: i64 = 0; let mut i: usize = 1; while i + 1 < n { if nums[i] == nums[i - 1] { i += 1; } else { let mut r: usize = i; while r + 1 < n && nums[r + 1] == nums[i] { ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [count_hill_valley]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option lin...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [count_hill_valley]: function definitions module public import Aeneas public import Aegis.CountHillValley.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.CountHillValley.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval aegis...
[ { "input": "[[1, 3, 2, 3, 1]]", "output": "3" }, { "input": "[[5, 5, 5, 5, 5]]", "output": "0" }, { "input": "[[1, 1, 1, 1, 1]]", "output": "0" }, { "input": "[[1, 2, 2, 2, 3]]", "output": "0" }, { "input": "[[1, 2, 3, 2, 1]]", "output": "1" }, { "inpu...
154
false
154
verified
10
10
1
4,402
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.CountHillValley.Code.Funs /-! # Specifications of `Aegis.CountHillValley.count_hill_valley` LeetCode problem `count-hills-and-valleys-in-an-array`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.CountHillValley open Aeneas.Std Aene...
10