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
maximum-element-sum-of-a-complete-subset-of-indices
2,862
Hard
[ "Array", "Math", "Number Theory" ]
You are given a 1-indexed array nums. Your task is to select a complete subset from nums where every pair of selected indices multiplied is a perfect square,. i. e. if you select ai and aj, i * j must be a perfect square. Return the sum of the complete subset with the maximum sum.   Example 1: Input: nums = [8,7,3,5,7...
maximumSum(nums: list_int) -> int
pub fn maximum_sum(nums: &[i64]) -> i64
Aegis.MaximumSum.maximum_sum
fn squarefree_kernel(mut x: usize) -> usize { let mut d: usize = 2; while d * d <= x { let sq = d * d; while x % sq == 0 { x = x / sq; } d += 1; } x } pub fn maximum_sum(nums: &[i64]) -> i64 { let n = nums.len(); let mut sums: Vec<i64> = Vec::new(); ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [maximum_sum]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter.st...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [maximum_sum]: function definitions module public import Aeneas public import Aegis.MaximumSum.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.MaximumSum.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval aegisCase ...
[ { "input": "[[8, 7, 3, 5, 7, 2, 4, 9]]", "output": "16" }, { "input": "[[8, 10, 3, 8, 1, 13, 7, 9, 4]]", "output": "20" }, { "input": "[[1, 1, 1, 1, 1, 1, 1, 1, 1, 1]]", "output": "3" }, { "input": "[[10, 10, 10, 10, 10, 10, 10, 10, 10, 10]]", "output": "30" }, { ...
62
false
62
verified
10
10
1
3,596
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MaximumSum.Code.Funs /-! # Specifications of `Aegis.MaximumSum.maximum_sum` LeetCode problem `maximum-element-sum-of-a-complete-subset-of-indices`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result set_option autoImplicit false namespace AegisSpec.MaximumSum...
17
maximum-length-of-semi-decreasing-subarrays
2,863
Medium
[ "Stack", "Array", "Sorting", "Monotonic Stack" ]
You are given an integer array nums. Return the length of the longest semi-decreasing subarray of nums, and 0 if there are no such subarrays. A subarray is a contiguous non-empty sequence of elements within an array. A non-empty array is semi-decreasing if its first element is strictly greater than its last element. ...
maxSubarrayLength(nums: list_int) -> int
pub fn max_subarray_length(nums: &[i64]) -> i64
Aegis.MaxSubarrayLength.max_subarray_length
pub fn max_subarray_length(nums: &[i64]) -> i64 { let n = nums.len(); if n <= 1 { return 0; } // Candidate left endpoints: indices whose value is strictly greater // than every value before them. let mut left: Vec<i64> = Vec::new(); left.push(0_i64); let mut max_val: i64 = nums...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [max_subarray_length]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option l...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [max_subarray_length]: function definitions module public import Aeneas public import Aegis.MaxSubarrayLength.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false...
import Aegis.MaxSubarrayLength.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval aeg...
[ { "input": "[[1]]", "output": "0" }, { "input": "[[1, 2, 3, 4]]", "output": "0" }, { "input": "[[1000000000, -1000000000, 1000000000, -1000000000, 1000000000]]", "output": "4" }, { "input": "[[5, 5, 5, 5, 5, 5, 5]]", "output": "0" }, { "input": "[[1, 3, 2, 4, 5, 3...
126
false
126
verified
10
10
1
8,140
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MaxSubarrayLength.Code.Funs /-! # Specifications of `Aegis.MaxSubarrayLength.max_subarray_length` LeetCode problem `maximum-length-of-semi-decreasing-subarrays`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.MaxSubarrayLength namespace AegisSpe...
12
beautiful-towers-i
2,865
Medium
[ "Stack", "Array", "Monotonic Stack" ]
You are given an array heights of n integers representing the number of bricks in n consecutive towers. Your task is to remove some bricks to form a mountain-shaped tower arrangement. In this arrangement, the tower heights are non-decreasing, reaching a maximum peak value with one or multiple consecutive towers and the...
maximumSumOfHeights(heights: list_int) -> int
pub fn maximum_sum_of_heights(heights: &[i64]) -> i64
Aegis.MaximumSumOfHeights.maximum_sum_of_heights
pub fn maximum_sum_of_heights(heights: &[i64]) -> i64 { let n = heights.len(); let mut ans: i64 = 0; let mut p: usize = 0; while p < n { let peak = heights[p]; let mut total = peak; let mut prev = peak; let mut i = p; while i > 0 { i -= 1; ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [maximum_sum_of_heights]: type definitions module public import Aeneas @[expose] public 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 -- [maximum_sum_of_heights]: function definitions module public import Aeneas public import Aegis.MaximumSumOfHeights.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand ...
import Aegis.MaximumSumOfHeights.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := 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, 10]]", "output": "40" }, { "input": "[[1000000000, 1000000000, 1000000000]]", "output": "3000000000" }, { "input": "[[1, 2, 1]]", "output": "4" }, { "input": "[[2, 1, 2]]", "output": "4" }, { "input": "[[1000000000, 1000000000, 1000000000]]",...
184
false
184
verified
10
10
1
3,057
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MaximumSumOfHeights.Code.Funs /-! # Specifications of `Aegis.MaximumSumOfHeights.maximum_sum_of_heights` LeetCode problem `beautiful-towers-i`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.MaximumSumOfHeights def heightAt (heights : ...
12
beautiful-towers-ii
2,866
Medium
[ "Stack", "Array", "Monotonic Stack" ]
You are given a 0-indexed array maxHeights of n integers. You are tasked with building n towers in the coordinate line. The ith tower is built at coordinate i and has a height of heights[i]. A configuration of towers is beautiful if the following conditions hold: 1 <= heights[i] <= maxHeights[i] heights is a mountain ...
maximumSumOfHeights(maxHeights: list_int) -> int
pub fn maximum_sum_of_heights(maxHeights: &[i64]) -> i64
Aegis.MaximumSumOfHeights.maximum_sum_of_heights
pub fn maximum_sum_of_heights(maxHeights: &[i64]) -> i64 { let n = maxHeights.len(); if n == 0 { return 0; } let mut left: Vec<i64> = Vec::new(); let mut right: Vec<i64> = Vec::new(); let mut stack: Vec<usize> = Vec::new(); let mut init: usize = 0; while init < n { left...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [maximum_sum_of_heights]: type definitions module public import Aeneas @[expose] public 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 -- [maximum_sum_of_heights]: function definitions module public import Aeneas public import Aegis.MaximumSumOfHeights.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand ...
import Aegis.MaximumSumOfHeights.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := 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, 2, 3, 4, 5]]", "output": "15" }, { "input": "[[5, 4, 3, 2, 1]]", "output": "15" }, { "input": "[[1000000000, 1000000000, 1000000000, 1000000000, 1000000000]]", "output": "5000000000" }, { "input": "[[10, 10, 10, 10, 10]]", "output": "50" }, { "inp...
111
false
111
verified
10
10
1
8,586
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MaximumSumOfHeights.Code.Funs /-! # Specifications of `Aegis.MaximumSumOfHeights.maximum_sum_of_heights` LeetCode problem `beautiful-towers-ii`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.MaximumSumOfHeights namespace AegisSpec.MaximumSumOfH...
11
count-valid-paths-in-a-tree
2,867
Hard
[ "Tree", "Depth-First Search", "Math", "Dynamic Programming", "Number Theory" ]
There is an undirected tree with n nodes labeled from 1 to n. You are given the integer n and a 2D integer array edges of length n - 1, where edges[i] = [ui, vi] indicates that there is an edge between nodes ui and vi in the tree. Return the number of valid paths in the tree. A path (a, b) is valid if there exists exac...
countPaths(n: int, edges: list_list_int) -> int
pub fn count_paths(n: i64, edges: &[Vec<i64>]) -> i64
Aegis.CountPaths.count_paths
pub fn count_paths(n: i64, edges: &[Vec<i64>]) -> i64 { let n_usize = n as usize; // Sieve of Eratosthenes: is_prime[i] == true iff i is prime. let mut is_prime: Vec<bool> = Vec::new(); let mut i = 0usize; while i <= n_usize { is_prime.push(true); i += 1; } if n_usize >= 0 ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [count_paths]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter.st...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [count_paths]: function definitions module public import Aeneas public import Aegis.CountPaths.Code.Types public import Aegis.CountPaths.Code.FunsExternal @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false s...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [count_paths]: external functions. -- This is a template file: rename it to "FunsExternal.lean" and fill the holes. module public import Aeneas public import Aegis.CountPaths.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_opt...
import Aegis.CountPaths.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := 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, [[1, 2], [2, 3]]]", "output": "1" }, { "input": "[5, [[1, 2], [1, 3], [2, 4], [2, 5]]]", "output": "4" }, { "input": "[6, [[1, 2], [1, 3], [2, 4], [3, 5], [3, 6]]]", "output": "6" }, { "input": "[7, [[1, 2], [1, 3], [1, 4], [2, 5], [2, 6], [2, 7]]]", "outp...
34
false
34
verified
10
10
1
3,814
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.CountPaths.Code.Funs /-! # Specifications of `Aegis.CountPaths.count_paths` LeetCode problem `count-valid-paths-in-a-tree`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.CountPaths def edgeLabels (e : alloc.vec.Vec Std.I64) : List Int...
10
minimum-operations-to-collect-elements
2,869
Easy
[ "Bit Manipulation", "Array", "Hash Table" ]
You are given an array nums of positive integers and an integer k. In one operation, you can remove the last element of the array and add it to your collection. Return the minimum number of operations needed to collect elements 1, 2, ..., k.   Example 1: Input: nums = [3,1,5,4,2], k = 2 Output: 4 Explanation: After 4 ...
minOperations(nums: list_int, k: int) -> int
pub fn min_operations(nums: &[i64], k: i64) -> i64
Aegis.MinOperations.min_operations
pub fn min_operations(nums: &[i64], k: i64) -> i64 { let n = nums.len(); let kk = k as usize; let mut seen: Vec<bool> = Vec::new(); let mut j = 0usize; while j <= kk { seen.push(false); j += 1; } let mut count: i64 = 0; let mut i = n; while i > 0 { i -= 1; ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [min_operations]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [min_operations]: function definitions module public import Aeneas public import Aegis.MinOperations.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_opti...
import Aegis.MinOperations.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval aegisCa...
[ { "input": "[[2, 1, 2, 1, 2], 2]", "output": "2" }, { "input": "[[2, 3, 1, 4, 5], 4]", "output": "5" }, { "input": "[[3, 1, 5, 4, 2], 5]", "output": "5" }, { "input": "[[4, 3, 2, 1, 5], 5]", "output": "5" }, { "input": "[[1, 2, 2, 3, 3], 3]", "output": "5" }...
94
false
94
verified
10
10
1
1,320
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MinOperations.Code.Funs /-! # Specifications of `Aegis.MinOperations.min_operations` LeetCode problem `minimum-operations-to-collect-elements`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.MinOperations def size (nums : Slice Std...
11
minimum-number-of-operations-to-make-array-empty
2,870
Medium
[ "Greedy", "Array", "Hash Table", "Counting" ]
You are given a 0-indexed array nums consisting of positive integers. There are two types of operations that you can apply on the array any number of times: Choose two elements with equal values and delete them from the array. Choose three elements with equal values and delete them from the array. Return the minimum ...
minOperations(nums: list_int) -> int
pub fn min_operations(nums: &[i64]) -> i64
Aegis.MinOperations.min_operations
pub fn min_operations(nums: &[i64]) -> i64 { let n: usize = nums.len(); if n == 0 { return 0; } // A small hash table whose size depends only on the number of elements, // never on the magnitude of the values in nums. let cap: usize = n * 2 + 1; let cap_i: i64 = cap as i64; let...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [min_operations]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [min_operations]: function definitions module public import Aeneas public import Aegis.MinOperations.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_opti...
import Aegis.MinOperations.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval aegisCa...
[ { "input": "[[1000000, 1000000, 1000000]]", "output": "1" }, { "input": "[[1000000, 1000000, 1000000]]", "output": "1" }, { "input": "[[1, 1, 1, 2, 2, 3]]", "output": "-1" }, { "input": "[[2, 1, 2, 2, 3, 3]]", "output": "-1" }, { "input": "[[1, 2, 3, 4, 5, 6]]", ...
107
false
107
verified
10
10
2
6,688
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MinOperations.Code.Funs /-! # Specifications of `Aegis.MinOperations.min_operations` LeetCode problem `minimum-number-of-operations-to-make-array-empty`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.MinOperations open Classical ...
12
split-array-into-maximum-number-of-subarrays
2,871
Medium
[ "Greedy", "Bit Manipulation", "Array" ]
You are given an array nums consisting of non-negative integers. We define the score of subarray nums[l..r] such that l <= r as nums[l] AND nums[l + 1] AND ... AND nums[r] where AND is the bitwise AND operation. Consider splitting the array into one or more subarrays such that the following conditions are satisfied: E...
maxSubarrays(nums: list_int) -> int
pub fn max_subarrays(nums: &[i64]) -> i64
Aegis.MaxSubarrays.max_subarrays
pub fn max_subarrays(nums: &[i64]) -> i64 { let mut cur: i64 = -1; let mut count: i64 = 0; let n = nums.len(); let mut i: usize = 0; while i < n { cur = cur & nums[i]; if cur == 0 { count += 1; cur = -1; } i += 1; } if count == 0 { ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [max_subarrays]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter....
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [max_subarrays]: function definitions module public import Aeneas public import Aegis.MaxSubarrays.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.MaxSubarrays.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := 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": "[[5, 7, 1, 3]]", "output": "1" }, { "input": "[[0, 0, 0, 0]]", "output": "4" }, { "input": "[[8, 12, 4, 6]]", "output": "1" }, { "input": "[[8, 8, 8, 8, 8]]", "output": "1" }, { "input": "[[0, 0, 0, 0, 0]]", "output": "5" }, { "input": "[[1...
103
false
103
verified
10
10
1
3,886
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MaxSubarrays.Code.Funs /-! # Specifications of `Aegis.MaxSubarrays.max_subarrays` LeetCode problem `split-array-into-maximum-number-of-subarrays`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.MaxSubarrays namespace AegisSpec.MaxSubarrays def ...
12
maximum-number-of-k-divisible-components
2,872
Hard
[ "Tree", "Depth-First Search" ]
There is an undirected tree with n nodes labeled from 0 to n - 1. You are given the integer n and a 2D integer array edges of length n - 1, where edges[i] = [ai, bi] indicates that there is an edge between nodes ai and bi in the tree. You are also given a 0-indexed integer array values of length n, where values[i] is t...
maxKDivisibleComponents(n: int, edges: list_list_int, values: list_int, k: int) -> int
pub fn max_k_divisible_components(n: i64, edges: &[Vec<i64>], values: &[i64], k: i64) -> i64
Aegis.MaxKDivisibleComponents.max_k_divisible_components
pub fn max_k_divisible_components(n: i64, edges: &[Vec<i64>], values: &[i64], k: i64) -> i64 { let n_us = n as usize; // Build a flat adjacency list. // For each directed edge, to[e] is the destination and next[e] is the next edge index. let mut head: Vec<i64> = Vec::new(); let mut i: usize = 0; ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [max_k_divisible_components]: type definitions module public import Aeneas @[expose] public 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 -- [max_k_divisible_components]: function definitions module public import Aeneas public import Aegis.MaxKDivisibleComponents.Code.Types public import Aegis.MaxKDivisibleComponents.Code.FunsExternal @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Err...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [max_k_divisible_components]: external functions. -- This is a template file: rename it to "FunsExternal.lean" and fill the holes. module public import Aeneas public import Aegis.MaxKDivisibleComponents.Code.Types @[expose] public section open Aeneas Aeneas.Std Resu...
import Aegis.MaxKDivisibleComponents.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO 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": "[3, [[0, 1], [0, 2]], [1, 1, 1], 2]", "output": "0" }, { "input": "[3, [[0, 1], [1, 2]], [3, 9, 12], 3]", "output": "3" }, { "input": "[3, [[0, 1], [0, 2]], [3, 0, 6], 3]", "output": "3" }, { "input": "[3, [[0, 1], [0, 2]], [1, 2, 3], 1]", "output": "3" }, ...
78
false
78
verified
10
10
1
10,808
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MaxKDivisibleComponents.Code.Funs /-! # Specifications of `Aegis.MaxKDivisibleComponents.max_k_divisible_components` LeetCode problem `maximum-number-of-k-divisible-components`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.MaxKDivisibleComponen...
11
maximum-value-of-an-ordered-triplet-i
2,873
Easy
[ "Array" ]
You are given a 0-indexed integer array nums. Return the maximum value over all triplets of indices (i, j, k) such that i < j < k. If all such triplets have a negative value, return 0. The value of a triplet of indices (i, j, k) is equal to (nums[i] - nums[j]) * nums[k].   Example 1: Input: nums = [12,6,1,2,7] Output:...
maximumTripletValue(nums: list_int) -> int
pub fn maximum_triplet_value(nums: &[i64]) -> i64
Aegis.MaximumTripletValue.maximum_triplet_value
pub fn maximum_triplet_value(nums: &[i64]) -> i64 { let n = nums.len(); let mut best: i64 = 0; let mut i: usize = 0; while i < n { let mut j: usize = i + 1; while j < n { let mut k: usize = j + 1; while k < n { let value = (nums[i] - nums[j]) * nu...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [maximum_triplet_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...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [maximum_triplet_value]: function definitions module public import Aeneas public import Aegis.MaximumTripletValue.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand f...
import Aegis.MaximumTripletValue.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := 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, 2, 3]]", "output": "0" }, { "input": "[[100, 100, 100]]", "output": "0" }, { "input": "[[12, 6, 1, 2, 7]]", "output": "77" }, { "input": "[[10, 20, 30, 40, 50]]", "output": "0" }, { "input": "[[5, 5, 5, 5, 5]]", "output": "0" }, { "inp...
126
false
126
verified
10
10
1
454
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MaximumTripletValue.Code.Funs /-! # Specifications of `Aegis.MaximumTripletValue.maximum_triplet_value` LeetCode problem `maximum-value-of-an-ordered-triplet-i`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.MaximumTripletValue namespace AegisS...
10
maximum-value-of-an-ordered-triplet-ii
2,874
Medium
[ "Array" ]
You are given a 0-indexed integer array nums. Return the maximum value over all triplets of indices (i, j, k) such that i < j < k. If all such triplets have a negative value, return 0. The value of a triplet of indices (i, j, k) is equal to (nums[i] - nums[j]) * nums[k].   Example 1: Input: nums = [12,6,1,2,7] Output:...
maximumTripletValue(nums: list_int) -> int
pub fn maximum_triplet_value(nums: &[i64]) -> i64
Aegis.MaximumTripletValue.maximum_triplet_value
pub fn maximum_triplet_value(nums: &[i64]) -> i64 { let n = nums.len(); let mut max_i: i64 = nums[0]; let mut max_diff: i64 = 0; let mut ans: i64 = 0; let mut k: usize = 1; while k < n { let val = max_diff * nums[k]; if val > ans { ans = val; } let d...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [maximum_triplet_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...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [maximum_triplet_value]: function definitions module public import Aeneas public import Aegis.MaximumTripletValue.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand f...
import Aegis.MaximumTripletValue.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := 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, 2, 3]]", "output": "0" }, { "input": "[[12, 6, 1, 2, 7]]", "output": "77" }, { "input": "[[10, 20, 30, 40, 50]]", "output": "0" }, { "input": "[[5, 5, 5, 5, 5]]", "output": "0" }, { "input": "[[5, 6, 7, 8, 9]]", "output": "0" }, { "inp...
119
false
119
verified
10
10
1
1,588
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MaximumTripletValue.Code.Funs /-! # Specifications of `Aegis.MaximumTripletValue.maximum_triplet_value` LeetCode problem `maximum-value-of-an-ordered-triplet-ii`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.MaximumTripletValue d...
8
minimum-size-subarray-in-infinite-array
2,875
Medium
[ "Array", "Hash Table", "Prefix Sum", "Sliding Window" ]
You are given a 0-indexed array nums and an integer target. A 0-indexed array infinite_nums is generated by infinitely appending the elements of nums to itself. Return the length of the shortest subarray of the array infinite_nums with a sum equal to target. If there is no such subarray return -1.   Example 1: Input: ...
minSizeSubarray(nums: list_int, target: int) -> int
pub fn min_size_subarray(nums: &[i64], target: i64) -> i64
Aegis.MinSizeSubarray.min_size_subarray
pub fn min_size_subarray(nums: &[i64], target: i64) -> i64 { let n = nums.len(); if n == 0 { return -1; } let mut total: i64 = 0; let mut i: usize = 0; while i < n { total += nums[i]; i += 1; } if total <= 0 { return -1; } let q: i64 = target / ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [min_size_subarray]: type definitions module public import Aeneas @[expose] public section 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_size_subarray]: function definitions module public import Aeneas public import Aegis.MinSizeSubarray.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.MinSizeSubarray.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := 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": "1" }, { "input": "[[100000], 100000]", "output": "1" }, { "input": "[[100000], 500000]", "output": "5" }, { "input": "[[100000], 1000000000]", "output": "10000" }, { "input": "[[1], 100000]", "output": "100000" }, { "i...
117
false
117
verified
10
10
1
6,737
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MinSizeSubarray.Code.Funs /-! # Specifications of `Aegis.MinSizeSubarray.min_size_subarray` LeetCode problem `minimum-size-subarray-in-infinite-array`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.MinSizeSubarray def vals (nums :...
15
count-visited-nodes-in-a-directed-graph
2,876
Hard
[ "Graph", "Memoization", "Dynamic Programming" ]
There is a directed graph consisting of n nodes numbered from 0 to n - 1 and n directed edges. You are given a 0-indexed array edges where edges[i] indicates that there is an edge from node i to node edges[i]. Consider the following process on the graph: You start from a node x and keep visiting other nodes through ed...
countVisitedNodes(edges: list_int) -> list_int
pub fn count_visited_nodes(edges: &[i64]) -> Vec<i64>
Aegis.CountVisitedNodes.count_visited_nodes
pub fn count_visited_nodes(edges: &[i64]) -> Vec<i64> { let n = edges.len(); let mut state: Vec<i64> = Vec::new(); let mut ans: Vec<i64> = Vec::new(); let mut i = 0; while i < n { state.push(0); ans.push(0); i += 1; } let mut start = 0; while start < n { ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [count_visited_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 l...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [count_visited_nodes]: function definitions module public import Aeneas public import Aegis.CountVisitedNodes.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false...
import Aegis.CountVisitedNodes.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := 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": "[2, 2]" }, { "input": "[[1, 2, 0, 0]]", "output": "[3, 3, 3, 4]" }, { "input": "[[2, 2, 3, 1]]", "output": "[4, 3, 3, 3]" }, { "input": "[[3, 3, 3, 3]]", "output": "[2, 2, 2, 1]" }, { "input": "[[3, 3, 3, 1]]", "output": "[3, ...
91
false
91
verified
10
10
1
7,186
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.CountVisitedNodes.Code.Funs /-! # Specifications of `Aegis.CountVisitedNodes.count_visited_nodes` LeetCode problem `count-visited-nodes-in-a-directed-graph`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.CountVisitedNodes open Aeg...
15
minimizing-array-after-replacing-pairs-with-their-product
2,892
Medium
[ "Greedy", "Array", "Dynamic Programming" ]
Given an integer array nums and an integer k, you can perform the following operation on the array any number of times: Select two adjacent elements of the array like x and y, such that x * y <= k, and replace both of them with a single element with value x * y (e.g. in one operation the array [1, 2, 2, 3] with k = 5 ...
minArrayLength(nums: list_int, k: int) -> int
pub fn min_array_length(nums: &[i64], k: i64) -> i64
Aegis.MinArrayLength.min_array_length
pub fn min_array_length(nums: &[i64], k: i64) -> i64 { let n: usize = nums.len(); if n == 0 { return 0; } // With nonnegative nums, if k is negative no operation is possible. if k < 0 { return n as i64; } // If there is any zero, it can absorb every other element one by on...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [min_array_length]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option lint...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [min_array_length]: function definitions module public import Aeneas public import Aegis.MinArrayLength.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.MinArrayLength.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval aegisC...
[ { "input": "[[1000000000, 1000000000], 1000000000000000000]", "output": "1" }, { "input": "[[3, 3, 3, 3], 6]", "output": "4" }, { "input": "[[10, 5, 2, 1], 50]", "output": "2" }, { "input": "[[10, 10, 10, 10], 100]", "output": "2" }, { "input": "[[1, 0, 0, 1], 0]"...
125
false
125
verified
10
10
1
7,466
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MinArrayLength.Code.Funs /-! # Specifications of `Aegis.MinArrayLength.min_array_length` LeetCode problem `minimizing-array-after-replacing-pairs-with-their-product`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.MinArrayLength (min_array_length...
13
divisible-and-non-divisible-sums-difference
2,894
Easy
[ "Math" ]
You are given positive integers n and m. Define two integers as follows: num1: The sum of all integers in the range [1, n] (both inclusive) that are not divisible by m. num2: The sum of all integers in the range [1, n] (both inclusive) that are divisible by m. Return the integer num1 - num2.   Example 1: Input: n = ...
differenceOfSums(n: int, m: int) -> int
pub fn difference_of_sums(n: i64, m: i64) -> i64
Aegis.DifferenceOfSums.difference_of_sums
pub fn difference_of_sums(n: i64, m: i64) -> i64 { let mut ans: i64 = 0; let mut i: i64 = 1; while i <= n { if i % m == 0 { ans -= i; } else { ans += i; } i += 1; } ans }
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [difference_of_sums]: type definitions module public import Aeneas @[expose] public section 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 -- [difference_of_sums]: function definitions module public import Aeneas public import Aegis.DifferenceOfSums.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.DifferenceOfSums.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := 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": "[1000, 1000]", "output": "498500" }, { "input": "[5, 6]", "output": "15" }, { "input": "[5, 1]", "output": "-15" }, { "input": "[20, 4]", "output": "90" }, { "input": "[100, 10]", "output": "3950" }, { "input": "[1, 1]", "output": "-1" ...
93
false
93
verified
10
10
1
266
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.DifferenceOfSums.Code.Funs /-! # Specifications of `Aegis.DifferenceOfSums.difference_of_sums` LeetCode problem `divisible-and-non-divisible-sums-difference`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.DifferenceOfSums def tria...
8
minimum-processing-time
2,895
Medium
[ "Greedy", "Array", "Sorting" ]
You have a certain number of processors, each having 4 cores. The number of tasks to be executed is four times the number of processors. Each task must be assigned to a unique core, and each core can only be used once. You are given an array processorTime representing the time each processor becomes available and an ar...
minProcessingTime(processorTime: list_int, tasks: list_int) -> int
pub fn min_processing_time(processorTime: &[i64], tasks: &[i64]) -> i64
Aegis.MinProcessingTime.min_processing_time
fn sift_down(a: &mut Vec<i64>, mut root: usize, end: usize) { let mut cont = true; while cont { let left = root * 2 + 1; if left >= end { cont = false; } else { let mut child = left; let right = left + 1; if right < end { if...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [min_processing_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 -- [min_processing_time]: function definitions module public import Aeneas public import Aegis.MinProcessingTime.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false...
import Aegis.MinProcessingTime.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := 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": "[[1000000000], [1, 1, 1, 1]]", "output": "1000000001" }, { "input": "[[1000000000, 1000000000], [1000000000, 1000000000, 1000000000, 1000000000]]", "output": "2000000000" }, { "input": "[[10, 20], [2, 3, 1, 2, 5, 8, 4, 3]]", "output": "23" }, { "input": "[[8, 10],...
85
false
85
verified
10
10
2
40,248
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MinProcessingTime.Code.Funs /-! # Specifications of `Aegis.MinProcessingTime.min_processing_time` LeetCode problem `minimum-processing-time`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.MinProcessingTime namespace AegisSpec.MinProcessingT...
17
apply-operations-to-make-two-strings-equal
2,896
Medium
[ "String", "Dynamic Programming" ]
You are given two 0-indexed binary strings s1 and s2, both of length n, and a positive integer x. You can perform any of the following operations on the string s1 any number of times: Choose two indices i and j, and flip both s1[i] and s1[j]. The cost of this operation is x. Choose an index i such that i < n - 1 and f...
minOperations(s1: str, s2: str, x: int) -> int
pub fn min_operations(s1: &[u8], s2: &[u8], x: i64) -> i64
Aegis.MinOperations.min_operations
pub fn min_operations(s1: &[u8], s2: &[u8], x: i64) -> i64 { let n = s1.len(); let mut pos: Vec<i64> = Vec::new(); let mut i: usize = 0; while i < n { if s1[i] != s2[i] { pos.push(i as i64); } i += 1; } let m = pos.len(); if m % 2 == 1 { return -...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [min_operations]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [min_operations]: function definitions module public import Aeneas public import Aegis.MinOperations.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_opti...
import Aegis.MinOperations.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval aegisCa...
[ { "input": "[\"101010\", \"010101\", 1]", "output": "3" }, { "input": "[\"1111\", \"1111\", 3]", "output": "0" }, { "input": "[\"101010\", \"010101\", 5]", "output": "3" }, { "input": "[\"1111\", \"1111\", 5]", "output": "0" }, { "input": "[\"1111\", \"1111\", 10]...
113
false
113
verified
10
10
1
15,049
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MinOperations.Code.Funs /-! # Specifications of `Aegis.MinOperations.min_operations` LeetCode problem `apply-operations-to-make-two-strings-equal`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.MinOperations def isBitByte (b : Std.U8)...
17
apply-operations-on-array-to-maximize-sum-of-squares
2,897
Hard
[ "Greedy", "Bit Manipulation", "Array", "Hash Table" ]
You are given a 0-indexed integer array nums and a positive integer k. You can do the following operation on the array any number of times: Choose any two distinct indices i and j and simultaneously update the values of nums[i] to (nums[i] AND nums[j]) and nums[j] to (nums[i] OR nums[j]). Here, OR denotes the bitwise ...
maxSum(nums: list_int, k: int) -> int
pub fn max_sum(nums: &[i64], k: i64) -> i64
Aegis.MaxSum.max_sum
pub fn max_sum(nums: &[i64], k: i64) -> i64 { let modulus: i64 = 1000000007; let bits: usize = 63; let n = nums.len(); let mut cnt: Vec<i64> = Vec::new(); let mut b: usize = 0; while b < bits { cnt.push(0); b += 1; } let mut i: usize = 0; while i < n { let ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [max_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 -- [max_sum]: function definitions module public import Aeneas public import Aegis.MaxSum.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unus...
import Aegis.MaxSum.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := 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 "eva...
[ { "input": "[[1000000000, 1000000000, 1000000000], 2]", "output": "98" }, { "input": "[[10, 10, 10, 10], 4]", "output": "400" }, { "input": "[[10, 10, 10, 10], 2]", "output": "200" }, { "input": "[[1, 1, 1, 1], 4]", "output": "4" }, { "input": "[[2, 6, 5, 8], 2]",...
98
false
98
verified
10
10
1
6,634
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MaxSum.Code.Funs /-! # Specifications of `Aegis.MaxSum.max_sum` LeetCode problem `apply-operations-on-array-to-maximize-sum-of-squares`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.MaxSum def M : ℤ := 1000000007 def bitWidth : ℕ :=...
8
maximum-linear-stock-score
2,898
Medium
[ "Array", "Hash Table" ]
Given a 1-indexed integer array prices, where prices[i] is the price of a particular stock on the ith day, your task is to select some of the elements of prices such that your selection is linear. A selection indexes, where indexes is a 1-indexed integer array of length k which is a subsequence of the array [1, 2, ...,...
maxScore(prices: list_int) -> int
pub fn max_score(prices: &[i64]) -> i64
Aegis.MaxScore.max_score
pub fn max_score(prices: &[i64]) -> i64 { let n = prices.len(); if n == 0 { return 0; } let mut keys: Vec<i64> = Vec::new(); let mut i: usize = 0; while i < n { keys.push(prices[i] - (i as i64)); i += 1; } let mut temp: Vec<i64> = Vec::new(); let mut z: usiz...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [max_score]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter.styl...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [max_score]: function definitions module public import Aeneas public import Aegis.MaxScore.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter....
import Aegis.MaxScore.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval aegisCase "e...
[ { "input": "[[1, 2, 4, 8, 16]]", "output": "16" }, { "input": "[[9, 7, 5, 3, 1]]", "output": "9" }, { "input": "[[1, 5, 3, 7, 8]]", "output": "20" }, { "input": "[[1, 3, 6, 10, 15]]", "output": "15" }, { "input": "[[5, 6, 7, 8, 9]]", "output": "35" }, { ...
153
false
153
verified
10
10
1
3,072
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MaxScore.Code.Funs /-! # Specifications of `Aegis.MaxScore.max_score` LeetCode problem `maximum-linear-stock-score`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.MaxScore def keyOf (p : Std.I64 × ℕ) : ℤ := p.1.val - (p.2 : ℤ) ...
7
last-visited-integers
2,899
Easy
[ "Array", "Simulation" ]
Given an integer array nums where nums[i] is either a positive integer or -1. We need to find for each -1 the respective positive integer, which we call the last visited integer. To achieve this goal, let's define two empty arrays: seen and ans. Start iterating from the beginning of the array nums. If a positive integ...
lastVisitedIntegers(nums: list_int) -> list_int
pub fn last_visited_integers(nums: &[i64]) -> Vec<i64>
Aegis.LastVisitedIntegers.last_visited_integers
pub fn last_visited_integers(nums: &[i64]) -> Vec<i64> { let mut seen: Vec<i64> = Vec::new(); let mut ans: Vec<i64> = Vec::new(); let mut k: usize = 0; let mut i: usize = 0; while i < nums.len() { let x = nums[i]; if x == -1 { k = k + 1; if k <= seen.len() {...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [last_visited_integers]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [last_visited_integers]: function definitions module public import Aeneas public import Aegis.LastVisitedIntegers.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand f...
import Aegis.LastVisitedIntegers.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval a...
[ { "input": "[[1]]", "output": "[]" }, { "input": "[[-1]]", "output": "[-1]" }, { "input": "[[1, -1]]", "output": "[1]" }, { "input": "[[1, 2, 3, 4, 5]]", "output": "[]" }, { "input": "[[-1, -1, -1]]", "output": "[-1, -1, -1]" }, { "input": "[[-1, -1, -...
261
false
261
verified
10
10
1
1,051
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.LastVisitedIntegers.Code.Funs /-! # Specifications of `Aegis.LastVisitedIntegers.last_visited_integers` LeetCode problem `last-visited-integers`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.LastVisitedIntegers open Aegis.LastVisited...
11
find-indices-with-index-and-value-difference-i
2,903
Easy
[ "Array", "Two Pointers" ]
You are given a 0-indexed integer array nums having length n, an integer indexDifference, and an integer valueDifference. Your task is to find two indices i and j, both in the range [0, n - 1], that satisfy the following conditions: abs(i - j) >= indexDifference, and abs(nums[i] - nums[j]) >= valueDifference Return a...
findIndices(nums: list_int, indexDifference: int, valueDifference: int) -> list_int
pub fn find_indices(nums: &[i64], indexDifference: i64, valueDifference: i64) -> Vec<i64>
Aegis.FindIndices.find_indices
pub fn find_indices(nums: &[i64], indexDifference: i64, valueDifference: i64) -> Vec<i64> { let n = nums.len() as i64; let mut min_index: i64 = 0; let mut max_index: i64 = 0; let mut i: i64 = indexDifference; while i < n { let j: i64 = i - indexDifference; let nv = nums[j as usize];...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [find_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.s...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [find_indices]: function definitions module public import Aeneas public import Aegis.FindIndices.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.FindIndices.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := 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, 1], 0, 0]", "output": "[0, 0]" }, { "input": "[[1, 2, 3], 2, 4]", "output": "[-1, -1]" }, { "input": "[[0, 0, 0, 0], 3, 1]", "output": "[-1, -1]" }, { "input": "[[0, 0, 0, 0], 1, 1]", "output": "[-1, -1]" }, { "input": "[[5, 1, 4, 1], 2, 4]", ...
137
false
137
verified
10
10
2
7,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.FindIndices.Code.Funs /-! # Specifications of `Aegis.FindIndices.find_indices` LeetCode problem `find-indices-with-index-and-value-difference-i`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.FindIndices def elem (nums : Slice Std.I64...
2
find-indices-with-index-and-value-difference-ii
2,905
Medium
[ "Array", "Two Pointers" ]
You are given a 0-indexed integer array nums having length n, an integer indexDifference, and an integer valueDifference. Your task is to find two indices i and j, both in the range [0, n - 1], that satisfy the following conditions: abs(i - j) >= indexDifference, and abs(nums[i] - nums[j]) >= valueDifference Return a...
findIndices(nums: list_int, indexDifference: int, valueDifference: int) -> list_int
pub fn find_indices(nums: &[i64], indexDifference: i64, valueDifference: i64) -> Vec<i64>
Aegis.FindIndices.find_indices
pub fn find_indices(nums: &[i64], indexDifference: i64, valueDifference: i64) -> Vec<i64> { let n: usize = nums.len(); let d: usize = indexDifference as usize; let mut found: bool = false; let mut ri: i64 = -1; let mut rj: i64 = -1; let mut min_val: i64 = nums[0]; let mut min_idx: usize = ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [find_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.s...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [find_indices]: function definitions module public import Aeneas public import Aegis.FindIndices.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.FindIndices.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := 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, 1], 0, 0]", "output": "[0, 0]" }, { "input": "[[1, 2, 3], 2, 4]", "output": "[-1, -1]" }, { "input": "[[4, 1, 3, 2], 1, 2]", "output": "[0, 1]" }, { "input": "[[5, 5, 5, 5], 1, 1]", "output": "[-1, -1]" }, { "input": "[[5, 1, 4, 1], 2, 4]", "o...
126
false
126
verified
10
10
2
10,930
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.FindIndices.Code.Funs /-! # Specifications of `Aegis.FindIndices.find_indices` LeetCode problem `find-indices-with-index-and-value-difference-ii`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.FindIndices open Aegis.FindIndices (f...
6
construct-product-matrix
2,906
Medium
[ "Array", "Matrix", "Prefix Sum" ]
Given a 0-indexed 2D integer matrix grid of size n * m, we define a 0-indexed 2D matrix p of size n * m as the product matrix of grid if the following condition is met: Each element p[i][j] is calculated as the product of all elements in grid except for the element grid[i][j]. This product is then taken modulo 12345. ...
constructProductMatrix(grid: list_list_int) -> list_list_int
pub fn construct_product_matrix(grid: &[Vec<i64>]) -> Vec<Vec<i64>>
Aegis.ConstructProductMatrix.construct_product_matrix
pub fn construct_product_matrix(grid: &[Vec<i64>]) -> Vec<Vec<i64>> { let n = grid.len(); if n == 0 { return Vec::new(); } let cols = grid[0].len(); let modulus: i64 = 12345; let total = n * cols; let mut prefix: Vec<i64> = Vec::new(); let mut prod: i64 = 1; let mut i: usiz...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [construct_product_matrix]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_opt...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [construct_product_matrix]: function definitions module public import Aeneas public import Aegis.ConstructProductMatrix.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCom...
import Aegis.ConstructProductMatrix.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eva...
[ { "input": "[[[7], [11], [13]]]", "output": "[[143], [91], [77]]" }, { "input": "[[[12345], [2], [1]]]", "output": "[[2], [0], [0]]" }, { "input": "[[[1, 2], [3, 4]]]", "output": "[[24, 12], [8, 6]]" }, { "input": "[[[5, 10], [15, 20]]]", "output": "[[3000, 1500], [1000, ...
82
false
82
verified
10
10
1
3,957
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.ConstructProductMatrix.Code.Funs /-! # Specifications of `Aegis.ConstructProductMatrix.construct_product_matrix` LeetCode problem `construct-product-matrix`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aeneas.Std.Result open Aegis.ConstructProductMa...
5
maximum-profitable-triplets-with-increasing-prices-i
2,907
Medium
[ "Binary Indexed Tree", "Segment Tree", "Array" ]
Given the 0-indexed arrays prices and profits of length n. There are n items in an store where the ith item has a price of prices[i] and a profit of profits[i]. We have to pick three items with the following condition: prices[i] < prices[j] < prices[k] where i < j < k. If we pick items with indices i, j and k satisfy...
maxProfit(prices: list_int, profits: list_int) -> int
pub fn max_profit(prices: &[i64], profits: &[i64]) -> i64
Aegis.MaxProfit.max_profit
pub fn max_profit(prices: &[i64], profits: &[i64]) -> i64 { let n = prices.len(); if n < 3 { return -1; } let mut ans: i64 = -1; let mut j: usize = 1; while j < n - 1 { let mut best_left: i64 = -1; let mut i: usize = 0; while i < j { if prices[i] < ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [max_profit]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter.sty...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [max_profit]: function definitions module public import Aeneas public import Aegis.MaxProfit.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.MaxProfit.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := 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, 101, 102], [1000, 1001, 1002]]", "output": "3003" }, { "input": "[[1, 1, 1], [1, 1, 1]]", "output": "-1" }, { "input": "[[1, 2, 3], [1000, 2000, 3000]]", "output": "6000" }, { "input": "[[1, 2, 3], [3, 2, 1]]", "output": "6" }, { "input": "[[100...
123
false
123
verified
10
10
1
726
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MaxProfit.Code.Funs /-! # Specifications of `Aegis.MaxProfit.max_profit` LeetCode problem `maximum-profitable-triplets-with-increasing-prices-i`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.MaxProfit def valAt (s : Slice Std.I64...
13
minimum-sum-of-mountain-triplets-i
2,908
Easy
[ "Array" ]
You are given a 0-indexed array nums of integers. A triplet of indices (i, j, k) is a mountain if: i < j < k nums[i] < nums[j] and nums[k] < nums[j] Return the minimum possible sum of a mountain triplet of nums. If no such triplet exists, return -1.   Example 1: Input: nums = [8,6,1,5,3] Output: 9 Explanation: Tripl...
minimumSum(nums: list_int) -> int
pub fn minimum_sum(nums: &[i64]) -> i64
Aegis.MinimumSum.minimum_sum
pub fn minimum_sum(nums: &[i64]) -> i64 { let n = nums.len(); let mut best: i64 = 1_000_000_000; let mut i: usize = 0; while i < n { let mut j: usize = i + 1; while j < n { let mut k: usize = j + 1; while k < n { if nums[i] < nums[j] && nums[k] < ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [minimum_sum]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter.st...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [minimum_sum]: function definitions module public import Aeneas public import Aegis.MinimumSum.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option lin...
import Aegis.MinimumSum.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval aegisCase ...
[ { "input": "[[1, 3, 1, 3, 1]]", "output": "5" }, { "input": "[[1, 2, 3, 4, 5]]", "output": "-1" }, { "input": "[[3, 1, 4, 2, 5]]", "output": "7" }, { "input": "[[5, 4, 3, 2, 1]]", "output": "-1" }, { "input": "[[1, 5, 3, 5, 1]]", "output": "5" }, { "in...
118
false
118
verified
10
10
1
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.MinimumSum.Code.Funs /-! # Specifications of `Aegis.MinimumSum.minimum_sum` LeetCode problem `minimum-sum-of-mountain-triplets-i`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.MinimumSum (minimum_sum) set_option autoImplicit false namespace A...
10
minimum-sum-of-mountain-triplets-ii
2,909
Medium
[ "Array" ]
You are given a 0-indexed array nums of integers. A triplet of indices (i, j, k) is a mountain if: i < j < k nums[i] < nums[j] and nums[k] < nums[j] Return the minimum possible sum of a mountain triplet of nums. If no such triplet exists, return -1.   Example 1: Input: nums = [8,6,1,5,3] Output: 9 Explanation: Tripl...
minimumSum(nums: list_int) -> int
pub fn minimum_sum(nums: &[i64]) -> i64
Aegis.MinimumSum.minimum_sum
pub fn minimum_sum(nums: &[i64]) -> i64 { let n = nums.len(); if n < 3 { return -1; } let mut suffix_min: Vec<i64> = Vec::new(); let mut i: usize = 0; while i < n { suffix_min.push(0); i += 1; } let mut current_min: i64 = nums[n - 1]; let mut idx: usize = n;...
-- 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": "[[100000000, 1, 100000000, 2, 100000000]]", "output": "100000003" }, { "input": "[[1, 3, 1, 3, 1]]", "output": "5" }, { "input": "[[1, 2, 3, 4, 5]]", "output": "-1" }, { "input": "[[5, 4, 3, 2, 1]]", "output": "-1" }, { "input": "[[8, 6, 1, 5, 3]]", ...
110
false
110
verified
10
10
1
2,359
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": 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-mountain-triplets-ii`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.MinimumSum abbrev I64Slice : Type := Slice Std.I64 ...
12
minimum-changes-to-make-k-semi-palindromes
2,911
Hard
[ "Two Pointers", "String", "Dynamic Programming" ]
Given a string s and an integer k, partition s into k substrings such that the letter changes needed to make each substring a semi-palindrome are minimized. Return the minimum number of letter changes required. A semi-palindrome is a special type of string that can be divided into palindromes based on a repeating patte...
minimumChanges(s: str, k: int) -> int
pub fn minimum_changes(s: &[u8], k: i64) -> i64
Aegis.MinimumChanges.minimum_changes
fn substring_cost(s: &[u8], l: usize, r: usize) -> i64 { let inf: i64 = 1000000000; let len = r - l + 1; if len <= 1 { return inf; } let mut best = inf; let mut d: usize = 1; while d < len { if len % d == 0 { let mut changes: i64 = 0; let mut q: usi...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [minimum_changes]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linte...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [minimum_changes]: function definitions module public import Aeneas public import Aegis.MinimumChanges.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.MinimumChanges.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := 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": "[\"aabbcc\", 3]", "output": "0" }, { "input": "[\"abccba\", 2]", "output": "2" }, { "input": "[\"aabbccdd\", 4]", "output": "0" }, { "input": "[\"abcabcabc\", 4]", "output": "4" }, { "input": "[\"aaaaaa\", 2]", "output": "0" }, { "input": "...
119
false
119
verified
10
10
1
9,044
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MinimumChanges.Code.Funs /-! # Specifications of `Aegis.MinimumChanges.minimum_changes` LeetCode problem `minimum-changes-to-make-k-semi-palindromes`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.MinimumChanges def IsLowerByte (b...
15
number-of-ways-to-reach-destination-in-the-grid
2,912
Hard
[ "Math", "Dynamic Programming", "Combinatorics" ]
You are given two integers n and m which represent the size of a 1-indexed grid. You are also given an integer k, a 1-indexed integer array source and a 1-indexed integer array dest, where source and dest are in the form [x, y] representing a cell on the given grid. You can move through the grid in the following way: ...
numberOfWays(n: int, m: int, k: int, source: list_int, dest: list_int) -> int
pub fn number_of_ways(n: i64, m: i64, k: i64, source: &[i64], dest: &[i64]) -> i64
Aegis.NumberOfWays.number_of_ways
pub fn number_of_ways(n: i64, m: i64, k: i64, source: &[i64], dest: &[i64]) -> i64 { let modulo: i64 = 1000000007; let sr = source[0]; let sc = source[1]; let dr = dest[0]; let dc = dest[1]; let mut row_size: Vec<i64> = Vec::new(); let mut rows: usize = 0; let mut src_rt: usize = 0; ...
-- 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": "[7, 3, 6, [2, 1], [5, 3]]", "output": "11742" }, { "input": "[5, 5, 4, [1, 1], [5, 5]]", "output": "158" }, { "input": "[3, 4, 3, [1, 2], [2, 3]]", "output": "9" }, { "input": "[10, 10, 5, [3, 3], [7, 7]]", "output": "18240" }, { "input": "[100, 100, 1...
104
false
104
verified
10
10
1
12,951
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.NumberOfWays.Code.Funs /-! # Specifications of `Aegis.NumberOfWays.number_of_ways` LeetCode problem `number-of-ways-to-reach-destination-in-the-grid`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.NumberOfWays def MOD : ℤ := 100000000...
12
subarrays-distinct-element-sum-of-squares-i
2,913
Easy
[ "Array", "Hash Table" ]
You are given a 0-indexed integer array nums. The distinct count of a subarray of nums is defined as: Let nums[i..j] be a subarray of nums consisting of all the indices from i to j such that 0 <= i <= j < nums.length. Then the number of distinct values in nums[i..j] is called the distinct count of nums[i..j]. Return ...
sumCounts(nums: list_int) -> int
pub fn sum_counts(nums: &[i64]) -> i64
Aegis.SumCounts.sum_counts
pub fn sum_counts(nums: &[i64]) -> i64 { let n = nums.len(); let mut total: i64 = 0; let mut i: usize = 0; while i < n { let mut j: usize = i; let mut distinct: i64 = 0; while j < n { let mut seen_before: bool = false; let mut k: usize = i; ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [sum_counts]: type definitions module public import Aeneas @[expose] public section 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 -- [sum_counts]: function definitions module public import Aeneas public import Aegis.SumCounts.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.SumCounts.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := 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": "[[5]]", "output": "1" }, { "input": "[[1, 2]]", "output": "6" }, { "input": "[[1, 1]]", "output": "3" }, { "input": "[[1, 2, 1]]", "output": "15" }, { "input": "[[10, 10, 10]]", "output": "6" }, ...
105
false
105
verified
10
10
1
730
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.SumCounts.Code.Funs /-! # Specifications of `Aegis.SumCounts.sum_counts` LeetCode problem `subarrays-distinct-element-sum-of-squares-i`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.SumCounts open scoped BigOperators namespace AegisSpec...
10
minimum-number-of-changes-to-make-binary-string-beautiful
2,914
Medium
[ "String" ]
You are given a 0-indexed binary string s having an even length. A string is beautiful if it's possible to partition it into one or more substrings such that: Each substring has an even length. Each substring contains only 1's or only 0's. You can change any character in s to 0 or 1. Return the minimum number of chan...
minChanges(s: str) -> int
pub fn min_changes(s: &[u8]) -> i64
Aegis.MinChanges.min_changes
pub fn min_changes(s: &[u8]) -> i64 { let n = s.len(); let mut ans: i64 = 0; let mut i: usize = 0; while i + 1 < n { if s[i] != s[i + 1] { ans += 1; } i += 2; } ans }
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [min_changes]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter.st...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [min_changes]: function definitions module public import Aeneas public import Aegis.MinChanges.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option lin...
import Aegis.MinChanges.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval aegisCase ...
[ { "input": "[\"1111\"]", "output": "0" }, { "input": "[\"101010\"]", "output": "3" }, { "input": "[\"11001100\"]", "output": "0" }, { "input": "[\"001100\"]", "output": "0" }, { "input": "[\"10\"]", "output": "1" }, { "input": "[\"110011\"]", "outp...
116
false
116
verified
10
10
1
467
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MinChanges.Code.Funs /-! # Specifications of `Aegis.MinChanges.min_changes` LeetCode problem `minimum-number-of-changes-to-make-binary-string-beautiful`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.MinChanges def bytes (s : Slic...
10
length-of-the-longest-subsequence-that-sums-to-target
2,915
Medium
[ "Array", "Dynamic Programming" ]
You are given a 0-indexed array of integers nums, and an integer target. Return the length of the longest subsequence of nums that sums up to target. If no such subsequence exists, return -1. A subsequence is an array that can be derived from another array by deleting some or no elements without changing the order of t...
lengthOfLongestSubsequence(nums: list_int, target: int) -> int
pub fn length_of_longest_subsequence(nums: &[i64], target: i64) -> i64
Aegis.LengthOfLongestSubsequence.length_of_longest_subsequence
pub fn length_of_longest_subsequence(nums: &[i64], target: i64) -> i64 { if target < 0 { return -1; } let t: usize = target as usize; let mut dp: Vec<i64> = Vec::new(); let mut i: usize = 0; while i <= t { dp.push(-1); i += 1; } dp[0] = 0; let n = nums.len...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [length_of_longest_subsequence]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false se...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [length_of_longest_subsequence]: function definitions module public import Aeneas public import Aegis.LengthOfLongestSubsequence.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linte...
import Aegis.LengthOfLongestSubsequence.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" ...
[ { "input": "[[1], 1]", "output": "1" }, { "input": "[[1000], 1000]", "output": "1" }, { "input": "[[999, 1], 1000]", "output": "2" }, { "input": "[[100, 200, 300], 100]", "output": "1" }, { "input": "[[1, 2, 3], 7]", "output": "-1" }, { "input": "[[1, ...
110
false
110
verified
10
10
1
977
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.LengthOfLongestSubsequence.Code.Funs /-! # Specifications of `Aegis.LengthOfLongestSubsequence.length_of_longest_subsequence` LeetCode problem `length-of-the-longest-subsequence-that-sums-to-target`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespa...
14
subarrays-distinct-element-sum-of-squares-ii
2,916
Hard
[ "Binary Indexed Tree", "Segment Tree", "Array", "Dynamic Programming" ]
You are given a 0-indexed integer array nums. The distinct count of a subarray of nums is defined as: Let nums[i..j] be a subarray of nums consisting of all the indices from i to j such that 0 <= i <= j < nums.length. Then the number of distinct values in nums[i..j] is called the distinct count of nums[i..j]. Return ...
sumCounts(nums: list_int) -> int
pub fn sum_counts(nums: &[i64]) -> i64
Aegis.SumCounts.sum_counts
const MOD: i64 = 1000000007; fn bit_add(bit: &mut Vec<i64>, n: usize, pos: usize, delta: i64) { let mut i = pos + 1; while i <= n { bit[i] = bit[i] + delta; let lsb = i & (!i + 1); i += lsb; } } fn bit_query(bit: &[i64], idx: usize) -> i64 { let mut s: i64 = 0; let mut i = ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [sum_counts]: type definitions module public import Aeneas @[expose] public section 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 -- [sum_counts]: function definitions module public import Aeneas public import Aegis.SumCounts.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.SumCounts.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := 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, 2]]", "output": "3" }, { "input": "[[1, 2, 1]]", "output": "15" }, { "input": "[[5, 4, 3, 2, 1]]", "output": "105" }, { "input": "[[100000, 99999, 99998, 99997, 99996]]", "output": "105" }, { "input...
113
false
113
verified_partial
10
4
1
15,452
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.SumCounts.Code.Funs /-! # Specifications of `Aegis.SumCounts.sum_counts` LeetCode problem `subarrays-distinct-element-sum-of-squares-ii`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.SumCounts open scoped BigOperators def M : ℤ := 1...
10
find-the-k-or-of-an-array
2,917
Easy
[ "Bit Manipulation", "Array" ]
You are given an integer array nums, and an integer k. Let's introduce K-or operation by extending the standard bitwise OR. In K-or, a bit position in the result is set to 1 if at least k numbers in nums have a 1 in that position. Return the K-or of nums.   Example 1: Input: nums = [7,12,9,8,9,15], k = 4 Output: 9 ...
findKOr(nums: list_int, k: int) -> int
pub fn find_k_or(nums: &[i64], k: i64) -> i64
Aegis.FindKOr.find_k_or
pub fn find_k_or(nums: &[i64], k: i64) -> i64 { let mut ans: i64 = 0; let mut bit: usize = 0; while bit < 32 { let mut count: i64 = 0; let mut i: usize = 0; while i < nums.len() { if ((nums[i] >> bit) & 1) == 1 { count += 1; } i +...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [find_k_or]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter.styl...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [find_k_or]: function definitions module public import Aeneas public import Aegis.FindKOr.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.u...
import Aegis.FindKOr.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := 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": "[[111111111, 222222222, 333333333, 444444444, 555555555], 2]", "output": "536870879" }, { "input": "[[4294967295, 4294967294, 4294967293, 4294967292, 4294967291], 3]", "output": "4294967295" }, { "input": "[[1000000000, 1000000000, 1000000000, 1000000000, 1000000000], 5]", ...
92
false
92
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.FindKOr.Code.Funs /-! # Specifications of `Aegis.FindKOr.find_k_or` LeetCode problem `find-the-k-or-of-an-array`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.FindKOr open Aegis.FindKOr def bit (x : ℤ) (b : ℕ) : ℤ := (x / (2 : ℤ) ^ ...
13
minimum-equal-sum-of-two-arrays-after-replacing-zeros
2,918
Medium
[ "Greedy", "Array" ]
You are given two arrays nums1 and nums2 consisting of positive integers. You have to replace all the 0's in both arrays with strictly positive integers such that the sum of elements of both arrays becomes equal. Return the minimum equal sum you can obtain, or -1 if it is impossible.   Example 1: Input: nums1 = [3,2,0...
minSum(nums1: list_int, nums2: list_int) -> int
pub fn min_sum(nums1: &[i64], nums2: &[i64]) -> i64
Aegis.MinSum.min_sum
pub fn min_sum(nums1: &[i64], nums2: &[i64]) -> i64 { let mut sum1: i64 = 0; let mut zeros1: i64 = 0; let mut i: usize = 0; while i < nums1.len() { sum1 += nums1[i]; if nums1[i] == 0 { zeros1 += 1; } i += 1; } let mut sum2: i64 = 0; let mut zeros2...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [min_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 -- [min_sum]: function definitions module public import Aeneas public import Aegis.MinSum.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unus...
import Aegis.MinSum.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := 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 "eva...
[ { "input": "[[1000000], [1000000]]", "output": "1000000" }, { "input": "[[1, 0], [0, 1]]", "output": "2" }, { "input": "[[2, 0, 2, 0], [1, 4]]", "output": "-1" }, { "input": "[[1, 2, 3], [3, 2, 1]]", "output": "6" }, { "input": "[[1, 0, 3], [2, 0, 2]]", "outpu...
104
false
104
verified
10
10
1
1,283
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MinSum.Code.Funs /-! # Specifications of `Aegis.MinSum.min_sum` LeetCode problem `minimum-equal-sum-of-two-arrays-after-replacing-zeros`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result ControlFlow Error namespace AegisSpec.MinSum def vals (s : Slice I64) ...
9
minimum-increment-operations-to-make-array-beautiful
2,919
Medium
[ "Array", "Dynamic Programming" ]
You are given a 0-indexed integer array nums having length n, and an integer k. You can perform the following increment operation any number of times (including zero): Choose an index i in the range [0, n - 1], and increase nums[i] by 1. An array is considered beautiful if, for any subarray with a size of 3 or more, ...
minIncrementOperations(nums: list_int, k: int) -> int
pub fn min_increment_operations(nums: &[i64], k: i64) -> i64
Aegis.MinIncrementOperations.min_increment_operations
pub fn min_increment_operations(nums: &[i64], k: i64) -> i64 { let n = nums.len(); if n < 3 { return 0; } let mut dp: Vec<i64> = Vec::new(); let mut i: usize = 0; while i < n { let mut cost: i64 = 0; if nums[i] < k { cost = k - nums[i]; } if...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [min_increment_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_opt...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [min_increment_operations]: function definitions module public import Aeneas public import Aegis.MinIncrementOperations.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCom...
import Aegis.MinIncrementOperations.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eva...
[ { "input": "[[1000000000, 1000000000, 1000000000], 1000000000]", "output": "0" }, { "input": "[[1, 1, 2], 1]", "output": "0" }, { "input": "[[5, 5, 5, 5], 3]", "output": "0" }, { "input": "[[0, 1, 3, 3], 5]", "output": "2" }, { "input": "[[5, 5, 5, 5, 5], 5]", ...
118
false
118
verified
10
10
1
5,187
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MinIncrementOperations.Code.Funs /-! # Specifications of `Aegis.MinIncrementOperations.min_increment_operations` LeetCode problem `minimum-increment-operations-to-make-array-beautiful`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.MinIncrementO...
15
maximum-points-after-collecting-coins-from-all-nodes
2,920
Hard
[ "Bit Manipulation", "Tree", "Depth-First Search", "Memoization", "Array", "Dynamic Programming" ]
There exists an undirected tree rooted at node 0 with n nodes labeled from 0 to n - 1. You are given a 2D integer array edges of length n - 1, where edges[i] = [ai, bi] indicates that there is an edge between nodes ai and bi in the tree. You are also given a 0-indexed array coins of size n where coins[i] indicates the ...
maximumPoints(edges: list_list_int, coins: list_int, k: int) -> int
pub fn maximum_points(edges: &[Vec<i64>], coins: &[i64], k: i64) -> i64
Aegis.MaximumPoints.maximum_points
pub fn maximum_points(edges: &[Vec<i64>], coins: &[i64], k: i64) -> i64 { let n = coins.len(); let mut head: Vec<i64> = Vec::new(); let mut i = 0; while i < n { head.push(-1); i += 1; } let mut to: Vec<i64> = Vec::new(); let mut next: Vec<i64> = Vec::new(); let mut ec: ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [maximum_points]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [maximum_points]: function definitions module public import Aeneas public import Aegis.MaximumPoints.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_opti...
import Aegis.MaximumPoints.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval aegisCa...
[ { "input": "[[[0, 1]], [10000, 1], 5000]", "output": "5000" }, { "input": "[[[0, 1], [0, 2]], [8, 4, 4], 0]", "output": "16" }, { "input": "[[[0, 1], [1, 2], [2, 3]], [10, 10, 3, 3], 5]", "output": "11" }, { "input": "[[[0, 1], [0, 2], [0, 3]], [1000, 2000, 3000, 4000], 500]"...
55
false
55
verified
10
10
1
11,862
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MaximumPoints.Code.Funs /-! # Specifications of `Aegis.MaximumPoints.maximum_points` LeetCode problem `maximum-points-after-collecting-coins-from-all-nodes`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.MaximumPoints namespace AegisSpec.Ma...
11
maximum-profitable-triplets-with-increasing-prices-ii
2,921
Hard
[ "Binary Indexed Tree", "Segment Tree", "Array" ]
Given the 0-indexed arrays prices and profits of length n. There are n items in an store where the ith item has a price of prices[i] and a profit of profits[i]. We have to pick three items with the following condition: prices[i] < prices[j] < prices[k] where i < j < k. If we pick items with indices i, j and k satisfy...
maxProfit(prices: list_int, profits: list_int) -> int
pub fn max_profit(prices: &[i64], profits: &[i64]) -> i64
Aegis.MaxProfit.max_profit
fn seg_query(tree: &[i64], size: usize, mut l: usize, mut r: usize) -> i64 { let mut ans: i64 = 0; l += size; r += size; while l < r { if l % 2 == 1 { if tree[l] > ans { ans = tree[l]; } l += 1; } if r % 2 == 1 { r ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [max_profit]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter.sty...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [max_profit]: function definitions module public import Aeneas public import Aegis.MaxProfit.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.MaxProfit.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval aegisCase "...
[ { "input": "[[1, 2, 3], [100000, 200000, 300000]]", "output": "600000" }, { "input": "[[100, 200, 300], [1000, 2000, 3000]]", "output": "6000" }, { "input": "[[100, 200, 300, 400], [1000, 2000, 3000, 4000]]", "output": "9000" }, { "input": "[[4, 3, 2, 1], [33, 20, 19, 87]]", ...
127
false
127
verified_partial
10
4
1
8,864
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MaxProfit.Code.Funs /-! # Specifications of `Aegis.MaxProfit.max_profit` LeetCode problem `maximum-profitable-triplets-with-increasing-prices-ii`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.MaxProfit namespace AegisSpec.MaxProfit def ...
7
find-champion-i
2,923
Easy
[ "Array", "Matrix" ]
There are n teams numbered from 0 to n - 1 in a tournament. Given a 0-indexed 2D boolean matrix grid of size n * n. For all i, j that 0 <= i, j <= n - 1 and i != j team i is stronger than team j if grid[i][j] == 1, otherwise, team j is stronger than team i. Team a will be the champion of the tournament if there is no t...
findChampion(grid: list_list_int) -> int
pub fn find_champion(grid: &[Vec<i64>]) -> i64
Aegis.FindChampion.find_champion
pub fn find_champion(grid: &[Vec<i64>]) -> i64 { let n = grid.len(); let mut i: usize = 0; while i < n { let row = &grid[i]; let mut is_champion: bool = true; let mut j: usize = 0; while j < n { if i != j { if row[j] != 1 { is...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [find_champion]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter....
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [find_champion]: function definitions module public import Aeneas public import Aegis.FindChampion.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.FindChampion.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := 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], [0, 0]]]", "output": "0" }, { "input": "[[[0, 0, 1], [1, 0, 1], [0, 0, 0]]]", "output": "1" }, { "input": "[[[0, 1, 1], [0, 0, 0], [0, 1, 0]]]", "output": "0" }, { "input": "[[[0, 1, 1], [0, 0, 1], [0, 0, 0]]]", "output": "0" }, { "input": "[...
12
false
12
verified
10
10
1
830
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.FindChampion.Code.Funs /-! # Specifications of `Aegis.FindChampion.find_champion` LeetCode problem `find-champion-i`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.FindChampion open Aegis.FindChampion def gridLen (grid : Slice (alloc...
11
find-champion-ii
2,924
Medium
[ "Graph" ]
There are n teams numbered from 0 to n - 1 in a tournament; each team is also a node in a DAG. You are given the integer n and a 0-indexed 2D integer array edges of length m representing the DAG, where edges[i] = [ui, vi] indicates that there is a directed edge from team ui to team vi in the graph. A directed edge from...
findChampion(n: int, edges: list_list_int) -> int
pub fn find_champion(n: i64, edges: &[Vec<i64>]) -> i64
Aegis.FindChampion.find_champion
pub fn find_champion(n: i64, edges: &[Vec<i64>]) -> i64 { let nn: usize = n as usize; let mut indegree: Vec<i64> = Vec::new(); let mut i: usize = 0; while i < nn { indegree.push(0); i += 1; } let mut e: usize = 0; while e < edges.len() { let to: usize = edges[e][1] ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [find_champion]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter....
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [find_champion]: function definitions module public import Aeneas public import Aegis.FindChampion.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.FindChampion.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := 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": "[2, []]", "output": "-1" }, { "input": "[1, []]", "output": "0" }, { "input": "[2, [[0, 1]]]", "output": "0" }, { "input": "[3, [[0, 1]]]", "output": "-1" }, { "input": "[3, [[0, 1], [1, 2]]]", "output": "0" }, { "input": "[4, [[0, 1], [2, ...
78
false
78
verified
10
10
1
990
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.FindChampion.Code.Funs /-! # Specifications of `Aegis.FindChampion.find_champion` LeetCode problem `find-champion-ii`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result set_option autoImplicit false namespace AegisSpec.FindChampion abbrev EdgeSlice : Type :...
9
maximum-balanced-subsequence-sum
2,926
Hard
[ "Binary Indexed Tree", "Segment Tree", "Array", "Binary Search", "Dynamic Programming" ]
You are given a 0-indexed integer array nums. A subsequence of nums having length k and consisting of indices i0 < i1 < ... < ik-1 is balanced if the following holds: nums[ij] - nums[ij-1] >= ij - ij-1, for every j in the range [1, k - 1]. A subsequence of nums having length 1 is considered balanced. Return an intege...
maxBalancedSubsequenceSum(nums: list_int) -> int
pub fn max_balanced_subsequence_sum(nums: &[i64]) -> i64
Aegis.MaxBalancedSubsequenceSum.max_balanced_subsequence_sum
pub fn max_balanced_subsequence_sum(nums: &[i64]) -> i64 { let n = nums.len(); if n == 0 { return 0; } let mut vals: Vec<i64> = Vec::new(); let mut i: usize = 0; while i < n { vals.push(nums[i] - (i as i64)); i += 1; } // Bottom-up merge sort on vals. let mu...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [max_balanced_subsequence_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...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [max_balanced_subsequence_sum]: function definitions module public import Aeneas public import Aegis.MaxBalancedSubsequenceSum.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter....
import Aegis.MaxBalancedSubsequenceSum.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #...
[ { "input": "[[-2, -1]]", "output": "-1" }, { "input": "[[3, 3, 5, 6]]", "output": "14" }, { "input": "[[5, -1, -3, 8]]", "output": "13" }, { "input": "[[1000000000, -1000000000, 1000000000, -1000000000, 1000000000]]", "output": "1000000000" }, { "input": "[[-1, 0,...
159
false
159
verified
10
10
1
6,296
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MaxBalancedSubsequenceSum.Code.Funs /-! # Specifications of `Aegis.MaxBalancedSubsequenceSum.max_balanced_subsequence_sum` LeetCode problem `maximum-balanced-subsequence-sum`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.MaxBalanced...
12
distribute-candies-among-children-iii
2,927
Hard
[ "Math", "Combinatorics" ]
You are given two positive integers n and limit. Return the total number of ways to distribute n candies among 3 children such that no child gets more than limit candies.   Example 1: Input: n = 5, limit = 2 Output: 3 Explanation: There are 3 ways to distribute 5 candies such that no child gets more than 2 candies: (1...
distributeCandies(n: int, limit: int) -> int
pub fn distribute_candies(n: i64, limit: i64) -> i64
Aegis.DistributeCandies.distribute_candies
fn ways3(m: i64) -> i64 { if m < 0 { 0 } else { (m + 2) * (m + 1) / 2 } } pub fn distribute_candies(n: i64, limit: i64) -> i64 { let a = ways3(n); let b = ways3(n - (limit + 1)); let c = ways3(n - 2 * (limit + 1)); let d = ways3(n - 3 * (limit + 1)); a - 3 * b + 3 * c -...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [distribute_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 li...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [distribute_candies]: function definitions module public import Aeneas public import Aegis.DistributeCandies.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false ...
import Aegis.DistributeCandies.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval aeg...
[ { "input": "[10, 5]", "output": "21" }, { "input": "[3, 3]", "output": "10" }, { "input": "[5, 2]", "output": "3" }, { "input": "[7, 3]", "output": "6" }, { "input": "[20, 10]", "output": "66" }, { "input": "[1, 1]", "output": "3" }, { "inp...
74
false
74
verified
10
10
1
1,213
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.DistributeCandies.Code.Funs /-! # Specifications of `Aegis.DistributeCandies.distribute_candies` LeetCode problem `distribute-candies-among-children-iii`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.DistributeCandies (distribute_candies) name...
12
distribute-candies-among-children-i
2,928
Easy
[ "Math", "Combinatorics", "Enumeration" ]
You are given two positive integers n and limit. Return the total number of ways to distribute n candies among 3 children such that no child gets more than limit candies.   Example 1: Input: n = 5, limit = 2 Output: 3 Explanation: There are 3 ways to distribute 5 candies such that no child gets more than 2 candies: (1...
distributeCandies(n: int, limit: int) -> int
pub fn distribute_candies(n: i64, limit: i64) -> i64
Aegis.DistributeCandies.distribute_candies
pub fn distribute_candies(n: i64, limit: i64) -> i64 { let mut ways: i64 = 0; let mut a: i64 = 0; while a <= limit && a <= n { let mut b: i64 = 0; while b <= limit && b <= n - a { let c: i64 = n - a - b; if c >= 0 && c <= limit { ways += 1; ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [distribute_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 li...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [distribute_candies]: function definitions module public import Aeneas public import Aegis.DistributeCandies.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false ...
import Aegis.DistributeCandies.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval aeg...
[ { "input": "[10, 5]", "output": "21" }, { "input": "[3, 3]", "output": "10" }, { "input": "[5, 2]", "output": "3" }, { "input": "[4, 2]", "output": "6" }, { "input": "[7, 3]", "output": "6" }, { "input": "[4, 4]", "output": "15" }, { "input...
71
false
71
verified
10
10
1
809
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.DistributeCandies.Code.Funs /-! # Specifications of `Aegis.DistributeCandies.distribute_candies` LeetCode problem `distribute-candies-among-children-i`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.DistributeCandies open Aegis.Distri...
11
distribute-candies-among-children-ii
2,929
Medium
[ "Math", "Combinatorics", "Enumeration" ]
You are given two positive integers n and limit. Return the total number of ways to distribute n candies among 3 children such that no child gets more than limit candies.   Example 1: Input: n = 5, limit = 2 Output: 3 Explanation: There are 3 ways to distribute 5 candies such that no child gets more than 2 candies: (1...
distributeCandies(n: int, limit: int) -> int
pub fn distribute_candies(n: i64, limit: i64) -> i64
Aegis.DistributeCandies.distribute_candies
fn choose2(m: i64) -> i64 { if m < 2 { 0 } else { m * (m - 1) / 2 } } pub fn distribute_candies(n: i64, limit: i64) -> i64 { let step = limit + 1; let total = choose2(n + 2); let over1 = choose2(n + 2 - step); let over2 = choose2(n + 2 - 2 * step); let over3 = choose2(n ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [distribute_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 li...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [distribute_candies]: function definitions module public import Aeneas public import Aegis.DistributeCandies.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false ...
import Aegis.DistributeCandies.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := 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": "[7, 7]", "output": "36" }, { "input": "[1000000, 1000000]", "output": "500001500001" }, { "input": "[10, 5]", "output": "21" }, { "input": "[3, 3]", "output": "10" }, { "input": "[5, 2]", "output": "3" }, { "input": "[100, 10]", "output...
90
false
90
verified
10
10
1
1,437
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.DistributeCandies.Code.Funs import Mathlib.Data.Int.Interval /-! # Specifications of `Aegis.DistributeCandies.distribute_candies` LeetCode problem `distribute-candies-among-children-ii`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.Di...
9
number-of-strings-which-can-be-rearranged-to-contain-substring
2,930
Medium
[ "Math", "Dynamic Programming", "Combinatorics" ]
You are given an integer n. A string s is called good if it contains only lowercase English characters and it is possible to rearrange the characters of s such that the new string contains "leet" as a substring. For example: The string "lteer" is good because we can rearrange it to form "leetr" . "letl" is not good be...
stringCount(n: int) -> int
pub fn string_count(n: i64) -> i64
Aegis.StringCount.string_count
pub fn string_count(n: i64) -> i64 { let md: i64 = 1000000007; let mut dp: Vec<i64> = Vec::new(); let mut ndp: Vec<i64> = Vec::new(); let mut i: usize = 0; while i < 12 { dp.push(0); ndp.push(0); i += 1; } dp[0] = 1; let mut step: i64 = 0; while step < n {...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [string_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 -- [string_count]: function definitions module public import Aeneas public import Aegis.StringCount.Code.Types public import Aegis.StringCount.Code.FunsExternal @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace fals...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [string_count]: external functions. -- This is a template file: rename it to "FunsExternal.lean" and fill the holes. module public import Aeneas public import Aegis.StringCount.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_o...
import Aegis.StringCount.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval aegisCase...
[ { "input": "[4]", "output": "12" }, { "input": "[1]", "output": "0" }, { "input": "[10]", "output": "83943898" }, { "input": "[5]", "output": "1460" }, { "input": "[3]", "output": "0" }, { "input": "[125]", "output": "558399309" }, { "input...
21
false
21
verified
10
10
1
6,550
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.StringCount.Code.Funs /-! # Specifications of `Aegis.StringCount.string_count` LeetCode problem `number-of-strings-which-can-be-rearranged-to-contain-substring`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.StringCount def MOD : ...
6
maximum-strong-pair-xor-i
2,932
Easy
[ "Bit Manipulation", "Trie", "Array", "Hash Table", "Sliding Window" ]
You are given a 0-indexed integer array nums. A pair of integers x and y is called a strong pair if it satisfies the condition: |x - y| <= min(x, y) You need to select two integers from nums such that they form a strong pair and their bitwise XOR is the maximum among all strong pairs in the array. Return the maximum ...
maximumStrongPairXor(nums: list_int) -> int
pub fn maximum_strong_pair_xor(nums: &[i64]) -> i64
Aegis.MaximumStrongPairXor.maximum_strong_pair_xor
pub fn maximum_strong_pair_xor(nums: &[i64]) -> i64 { let n = nums.len(); let mut best = 0i64; let mut i = 0usize; while i < n { let mut j = i; while j < n { let x = nums[i]; let y = nums[j]; let diff = if x >= y { x - y } else { y - x }; ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [maximum_strong_pair_xor]: type definitions module public import Aeneas @[expose] public 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 -- [maximum_strong_pair_xor]: function definitions module public import Aeneas public import Aegis.MaximumStrongPairXor.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashComman...
import Aegis.MaximumStrongPairXor.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := 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": "[[100]]", "output": "0" }, { "input": "[[10, 100]]", "output": "0" }, { "input": "[[1, 1, 1, 1]]", "output": "0" }, { "input": "[[5, 6, 25, 30]]", "output": "7" }, { "input": "[[15, 25, 35, 45, 55]]", "output": "58" }, { "input": "[[1, 2, 4...
125
false
125
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.MaximumStrongPairXor.Code.Funs /-! # Specifications of `Aegis.MaximumStrongPairXor.maximum_strong_pair_xor` LeetCode problem `maximum-strong-pair-xor-i`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.MaximumStrongPairXor namespace AegisSpec...
8
minimum-operations-to-maximize-last-elements-in-arrays
2,934
Medium
[ "Array", "Enumeration" ]
You are given two 0-indexed integer arrays, nums1 and nums2, both having length n. You are allowed to perform a series of operations (possibly none). In an operation, you select an index i in the range [0, n - 1] and swap the values of nums1[i] and nums2[i]. Your task is to find the minimum number of operations require...
minOperations(nums1: list_int, nums2: list_int) -> int
pub fn min_operations(nums1: &[i64], nums2: &[i64]) -> i64
Aegis.MinOperations.min_operations
pub fn min_operations(nums1: &[i64], nums2: &[i64]) -> i64 { let n = nums1.len(); if n == 0 { return 0; } let big = 1_000_000_000_i64; let mut ans = big; let last1 = nums1[n - 1]; let last2 = nums2[n - 1]; // Case 1: do not swap the last elements. let mut total = 0_i64; ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [min_operations]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [min_operations]: function definitions module public import Aeneas public import Aegis.MinOperations.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_opti...
import Aegis.MinOperations.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval aegisCa...
[ { "input": "[[9], [9]]", "output": "0" }, { "input": "[[1], [2]]", "output": "0" }, { "input": "[[1], [1]]", "output": "0" }, { "input": "[[1, 2], [2, 1]]", "output": "1" }, { "input": "[[3, 1], [2, 2]]", "output": "-1" }, { "input": "[[1000000000, 100...
130
false
130
verified
10
10
1
3,078
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MinOperations.Code.Funs /-! # Specifications of `Aegis.MinOperations.min_operations` LeetCode problem `minimum-operations-to-maximize-last-elements-in-arrays`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.MinOperations (min_operations) namespa...
10
separate-black-and-white-balls
2,938
Medium
[ "Greedy", "Two Pointers", "String" ]
There are n balls on a table, each ball has a color black or white. You are given a 0-indexed binary string s of length n, where 1 and 0 represent black and white balls, respectively. In each step, you can choose two adjacent balls and swap them. Return the minimum number of steps to group all the black balls to the ri...
minimumSteps(s: str) -> int
pub fn minimum_steps(s: &[u8]) -> i64
Aegis.MinimumSteps.minimum_steps
pub fn minimum_steps(s: &[u8]) -> i64 { let mut ones: i64 = 0; let mut steps: i64 = 0; let n = s.len(); let mut i: usize = 0; while i < n { if s[i] == b'1' { ones += 1; } else { steps += ones; } i += 1; } steps }
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [minimum_steps]: type definitions module public import Aeneas @[expose] public section 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_steps]: function definitions module public import Aeneas public import Aegis.MinimumSteps.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.MinimumSteps.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := 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": "[\"110100\"]", "output": "8" }, { "input": "[\"1111\"]", "output": "0" }, { "input": "[\"100100101\"]", "output": "9" }, { "input": "[\"110011\"]", "output": "4" }, { "input": "[\"00110011\"]", "output": "4" }, { "input": "[\"11110000\"]", ...
152
false
152
verified
10
10
1
335
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MinimumSteps.Code.Funs /-! # Specifications of `Aegis.MinimumSteps.minimum_steps` LeetCode problem `separate-black-and-white-balls`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result set_option autoImplicit false namespace AegisSpec.MinimumSteps def bytes (...
13
find-building-where-alice-and-bob-can-meet
2,940
Hard
[ "Stack", "Binary Indexed Tree", "Segment Tree", "Array", "Binary Search", "Monotonic Stack", "Heap (Priority Queue)" ]
You are given a 0-indexed array heights of positive integers, where heights[i] represents the height of the ith building. If a person is in building i, they can move to any other building j if and only if i < j and heights[i] < heights[j]. You are also given another array queries where queries[i] = [ai, bi]. On the ith...
leftmostBuildingQueries(heights: list_int, queries: list_list_int) -> list_int
pub fn leftmost_building_queries(heights: &[i64], queries: &[Vec<i64>]) -> Vec<i64>
Aegis.LeftmostBuildingQueries.leftmost_building_queries
fn descend(tree: &[i64], size: usize, mut node: usize, x: i64) -> i64 { while node < size { let left = node * 2; if tree[left] > x { node = left; } else { node = left + 1; } } (node - size) as i64 } fn first_greater(tree: &[i64], size: usize, n: usize...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [leftmost_building_queries]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_op...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [leftmost_building_queries]: function definitions module public import Aeneas public import Aegis.LeftmostBuildingQueries.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashC...
import Aegis.LeftmostBuildingQueries.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO 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": "[[10, 20, 30, 40, 50], [[0, 4], [1, 3], [2, 2], [3, 1]]]", "output": "[4, 3, 2, 3]" }, { "input": "[[5, 4, 3, 2, 1], [[0, 1], [1, 2], [2, 3], [3, 4]]]", "output": "[-1, -1, -1, -1]" }, { "input": "[[1, 3, 5, 7, 9], [[0, 2], [1, 3], [2, 4], [3, 4]]]", "output": "[2, 3, 4, ...
111
false
111
verified
10
10
2
12,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.LeftmostBuildingQueries.Code.Funs /-! # Specifications of `Aegis.LeftmostBuildingQueries.leftmost_building_queries` LeetCode problem `find-building-where-alice-and-bob-can-meet`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.LeftmostBuildingQuer...
15
maximum-gcd-sum-of-a-subarray
2,941
Hard
[ "Array", "Math", "Binary Search", "Number Theory" ]
You are given an array of integers nums and an integer k. The gcd-sum of an array a is calculated as follows: Let s be the sum of all the elements of a. Let g be the greatest common divisor of all the elements of a. The gcd-sum of a is equal to s * g. Return the maximum gcd-sum of a subarray of nums with at least k e...
maxGcdSum(nums: list_int, k: int) -> int
pub fn max_gcd_sum(nums: &[i64], k: i64) -> i64
Aegis.MaxGcdSum.max_gcd_sum
fn gcd_i64(mut a: i64, mut b: i64) -> i64 { while b != 0 { let r = a % b; a = b; b = r; } a } pub fn max_gcd_sum(nums: &[i64], k: i64) -> i64 { let n = nums.len(); let mut prefix: Vec<i64> = Vec::new(); prefix.push(0); let mut i: usize = 0; while i < n { ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [max_gcd_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 -- [max_gcd_sum]: function definitions module public import Aeneas public import Aegis.MaxGcdSum.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option lint...
import Aegis.MaxGcdSum.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := 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": "[[1000000, 1000000, 1000000], 2]", "output": "3000000000000" }, { "input": "[[1000000, 1000000, 1000000, 1000000], 3]", "output": "4000000000000" }, { "input": "[[7, 3, 9, 4], 1]", "output": "81" }, { "input": "[[1000000, 1000000, 1000000, 1000000], 4]", "outp...
97
false
97
verified
10
10
1
6,170
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MaxGcdSum.Code.Funs /-! # Specifications of `Aegis.MaxGcdSum.max_gcd_sum` LeetCode problem `maximum-gcd-sum-of-a-subarray`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.MaxGcdSum (max_gcd_sum) namespace AegisSpec.MaxGcdSum def vals (nums : Sl...
11
find-words-containing-character
2,942
Easy
[ "Array", "String" ]
You are given a 0-indexed array of strings words and a character x. Return an array of indices representing the words that contain the character x. Note that the returned array may be in any order.   Example 1: Input: words = ["leet","code"], x = "e" Output: [0,1] Explanation: "e" occurs in both words: "leet", and "co...
findWordsContaining(words: list_str, x: str) -> list_int
pub fn find_words_containing(words: &[Vec<u8>], x: &[u8]) -> Vec<i64>
Aegis.FindWordsContaining.find_words_containing
pub fn find_words_containing(words: &[Vec<u8>], x: &[u8]) -> Vec<i64> { let mut result: Vec<i64> = Vec::new(); if x.len() == 0 { return result; } let target: u8 = x[0]; let mut i: usize = 0; while i < words.len() { let word = &words[i]; let mut j: usize = 0; le...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [find_words_containing]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [find_words_containing]: function definitions module public import Aeneas public import Aegis.FindWordsContaining.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand f...
import Aegis.FindWordsContaining.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := 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": "[[\"single\"], \"s\"]", "output": "[0]" }, { "input": "[[\"ab\", \"cd\", \"ef\"], \"g\"]", "output": "[]" }, { "input": "[[\"unique\", \"characters\"], \"u\"]", "output": "[0]" }, { "input": "[[\"a\", \"b\", \"c\"], \"d\"]", "output": "[]" }, { "input"...
141
true
141
verified
10
10
1
556
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.FindWordsContaining.Code.Funs /-! # Specifications of `Aegis.FindWordsContaining.find_words_containing` LeetCode problem `find-words-containing-character`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.FindWordsContaining (find_words_containing)...
9
maximize-area-of-square-hole-in-grid
2,943
Medium
[ "Array", "Sorting" ]
You are given the two integers, n and m and two integer arrays, hBars and vBars. The grid has n + 2 horizontal and m + 2 vertical bars, creating 1 x 1 unit cells. The bars are indexed starting from 1. You can remove some of the bars in hBars from horizontal bars and some of the bars in vBars from vertical bars. Note th...
maximizeSquareHoleArea(n: int, m: int, hBars: list_int, vBars: list_int) -> int
pub fn maximize_square_hole_area(n: i64, m: i64, hBars: &[i64], vBars: &[i64]) -> i64
Aegis.MaximizeSquareHoleArea.maximize_square_hole_area
pub fn maximize_square_hole_area(n: i64, m: i64, hBars: &[i64], vBars: &[i64]) -> i64 { let h = max_consecutive_len(hBars); let v = max_consecutive_len(vBars); let side = if h < v { h + 1 } else { v + 1 }; side * side } fn max_consecutive_len(bars: &[i64]) -> i64 { let len = bars.len(); if len...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [maximize_square_hole_area]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_op...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [maximize_square_hole_area]: function definitions module public import Aeneas public import Aegis.MaximizeSquareHoleArea.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCo...
import Aegis.MaximizeSquareHoleArea.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eva...
[ { "input": "[1, 1, [], []]", "output": "4" }, { "input": "[1, 1, [2], [2]]", "output": "4" }, { "input": "[2, 1, [2, 3], [2]]", "output": "4" }, { "input": "[3, 2, [2, 3], [2]]", "output": "4" }, { "input": "[2, 3, [2, 3], [2, 4]]", "output": "4" }, { ...
100
false
100
verified
10
10
1
6,338
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MaximizeSquareHoleArea.Code.Funs /-! # Specifications of `Aegis.MaximizeSquareHoleArea.maximize_square_hole_area` LeetCode problem `maximize-area-of-square-hole-in-grid`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.MaximizeSquareHo...
13
minimum-number-of-coins-for-fruits
2,944
Medium
[ "Queue", "Array", "Dynamic Programming", "Monotonic Queue", "Heap (Priority Queue)" ]
You are given an 0-indexed integer array prices where prices[i] denotes the number of coins needed to purchase the (i + 1)th fruit. The fruit market has the following reward for each fruit: If you purchase the (i + 1)th fruit at prices[i] coins, you can get any number of the next i fruits for free. Note that even if ...
minimumCoins(prices: list_int) -> int
pub fn minimum_coins(prices: &[i64]) -> i64
Aegis.MinimumCoins.minimum_coins
pub fn minimum_coins(prices: &[i64]) -> i64 { let n = prices.len(); // dp[i] = minimum coins needed to acquire the first i fruits. let mut dp: Vec<i64> = Vec::new(); let mut k: usize = 0; while k <= n { dp.push(0); k += 1; } let mut i: usize = 1; while i <= n { ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [minimum_coins]: type definitions module public import Aeneas @[expose] public section 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_coins]: function definitions module public import Aeneas public import Aegis.MinimumCoins.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.MinimumCoins.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval aegisCas...
[ { "input": "[[1]]", "output": "1" }, { "input": "[[5]]", "output": "5" }, { "input": "[[3, 1, 2]]", "output": "4" }, { "input": "[[1, 10, 1, 1]]", "output": "2" }, { "input": "[[5, 5, 5, 5]]", "output": "10" }, { "input": "[[1, 2, 3, 4, 5]]", "outp...
122
false
122
verified
10
10
1
6,318
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MinimumCoins.Code.Funs /-! # Specifications of `Aegis.MinimumCoins.minimum_coins` LeetCode problem `minimum-number-of-coins-for-fruits`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.MinimumCoins def price (prices : Slice I64) (i : ℕ)...
10
matrix-similarity-after-cyclic-shifts
2,946
Easy
[ "Array", "Math", "Matrix", "Simulation" ]
You are given an m x n integer matrix mat and an integer k. The matrix rows are 0-indexed. The following proccess happens k times: Even-indexed rows (0, 2, 4, ...) are cyclically shifted to the left. Odd-indexed rows (1, 3, 5, ...) are cyclically shifted to the right. Return true if the final modified matrix afte...
areSimilar(mat: list_list_int, k: int) -> bool
pub fn are_similar(mat: &[Vec<i64>], k: i64) -> bool
Aegis.AreSimilar.are_similar
pub fn are_similar(mat: &[Vec<i64>], k: i64) -> bool { let m = mat.len(); let mut similar: bool = true; let mut i: usize = 0; while i < m { if similar { let row = &mat[i]; let n = row.len(); // Compute shift = k mod n using a simple loop (no nested returns)....
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [are_similar]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter.st...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [are_similar]: function definitions module public import Aeneas public import Aegis.AreSimilar.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.AreSimilar.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := 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]], 3]", "output": "true" }, { "input": "[[[5, 10], [15, 20]], 1]", "output": "false" }, { "input": "[[[3, 4, 5], [6, 7, 8]], 1]", "output": "false" }, { "input": "[[[3, 4, 5], [8, 7, 6]], 2]", "output": "false" }, { "input": "[[[1, 2], ...
99
false
99
verified
10
10
2
3,467
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.AreSimilar.Code.Funs /-! # Specifications of `Aegis.AreSimilar.are_similar` LeetCode problem `matrix-similarity-after-cyclic-shifts`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.AreSimilar namespace AegisSpec.AreSimilar def matAt (mat : Slic...
10
count-beautiful-substrings-i
2,947
Medium
[ "Hash Table", "Math", "String", "Enumeration", "Number Theory", "Prefix Sum" ]
You are given a string s and a positive integer k. Let vowels and consonants be the number of vowels and consonants in a string. A string is beautiful if: vowels == consonants. (vowels * consonants) % k == 0, in other terms the multiplication of vowels and consonants is divisible by k. Return the number of non-empty ...
beautifulSubstrings(s: str, k: int) -> int
pub fn beautiful_substrings(s: &[u8], k: i64) -> i64
Aegis.BeautifulSubstrings.beautiful_substrings
fn is_vowel(c: u8) -> bool { c == b'a' || c == b'e' || c == b'i' || c == b'o' || c == b'u' } pub fn beautiful_substrings(s: &[u8], k: i64) -> i64 { let n = s.len(); let mut ans: i64 = 0; let mut i: usize = 0; while i < n { let mut vowels: i64 = 0; let mut consonants: i64 = 0; ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [beautiful_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 -- [beautiful_substrings]: function definitions module public import Aeneas public import Aegis.BeautifulSubstrings.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand fa...
import Aegis.BeautifulSubstrings.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := 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": "[\"aeaeaeae\", 8]", "output": "0" }, { "input": "[\"bcdfghjklmnpqrstvwxyz\", 2]", "output": "0" }, { "input": "[\"aebcdfe\", 3]", "output": "0" }, { "input": "[\"\", 1]", "output": "0" }, { "input": "[\"baeyh\", 2]", "output": "2" }, { "inp...
90
false
90
verified
10
10
1
1,012
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.BeautifulSubstrings.Code.Funs /-! # Specifications of `Aegis.BeautifulSubstrings.beautiful_substrings` LeetCode problem `count-beautiful-substrings-i`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.BeautifulSubstrings namespace AegisSpec.Beauti...
10
make-lexicographically-smallest-array-by-swapping-elements
2,948
Medium
[ "Union Find", "Array", "Sorting" ]
You are given a 0-indexed array of positive integers nums and a positive integer limit. In one operation, you can choose any two indices i and j and swap nums[i] and nums[j] if |nums[i] - nums[j]| <= limit. Return the lexicographically smallest array that can be obtained by performing the operation any number of times....
lexicographicallySmallestArray(nums: list_int, limit: int) -> list_int
pub fn lexicographically_smallest_array(nums: &[i64], limit: i64) -> Vec<i64>
Aegis.LexicographicallySmallestArray.lexicographically_smallest_array
pub fn lexicographically_smallest_array(nums: &[i64], limit: i64) -> Vec<i64> { let n: usize = nums.len(); let mut ans: Vec<i64> = Vec::new(); if n == 0 { return ans; } let base: i64 = (n as i64) + 1; let mut keys: Vec<i64> = Vec::new(); let mut i: usize = 0; while i < n { ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [lexicographically_smallest_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...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [lexicographically_smallest_array]: function definitions module public import Aeneas public import Aegis.LexicographicallySmallestArray.Code.Types public import Aegis.LexicographicallySmallestArray.Code.FunsExternal @[expose] public section open Aeneas Aeneas.Std Re...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [lexicographically_smallest_array]: external functions. -- This is a template file: rename it to "FunsExternal.lean" and fill the holes. module public import Aeneas public import Aegis.LexicographicallySmallestArray.Code.Types @[expose] public section open Aeneas Ae...
import Aegis.LexicographicallySmallestArray.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b...
[ { "input": "[[10, 10, 10, 10, 10], 0]", "output": "[10, 10, 10, 10, 10]" }, { "input": "[[1, 1, 1, 1, 1], 1]", "output": "[1, 1, 1, 1, 1]" }, { "input": "[[9, 7, 5, 3, 1], 2]", "output": "[1, 3, 5, 7, 9]" }, { "input": "[[10, 20, 30, 40, 50], 5]", "output": "[10, 20, 30, ...
138
false
138
verified
10
10
1
4,540
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.LexicographicallySmallestArray.Code.Funs /-! # Specifications of `Aegis.LexicographicallySmallestArray.lexicographically_smallest_array` LeetCode problem `make-lexicographically-smallest-array-by-swapping-elements`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std R...
12
count-beautiful-substrings-ii
2,949
Hard
[ "Hash Table", "Math", "String", "Number Theory", "Prefix Sum" ]
You are given a string s and a positive integer k. Let vowels and consonants be the number of vowels and consonants in a string. A string is beautiful if: vowels == consonants. (vowels * consonants) % k == 0, in other terms the multiplication of vowels and consonants is divisible by k. Return the number of non-empty ...
beautifulSubstrings(s: str, k: int) -> int
pub fn beautiful_substrings(s: &[u8], k: i64) -> i64
Aegis.BeautifulSubstrings.beautiful_substrings
fn merge_sort(v: &[i64]) -> Vec<i64> { let n = v.len(); let mut src: Vec<i64> = Vec::new(); let mut i: usize = 0; while i < n { src.push(v[i]); i += 1; } if n <= 1 { return src; } let mut width: usize = 1; while width < n { let mut dst: Vec<i64> = Ve...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [beautiful_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 -- [beautiful_substrings]: function definitions module public import Aeneas public import Aegis.BeautifulSubstrings.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand fa...
import Aegis.BeautifulSubstrings.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := 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": "[\"aeiaaioaaaaeiiiiouuuooououuoiiiuuuuaeiou\", 10]", "output": "0" }, { "input": "[\"aabbcc\", 4]", "output": "1" }, { "input": "[\"zzzzz\", 1]", "output": "0" }, { "input": "[\"\", 1]", "output": "0" }, { "input": "[\"baeyh\", 2]", "output": "2" ...
91
false
91
verified
10
10
2
20,834
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.BeautifulSubstrings.Code.Funs /-! # Specifications of `Aegis.BeautifulSubstrings.beautiful_substrings` LeetCode problem `count-beautiful-substrings-ii`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.BeautifulSubstrings namespace AegisSpec.B...
15
number-of-divisible-substrings
2,950
Medium
[ "Hash Table", "String", "Counting", "Prefix Sum" ]
Each character of the English alphabet has been mapped to a digit as shown below. A string is divisible if the sum of the mapped values of its characters is divisible by its length. Given a string s, return the number of divisible substrings of s. A substring is a contiguous non-empty sequence of characters within a s...
countDivisibleSubstrings(word: str) -> int
pub fn count_divisible_substrings(word: &[u8]) -> i64
Aegis.CountDivisibleSubstrings.count_divisible_substrings
fn letter_value(b: u8) -> i64 { let p: i64 = (b as i64) - 97 + 1; if p <= 2 { 1 } else { 2 + (p - 3) / 3 } } pub fn count_divisible_substrings(word: &[u8]) -> i64 { let n: usize = word.len(); let mut ans: i64 = 0; let mut i: usize = 0; while i < n { let mut sum:...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [count_divisible_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_o...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [count_divisible_substrings]: function definitions module public import Aeneas public import Aegis.CountDivisibleSubstrings.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.has...
import Aegis.CountDivisibleSubstrings.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #e...
[ { "input": "[\"aaabbbccc\"]", "output": "27" }, { "input": "[\"aaa\"]", "output": "6" }, { "input": "[\"z\"]", "output": "1" }, { "input": "[\"bdh\"]", "output": "4" }, { "input": "[\"abcdefghij\"]", "output": "22" }, { "input": "[\"asdf\"]", "outp...
90
false
90
verified
10
10
1
3,596
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.CountDivisibleSubstrings.Code.Funs /-! # Specifications of `Aegis.CountDivisibleSubstrings.count_divisible_substrings` LeetCode problem `number-of-divisible-substrings`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.CountDivisibleSubstrings nam...
13
find-the-peaks
2,951
Easy
[ "Array", "Enumeration" ]
You are given a 0-indexed array mountain. Your task is to find all the peaks in the mountain array. Return an array that consists of indices of peaks in the given array in any order. Notes: A peak is defined as an element that is strictly greater than its neighboring elements. The first and last elements of the array ...
findPeaks(mountain: list_int) -> list_int
pub fn find_peaks(mountain: &[i64]) -> Vec<i64>
Aegis.FindPeaks.find_peaks
pub fn find_peaks(mountain: &[i64]) -> Vec<i64> { let mut peaks: Vec<i64> = Vec::new(); let n = mountain.len(); if n < 3 { return peaks; } let mut i: usize = 1; while i + 1 < n { if mountain[i] > mountain[i - 1] && mountain[i] > mountain[i + 1] { peaks.push(i as i64...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [find_peaks]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter.sty...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [find_peaks]: function definitions module public import Aeneas public import Aegis.FindPeaks.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.FindPeaks.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := 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, 4, 4]]", "output": "[]" }, { "input": "[[1, 2, 3, 4, 5]]", "output": "[]" }, { "input": "[[1, 3, 2, 1]]", "output": "[1]" }, { "input": "[[5, 4, 3, 2, 1]]", "output": "[]" }, { "input": "[[10, 20, 10, 20, 10]]", "output": "[1, 3]" }, { ...
115
true
115
verified
10
10
1
494
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.FindPeaks.Code.Funs /-! # Specifications of `Aegis.FindPeaks.find_peaks` LeetCode problem `find-the-peaks`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.FindPeaks def vals (l : List Std.I64) : List Int := l.map (fun x => x.val) ...
13
minimum-number-of-coins-to-be-added
2,952
Medium
[ "Greedy", "Array", "Sorting" ]
You are given a 0-indexed integer array coins, representing the values of the coins available, and an integer target. An integer x is obtainable if there exists a subsequence of coins that sums to x. Return the minimum number of coins of any value that need to be added to the array so that every integer in the range [1...
minimumAddedCoins(coins: list_int, target: int) -> int
pub fn minimum_added_coins(coins: &[i64], target: i64) -> i64
Aegis.MinimumAddedCoins.minimum_added_coins
pub fn minimum_added_coins(coins: &[i64], target: i64) -> i64 { let n: usize = (target as usize) + 1; let mut freq: Vec<i64> = Vec::new(); let mut i: usize = 0; while i < n { freq.push(0); i = i + 1; } let mut j: usize = 0; while j < coins.len() { let c: i64 = coins[...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [minimum_added_coins]: type definitions module public import Aeneas @[expose] public section 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_added_coins]: function definitions module public import Aeneas public import Aegis.MinimumAddedCoins.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false...
import Aegis.MinimumAddedCoins.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := 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, 6, 9], 15]", "output": "2" }, { "input": "[[2, 5, 10], 20]", "output": "2" }, { "input": "[[1, 4, 10], 19]", "output": "2" }, { "input": "[[1, 1, 1], 20]", "output": "3" }, { "input": "[[5, 10, 25], 100]", "output": "5" }, { "input": "...
110
false
110
verified
10
10
1
4,174
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MinimumAddedCoins.Code.Funs /-! # Specifications of `Aegis.MinimumAddedCoins.minimum_added_coins` LeetCode problem `minimum-number-of-coins-to-be-added`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.MinimumAddedCoins open Aegis.Minim...
13
count-complete-substrings
2,953
Hard
[ "Hash Table", "String", "Sliding Window" ]
You are given a string word and an integer k. A substring s of word is complete if: Each character in s occurs exactly k times. The difference between two adjacent characters is at most 2. That is, for any two adjacent characters c1 and c2 in s, the absolute difference in their positions in the alphabet is at most 2. ...
countCompleteSubstrings(word: str, k: int) -> int
pub fn count_complete_substrings(word: &[u8], k: i64) -> i64
Aegis.CountCompleteSubstrings.count_complete_substrings
pub fn count_complete_substrings(word: &[u8], k: i64) -> i64 { let n = word.len(); if n == 0 || k <= 0 { return 0; } let mut ans: i64 = 0; let mut i: usize = 0; while i < n { let mut j: usize = i; while j + 1 < n { let a = word[j] as i64; let b ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [count_complete_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_op...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [count_complete_substrings]: function definitions module public import Aeneas public import Aegis.CountCompleteSubstrings.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashC...
import Aegis.CountCompleteSubstrings.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO 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": "[\"xyzyxzyzxzyz\", 2]", "output": "2" }, { "input": "[\"mississippi\", 1]", "output": "11" }, { "input": "[\"zzzzzzzzz\", 9]", "output": "1" }, { "input": "[\"abcdefghijklmnopqrstuvwxyz\", 1]", "output": "351" }, { "input": "[\"ababababab\", 1]", "...
91
false
91
verified
10
10
1
7,394
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.CountCompleteSubstrings.Code.Funs /-! # Specifications of `Aegis.CountCompleteSubstrings.count_complete_substrings` LeetCode problem `count-complete-substrings`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result set_option autoImplicit false namespace Ae...
13
number-of-same-end-substrings
2,955
Medium
[ "Array", "Hash Table", "String", "Counting", "Prefix Sum" ]
You are given a 0-indexed string s, and a 2D array of integers queries, where queries[i] = [li, ri] indicates a substring of s starting from the index li and ending at the index ri (both inclusive), i.e. s[li..ri]. Return an array ans where ans[i] is the number of same-end substrings of queries[i]. A 0-indexed string t...
sameEndSubstringCount(s: str, queries: list_list_int) -> list_int
pub fn same_end_substring_count(s: &[u8], queries: &[Vec<i64>]) -> Vec<i64>
Aegis.SameEndSubstringCount.same_end_substring_count
pub fn same_end_substring_count(s: &[u8], queries: &[Vec<i64>]) -> Vec<i64> { let n = s.len(); // pref[c][i] = number of occurrences of byte ('a' + c) in s[0..i] let mut pref: Vec<Vec<i64>> = Vec::new(); let mut c: usize = 0; while c < 26 { let target: u8 = b'a' + (c as u8); let mut...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [same_end_substring_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_opt...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [same_end_substring_count]: function definitions module public import Aeneas public import Aegis.SameEndSubstringCount.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashComm...
import Aegis.SameEndSubstringCount.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := 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": "[\"abcd\", [[0, 3]]]", "output": "[4]" }, { "input": "[\"xyzxyz\", [[0, 2], [3, 5], [0, 5]]]", "output": "[3, 3, 9]" }, { "input": "[\"aabbcc\", [[0, 2], [3, 5], [0, 5]]]", "output": "[4, 4, 9]" }, { "input": "[\"xyz\", [[0, 0], [0, 1], [0, 2]]]", "output": "[...
62
false
62
verified
10
10
1
1,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.SameEndSubstringCount.Code.Funs /-! # Specifications of `Aegis.SameEndSubstringCount.same_end_substring_count` LeetCode problem `number-of-same-end-substrings`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.SameEndSubstringCount d...
13
find-common-elements-between-two-arrays
2,956
Easy
[ "Array", "Hash Table" ]
You are given two integer arrays nums1 and nums2 of sizes n and m, respectively. Calculate the following values: answer1 : the number of indices i such that nums1[i] exists in nums2. answer2 : the number of indices i such that nums2[i] exists in nums1. Return [answer1,answer2].   Example 1: Input: nums1 = [2,3,2], n...
findIntersectionValues(nums1: list_int, nums2: list_int) -> list_int
pub fn find_intersection_values(nums1: &[i64], nums2: &[i64]) -> Vec<i64>
Aegis.FindIntersectionValues.find_intersection_values
pub fn find_intersection_values(nums1: &[i64], nums2: &[i64]) -> Vec<i64> { let n = nums1.len(); let m = nums2.len(); let mut answer1: i64 = 0; let mut i: usize = 0; while i < n { let mut found: bool = false; let mut j: usize = 0; while j < m { if nums1[i] == num...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [find_intersection_values]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_opt...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [find_intersection_values]: function definitions module public import Aeneas public import Aegis.FindIntersectionValues.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCom...
import Aegis.FindIntersectionValues.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eva...
[ { "input": "[[1], [2]]", "output": "[0, 0]" }, { "input": "[[10], [10]]", "output": "[1, 1]" }, { "input": "[[1], [1]]", "output": "[1, 1]" }, { "input": "[[100], [100]]", "output": "[1, 1]" }, { "input": "[[50], [50]]", "output": "[1, 1]" }, { "input"...
102
false
102
verified
10
10
1
557
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.FindIntersectionValues.Code.Funs /-! # Specifications of `Aegis.FindIntersectionValues.find_intersection_values` LeetCode problem `find-common-elements-between-two-arrays`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.FindIntersectionValues na...
15
remove-adjacent-almost-equal-characters
2,957
Medium
[ "Greedy", "String", "Dynamic Programming" ]
You are given a 0-indexed string word. In one operation, you can pick any index i of word and change word[i] to any lowercase English letter. Return the minimum number of operations needed to remove all adjacent almost-equal characters from word. Two characters a and b are almost-equal if a == b or a and b are adjacent...
removeAlmostEqualCharacters(word: str) -> int
pub fn remove_almost_equal_characters(word: &[u8]) -> i64
Aegis.RemoveAlmostEqualCharacters.remove_almost_equal_characters
pub fn remove_almost_equal_characters(word: &[u8]) -> i64 { let n = word.len(); let mut ans: i64 = 0; let mut i: usize = 1; while i < n { let a = word[i - 1] as i64; let b = word[i] as i64; let mut diff = b - a; if diff < 0 { diff = -diff; } ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [remove_almost_equal_characters]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false s...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [remove_almost_equal_characters]: function definitions module public import Aeneas public import Aegis.RemoveAlmostEqualCharacters.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option lin...
import Aegis.RemoveAlmostEqualCharacters.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" ...
[ { "input": "[\"abddez\"]", "output": "2" }, { "input": "[\"qrstuvwpqrstuvwxyz\"]", "output": "8" }, { "input": "[\"abecidof\"]", "output": "1" }, { "input": "[\"zzz\"]", "output": "1" }, { "input": "[\"abacaba\"]", "output": "2" }, { "input": "[\"ababa...
95
false
95
verified
10
10
1
1,495
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.RemoveAlmostEqualCharacters.Code.Funs /-! # Specifications of `Aegis.RemoveAlmostEqualCharacters.remove_almost_equal_characters` LeetCode problem `remove-adjacent-almost-equal-characters`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpe...
17
length-of-longest-subarray-with-at-most-k-frequency
2,958
Medium
[ "Array", "Hash Table", "Sliding Window" ]
You are given an integer array nums and an integer k. The frequency of an element x is the number of times it occurs in an array. An array is called good if the frequency of each element in this array is less than or equal to k. Return the length of the longest good subarray of nums. A subarray is a contiguous non-empt...
maxSubarrayLength(nums: list_int, k: int) -> int
pub fn max_subarray_length(nums: &[i64], k: i64) -> i64
Aegis.MaxSubarrayLength.max_subarray_length
pub fn max_subarray_length(nums: &[i64], k: i64) -> i64 { let n = nums.len(); if n == 0 { return 0; } let sorted = sorted_copy(nums); let mut unique: Vec<i64> = Vec::new(); let mut i: usize = 0; while i < n { if i == 0 { unique.push(sorted[i]); } else { ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [max_subarray_length]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option l...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [max_subarray_length]: function definitions module public import Aeneas public import Aegis.MaxSubarrayLength.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false...
import Aegis.MaxSubarrayLength.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := 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": "1" }, { "input": "[[1000000000, 1000000000, 1000000000, 1000000000], 2]", "output": "2" }, { "input": "[[10, 20, 30, 40, 50], 2]", "output": "5" }, { "input": "[[10, 20, 30, 40, 50], 1]", "output": "5" }, { "input": "[[1, 1, 1, 1,...
107
false
107
verified
10
10
1
6,943
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MaxSubarrayLength.Code.Funs /-! # Specifications of `Aegis.MaxSubarrayLength.max_subarray_length` LeetCode problem `length-of-longest-subarray-with-at-most-k-frequency`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.MaxSubarrayLength (max_subarr...
17
number-of-possible-sets-of-closing-branches
2,959
Hard
[ "Bit Manipulation", "Graph", "Enumeration", "Shortest Path", "Heap (Priority Queue)" ]
There is a company with n branches across the country, some of which are connected by roads. Initially, all branches are reachable from each other by traveling some roads. The company has realized that they are spending an excessive amount of time traveling between their branches. As a result, they have decided to clos...
numberOfSets(n: int, maxDistance: int, roads: list_list_int) -> int
pub fn number_of_sets(n: i64, maxDistance: i64, roads: &[Vec<i64>]) -> i64
Aegis.NumberOfSets.number_of_sets
pub fn number_of_sets(n: i64, maxDistance: i64, roads: &[Vec<i64>]) -> i64 { let n_us = n as usize; let mut total: usize = 1; let mut p: usize = 0; while p < n_us { total = total * 2; p += 1; } let inf: i64 = 1000000000; let mut ans: i64 = 0; let mut mask: usize = 0; ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [number_of_sets]: type definitions module public import Aeneas @[expose] public section 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_sets]: function definitions module public import Aeneas public import Aegis.NumberOfSets.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.NumberOfSets.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval aegisCas...
[ { "input": "[1, 10, []]", "output": "2" }, { "input": "[2, 1, [[0, 1, 1]]]", "output": "4" }, { "input": "[3, 5, [[0, 1, 2], [1, 2, 10], [0, 2, 10]]]", "output": "5" }, { "input": "[4, 6, [[0, 1, 1], [1, 2, 1], [2, 3, 1], [3, 0, 1]]]", "output": "14" }, { "input":...
86
false
86
verified
10
10
1
7,493
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.NumberOfSets.Code.Funs /-! # Specifications of `Aegis.NumberOfSets.number_of_sets` LeetCode problem `number-of-possible-sets-of-closing-branches`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Classical namespace AegisSpec.NumberOfSets def roa...
12
count-tested-devices-after-test-operations
2,960
Easy
[ "Array", "Counting", "Simulation" ]
You are given a 0-indexed integer array batteryPercentages having length n, denoting the battery percentages of n 0-indexed devices. Your task is to test each device i in order from 0 to n - 1, by performing the following test operations: If batteryPercentages[i] is greater than 0: Increment the count of tested dev...
countTestedDevices(batteryPercentages: list_int) -> int
pub fn count_tested_devices(batteryPercentages: &[i64]) -> i64
Aegis.CountTestedDevices.count_tested_devices
pub fn count_tested_devices(batteryPercentages: &[i64]) -> i64 { let n = batteryPercentages.len(); let mut tested: i64 = 0; let mut i: usize = 0; while i < n { if batteryPercentages[i] > tested { tested += 1; } i += 1; } tested }
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [count_tested_devices]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [count_tested_devices]: function definitions module public import Aeneas public import Aegis.CountTestedDevices.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand fal...
import Aegis.CountTestedDevices.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval ae...
[ { "input": "[[1]]", "output": "1" }, { "input": "[[100]]", "output": "1" }, { "input": "[[0]]", "output": "0" }, { "input": "[[100, 100, 100]]", "output": "3" }, { "input": "[[0, 0, 0]]", "output": "0" }, { "input": "[[0, 1, 2]]", "output": "2" }...
107
false
107
verified
10
10
1
515
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.CountTestedDevices.Code.Funs /-! # Specifications of `Aegis.CountTestedDevices.count_tested_devices` LeetCode problem `count-tested-devices-after-test-operations`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.CountTestedDevices o...
12
count-subarrays-where-max-element-appears-at-least-k-times
2,962
Medium
[ "Array", "Sliding Window" ]
You are given an integer array nums and a positive integer k. Return the number of subarrays where the maximum element of nums appears at least k times in that subarray. A subarray is a contiguous sequence of elements within an array.   Example 1: Input: nums = [1,3,2,3,3], k = 2 Output: 6 Explanation: The subarrays t...
countSubarrays(nums: list_int, k: int) -> int
pub fn count_subarrays(nums: &[i64], k: i64) -> i64
Aegis.CountSubarrays.count_subarrays
pub fn count_subarrays(nums: &[i64], k: i64) -> i64 { let n = nums.len(); if n == 0 { return 0; } let mut max_val = nums[0]; let mut i = 1usize; while i < n { if nums[i] > max_val { max_val = nums[i]; } i += 1; } let mut positions: Vec<i64> =...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [count_subarrays]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linte...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [count_subarrays]: function definitions module public import Aeneas public import Aegis.CountSubarrays.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_op...
import Aegis.CountSubarrays.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval aegisC...
[ { "input": "[[1], 1]", "output": "1" }, { "input": "[[1, 4, 2, 1], 3]", "output": "0" }, { "input": "[[10, 10, 1, 10, 10], 4]", "output": "1" }, { "input": "[[1, 3, 2, 3, 3], 2]", "output": "6" }, { "input": "[[1, 2, 3, 4, 5], 1]", "output": "5" }, { "...
90
false
90
verified
10
10
1
6,066
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.CountSubarrays.Code.Funs /-! # Specifications of `Aegis.CountSubarrays.count_subarrays` LeetCode problem `count-subarrays-where-max-element-appears-at-least-k-times`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.CountSubarrays (count_subarray...
11
number-of-divisible-triplet-sums
2,964
Medium
[ "Array", "Hash Table" ]
Given a 0-indexed integer array nums and an integer d, return the number of triplets (i, j, k) such that i < j < k and (nums[i] + nums[j] + nums[k]) % d == 0.   Example 1: Input: nums = [3,3,4,7,8], d = 5 Output: 3 Explanation: The triplets which are divisible by 5 are: (0, 1, 2), (0, 2, 4), (1, 2, 4). It can be shown...
divisibleTripletCount(nums: list_int, d: int) -> int
pub fn divisible_triplet_count(nums: &[i64], d: i64) -> i64
Aegis.DivisibleTripletCount.divisible_triplet_count
pub fn divisible_triplet_count(nums: &[i64], d: i64) -> i64 { let n = nums.len(); let mut residues: Vec<i64> = Vec::new(); let mut counts: Vec<i64> = Vec::new(); let mut ans: i64 = 0; let mut k: usize = 0; while k < n { let rk = nums[k] % d; let target = (d - rk) % d; a...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [divisible_triplet_count]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_opti...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [divisible_triplet_count]: function definitions module public import Aeneas public import Aegis.DivisibleTripletCount.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashComma...
import Aegis.DivisibleTripletCount.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := 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": "[[3, 3, 3, 3], 3]", "output": "4" }, { "input": "[[3, 3, 3, 3], 6]", "output": "0" }, { "input": "[[999999999, 999999999, 999999999, 999999999], 9]", "output": "4" }, { "input": "[[1000000000, 1000000000, 1000000000, 1000000000], 1000000000]", "output": "4" ...
102
false
102
verified
10
10
1
8,803
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.DivisibleTripletCount.Code.Funs /-! # Specifications of `Aegis.DivisibleTripletCount.divisible_triplet_count` LeetCode problem `number-of-divisible-triplet-sums`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.DivisibleTripletCount (divisible_tri...
11
apply-operations-to-maximize-frequency-score
2,968
Hard
[ "Array", "Binary Search", "Prefix Sum", "Sorting", "Sliding Window" ]
You are given a 0-indexed integer array nums and an integer k. You can perform the following operation on the array at most k times: Choose any index i from the array and increase or decrease nums[i] by 1. The score of the final array is the frequency of the most frequent element in the array. Return the maximum scor...
maxFrequencyScore(nums: list_int, k: int) -> int
pub fn max_frequency_score(nums: &[i64], k: i64) -> i64
Aegis.MaxFrequencyScore.max_frequency_score
fn exists_window(a: &[i64], pref: &[i64], m: usize, k: i64) -> bool { let n = a.len(); if m == 0 { return true; } if m > n { return false; } let mut l: usize = 0; while l + m <= n { let r: usize = l + m - 1; let mid: usize = (l + r) / 2; let median: i...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [max_frequency_score]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option l...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [max_frequency_score]: function definitions module public import Aeneas public import Aegis.MaxFrequencyScore.Code.Types public import Aegis.MaxFrequencyScore.Code.FunsExternal @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linte...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [max_frequency_score]: external functions. -- This is a template file: rename it to "FunsExternal.lean" and fill the holes. module public import Aeneas public import Aegis.MaxFrequencyScore.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlo...
import Aegis.MaxFrequencyScore.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := 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": "[[1000000000], 1000000000000]", "output": "1" }, { "input": "[[1, 1000000000], 1000000000]", "output": "2" }, { "input": "[[1, 1000000000], 500000000]", "output": "1" }, { "input": "[[1, 1000000000], 1000000000]", "output": "2" }, { "input": "[[1000000...
96
false
96
verified
10
10
1
5,173
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MaxFrequencyScore.Code.Funs /-! # Specifications of `Aegis.MaxFrequencyScore.max_frequency_score` LeetCode problem `apply-operations-to-maximize-frequency-score`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.MaxFrequencyScore def...
13
minimum-number-of-coins-for-fruits-ii
2,969
Hard
[ "Queue", "Array", "Dynamic Programming", "Monotonic Queue", "Heap (Priority Queue)" ]
You are at a fruit market with different types of exotic fruits on display. You are given a 1-indexed array prices, where prices[i] denotes the number of coins needed to purchase the ith fruit. The fruit market has the following offer: If you purchase the ith fruit at prices[i] coins, you can get the next i fruits for...
minimumCoins(prices: list_int) -> int
pub fn minimum_coins(prices: &[i64]) -> i64
Aegis.MinimumCoins.minimum_coins
pub fn minimum_coins(prices: &[i64]) -> i64 { let n = prices.len(); let mut dp: Vec<i64> = Vec::new(); let mut k: usize = 0; while k < n + 2 { dp.push(0); k += 1; } let mut dq: Vec<usize> = Vec::new(); let mut k2: usize = 0; while k2 < n + 2 { dq.push(0); ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [minimum_coins]: type definitions module public import Aeneas @[expose] public section 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_coins]: function definitions module public import Aeneas public import Aegis.MinimumCoins.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.MinimumCoins.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval aegisCas...
[ { "input": "[[1]]", "output": "1" }, { "input": "[[1, 2]]", "output": "1" }, { "input": "[[1, 2, 3]]", "output": "3" }, { "input": "[[3, 1, 2]]", "output": "4" }, { "input": "[[1, 10, 1, 1]]", "output": "2" }, { "input": "[[5, 5, 5, 5, 5]]", "outpu...
119
false
119
verified
10
10
1
8,516
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MinimumCoins.Code.Funs /-! # Specifications of `Aegis.MinimumCoins.minimum_coins` LeetCode problem `minimum-number-of-coins-for-fruits-ii`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.MinimumCoins namespace AegisSpec.MinimumCoins def I...
12
count-the-number-of-incremovable-subarrays-i
2,970
Easy
[ "Array", "Two Pointers", "Binary Search", "Enumeration" ]
You are given a 0-indexed array of positive integers nums. A subarray of nums is called incremovable if nums becomes strictly increasing on removing the subarray. For example, the subarray [3, 4] is an incremovable subarray of [5, 3, 4, 6, 7] because removing this subarray changes the array [5, 3, 4, 6, 7] to [5, 6, 7]...
incremovableSubarrayCount(nums: list_int) -> int
pub fn incremovable_subarray_count(nums: &[i64]) -> i64
Aegis.IncremovableSubarrayCount.incremovable_subarray_count
pub fn incremovable_subarray_count(nums: &[i64]) -> i64 { let n = nums.len(); // pref[k] == 1 <=> nums[0..k] (first k elements) is strictly increasing. let mut pref: Vec<i64> = Vec::new(); pref.push(1); // pref[0] : empty prefix if n >= 1 { pref.push(1); // pref[1] : single element prefix...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [incremovable_subarray_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_...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [incremovable_subarray_count]: function definitions module public import Aeneas public import Aegis.IncremovableSubarrayCount.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.h...
import Aegis.IncremovableSubarrayCount.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #...
[ { "input": "[[1]]", "output": "1" }, { "input": "[[1, 2]]", "output": "3" }, { "input": "[[2, 1]]", "output": "3" }, { "input": "[[6, 5, 7, 8]]", "output": "7" }, { "input": "[[1, 2, 2, 3]]", "output": "8" }, { "input": "[[1, 2, 3, 4]]", "output": ...
123
false
123
verified
10
10
2
14,523
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.IncremovableSubarrayCount.Code.Funs /-! # Specifications of `Aegis.IncremovableSubarrayCount.incremovable_subarray_count` LeetCode problem `count-the-number-of-incremovable-subarrays-i`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.In...
11
find-polygon-with-the-largest-perimeter
2,971
Medium
[ "Greedy", "Array", "Prefix Sum", "Sorting" ]
You are given an array of positive integers nums of length n. A polygon is a closed plane figure that has at least 3 sides. The longest side of a polygon is smaller than the sum of its other sides. Conversely, if you have k (k >= 3) positive real numbers a1, a2, a3, ..., ak where a1 <= a2 <= a3 <= ... <= ak and a1 + a2...
largestPerimeter(nums: list_int) -> int
pub fn largest_perimeter(nums: &[i64]) -> i64
Aegis.LargestPerimeter.largest_perimeter
pub fn largest_perimeter(nums: &[i64]) -> i64 { let n = nums.len(); let mut v: Vec<i64> = Vec::new(); let mut i0 = 0; while i0 < n { v.push(nums[i0]); i0 += 1; } let mut width: usize = 1; while width < n { let mut out: Vec<i64> = Vec::new(); let mut start: us...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [largest_perimeter]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option lin...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [largest_perimeter]: function definitions module public import Aeneas public import Aegis.LargestPerimeter.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.LargestPerimeter.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := 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": "[[5, 5, 50]]", "output": "-1" }, { "input": "[[5, 5, 5]]", "output": "15" }, { "input": "[[1000000000, 1000000000, 1000000000]]", "output": "3000000000" }, { "input": "[[1000000000, 1000000000, 1000000000]]", "output": "3000000000" }, { "input": "[[100...
95
false
95
verified
10
10
1
3,485
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.LargestPerimeter.Code.Funs /-! # Specifications of `Aegis.LargestPerimeter.largest_perimeter` LeetCode problem `find-polygon-with-the-largest-perimeter`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.LargestPerimeter open Aegis.Larges...
11
count-the-number-of-incremovable-subarrays-ii
2,972
Hard
[ "Array", "Two Pointers", "Binary Search" ]
You are given a 0-indexed array of positive integers nums. A subarray of nums is called incremovable if nums becomes strictly increasing on removing the subarray. For example, the subarray [3, 4] is an incremovable subarray of [5, 3, 4, 6, 7] because removing this subarray changes the array [5, 3, 4, 6, 7] to [5, 6, 7]...
incremovableSubarrayCount(nums: list_int) -> int
pub fn incremovable_subarray_count(nums: &[i64]) -> i64
Aegis.IncremovableSubarrayCount.incremovable_subarray_count
pub fn incremovable_subarray_count(nums: &[i64]) -> i64 { let n = nums.len(); if n == 0 { return 0; } let mut p: usize = 1; while p < n && nums[p - 1] < nums[p] { p += 1; } let n_i = n as i64; if p == n { return n_i * (n_i + 1) / 2; } let mut s: usize ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [incremovable_subarray_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_...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [incremovable_subarray_count]: function definitions module public import Aeneas public import Aegis.IncremovableSubarrayCount.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.h...
import Aegis.IncremovableSubarrayCount.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #...
[ { "input": "[[1]]", "output": "1" }, { "input": "[[2, 1]]", "output": "3" }, { "input": "[[1, 2]]", "output": "3" }, { "input": "[[1, 3, 2]]", "output": "5" }, { "input": "[[6, 5, 7, 8]]", "output": "7" }, { "input": "[[1, 2, 2, 3]]", "output": "8"...
153
false
153
verified
10
10
1
8,386
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.IncremovableSubarrayCount.Code.Funs /-! # Specifications of `Aegis.IncremovableSubarrayCount.incremovable_subarray_count` LeetCode problem `count-the-number-of-incremovable-subarrays-ii`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.I...
14
find-number-of-coins-to-place-in-tree-nodes
2,973
Hard
[ "Tree", "Depth-First Search", "Dynamic Programming", "Sorting", "Heap (Priority Queue)" ]
You are given an undirected tree with n nodes labeled from 0 to n - 1, and rooted at node 0. You are given a 2D integer array edges of length n - 1, where edges[i] = [ai, bi] indicates that there is an edge between nodes ai and bi in the tree. You are also given a 0-indexed integer array cost of length n, where cost[i]...
placedCoins(edges: list_list_int, cost: list_int) -> list_int
pub fn placed_coins(edges: &[Vec<i64>], cost: &[i64]) -> Vec<i64>
Aegis.PlacedCoins.placed_coins
pub fn placed_coins(edges: &[Vec<i64>], cost: &[i64]) -> Vec<i64> { let n = cost.len(); let mut adj: Vec<Vec<i64>> = Vec::new(); let mut i: usize = 0; while i < n { let row: Vec<i64> = Vec::new(); adj.push(row); i += 1; } let m = edges.len(); let mut e: usize = 0; ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [placed_coins]: type definitions module public import Aeneas @[expose] public section 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 -- [placed_coins]: function definitions module public import Aeneas public import Aegis.PlacedCoins.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.PlacedCoins.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval aegisCase...
[ { "input": "[[[0, 1], [0, 2]], [1, 2, -2]]", "output": "[0, 1, 1]" }, { "input": "[[[0, 1], [0, 2], [0, 3]], [1, -2, -3, -4]]", "output": "[12, 1, 1, 1]" }, { "input": "[[[0, 1], [0, 2], [0, 3], [0, 4], [0, 5]], [1, 2, 3, 4, 5, 6]]", "output": "[120, 1, 1, 1, 1, 1]" }, { "inp...
47
false
47
verified
10
10
1
11,632
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.PlacedCoins.Code.Funs /-! # Specifications of `Aegis.PlacedCoins.placed_coins` LeetCode problem `find-number-of-coins-to-place-in-tree-nodes`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.PlacedCoins open Aegis.PlacedCoins (placed_co...
9
minimum-number-game
2,974
Easy
[ "Array", "Sorting", "Simulation", "Heap (Priority Queue)" ]
You are given a 0-indexed integer array nums of even length and there is also an empty array arr. Alice and Bob decided to play a game where in every round Alice and Bob will do one move. The rules of the game are as follows: Every round, first Alice will remove the minimum element from nums, and then Bob does the sam...
numberGame(nums: list_int) -> list_int
pub fn number_game(nums: &[i64]) -> Vec<i64>
Aegis.NumberGame.number_game
pub fn number_game(nums: &[i64]) -> Vec<i64> { let n = nums.len(); let mut sorted: Vec<i64> = Vec::new(); let mut i = 0; while i < n { sorted.push(nums[i]); i += 1; } let mut i = 1; while i < n { let key = sorted[i]; let mut j = i; while j > 0 && sor...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [number_game]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter.st...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [number_game]: function definitions module public import Aeneas public import Aegis.NumberGame.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.NumberGame.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := 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, 5]]", "output": "[5, 2]" }, { "input": "[[6, 2, 8, 4]]", "output": "[4, 2, 8, 6]" }, { "input": "[[5, 4, 2, 3]]", "output": "[3, 2, 5, 4]" }, { "input": "[[100, 1, 99, 2]]", "output": "[2, 1, 100, 99]" }, { "input": "[[6, 4, 3, 2]]", "output":...
91
false
91
verified
10
10
1
699
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.NumberGame.Code.Funs /-! # Specifications of `Aegis.NumberGame.number_game` LeetCode problem `minimum-number-game`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.NumberGame def vals (l : List Std.I64) : List Int := l.map (fun x =>...
12
maximum-square-area-by-removing-fences-from-a-field
2,975
Medium
[ "Array", "Hash Table", "Enumeration" ]
There is a large (m - 1) x (n - 1) rectangular field with corners at (1, 1) and (m, n) containing some horizontal and vertical fences given in arrays hFences and vFences respectively. Horizontal fences are from the coordinates (hFences[i], 1) to (hFences[i], n) and vertical fences are from the coordinates (1, vFences[i...
maximizeSquareArea(m: int, n: int, hFences: list_int, vFences: list_int) -> int
pub fn maximize_square_area(m: i64, n: i64, hFences: &[i64], vFences: &[i64]) -> i64
Aegis.MaximizeSquareArea.maximize_square_area
fn collect_distances(bound: i64, fences: &[i64]) -> Vec<i64> { let mut positions: Vec<i64> = Vec::new(); positions.push(1); let mut k = 0; while k < fences.len() { positions.push(fences[k]); k += 1; } positions.push(bound); let len = positions.len(); let mut distances:...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [maximize_square_area]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [maximize_square_area]: function definitions module public import Aeneas public import Aegis.MaximizeSquareArea.Code.Types public import Aegis.MaximizeSquareArea.Code.FunsExternal @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option li...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [maximize_square_area]: external functions. -- This is a template file: rename it to "FunsExternal.lean" and fill the holes. module public import Aeneas public import Aegis.MaximizeSquareArea.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlF...
import Aegis.MaximizeSquareArea.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := 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": "[9, 9, [5], [5]]", "output": "64" }, { "input": "[6, 7, [2], [4]]", "output": "-1" }, { "input": "[500000000, 500000000, [250000000], [250000000]]", "output": "250000022" }, { "input": "[1000000000, 1000000000, [500000000], [500000000]]", "output": "64" }, ...
101
false
101
verified
10
10
1
3,305
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MaximizeSquareArea.Code.Funs /-! # Specifications of `Aegis.MaximizeSquareArea.maximize_square_area` LeetCode problem `maximum-square-area-by-removing-fences-from-a-field`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.MaximizeSquare...
9
minimum-cost-to-convert-string-ii
2,977
Hard
[ "Graph", "Trie", "Array", "String", "Dynamic Programming", "Shortest Path" ]
You are given two 0-indexed strings source and target, both of length n and consisting of lowercase English characters. You are also given two 0-indexed string arrays original and changed, and an integer array cost, where cost[i] represents the cost of converting the string original[i] to the string changed[i]. You sta...
minimumCost(source: str, target: str, original: list_str, changed: list_str, cost: list_int) -> int
pub fn minimum_cost(source: &[u8], target: &[u8], original: &[Vec<u8>], changed: &[Vec<u8>], cost: &[i64]) -> i64
Aegis.MinimumCost.minimum_cost
fn vec_u8_eq(a: &Vec<u8>, b: &Vec<u8>) -> bool { if a.len() != b.len() { return false; } let mut i: usize = 0; while i < a.len() { if a[i] != b[i] { return false; } i += 1; } true } pub fn minimum_cost( source: &[u8], target: &[u8], origin...
-- 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": "[\"abracadabra\", \"abracabadaa\", [\"ra\"], [\"aa\"], [3]]", "output": "-1" }, { "input": "[\"abcdefgabcdefgabcdefg\", \"bcdefgbcdefgbcdefga\", [\"abcdefg\"], [\"bcdefga\"], [500]]", "output": "-1" }, { "input": "[\"mississippi\", \"mississippa\", [\"ippi\"], [\"appa\"], [5]...
91
false
91
verified
10
10
1
17,502
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MinimumCost.Code.Funs /-! # Specifications of `Aegis.MinimumCost.minimum_cost` LeetCode problem `minimum-cost-to-convert-string-ii`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.MinimumCost namespace AegisSpec.MinimumCost def sBytes (s : Slic...
13
most-expensive-item-that-can-not-be-bought
2,979
Medium
[ "Math", "Dynamic Programming", "Number Theory" ]
You are given two distinct prime numbers primeOne and primeTwo. Alice and Bob are visiting a market. The market has an infinite number of items, for any positive integer x there exists an item whose price is x. Alice wants to buy some items from the market to gift to Bob. She has an infinite number of coins in the deno...
mostExpensiveItem(primeOne: int, primeTwo: int) -> int
pub fn most_expensive_item(primeOne: i64, primeTwo: i64) -> i64
Aegis.MostExpensiveItem.most_expensive_item
pub fn most_expensive_item(primeOne: i64, primeTwo: i64) -> i64 { primeOne * primeTwo - primeOne - primeTwo }
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [most_expensive_item]: type definitions module public import Aeneas @[expose] public section 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 -- [most_expensive_item]: function definitions module public import Aeneas public import Aegis.MostExpensiveItem.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false...
import Aegis.MostExpensiveItem.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := 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": "[19, 23]", "output": "395" }, { "input": "[5, 7]", "output": "23" }, { "input": "[2, 5]", "output": "3" }, { "input": "[11, 17]", "output": "159" }, { "input": "[7, 13]", "output": "71" }, { "input": "[13, 17]", "output": "191" }, {...
80
false
80
verified
10
10
1
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.MostExpensiveItem.Code.Funs /-! # Specifications of `Aegis.MostExpensiveItem.most_expensive_item` LeetCode problem `most-expensive-item-that-can-not-be-bought`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.MostExpensiveItem /-- T...
10
check-if-bitwise-or-has-trailing-zeros
2,980
Easy
[ "Bit Manipulation", "Array" ]
You are given an array of positive integers nums. You have to check if it is possible to select two or more elements in the array such that the bitwise OR of the selected elements has at least one trailing zero in its binary representation. For example, the binary representation of 5, which is "101", does not have any ...
hasTrailingZeros(nums: list_int) -> bool
pub fn has_trailing_zeros(nums: &[i64]) -> bool
Aegis.HasTrailingZeros.has_trailing_zeros
pub fn has_trailing_zeros(nums: &[i64]) -> bool { let mut even_count: i64 = 0; let mut i: usize = 0; while i < nums.len() { if nums[i] % 2 == 0 { even_count += 1; } i += 1; } even_count >= 2 }
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [has_trailing_zeros]: type definitions module public import Aeneas @[expose] public section 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 -- [has_trailing_zeros]: function definitions module public import Aeneas public import Aegis.HasTrailingZeros.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.HasTrailingZeros.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval aegi...
[ { "input": "[[3, 5]]", "output": "false" }, { "input": "[[1, 2]]", "output": "false" }, { "input": "[[8, 16, 32]]", "output": "true" }, { "input": "[[1, 1, 1, 1]]", "output": "false" }, { "input": "[[5, 7, 9, 11]]", "output": "false" }, { "input": "[[7...
119
false
119
verified
10
10
1
506
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.HasTrailingZeros.Code.Funs /-! # Specifications of `Aegis.HasTrailingZeros.has_trailing_zeros` LeetCode problem `check-if-bitwise-or-has-trailing-zeros`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.HasTrailingZeros def item (num...
12
find-longest-special-substring-that-occurs-thrice-i
2,981
Medium
[ "Hash Table", "String", "Binary Search", "Counting", "Sliding Window" ]
You are given a string s that consists of lowercase English letters. A string is called special if it is made up of only a single character. For example, the string "abc" is not special, whereas the strings "ddd", "zz", and "f" are special. Return the length of the longest special substring of s which occurs at least t...
maximumLength(s: str) -> int
pub fn maximum_length(s: &[u8]) -> i64
Aegis.MaximumLength.maximum_length
pub fn maximum_length(s: &[u8]) -> i64 { let n = s.len(); let mut best: i64 = -1; let mut c: u8 = b'a'; while c <= b'z' { let mut k: usize = 1; while k <= n { let mut total: i64 = 0; let mut i: usize = 0; while i < n { if s[i] == c { ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [maximum_length]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [maximum_length]: function definitions module public import Aeneas public import Aegis.MaximumLength.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_opti...
import Aegis.MaximumLength.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval aegisCa...
[ { "input": "[\"zzzzzzzzz\"]", "output": "7" }, { "input": "[\"abcabcabc\"]", "output": "1" }, { "input": "[\"aaabbbccc\"]", "output": "1" }, { "input": "[\"aabbcc\"]", "output": "-1" }, { "input": "[\"aaaabbbbcccc\"]", "output": "2" }, { "input": "[\"a...
95
false
95
verified
10
10
1
1,560
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MaximumLength.Code.Funs /-! # Specifications of `Aegis.MaximumLength.maximum_length` LeetCode problem `find-longest-special-substring-that-occurs-thrice-i`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.MaximumLength def byte (s : Sli...
12
find-longest-special-substring-that-occurs-thrice-ii
2,982
Medium
[ "Hash Table", "String", "Binary Search", "Counting", "Sliding Window" ]
You are given a string s that consists of lowercase English letters. A string is called special if it is made up of only a single character. For example, the string "abc" is not special, whereas the strings "ddd", "zz", and "f" are special. Return the length of the longest special substring of s which occurs at least t...
maximumLength(s: str) -> int
pub fn maximum_length(s: &[u8]) -> i64
Aegis.MaximumLength.maximum_length
pub fn maximum_length(s: &[u8]) -> i64 { let n: usize = s.len(); let mut top1: Vec<i64> = Vec::new(); let mut top2: Vec<i64> = Vec::new(); let mut top3: Vec<i64> = Vec::new(); let mut i: usize = 0; while i < 26 { top1.push(0); top2.push(0); top3.push(0); i += 1;...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [maximum_length]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [maximum_length]: function definitions module public import Aeneas public import Aegis.MaximumLength.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_opti...
import Aegis.MaximumLength.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval aegisCa...
[ { "input": "[\"zzzzzzzzz\"]", "output": "7" }, { "input": "[\"aaabbbccc\"]", "output": "1" }, { "input": "[\"aabbbcccaaa\"]", "output": "2" }, { "input": "[\"abcdef\"]", "output": "-1" }, { "input": "[\"abacabadabacaba\"]", "output": "1" }, { "input": ...
22
false
22
verified
10
10
1
8,283
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MaximumLength.Code.Funs /-! # Specifications of `Aegis.MaximumLength.maximum_length` LeetCode problem `find-longest-special-substring-that-occurs-thrice-ii`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.MaximumLength open Aegis.M...
14
number-of-self-divisible-permutations
2,992
Medium
[ "Bit Manipulation", "Array", "Dynamic Programming", "Backtracking", "Bitmask" ]
Given an integer n, return the number of permutations of the 1-indexed array nums = [1, 2, ..., n], such that it's self-divisible. A 1-indexed array a of length n is self-divisible if for every 1 <= i <= n, gcd(a[i], i) == 1. A permutation of an array is a rearrangement of the elements of that array, for example here a...
selfDivisiblePermutationCount(n: int) -> int
pub fn self_divisible_permutation_count(n: i64) -> i64
Aegis.SelfDivisiblePermutationCount.self_divisible_permutation_count
fn gcd(mut a: i64, mut b: i64) -> i64 { while b != 0 { let t = b; b = a % b; a = t; } a } pub fn self_divisible_permutation_count(n: i64) -> i64 { let n_usize = n as usize; let total = 1usize << n_usize; let mut dp: Vec<i64> = Vec::new(); let mut i: usize = 0; w...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [self_divisible_permutation_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...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [self_divisible_permutation_count]: function definitions module public import Aeneas public import Aegis.SelfDivisiblePermutationCount.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option...
import Aegis.SelfDivisiblePermutationCount.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}...
[ { "input": "[8]", "output": "324" }, { "input": "[3]", "output": "3" }, { "input": "[11]", "output": "129744" }, { "input": "[4]", "output": "4" }, { "input": "[12]", "output": "63504" }, { "input": "[9]", "output": "3600" }, { "input": "[6...
12
false
12
verified
10
10
1
1,864
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.SelfDivisiblePermutationCount.Code.Funs /-! # Specifications of `Aegis.SelfDivisiblePermutationCount.self_divisible_permutation_count` LeetCode problem `number-of-self-divisible-permutations`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisS...
6
smallest-missing-integer-greater-than-sequential-prefix-sum
2,996
Easy
[ "Array", "Hash Table", "Sorting" ]
You are given a 0-indexed array of integers nums. A prefix nums[0..i] is sequential if, for all 1 <= j <= i, nums[j] = nums[j - 1] + 1. In particular, the prefix consisting only of nums[0] is sequential. Return the smallest integer x missing from nums such that x is greater than or equal to the sum of the longest seque...
missingInteger(nums: list_int) -> int
pub fn missing_integer(nums: &[i64]) -> i64
Aegis.MissingInteger.missing_integer
fn contains(nums: &[i64], x: i64) -> bool { let mut i: usize = 0; while i < nums.len() { if nums[i] == x { return true; } i += 1; } false } pub fn missing_integer(nums: &[i64]) -> i64 { if nums.len() == 0 { return 1; } let mut sum: i64 = nums[0];...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [missing_integer]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linte...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [missing_integer]: function definitions module public import Aeneas public import Aegis.MissingInteger.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.MissingInteger.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := 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, 3, 2, 4, 5]]", "output": "6" }, { "input": "[[10, 11, 12, 13, 14]]", "output": "60" }, { "input": "[[1, 3, 5, 7, 9]]", "output": "2" }, { "input": "[[50, 49, 48, 47, 46]]", "output": "51" }, { "input": "[[2, 3, 4, 5, 6]]", "output": "20" }, ...
123
false
123
verified
10
10
1
906
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MissingInteger.Code.Funs /-! # Specifications of `Aegis.MissingInteger.missing_integer` LeetCode problem `smallest-missing-integer-greater-than-sequential-prefix-sum`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.MissingInteger d...
10
minimum-number-of-operations-to-make-array-xor-equal-to-k
2,997
Medium
[ "Bit Manipulation", "Array" ]
You are given a 0-indexed integer array nums and a positive integer k. You can apply the following operation on the array any number of times: Choose any element of the array and flip a bit in its binary representation. Flipping a bit means changing a 0 to 1 or vice versa. Return the minimum number of operations requ...
minOperations(nums: list_int, k: int) -> int
pub fn min_operations(nums: &[i64], k: i64) -> i64
Aegis.MinOperations.min_operations
pub fn min_operations(nums: &[i64], k: i64) -> i64 { let mut x: i64 = 0; let mut i: usize = 0; while i < nums.len() { x = x ^ nums[i]; i += 1; } let mut v: i64 = x ^ k; let mut ans: i64 = 0; while v > 0 { if v % 2 == 1 { ans += 1; } v = ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [min_operations]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [min_operations]: function definitions module public import Aeneas public import Aegis.MinOperations.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_opti...
import Aegis.MinOperations.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval aegisCa...
[ { "input": "[[1000000], 1000000]", "output": "0" }, { "input": "[[1000000, 500000, 250000], 125000]", "output": "12" }, { "input": "[[1000000, 500000, 250000], 1250000]", "output": "5" }, { "input": "[[0, 0, 0, 0], 2]", "output": "1" }, { "input": "[[1, 1, 1, 1], ...
115
false
115
verified
10
10
1
724
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MinOperations.Code.Funs /-! # Specifications of `Aegis.MinOperations.min_operations` LeetCode problem `minimum-number-of-operations-to-make-array-xor-equal-to-k`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result set_option autoImplicit false namespace Aegis...
8
minimum-number-of-operations-to-make-x-and-y-equal
2,998
Medium
[ "Breadth-First Search", "Memoization", "Dynamic Programming" ]
You are given two positive integers x and y. In one operation, you can do one of the four following operations: Divide x by 11 if x is a multiple of 11. Divide x by 5 if x is a multiple of 5. Decrement x by 1. Increment x by 1. Return the minimum number of operations required to make x and y equal.   Example 1: Inp...
minimumOperationsToMakeEqual(x: int, y: int) -> int
pub fn minimum_operations_to_make_equal(x: i64, y: i64) -> i64
Aegis.MinimumOperationsToMakeEqual.minimum_operations_to_make_equal
pub fn minimum_operations_to_make_equal(x: i64, y: i64) -> i64 { if x <= y { return y - x; } let mut answer: i64 = x - y; let mut cur_v: Vec<i64> = Vec::new(); let mut cur_c: Vec<i64> = Vec::new(); cur_v.push(x); cur_c.push(0); while cur_v.len() > 0 { let n: usize = cu...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [minimum_operations_to_make_equal]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [minimum_operations_to_make_equal]: function definitions module public import Aeneas public import Aegis.MinimumOperationsToMakeEqual.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option ...
import Aegis.MinimumOperationsToMakeEqual.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}"...
[ { "input": "[1, 10000]", "output": "9999" }, { "input": "[11, 5]", "output": "5" }, { "input": "[10000, 1]", "output": "8" }, { "input": "[111, 11]", "output": "3" }, { "input": "[77, 7]", "output": "1" }, { "input": "[500, 20]", "output": "2" },...
133
false
133
verified
10
10
3
52,266
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MinimumOperationsToMakeEqual.Code.Funs /-! # Specifications of `Aegis.MinimumOperationsToMakeEqual.minimum_operations_to_make_equal` LeetCode problem `minimum-number-of-operations-to-make-x-and-y-equal`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result nam...
15
maximum-area-of-longest-diagonal-rectangle
3,000
Easy
[ "Array" ]
You are given a 2D 0-indexed integer array dimensions. For all indices i, 0 <= i < dimensions.length, dimensions[i][0] represents the length and dimensions[i][1] represents the width of the rectangle i. Return the area of the rectangle having the longest diagonal. If there are multiple rectangles with the longest diago...
areaOfMaxDiagonal(dimensions: list_list_int) -> int
pub fn area_of_max_diagonal(dimensions: &[Vec<i64>]) -> i64
Aegis.AreaOfMaxDiagonal.area_of_max_diagonal
pub fn area_of_max_diagonal(dimensions: &[Vec<i64>]) -> i64 { let n = dimensions.len(); let mut best_diag_sq: i64 = -1; let mut best_area: i64 = 0; let mut i: usize = 0; while i < n { let row = &dimensions[i]; let length = row[0]; let width = row[1]; let diag_sq = l...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [area_of_max_diagonal]: type definitions module public import Aeneas @[expose] public section 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 -- [area_of_max_diagonal]: function definitions module public import Aeneas public import Aegis.AreaOfMaxDiagonal.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand fals...
import Aegis.AreaOfMaxDiagonal.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := 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": "[[[9, 3], [8, 6]]]", "output": "48" }, { "input": "[[[100, 1], [1, 100]]]", "output": "100" }, { "input": "[[[3, 4], [4, 3]]]", "output": "12" }, { "input": "[[[5, 12], [13, 88], [20, 21]]]", "output": "1144" }, { "input": "[[[6, 8], [8, 6], [10, 24]]]...
107
false
107
verified
10
10
1
427
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.AreaOfMaxDiagonal.Code.Funs /-! # Specifications of `Aegis.AreaOfMaxDiagonal.area_of_max_diagonal` LeetCode problem `maximum-area-of-longest-diagonal-rectangle`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.AreaOfMaxDiagonal def rowP...
11
minimum-moves-to-capture-the-queen
3,001
Medium
[ "Math", "Enumeration" ]
There is a 1-indexed 8 x 8 chessboard containing 3 pieces. You are given 6 integers a, b, c, d, e, and f where: (a, b) denotes the position of the white rook. (c, d) denotes the position of the white bishop. (e, f) denotes the position of the black queen. Given that you can only move the white pieces, return the mini...
minMovesToCaptureTheQueen(a: int, b: int, c: int, d: int, e: int, f: int) -> int
pub fn min_moves_to_capture_the_queen(a: i64, b: i64, c: i64, d: i64, e: i64, f: i64) -> i64
Aegis.MinMovesToCaptureTheQueen.min_moves_to_capture_the_queen
pub fn min_moves_to_capture_the_queen(a: i64, b: i64, c: i64, d: i64, e: i64, f: i64) -> i64 { let mut rook_can = false; // Rook attacks along the same column a == e. if a == e { let mut blocked = false; if c == a { if (d > b && d < f) || (d < b && d > f) { block...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [min_moves_to_capture_the_queen]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false s...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [min_moves_to_capture_the_queen]: function definitions module public import Aeneas public import Aegis.MinMovesToCaptureTheQueen.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linte...
import Aegis.MinMovesToCaptureTheQueen.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #...
[ { "input": "[4, 4, 7, 7, 3, 3]", "output": "2" }, { "input": "[3, 3, 6, 6, 7, 7]", "output": "1" }, { "input": "[7, 2, 2, 7, 4, 4]", "output": "2" }, { "input": "[1, 8, 2, 7, 3, 6]", "output": "1" }, { "input": "[8, 8, 1, 1, 3, 3]", "output": "1" }, { ...
89
false
89
verified
10
10
1
2,764
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MinMovesToCaptureTheQueen.Code.Funs /-! # Specifications of `Aegis.MinMovesToCaptureTheQueen.min_moves_to_capture_the_queen` LeetCode problem `minimum-moves-to-capture-the-queen`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.MinMovesToCaptureTh...
6
maximum-size-of-a-set-after-removals
3,002
Medium
[ "Greedy", "Array", "Hash Table" ]
You are given two 0-indexed integer arrays nums1 and nums2 of even length n. You must remove n / 2 elements from nums1 and n / 2 elements from nums2. After the removals, you insert the remaining elements of nums1 and nums2 into a set s. Return the maximum possible size of the set s.   Example 1: Input: nums1 = [1,2,1,...
maximumSetSize(nums1: list_int, nums2: list_int) -> int
pub fn maximum_set_size(nums1: &[i64], nums2: &[i64]) -> i64
Aegis.MaximumSetSize.maximum_set_size
fn count_distinct_sorted(v: &[i64]) -> i64 { let n = v.len(); if n == 0 { return 0; } let mut count: i64 = 1; let mut i: usize = 1; while i < n { if v[i] != v[i - 1] { count += 1; } i += 1; } count } fn sort_vec(mut a: Vec<i64>) -> Vec<i64> {...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [maximum_set_size]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option lint...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [maximum_set_size]: function definitions module public import Aeneas public import Aegis.MaximumSetSize.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.MaximumSetSize.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := 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, 1, 1], [2, 2, 2, 2]]", "output": "2" }, { "input": "[[1, 2, 1, 2], [1, 1, 1, 1]]", "output": "2" }, { "input": "[[1, 2, 3, 4], [5, 6, 7, 8]]", "output": "4" }, { "input": "[[1000000000, 1000000000, 1000000000, 1000000000], [1000000000, 1000000000, 10000000...
103
false
103
verified
10
10
1
6,826
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MaximumSetSize.Code.Funs /-! # Specifications of `Aegis.MaximumSetSize.maximum_set_size` LeetCode problem `maximum-size-of-a-set-after-removals`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.MaximumSetSize open Aegis.MaximumSetSi...
13
maximize-the-number-of-partitions-after-operations
3,003
Hard
[ "Bit Manipulation", "String", "Dynamic Programming", "Bitmask" ]
You are given a string s and an integer k. First, you are allowed to change at most one index in s to another lowercase English letter. After that, do the following partitioning operation until s is empty: Choose the longest prefix of s containing at most k distinct characters. Delete the prefix from s and increase th...
maxPartitionsAfterOperations(s: str, k: int) -> int
pub fn max_partitions_after_operations(s: &[u8], k: i64) -> i64
Aegis.MaxPartitionsAfterOperations.max_partitions_after_operations
pub fn max_partitions_after_operations(s: &[u8], k: i64) -> i64 { let n = s.len(); if n == 0 { return 0; } // Prefix greedy states: before position i. let mut pre_parts: Vec<i64> = Vec::new(); let mut pre_mask: Vec<i64> = Vec::new(); let mut pre_cnt: Vec<i64> = Vec::new(); pre_...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [max_partitions_after_operations]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [max_partitions_after_operations]: function definitions module public import Aeneas public import Aegis.MaxPartitionsAfterOperations.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option l...
import Aegis.MaxPartitionsAfterOperations.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}"...
[ { "input": "[\"zzzzzzz\", 1]", "output": "3" }, { "input": "[\"abcdef\", 6]", "output": "1" }, { "input": "[\"aaaaaaa\", 1]", "output": "3" }, { "input": "[\"abcdefghijklmnop\", 5]", "output": "4" }, { "input": "[\"aabacbebebe\", 3]", "output": "2" }, { ...
113
false
113
verified
10
10
2
62,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.MaxPartitionsAfterOperations.Code.Funs /-! # Specifications of `Aegis.MaxPartitionsAfterOperations.max_partitions_after_operations` LeetCode problem `maximize-the-number-of-partitions-after-operations`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Aeneas.Std.Res...
14
count-elements-with-maximum-frequency
3,005
Easy
[ "Array", "Hash Table", "Counting" ]
You are given an array nums consisting of positive integers. Return the total frequencies of elements in nums such that those elements all have the maximum frequency. The frequency of an element is the number of occurrences of that element in the array.   Example 1: Input: nums = [1,2,2,3,1,4] Output: 4 Explanation: T...
maxFrequencyElements(nums: list_int) -> int
pub fn max_frequency_elements(nums: &[i64]) -> i64
Aegis.MaxFrequencyElements.max_frequency_elements
pub fn max_frequency_elements(nums: &[i64]) -> i64 { let mut counts: Vec<i64> = Vec::new(); let mut i: usize = 0; while i < 101 { counts.push(0); i = i + 1; } i = 0; while i < nums.len() { let v: i64 = nums[i]; if v >= 1 && v <= 100 { let idx: usize =...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [max_frequency_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_optio...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [max_frequency_elements]: function definitions module public import Aeneas public import Aegis.MaxFrequencyElements.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand...
import Aegis.MaxFrequencyElements.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval ...
[ { "input": "[[1]]", "output": "1" }, { "input": "[[1, 1]]", "output": "2" }, { "input": "[[5, 5, 5, 5, 5]]", "output": "5" }, { "input": "[[1, 2, 3, 4, 5]]", "output": "5" }, { "input": "[[7, 7, 7, 7, 7]]", "output": "5" }, { "input": "[[3, 3, 3, 2, 2,...
116
false
116
verified
10
10
1
1,041
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MaxFrequencyElements.Code.Funs /-! # Specifications of `Aegis.MaxFrequencyElements.max_frequency_elements` LeetCode problem `count-elements-with-maximum-frequency`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.MaxFrequencyElements namespac...
8
find-beautiful-indices-in-the-given-array-i
3,006
Medium
[ "Two Pointers", "String", "Binary Search", "String Matching", "Hash Function", "Rolling Hash" ]
You are given a 0-indexed string s, a string a, a string b, and an integer k. An index i is beautiful if: 0 <= i <= s.length - a.length s[i..(i + a.length - 1)] == a There exists an index j such that: 0 <= j <= s.length - b.length s[j..(j + b.length - 1)] == b |j - i| <= k Return the array that contains beautiful...
beautifulIndices(s: str, a: str, b: str, k: int) -> list_int
pub fn beautiful_indices(s: &[u8], a: &[u8], b: &[u8], k: i64) -> Vec<i64>
Aegis.BeautifulIndices.beautiful_indices
pub fn beautiful_indices(s: &[u8], a: &[u8], b: &[u8], k: i64) -> Vec<i64> { let n = s.len(); let la = a.len(); let lb = b.len(); let mut occ_a: Vec<usize> = Vec::new(); let mut occ_b: Vec<usize> = Vec::new(); if la <= n { let last = n - la; let mut i: usize = 0; while ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [beautiful_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 -- [beautiful_indices]: function definitions module public import Aeneas public import Aegis.BeautifulIndices.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.BeautifulIndices.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := 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": "[\"beautifulday\", \"day\", \"beat\", 10]", "output": "[]" }, { "input": "[\"longestsubstringhereandthere\", \"long\", \"here\", 12]", "output": "[]" }, { "input": "[\"aaaaaabaaaaaabaaaaaabaaaaaabaaaaaabaaaaaabaaaaaab\", \"aa\", \"bb\", 5]", "output": "[]" }, { "i...
115
false
115
verified
10
10
1
3,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.BeautifulIndices.Code.Funs /-! # Specifications of `Aegis.BeautifulIndices.beautiful_indices` LeetCode problem `find-beautiful-indices-in-the-given-array-i`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.BeautifulIndices def getByte (...
16
maximum-number-that-sum-of-the-prices-is-less-than-or-equal-to-k
3,007
Medium
[ "Bit Manipulation", "Binary Search", "Dynamic Programming" ]
You are given an integer k and an integer x. The price of a number num is calculated by the count of set bits at positions x, 2x, 3x, etc., in its binary representation, starting from the least significant bit. The following table contains examples of how price is calculated. x num Binary Representation Price 1 13...
findMaximumNumber(k: int, x: int) -> int
pub fn find_maximum_number(k: i64, x: i64) -> i64
Aegis.FindMaximumNumber.find_maximum_number
fn accumulated_price(n: i64, x: i64) -> i64 { let total = n + 1; // bit = 2^(x - 1), the first selected bit position, 0-indexed. let mut bit: i64 = 1; let mut p: i64 = 0; while p < x - 1 { bit = bit * 2; p = p + 1; } // step = 2^x, the distance between selected bit position...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [find_maximum_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 l...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [find_maximum_number]: function definitions module public import Aeneas public import Aegis.FindMaximumNumber.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false...
import Aegis.FindMaximumNumber.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := 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": "[15, 1]", "output": "9" }, { "input": "[5, 2]", "output": "8" }, { "input": "[100000000000000, 8]", "output": "40104798005951" }, { "input": "[500, 6]", "output": "1011" }, { "input": "[20, 2]", "output": "23" }, { "input": "[5, 1]", "o...
126
false
126
verified
10
10
1
10,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.FindMaximumNumber.Code.Funs /-! # Specifications of `Aegis.FindMaximumNumber.find_maximum_number` LeetCode problem `maximum-number-that-sum-of-the-prices-is-less-than-or-equal-to-k`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.Find...
10
find-beautiful-indices-in-the-given-array-ii
3,008
Hard
[ "Two Pointers", "String", "Binary Search", "String Matching", "Hash Function", "Rolling Hash" ]
You are given a 0-indexed string s, a string a, a string b, and an integer k. An index i is beautiful if: 0 <= i <= s.length - a.length s[i..(i + a.length - 1)] == a There exists an index j such that: 0 <= j <= s.length - b.length s[j..(j + b.length - 1)] == b |j - i| <= k Return the array that contains beautiful...
beautifulIndices(s: str, a: str, b: str, k: int) -> list_int
pub fn beautiful_indices(s: &[u8], a: &[u8], b: &[u8], k: i64) -> Vec<i64>
Aegis.BeautifulIndices.beautiful_indices
fn find_occurrences(text: &[u8], pat: &[u8]) -> Vec<i64> { let mut res: Vec<i64> = Vec::new(); let n = text.len(); let m = pat.len(); if m == 0 { let mut idx: usize = 0; while idx <= n { res.push(idx as i64); idx += 1; } return res; } if ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [beautiful_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 -- [beautiful_indices]: function definitions module public import Aeneas public import Aegis.BeautifulIndices.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.BeautifulIndices.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := 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": "[\"beautifuldayinbeautifultown\", \"day\", \"town\", 10]", "output": "[]" }, { "input": "[\"hellobeautifulworld\", \"bea\", \"ful\", 5]", "output": "[]" }, { "input": "[\"qwertyuiopasdfghjklzxcvbnmqwertyuiopasdfghjklzxcvbnm\", \"erty\", \"ghjk\", 10]", "output": "[]" },...
122
false
122
verified
10
10
1
4,270
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.BeautifulIndices.Code.Funs /-! # Specifications of `Aegis.BeautifulIndices.beautiful_indices` LeetCode problem `find-beautiful-indices-in-the-given-array-ii`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.BeautifulIndices def lowe...
9
divide-an-array-into-subarrays-with-minimum-cost-i
3,010
Easy
[ "Array", "Enumeration", "Sorting" ]
You are given an array of integers nums of length n. The cost of an array is the value of its first element. For example, the cost of [1,2,3] is 1 while the cost of [3,4,1] is 3. You need to divide nums into 3 disjoint contiguous subarrays. Return the minimum possible sum of the cost of these subarrays.   Example 1: I...
minimumCost(nums: list_int) -> int
pub fn minimum_cost(nums: &[i64]) -> i64
Aegis.MinimumCost.minimum_cost
pub fn minimum_cost(nums: &[i64]) -> i64 { let n = nums.len(); let mut best: i64 = nums[0] + nums[1] + nums[2]; let mut i: usize = 1; while i < n { let mut j: usize = i + 1; while j < n { let cost = nums[0] + nums[i] + nums[j]; if cost < best { be...
-- 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": "[[5, 4, 3]]", "output": "12" }, { "input": "[[10, 3, 1, 1]]", "output": "12" }, { "input": "[[1, 2, 3, 12]]", "output": "6" }, { "input": "[[30, 20, 10, 40, 50]]", "output": "60" }, { "input": "[[40, 30, 20, 10, 5]]", "output": "55" }, { "i...
116
false
116
verified
10
10
1
555
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MinimumCost.Code.Funs /-! # Specifications of `Aegis.MinimumCost.minimum_cost` LeetCode problem `divide-an-array-into-subarrays-with-minimum-cost-i`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.MinimumCost namespace AegisSpec.MinimumCost def...
11
find-if-array-can-be-sorted
3,011
Medium
[ "Bit Manipulation", "Array", "Sorting" ]
You are given a 0-indexed array of positive integers nums. In one operation, you can swap any two adjacent elements if they have the same number of set bits. You are allowed to do this operation any number of times (including zero). Return true if you can sort the array in ascending order, else return false.   Example ...
canSortArray(nums: list_int) -> bool
pub fn can_sort_array(nums: &[i64]) -> bool
Aegis.CanSortArray.can_sort_array
fn popcount(mut x: i64) -> i64 { let mut count = 0; while x > 0 { if x % 2 == 1 { count += 1; } x = x / 2; } count } pub fn can_sort_array(nums: &[i64]) -> bool { let n = nums.len(); // Copy input into an owned mutable buffer. let mut a: Vec<i64> = Vec::...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [can_sort_array]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [can_sort_array]: function definitions module public import Aeneas public import Aegis.CanSortArray.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.CanSortArray.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := 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": "[[31, 14, 7, 3, 1]]", "output": "false" }, { "input": "[[5, 3, 1, 4, 2]]", "output": "false" }, { "input": "[[5, 3, 9, 6, 12]]", "output": "true" }, { "input": "[[4, 4, 4, 4, 4]]", "output": "true" }, { "input": "[[8, 4, 2, 30, 15]]", "output": "tr...
135
false
135
verified
10
10
3
23,296
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.CanSortArray.Code.Funs /-! # Specifications of `Aegis.CanSortArray.can_sort_array` LeetCode problem `find-if-array-can-be-sorted`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.CanSortArray (can_sort_array) namespace AegisSpec.CanSortArray def...
12
minimize-length-of-array-using-operations
3,012
Medium
[ "Greedy", "Array", "Math", "Number Theory" ]
You are given a 0-indexed integer array nums containing positive integers. Your task is to minimize the length of nums by performing the following operations any number of times (including zero): Select two distinct indices i and j from nums, such that nums[i] > 0 and nums[j] > 0. Insert the result of nums[i] % nums[j...
minimumArrayLength(nums: list_int) -> int
pub fn minimum_array_length(nums: &[i64]) -> i64
Aegis.MinimumArrayLength.minimum_array_length
pub fn minimum_array_length(nums: &[i64]) -> i64 { let n = nums.len(); let mut mn = nums[0]; let mut i = 0; while i < n { if nums[i] < mn { mn = nums[i]; } i += 1; } let mut count_min: i64 = 0; let mut all_divisible = true; i = 0; while i < n { ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [minimum_array_length]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [minimum_array_length]: function definitions module public import Aeneas public import Aegis.MinimumArrayLength.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand fal...
import Aegis.MinimumArrayLength.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := 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": "[[1000000000, 1000000000, 1000000000]]", "output": "2" }, { "input": "[[2, 3, 4]]", "output": "1" }, { "input": "[[1, 4, 3, 1]]", "output": "1" }, { "input": "[[7, 14, 28, 35]]", "output": "1" }, { "input": "[[5, 5, 5, 10, 5]]", "output": "2" }, ...
136
false
136
verified
10
10
1
784
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MinimumArrayLength.Code.Funs /-! # Specifications of `Aegis.MinimumArrayLength.minimum_array_length` LeetCode problem `minimize-length-of-array-using-operations`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.MinimumArrayLength def ...
12
divide-an-array-into-subarrays-with-minimum-cost-ii
3,013
Hard
[ "Array", "Hash Table", "Sliding Window", "Heap (Priority Queue)" ]
You are given a 0-indexed array of integers nums of length n, and two positive integers k and dist. The cost of an array is the value of its first element. For example, the cost of [1,2,3] is 1 while the cost of [3,4,1] is 3. You need to divide nums into k disjoint contiguous subarrays, such that the difference between...
minimumCost(nums: list_int, k: int, dist: int) -> int
pub fn minimum_cost(nums: &[i64], k: i64, dist: i64) -> i64
Aegis.MinimumCost.minimum_cost
fn fenwick_add(bit: &mut Vec<i64>, idx: usize, delta: i64) { let m = bit.len() - 1; let mut i = idx + 1; while i <= m { bit[i] = bit[i] + delta; let low = i & (i ^ (i - 1)); i += low; } } fn value_rank(vals: &[i64], x: i64) -> usize { let mut lo = 0usize; let mut hi = va...
-- 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 public import Aegis.MinimumCost.Code.FunsExternal @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace fals...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [minimum_cost]: external functions. -- This is a template file: rename it to "FunsExternal.lean" and fill the holes. module public import Aeneas public import Aegis.MinimumCost.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_o...
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": "[[1000000000, 1000000000, 1000000000], 3, 2]", "output": "3000000000" }, { "input": "[[10, 8, 18, 9], 3, 1]", "output": "36" }, { "input": "[[10, 8, 18, 9], 3, 1]", "output": "36" }, { "input": "[[5, 4, 3, 2, 1], 2, 2]", "output": "6" }, { "input": "[[...
193
false
193
verified
10
10
1
14,574
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": 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 `divide-an-array-into-subarrays-with-minimum-cost-ii`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.MinimumCost (minimum_cost) namespace AegisS...
15
minimum-number-of-pushes-to-type-word-i
3,014
Easy
[ "Greedy", "Math", "String" ]
You are given a string word containing distinct lowercase English letters. Telephone keypads have keys mapped with distinct collections of lowercase English letters, which can be used to form words by pushing them. For example, the key 2 is mapped with ["a","b","c"], we need to push the key one time to type "a", two ti...
minimumPushes(word: str) -> int
pub fn minimum_pushes(word: &[u8]) -> i64
Aegis.MinimumPushes.minimum_pushes
pub fn minimum_pushes(word: &[u8]) -> i64 { let n = word.len(); let mut total: i64 = 0; let mut i: usize = 0; while i < n { let mut cost: i64 = 1; let mut remaining: usize = i; while remaining >= 8 { cost += 1; remaining -= 8; } total +=...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [minimum_pushes]: type definitions module public import Aeneas @[expose] public section 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_pushes]: function definitions module public import Aeneas public import Aegis.MinimumPushes.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.MinimumPushes.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := 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": "[\"ghijkl\"]", "output": "6" }, { "input": "[\"npqrstvwxy\"]", "output": "12" }, { "input": "[\"abcdefghi\"]", "output": "10" }, { "input": "[\"vwxyz\"]", "output": "5" }, { "input": "[\"abcdefghijklmnopq\"]", "output": "27" }, { "input": "...
202
false
202
verified
10
10
1
1,842
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MinimumPushes.Code.Funs /-! # Specifications of `Aegis.MinimumPushes.minimum_pushes` LeetCode problem `minimum-number-of-pushes-to-type-word-i`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.MinimumPushes (minimum_pushes) namespace AegisSpec.Mi...
12
count-the-number-of-houses-at-a-certain-distance-i
3,015
Medium
[ "Breadth-First Search", "Graph", "Prefix Sum" ]
You are given three positive integers n, x, and y. In a city, there exist houses numbered 1 to n connected by n streets. There is a street connecting the house numbered i with the house numbered i + 1 for all 1 <= i <= n - 1 . An additional street connects the house numbered x with the house numbered y. For each k, suc...
countOfPairs(n: int, x: int, y: int) -> list_int
pub fn count_of_pairs(n: i64, x: i64, y: i64) -> Vec<i64>
Aegis.CountOfPairs.count_of_pairs
pub fn count_of_pairs(n: i64, x: i64, y: i64) -> Vec<i64> { let nn = n as usize; let inf: i64 = 1000000; let mut dist: Vec<Vec<i64>> = Vec::new(); let mut i = 0; while i < nn { let mut row: Vec<i64> = Vec::new(); let mut j = 0; while j < nn { if i == j { ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [count_of_pairs]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [count_of_pairs]: function definitions module public import Aeneas public import Aegis.CountOfPairs.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.CountOfPairs.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := 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": "[2, 1, 2]", "output": "[2, 0]" }, { "input": "[3, 1, 3]", "output": "[6, 0, 0]" }, { "input": "[4, 1, 1]", "output": "[6, 4, 2, 0]" }, { "input": "[5, 2, 4]", "output": "[10, 8, 2, 0, 0]" }, { "input": "[6, 2, 5]", "output": "[12, 12, 6, 0, 0, 0]" ...
114
false
114
verified
10
10
1
3,559
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.CountOfPairs.Code.Funs /-! # Specifications of `Aegis.CountOfPairs.count_of_pairs` LeetCode problem `count-the-number-of-houses-at-a-certain-distance-i`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.CountOfPairs def Adj (n x y a ...
14
minimum-number-of-pushes-to-type-word-ii
3,016
Medium
[ "Greedy", "Hash Table", "String", "Counting", "Sorting" ]
You are given a string word containing lowercase English letters. Telephone keypads have keys mapped with distinct collections of lowercase English letters, which can be used to form words by pushing them. For example, the key 2 is mapped with ["a","b","c"], we need to push the key one time to type "a", two times to ty...
minimumPushes(word: str) -> int
pub fn minimum_pushes(word: &[u8]) -> i64
Aegis.MinimumPushes.minimum_pushes
pub fn minimum_pushes(word: &[u8]) -> i64 { let mut freq: Vec<i64> = Vec::new(); let mut i: usize = 0; while i < 26 { freq.push(0); i += 1; } let n = word.len(); let mut p: usize = 0; while p < n { let idx = (word[p] - b'a') as usize; freq[idx] = freq[idx] + ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [minimum_pushes]: type definitions module public import Aeneas @[expose] public section 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_pushes]: function definitions module public import Aeneas public import Aegis.MinimumPushes.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.MinimumPushes.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := 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": "[\"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\"]", "output": "52" }, { "input": "[\"abcde\"]", "output": "5" }, { "input": "[\"zyxwvutsrqponmlkjihgfedcba\"]", "output": "56" }, { "input": "[\"mississippi\"]", "output": "11" }, { "input": "[\"...
47
false
47
verified
10
10
1
1,478
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MinimumPushes.Code.Funs /-! # Specifications of `Aegis.MinimumPushes.minimum_pushes` LeetCode problem `minimum-number-of-pushes-to-type-word-ii`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.MinimumPushes (minimum_pushes) namespace AegisSp...
13