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
minimize-maximum-value-in-a-grid
2,371
Hard
[ "Union Find", "Graph", "Topological Sort", "Array", "Matrix", "Sorting" ]
You are given an m x n integer matrix grid containing distinct positive integers. You have to replace each integer in the matrix with a positive integer satisfying the following conditions: The relative order of every two elements that are in the same row or column should stay the same after the replacements. The maxi...
minScore(grid: list_list_int) -> list_list_int
pub fn min_score(grid: &[Vec<i64>]) -> Vec<Vec<i64>>
Aegis.MinScore.min_score
pub fn min_score(grid: &[Vec<i64>]) -> Vec<Vec<i64>> { let m = grid.len(); let n = grid[0].len(); let total = m * n; let base = total as i64; let mut cells: Vec<i64> = Vec::new(); let mut i = 0; while i < m { let mut j = 0; while j < n { let idx = (i * n + j) as ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [min_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 -- [min_score]: function definitions module public import Aeneas public import Aegis.MinScore.Code.Types public import Aegis.MinScore.Code.FunsExternal @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_opt...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [min_score]: external functions. -- This is a template file: rename it to "FunsExternal.lean" and fill the holes. module public import Aeneas public import Aegis.MinScore.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option ...
import Aegis.MinScore.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval aegisCase "e...
[ { "input": "[[[10]]]", "output": "[[1]]" }, { "input": "[[[3, 1], [2, 5]]]", "output": "[[2, 1], [1, 2]]" }, { "input": "[[[9, 8], [7, 6]]]", "output": "[[3, 2], [2, 1]]" }, { "input": "[[[1000000000], [999999999], [999999998], [999999997], [999999996]]]", "output": "[[5]...
79
false
79
verified
10
10
1
5,252
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MinScore.Code.Funs /-! # Specifications of `Aegis.MinScore.min_score` LeetCode problem `minimize-maximum-value-in-a-grid`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.MinScore def matOf (rows : List (alloc.vec.Vec Std.I64)) : Li...
14
largest-local-values-in-a-matrix
2,373
Easy
[ "Array", "Matrix" ]
You are given an n x n integer matrix grid. Generate an integer matrix maxLocal of size (n - 2) x (n - 2) such that: maxLocal[i][j] is equal to the largest value of the 3 x 3 matrix in grid centered around row i + 1 and column j + 1. In other words, we want to find the largest value in every contiguous 3 x 3 matrix i...
largestLocal(grid: list_list_int) -> list_list_int
pub fn largest_local(grid: &[Vec<i64>]) -> Vec<Vec<i64>>
Aegis.LargestLocal.largest_local
pub fn largest_local(grid: &[Vec<i64>]) -> Vec<Vec<i64>> { let n = grid.len(); let out_size = n - 2; let mut out: Vec<Vec<i64>> = Vec::new(); let mut i: usize = 0; while i < out_size { let mut row: Vec<i64> = Vec::new(); let mut j: usize = 0; while j < out_size { ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [largest_local]: type definitions module public import Aeneas @[expose] public section 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 -- [largest_local]: function definitions module public import Aeneas public import Aegis.LargestLocal.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.LargestLocal.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := 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": "[[[100, 100, 100], [100, 100, 100], [100, 100, 100]]]", "output": "[[100]]" }, { "input": "[[[5, 8, 4, 3], [3, 5, 9, 5], [7, 6, 7, 9], [4, 8, 5, 3]]]", "output": "[[9, 9], [9, 9]]" }, { "input": "[[[3, 0, 0, 5], [0, 7, 3, 2], [0, 2, 9, 7], [5, 1, 0, 0]]]", "output": "[[9,...
56
false
56
verified
10
10
1
530
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.LargestLocal.Code.Funs /-! # Specifications of `Aegis.LargestLocal.largest_local` LeetCode problem `largest-local-values-in-a-matrix`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.LargestLocal def matrix (grid : Slice (alloc.vec.Vec ...
11
node-with-highest-edge-score
2,374
Medium
[ "Graph", "Hash Table" ]
You are given a directed graph with n nodes labeled from 0 to n - 1, where each node has exactly one outgoing edge. The graph is represented by a given 0-indexed integer array edges of length n, where edges[i] indicates that there is a directed edge from node i to node edges[i]. The edge score of a node i is defined as...
edgeScore(edges: list_int) -> int
pub fn edge_score(edges: &[i64]) -> i64
Aegis.EdgeScore.edge_score
pub fn edge_score(edges: &[i64]) -> i64 { let n = edges.len(); let mut scores: Vec<i64> = Vec::new(); let mut i: usize = 0; while i < n { scores.push(0); i += 1; } i = 0; while i < n { let to = edges[i] as usize; scores[to] = scores[to] + (i as i64); ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [edge_score]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter.sty...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [edge_score]: function definitions module public import Aeneas public import Aegis.EdgeScore.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.EdgeScore.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := 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, 0, 0, 2]]", "output": "0" }, { "input": "[[3, 3, 3, 3]]", "output": "3" }, { "input": "[[3, 1, 2, 0]]", "output": "0" }, { "input": "[[3, 3, 3, 3, 3]]", "output": "3" }, { "input": "[[4, 4, 4, 4, 4]]", "output": "4" }, { "input": "[[5,...
26
false
26
verified
10
10
1
749
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.EdgeScore.Code.Funs /-! # Specifications of `Aegis.EdgeScore.edge_score` LeetCode problem `node-with-highest-edge-score`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.EdgeScore def edgeList (edges : Slice I64) : List Int := edges.v...
7
count-special-integers
2,376
Hard
[ "Math", "Dynamic Programming" ]
We call a positive integer special if all of its digits are distinct. Given a positive integer n, return the number of special integers that belong to the interval [1, n].   Example 1: Input: n = 20 Output: 19 Explanation: All the integers from 1 to 20, except 11, are special. Thus, there are 19 special integers. Exa...
countSpecialNumbers(n: int) -> int
pub fn count_special_numbers(n: i64) -> i64
Aegis.CountSpecialNumbers.count_special_numbers
fn digit_perm(a: i64, k: i64) -> i64 { if k > a { return 0; } let mut res: i64 = 1; let mut t: i64 = 0; while t < k { res = res * (a - t); t = t + 1; } res } fn number_to_digits(mut n: i64) -> Vec<i64> { let mut rev: Vec<i64> = Vec::new(); while n > 0 { ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [count_special_numbers]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [count_special_numbers]: function definitions module public import Aeneas public import Aegis.CountSpecialNumbers.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand f...
import Aegis.CountSpecialNumbers.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := 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": "[135]", "output": "110" }, { "input": "[999]", "output": "738" }, { "input": "[200]", "output": "162" }, { "input": "[10000]", "output": "5274" }, { "input": "[1234]", "output": "803" }, { "input": "[2000]", "output": "1242" }, { ...
57
false
57
verified
10
10
1
11,741
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.CountSpecialNumbers.Code.Funs /-! # Specifications of `Aegis.CountSpecialNumbers.count_special_numbers` LeetCode problem `count-special-integers`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.CountSpecialNumbers open Aegis.CountSpeci...
14
choose-edges-to-maximize-score-in-a-tree
2,378
Medium
[ "Tree", "Depth-First Search", "Dynamic Programming" ]
You are given a weighted tree consisting of n nodes numbered from 0 to n - 1. The tree is rooted at node 0 and represented with a 2D array edges of size n where edges[i] = [pari, weighti] indicates that node pari is the parent of node i, and the edge between them has a weight equal to weighti. Since the root does not h...
maxScore(edges: list_list_int) -> int
pub fn max_score(edges: &[Vec<i64>]) -> i64
Aegis.MaxScore.max_score
pub fn max_score(edges: &[Vec<i64>]) -> i64 { let n = edges.len(); if n == 0 { return 0; } let mut first: Vec<usize> = Vec::new(); let mut next: Vec<usize> = Vec::new(); let mut weight: Vec<i64> = Vec::new(); let mut i: usize = 0; while i < n { first.push(n); ne...
-- 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, -1], [0, 5], [0, -6], [0, 7]]]", "output": "7" }, { "input": "[[[-1, -1], [0, 100], [-1, -1], [2, 200]]]", "output": "100" }, { "input": "[[[-1, -1], [0, -5], [0, -10], [1, -6], [1, -4]]]", "output": "0" }, { "input": "[[[-1, -1], [0, 5], [0, 10], [2, 6], [...
87
false
87
verified
10
10
1
10,185
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": 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 `choose-edges-to-maximize-score-in-a-tree`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.MaxScore def rows (edges : Slice (alloc.vec.Vec Std.I64))...
12
minimum-recolors-to-get-k-consecutive-black-blocks
2,379
Easy
[ "String", "Sliding Window" ]
You are given a 0-indexed string blocks of length n, where blocks[i] is either 'W' or 'B', representing the color of the ith block. The characters 'W' and 'B' denote the colors white and black, respectively. You are also given an integer k, which is the desired number of consecutive black blocks. In one operation, you ...
minimumRecolors(blocks: str, k: int) -> int
pub fn minimum_recolors(blocks: &[u8], k: i64) -> i64
Aegis.MinimumRecolors.minimum_recolors
pub fn minimum_recolors(blocks: &[u8], k: i64) -> i64 { let n = blocks.len(); let kk = k as usize; let mut whites: i64 = 0; let mut i: usize = 0; while i < kk { if blocks[i] == b'W' { whites += 1; } i += 1; } let mut best: i64 = whites; let mut start...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [minimum_recolors]: type definitions module public import Aeneas @[expose] public section 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 -- [minimum_recolors]: function definitions module public import Aeneas public import Aegis.MinimumRecolors.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.MinimumRecolors.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := 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": "[\"WWWW\", 2]", "output": "2" }, { "input": "[\"WBBBWWBBBW\", 3]", "output": "0" }, { "input": "[\"WBBWWBBWBW\", 7]", "output": "3" }, { "input": "[\"BBBBB\", 3]", "output": "0" }, { "input": "[\"BWBWBWBWBW\", 6]", "output": "3" }, { "input...
101
false
101
verified
10
10
1
584
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MinimumRecolors.Code.Funs /-! # Specifications of `Aegis.MinimumRecolors.minimum_recolors` LeetCode problem `minimum-recolors-to-get-k-consecutive-black-blocks`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.MinimumRecolors open A...
8
time-needed-to-rearrange-a-binary-string
2,380
Medium
[ "String", "Dynamic Programming", "Simulation" ]
You are given a binary string s. In one second, all occurrences of "01" are simultaneously replaced with "10". This process repeats until no occurrences of "01" exist. Return the number of seconds needed to complete this process.   Example 1: Input: s = "0110101" Output: 4 Explanation: After one second, s becomes "10...
secondsToRemoveOccurrences(s: str) -> int
pub fn seconds_to_remove_occurrences(s: &[u8]) -> i64
Aegis.SecondsToRemoveOccurrences.seconds_to_remove_occurrences
pub fn seconds_to_remove_occurrences(s: &[u8]) -> i64 { let n = s.len(); let mut zeros: i64 = 0; let mut ans: i64 = 0; let mut i: usize = 0; while i < n { if s[i] == b'0' { zeros += 1; } else { if zeros > 0 { let next = ans + 1; ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [seconds_to_remove_occurrences]: type definitions module public import Aeneas @[expose] 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 -- [seconds_to_remove_occurrences]: function definitions module public import Aeneas public import Aegis.SecondsToRemoveOccurrences.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linte...
import Aegis.SecondsToRemoveOccurrences.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO 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": "[\"1111\"]", "output": "0" }, { "input": "[\"00110011\"]", "output": "5" }, { "input": "[\"0000\"]", "output": "0" }, { "input": "[\"111000\"]", "output": "0" }, { "input": "[\"0010110\"]", "output": "4" }, { "input": "[\"1001001\"]", "...
127
false
127
verified
10
10
1
622
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.SecondsToRemoveOccurrences.Code.Funs /-! # Specifications of `Aegis.SecondsToRemoveOccurrences.seconds_to_remove_occurrences` LeetCode problem `time-needed-to-rearrange-a-binary-string`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec....
14
minimum-hours-of-training-to-win-a-competition
2,383
Easy
[ "Greedy", "Array" ]
You are entering a competition, and are given two positive integers initialEnergy and initialExperience denoting your initial energy and initial experience respectively. You are also given two 0-indexed integer arrays energy and experience, both of length n. You will face n opponents in order. The energy and experience...
minNumberOfHours(initialEnergy: int, initialExperience: int, energy: list_int, experience: list_int) -> int
pub fn min_number_of_hours(initialEnergy: i64, initialExperience: i64, energy: &[i64], experience: &[i64]) -> i64
Aegis.MinNumberOfHours.min_number_of_hours
pub fn min_number_of_hours(initialEnergy: i64, initialExperience: i64, energy: &[i64], experience: &[i64]) -> i64 { let n = energy.len(); let mut hours: i64 = 0; let mut current_experience = initialExperience; let mut i = 0; while i < n { if current_experience <= experience[i] { ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [min_number_of_hours]: type definitions module public import Aeneas @[expose] public section 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_number_of_hours]: function definitions module public import Aeneas public import Aegis.MinNumberOfHours.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false ...
import Aegis.MinNumberOfHours.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval aegi...
[ { "input": "[1, 1, [100], [100]]", "output": "200" }, { "input": "[100, 100, [100], [100]]", "output": "2" }, { "input": "[2, 4, [1], [3]]", "output": "0" }, { "input": "[99, 99, [100], [100]]", "output": "4" }, { "input": "[100, 1, [100], [1]]", "output": "2"...
169
false
169
verified
10
10
1
1,235
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MinNumberOfHours.Code.Funs /-! # Specifications of `Aegis.MinNumberOfHours.min_number_of_hours` LeetCode problem `minimum-hours-of-training-to-win-a-competition`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.MinNumberOfHours def ...
13
find-the-k-sum-of-an-array
2,386
Hard
[ "Array", "Sorting", "Heap (Priority Queue)" ]
You are given an integer array nums and a positive integer k. You can choose any subsequence of the array and sum all of its elements together. We define the K-Sum of the array as the kth largest subsequence sum that can be obtained (not necessarily distinct). Return the K-Sum of the array. A subsequence is an array th...
kSum(nums: list_int, k: int) -> int
pub fn k_sum(nums: &[i64], k: i64) -> i64
Aegis.KSum.k_sum
fn max_heap_push(h: &mut Vec<i64>, val: i64) { let mut pos = h.len(); h.push(val); while pos > 0 { let parent = (pos - 1) / 2; if h[parent] >= val { break; } h[pos] = h[parent]; pos = parent; } h[pos] = val; } fn max_heap_pop(h: &mut Vec<i64>) { ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [k_sum]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter.style.wh...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [k_sum]: function definitions module public import Aeneas public import Aegis.KSum.Code.Types public import Aegis.KSum.Code.FunsExternal @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.h...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [k_sum]: external functions. -- This is a template file: rename it to "FunsExternal.lean" and fill the holes. module public import Aeneas public import Aegis.KSum.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.d...
import Aegis.KSum.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := 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 "eval/...
[ { "input": "[[1000000000, -1000000000, 1000000000], 3]", "output": "1000000000" }, { "input": "[[1, 2, 3], 1]", "output": "6" }, { "input": "[[-1, -2, -3], 4]", "output": "-3" }, { "input": "[[1, 2, 3], 2]", "output": "5" }, { "input": "[[2, 4, -2], 5]", "outp...
105
false
105
verified
10
10
1
31,261
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.KSum.Code.Funs /-! # Specifications of `Aegis.KSum.k_sum` LeetCode problem `find-the-k-sum-of-an-array`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.KSum namespace AegisSpec.KSum def asInts (nums : Slice I64) : List ℤ := nums.val.map (...
15
median-of-a-row-wise-sorted-matrix
2,387
Medium
[ "Array", "Binary Search", "Matrix" ]
Given an m x n matrix grid containing an odd number of integers where each row is sorted in non-decreasing order, return the median of the matrix. You must solve the problem in less than O(m * n) time complexity.   Example 1: Input: grid = [[1,1,2],[2,3,3],[1,3,4]] Output: 2 Explanation: The elements of the matrix in ...
matrixMedian(grid: list_list_int) -> int
pub fn matrix_median(grid: &[Vec<i64>]) -> i64
Aegis.MatrixMedian.matrix_median
pub fn matrix_median(grid: &[Vec<i64>]) -> i64 { let m: usize = grid.len(); let n: usize = grid[0].len(); let target: usize = (m * n + 1) / 2; let mut lo: i64 = 1; let mut hi: i64 = 1_000_000; while lo < hi { let mid: i64 = lo + (hi - lo) / 2; let mut count: usize = 0; ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [matrix_median]: type definitions module public import Aeneas @[expose] public section 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 -- [matrix_median]: function definitions module public import Aeneas public import Aegis.MatrixMedian.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.MatrixMedian.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := 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], [3], [5], [7], [9]]]", "output": "5" }, { "input": "[[[1, 1, 3, 3, 4]]]", "output": "3" }, { "input": "[[[5, 6, 7], [8, 9, 10], [1, 2, 3]]]", "output": "6" }, { "input": "[[[5, 6, 7], [2, 3, 4], [1, 8, 9]]]...
62
false
62
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.MatrixMedian.Code.Funs /-! # Specifications of `Aegis.MatrixMedian.matrix_median` LeetCode problem `median-of-a-row-wise-sorted-matrix`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.MatrixMedian (matrix_median) namespace AegisSpec.MatrixMedian...
12
longest-subsequence-with-limited-sum
2,389
Easy
[ "Greedy", "Array", "Binary Search", "Prefix Sum", "Sorting" ]
You are given an integer array nums of length n, and an integer array queries of length m. Return an array answer of length m where answer[i] is the maximum size of a subsequence that you can take from nums such that the sum of its elements is less than or equal to queries[i]. A subsequence is an array that can be deri...
answerQueries(nums: list_int, queries: list_int) -> list_int
pub fn answer_queries(nums: &[i64], queries: &[i64]) -> Vec<i64>
Aegis.AnswerQueries.answer_queries
pub fn answer_queries(nums: &[i64], queries: &[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; ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [answer_queries]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [answer_queries]: function definitions module public import Aeneas public import Aegis.AnswerQueries.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.AnswerQueries.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := 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": "[1]" }, { "input": "[[1, 1000000], [1000000]]", "output": "[1]" }, { "input": "[[2, 3, 4, 5], [1]]", "output": "[0]" }, { "input": "[[4, 5, 2, 1], [3, 10, 21]]", "output": "[2, 3, 4]" }, { "input": "[[10, 20, 30], [1...
108
false
108
verified
10
10
1
1,162
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.AnswerQueries.Code.Funs /-! # Specifications of `Aegis.AnswerQueries.answer_queries` LeetCode problem `longest-subsequence-with-limited-sum`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.AnswerQueries namespace AegisSpec.AnswerQueries d...
13
build-a-matrix-with-conditions
2,392
Hard
[ "Graph", "Topological Sort", "Array", "Matrix" ]
You are given a positive integer k. You are also given: a 2D integer array rowConditions of size n where rowConditions[i] = [abovei, belowi], and a 2D integer array colConditions of size m where colConditions[i] = [lefti, righti]. The two arrays contain integers from 1 to k. You have to build a k x k matrix that cont...
buildMatrix(k: int, rowConditions: list_list_int, colConditions: list_list_int) -> list_list_int
pub fn build_matrix(k: i64, rowConditions: &[Vec<i64>], colConditions: &[Vec<i64>]) -> Vec<Vec<i64>>
Aegis.BuildMatrix.build_matrix
#[macro_export] macro_rules! vec { () => { ::std::vec::Vec::<::std::vec::Vec<i64>>::new() }; ($elem:expr; $n:expr) => { ::std::vec![$elem; $n] }; ($($x:expr),+ $(,)?) => {{ let mut __v = ::std::vec::Vec::new(); $( __v.push($x); )+ __v }}; } fn topo_sort(k...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [build_matrix]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter.s...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [build_matrix]: function definitions module public import Aeneas public import Aegis.BuildMatrix.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.BuildMatrix.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := 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], [3, 1], [2, 3]], [[2, 1]]]", "output": "[]" }, { "input": "[3, [[1, 2], [3, 2]], [[2, 1], [3, 2]]]", "output": "[[0, 0, 1], [3, 0, 0], [0, 2, 0]]" }, { "input": "[4, [[1, 2], [3, 4]], [[1, 3], [2, 4]]]", "output": "[[1, 0, 0, 0], [0, 0, 3, 0], [0, 2, ...
85
false
85
verified
10
10
3
89,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.BuildMatrix.Code.Funs /-! # Specifications of `Aegis.BuildMatrix.build_matrix` LeetCode problem `build-a-matrix-with-conditions`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.BuildMatrix abbrev Mat : Type := alloc.vec.Vec (alloc.vec....
11
count-strictly-increasing-subarrays
2,393
Medium
[ "Array", "Math", "Dynamic Programming" ]
You are given an array nums consisting of positive integers. Return the number of subarrays of nums that are in strictly increasing order. A subarray is a contiguous part of an array.   Example 1: Input: nums = [1,3,5,4,4,6] Output: 10 Explanation: The strictly increasing subarrays are the following: - Subarrays of le...
countSubarrays(nums: list_int) -> int
pub fn count_subarrays(nums: &[i64]) -> i64
Aegis.CountSubarrays.count_subarrays
pub fn count_subarrays(nums: &[i64]) -> i64 { let n = nums.len(); if n == 0 { return 0; } let mut ans: i64 = 1; let mut run: i64 = 1; let mut i: usize = 1; while i < n { if nums[i] > nums[i - 1] { run += 1; } else { run = 1; } ...
-- 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]]", "output": "1" }, { "input": "[[1, 2]]", "output": "3" }, { "input": "[[1, 2, 1, 2, 3]]", "output": "9" }, { "input": "[[1, 2, 3, 4, 5]]", "output": "15" }, { "input": "[[10, 9, 8, 7, 6]]", "output": "5" }, { "input": "[[1, 1, 1, 1, ...
126
false
126
verified
10
10
1
554
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.CountSubarrays.Code.Funs /-! # Specifications of `Aegis.CountSubarrays.count_subarrays` LeetCode problem `count-strictly-increasing-subarrays`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.CountSubarrays open Aegis.CountSubarrays (co...
11
find-subarrays-with-equal-sum
2,395
Easy
[ "Array", "Hash Table" ]
Given a 0-indexed integer array nums, determine whether there exist two subarrays of length 2 with equal sum. Note that the two subarrays must begin at different indices. Return true if these subarrays exist, and false otherwise. A subarray is a contiguous non-empty sequence of elements within an array.   Example 1: I...
findSubarrays(nums: list_int) -> bool
pub fn find_subarrays(nums: &[i64]) -> bool
Aegis.FindSubarrays.find_subarrays
pub fn find_subarrays(nums: &[i64]) -> bool { let n = nums.len(); let mut found: bool = false; let mut i: usize = 0; while i + 1 < n { let sum1 = nums[i] + nums[i + 1]; let mut j: usize = i + 1; while j + 1 < n { let sum2 = nums[j] + nums[j + 1]; if sum1 =...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [find_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 -- [find_subarrays]: function definitions module public import Aeneas public import Aegis.FindSubarrays.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.FindSubarrays.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval aegisCa...
[ { "input": "[[1000000000, 1000000000]]", "output": "false" }, { "input": "[[0, 0, 0]]", "output": "true" }, { "input": "[[4, 2, 4]]", "output": "true" }, { "input": "[[1, 1, 1, 1]]", "output": "true" }, { "input": "[[5, -1, 5, -1]]", "output": "true" }, { ...
119
false
119
verified
10
10
2
1,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.FindSubarrays.Code.Funs /-! # Specifications of `Aegis.FindSubarrays.find_subarrays` LeetCode problem `find-subarrays-with-equal-sum`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.FindSubarrays def elem (nums : Slice Std.I64) (i ...
10
strictly-palindromic-number
2,396
Medium
[ "Brainteaser", "Math", "Two Pointers" ]
An integer n is strictly palindromic if, for every base b between 2 and n - 2 (inclusive), the string representation of the integer n in base b is palindromic. Given an integer n, return true if n is strictly palindromic and false otherwise. A string is palindromic if it reads the same forward and backward.   Example 1...
isStrictlyPalindromic(n: int) -> bool
pub fn is_strictly_palindromic(n: i64) -> bool
Aegis.IsStrictlyPalindromic.is_strictly_palindromic
pub fn is_strictly_palindromic(n: i64) -> bool { let _ = n; false }
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [is_strictly_palindromic]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_opti...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [is_strictly_palindromic]: function definitions module public import Aeneas public import Aegis.IsStrictlyPalindromic.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashComma...
import Aegis.IsStrictlyPalindromic.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := 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": "[15]", "output": "false" }, { "input": "[4]", "output": "false" }, { "input": "[9]", "output": "false" }, { "input": "[6]", "output": "false" }, { "input": "[20]", "output": "false" }, { "input": "[100]", "output": "false" }, { ...
57
false
57
verified
10
10
1
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.IsStrictlyPalindromic.Code.Funs /-! # Specifications of `Aegis.IsStrictlyPalindromic.is_strictly_palindromic` LeetCode problem `strictly-palindromic-number`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.IsStrictlyPalindromic namespace Aegi...
5
maximum-rows-covered-by-columns
2,397
Medium
[ "Bit Manipulation", "Array", "Backtracking", "Enumeration", "Matrix" ]
You are given an m x n binary matrix matrix and an integer numSelect. Your goal is to select exactly numSelect distinct columns from matrix such that you cover as many rows as possible. A row is considered covered if all the 1's in that row are also part of a column that you have selected. If a row does not have any 1s...
maximumRows(matrix: list_list_int, numSelect: int) -> int
pub fn maximum_rows(matrix: &[Vec<i64>], numSelect: i64) -> i64
Aegis.MaximumRows.maximum_rows
pub fn maximum_rows(matrix: &[Vec<i64>], numSelect: i64) -> i64 { let m = matrix.len(); if m == 0 { return 0; } let n = matrix[0].len(); let mut total: i64 = 1; let mut t: usize = 0; while t < n { total = total * 2; t += 1; } let mut best: i64 = 0; let ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [maximum_rows]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter.s...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [maximum_rows]: function definitions module public import Aeneas public import Aegis.MaximumRows.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.MaximumRows.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval aegisCase...
[ { "input": "[[[1], [0]], 1]", "output": "2" }, { "input": "[[[0, 0], [0, 0]], 1]", "output": "2" }, { "input": "[[[0, 0], [0, 0], [1, 1]], 2]", "output": "3" }, { "input": "[[[1, 1], [0, 0], [1, 0], [0, 1]], 1]", "output": "2" }, { "input": "[[[1, 1, 1], [0, 1, 1]...
99
false
99
verified
10
10
1
2,146
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MaximumRows.Code.Funs /-! # Specifications of `Aegis.MaximumRows.maximum_rows` LeetCode problem `maximum-rows-covered-by-columns`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.MaximumRows open Classical def rowsOf (matrix : Sl...
13
maximum-number-of-robots-within-budget
2,398
Hard
[ "Queue", "Array", "Binary Search", "Prefix Sum", "Sliding Window", "Monotonic Queue", "Heap (Priority Queue)" ]
You have n robots. You are given two 0-indexed integer arrays, chargeTimes and runningCosts, both of length n. The ith robot costs chargeTimes[i] units to charge and costs runningCosts[i] units to run. You are also given an integer budget. The total cost of running k chosen robots is equal to max(chargeTimes) + k * sum...
maximumRobots(chargeTimes: list_int, runningCosts: list_int, budget: int) -> int
pub fn maximum_robots(chargeTimes: &[i64], runningCosts: &[i64], budget: i64) -> i64
Aegis.MaximumRobots.maximum_robots
pub fn maximum_robots(chargeTimes: &[i64], runningCosts: &[i64], budget: i64) -> i64 { let n = chargeTimes.len(); if n == 0 { return 0; } let mut left: usize = 0; let mut right: usize = 0; let mut sum_running: i64 = 0; let mut best: i64 = 0; // Stores indices of chargeTimes in ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [maximum_robots]: type definitions module public import Aeneas @[expose] public section 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_robots]: function definitions module public import Aeneas public import Aegis.MaximumRobots.Code.Types public import Aegis.MaximumRobots.Code.FunsExternal @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespac...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [maximum_robots]: external functions. -- This is a template file: rename it to "FunsExternal.lean" and fill the holes. module public import Aeneas public import Aegis.MaximumRobots.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error s...
import Aegis.MaximumRobots.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := 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": "[[100000, 100000, 100000], [1, 1, 1], 300001]", "output": "3" }, { "input": "[[11, 12, 19], [10, 8, 7], 19]", "output": "0" }, { "input": "[[1, 2, 3], [10, 20, 30], 100]", "output": "2" }, { "input": "[[100000, 100000, 100000], [100000, 100000, 100000], 1000000000...
108
false
108
verified
10
10
1
5,365
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MaximumRobots.Code.Funs /-! # Specifications of `Aegis.MaximumRobots.maximum_robots` LeetCode problem `maximum-number-of-robots-within-budget`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result Aegis.MaximumRobots namespace AegisSpec.MaximumRobots def nthVal...
12
number-of-ways-to-reach-a-position-after-exactly-k-steps
2,400
Medium
[ "Math", "Dynamic Programming", "Combinatorics" ]
You are given two positive integers startPos and endPos. Initially, you are standing at position startPos on an infinite number line. With one step, you can move either one position to the left, or one position to the right. Given a positive integer k, return the number of different ways to reach the position endPos st...
numberOfWays(startPos: int, endPos: int, k: int) -> int
pub fn number_of_ways(startPos: i64, endPos: i64, k: i64) -> i64
Aegis.NumberOfWays.number_of_ways
pub fn number_of_ways(startPos: i64, endPos: i64, k: i64) -> i64 { let md: i64 = 1000000007; if k < 0 { return 0; } let k_usize = k as usize; let n = k_usize * 2 + 1; let mut dp: Vec<i64> = Vec::new(); let mut i = 0; while i < n { dp.push(0); i += 1; } ...
-- 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": "[1, 2, 3]", "output": "3" }, { "input": "[5, 5, 0]", "output": "1" }, { "input": "[0, 0, 2]", "output": "2" }, { "input": "[10, 1, 15]", "output": "455" }, { "input": "[5, 5, 10]", "output": "252" }, { "input": "[10, 1, 9]", "output": "...
39
false
39
verified
10
10
1
2,354
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": 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-a-position-after-exactly-k-steps`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.NumberOfWays open Aegis.Numb...
9
longest-nice-subarray
2,401
Medium
[ "Bit Manipulation", "Array", "Sliding Window" ]
You are given an array nums consisting of positive integers. We call a subarray of nums nice if the bitwise AND of every pair of elements that are in different positions in the subarray is equal to 0. Return the length of the longest nice subarray. A subarray is a contiguous part of an array. Note that subarrays of len...
longestNiceSubarray(nums: list_int) -> int
pub fn longest_nice_subarray(nums: &[i64]) -> i64
Aegis.LongestNiceSubarray.longest_nice_subarray
pub fn longest_nice_subarray(nums: &[i64]) -> i64 { let n = nums.len(); if n == 0 { return 0; } let mut left: usize = 0; let mut right: usize = 0; let mut used: i64 = 0; let mut best: i64 = 0; while right < n { let x = nums[right]; while (used & x) != 0 { ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [longest_nice_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...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [longest_nice_subarray]: function definitions module public import Aeneas public import Aegis.LongestNiceSubarray.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand f...
import Aegis.LongestNiceSubarray.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := 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": "1" }, { "input": "[[3, 1, 5, 11, 13]]", "output": "1" }, { "input": "[[31, 1, 4, 32, 16]]", "output": "4" }, { "input": "[[1, 2, 4, 8, 16]]", "output": "5" }, { "input": "[[7, 14, 28, 56, 112]]", "output": "1" }, { "input...
115
false
115
verified
10
10
1
945
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.LongestNiceSubarray.Code.Funs /-! # Specifications of `Aegis.LongestNiceSubarray.longest_nice_subarray` LeetCode problem `longest-nice-subarray`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.LongestNiceSubarray def len (nums : Slice ...
10
minimum-time-to-kill-all-monsters
2,403
Hard
[ "Bit Manipulation", "Array", "Dynamic Programming", "Bitmask" ]
You are given an integer array power where power[i] is the power of the ith monster. You start with 0 mana points, and each day you increase your mana points by gain where gain initially is equal to 1. Each day, after gaining gain mana, you can defeat a monster if your mana points are greater than or equal to the power...
minimumTime(power: list_int) -> int
pub fn minimum_time(power: &[i64]) -> i64
Aegis.MinimumTime.minimum_time
pub fn minimum_time(power: &[i64]) -> i64 { let n: usize = power.len(); let total: usize = 1usize << n; let inf: i64 = 1_000_000_000_000_000_000; let mut dp: Vec<i64> = Vec::new(); let mut idx: usize = 0; while idx < total { dp.push(inf); idx += 1; } dp[0] = 0; let ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [minimum_time]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter.s...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [minimum_time]: function definitions module public import Aeneas public import Aegis.MinimumTime.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option l...
import Aegis.MinimumTime.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval aegisCase...
[ { "input": "[[17]]", "output": "17" }, { "input": "[[1]]", "output": "1" }, { "input": "[[1, 1000000000]]", "output": "500000001" }, { "input": "[[10, 20, 30]]", "output": "30" }, { "input": "[[1, 1, 4]]", "output": "4" }, { "input": "[[3, 1, 4]]", ...
92
false
92
verified
10
10
1
2,685
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MinimumTime.Code.Funs /-! # Specifications of `Aegis.MinimumTime.minimum_time` LeetCode problem `minimum-time-to-kill-all-monsters`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.MinimumTime namespace AegisSpec.MinimumTime def ceilDiv (a...
13
most-frequent-even-element
2,404
Easy
[ "Array", "Hash Table", "Counting" ]
Given an integer array nums, return the most frequent even element. If there is a tie, return the smallest one. If there is no such element, return -1.   Example 1: Input: nums = [0,1,2,2,4,4,1] Output: 2 Explanation: The even elements are 0, 2, and 4. Of these, 2 and 4 appear the most. We return the smallest one, whi...
mostFrequentEven(nums: list_int) -> int
pub fn most_frequent_even(nums: &[i64]) -> i64
Aegis.MostFrequentEven.most_frequent_even
pub fn most_frequent_even(nums: &[i64]) -> i64 { let n = nums.len(); let mut best_val: i64 = -1; let mut best_count: i64 = 0; let mut i: usize = 0; while i < n { let x = nums[i]; if x % 2 == 0 { let mut cnt: i64 = 0; let mut j: usize = 0; while j...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [most_frequent_even]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option li...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [most_frequent_even]: function definitions module public import Aeneas public import Aegis.MostFrequentEven.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.MostFrequentEven.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := 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": "[[2]]", "output": "2" }, { "input": "[[0]]", "output": "0" }, { "input": "[[1, 3, 5, 7, 9]]", "output": "-1" }, { "input": "[[0, 0, 0, 0, 0]]", "output": "0" }, { "input": "[[100000, 100000, 99998, 99998, 99996]]", "output": "99998" }, { "i...
110
false
110
verified
10
10
1
1,847
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MostFrequentEven.Code.Funs /-! # Specifications of `Aegis.MostFrequentEven.most_frequent_even` LeetCode problem `most-frequent-even-element`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.MostFrequentEven def occ (l : List (Std.I64)) ...
10
optimal-partition-of-string
2,405
Medium
[ "Greedy", "Hash Table", "String" ]
Given a string s, partition the string into one or more substrings such that the characters in each substring are unique. That is, no letter appears in a single substring more than once. Return the minimum number of substrings in such a partition. Note that each character should belong to exactly one substring in a par...
partitionString(s: str) -> int
pub fn partition_string(s: &[u8]) -> i64
Aegis.PartitionString.partition_string
pub fn partition_string(s: &[u8]) -> i64 { let n = s.len(); if n == 0 { return 0; } let mut seen: Vec<bool> = Vec::new(); let mut k: usize = 0; while k < 26 { seen.push(false); k += 1; } let mut count: i64 = 1; let mut i: usize = 0; while i < n { ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [partition_string]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option lint...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [partition_string]: function definitions module public import Aeneas public import Aegis.PartitionString.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.PartitionString.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := 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": "[\"abcdefg\"]", "output": "1" }, { "input": "[\"abac\"]", "output": "2" }, { "input": "[\"abcdabcdeabcdefabcdefg\"]", "output": "4" }, { "input": "[\"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\"]", "output": "44" }, { "input": "[\"abababab\"]", "...
103
false
103
verified
10
10
1
894
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.PartitionString.Code.Funs /-! # Specifications of `Aegis.PartitionString.partition_string` LeetCode problem `optimal-partition-of-string`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.PartitionString def contents (s : Slice Std.U8) :...
14
longest-increasing-subsequence-ii
2,407
Hard
[ "Binary Indexed Tree", "Segment Tree", "Queue", "Array", "Divide and Conquer", "Dynamic Programming", "Monotonic Queue" ]
You are given an integer array nums and an integer k. Find the longest subsequence of nums that meets the following requirements: The subsequence is strictly increasing and The difference between adjacent elements in the subsequence is at most k. Return the length of the longest subsequence that meets the requirement...
lengthOfLIS(nums: list_int, k: int) -> int
pub fn length_of_lis(nums: &[i64], k: i64) -> i64
Aegis.LengthOfLis.length_of_lis
pub fn length_of_lis(nums: &[i64], k: i64) -> i64 { let n = nums.len(); if n == 0 { return 0; } let mut max_v: i64 = 0; let mut i: usize = 0; while i < n { if nums[i] > max_v { max_v = nums[i]; } i += 1; } let target: usize = (max_v as usize)...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [length_of_lis]: type definitions module public import Aeneas @[expose] public section 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 -- [length_of_lis]: function definitions module public import Aeneas public import Aegis.LengthOfLis.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.LengthOfLis.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval aegisCase...
[ { "input": "[[1, 5], 1]", "output": "1" }, { "input": "[[5, 4, 3, 2, 1], 2]", "output": "1" }, { "input": "[[5, 4, 3, 2, 1], 1]", "output": "1" }, { "input": "[[9, 7, 5, 3, 1], 2]", "output": "1" }, { "input": "[[1, 3, 5, 7, 9], 2]", "output": "5" }, { ...
110
false
110
verified
10
10
1
6,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.LengthOfLis.Code.Funs /-! # Specifications of `Aegis.LengthOfLis.length_of_lis` LeetCode problem `longest-increasing-subsequence-ii`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.LengthOfLis def valueAt (nums : List Std.I64) (i :...
14
count-days-spent-together
2,409
Easy
[ "Math", "String" ]
Alice and Bob are traveling to Rome for separate business meetings. You are given 4 strings arriveAlice, leaveAlice, arriveBob, and leaveBob. Alice will be in the city from the dates arriveAlice to leaveAlice (inclusive), while Bob will be in the city from the dates arriveBob to leaveBob (inclusive). Each will be a 5-c...
countDaysTogether(arriveAlice: str, leaveAlice: str, arriveBob: str, leaveBob: str) -> int
pub fn count_days_together(arriveAlice: &[u8], leaveAlice: &[u8], arriveBob: &[u8], leaveBob: &[u8]) -> i64
Aegis.CountDaysTogether.count_days_together
fn days_before_month(month: i64) -> i64 { if month <= 1 { 0 } else if month == 2 { 31 } else if month == 3 { 59 } else if month == 4 { 90 } else if month == 5 { 120 } else if month == 6 { 151 } else if month == 7 { 181 } else if mon...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [count_days_together]: type definitions module public import Aeneas @[expose] public section 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_days_together]: function definitions module public import Aeneas public import Aegis.CountDaysTogether.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false...
import Aegis.CountDaysTogether.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := 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": "[\"03-10\", \"05-20\", \"04-01\", \"04-30\"]", "output": "30" }, { "input": "[\"06-15\", \"06-20\", \"06-18\", \"06-25\"]", "output": "3" }, { "input": "[\"10-01\", \"10-31\", \"11-01\", \"12-31\"]", "output": "0" }, { "input": "[\"01-01\", \"12-31\", \"01-01\", \...
116
false
116
verified
10
10
1
2,460
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.CountDaysTogether.Code.Funs /-! # Specifications of `Aegis.CountDaysTogether.count_days_together` LeetCode problem `count-days-spent-together`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.CountDaysTogether open Aegis.CountDaysTogeth...
13
maximum-matching-of-players-with-trainers
2,410
Medium
[ "Greedy", "Array", "Two Pointers", "Sorting" ]
You are given a 0-indexed integer array players, where players[i] represents the ability of the ith player. You are also given a 0-indexed integer array trainers, where trainers[j] represents the training capacity of the jth trainer. The ith player can match with the jth trainer if the player's ability is less than or ...
matchPlayersAndTrainers(players: list_int, trainers: list_int) -> int
pub fn match_players_and_trainers(players: &[i64], trainers: &[i64]) -> i64
Aegis.MatchPlayersAndTrainers.match_players_and_trainers
fn sort_copy(xs: &[i64]) -> Vec<i64> { let mut v: Vec<i64> = Vec::new(); let mut k: usize = 0; while k < xs.len() { v.push(xs[k]); k = k + 1; } let n = v.len(); let mut i: usize = 1; while i < n { let key = v[i]; let mut j: usize = i; while j > 0 && v...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [match_players_and_trainers]: type definitions module public import Aeneas @[expose] public 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 -- [match_players_and_trainers]: function definitions module public import Aeneas public import Aegis.MatchPlayersAndTrainers.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hash...
import Aegis.MatchPlayersAndTrainers.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO 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": "[[1000000000], [1000000000]]", "output": "1" }, { "input": "[[1], [1]]", "output": "1" }, { "input": "[[1, 1000000000], [1000000000, 1]]", "output": "2" }, { "input": "[[1, 1, 1], [10]]", "output": "1" }, { "input": "[[1000000000, 1000000000, 100000000...
120
false
120
verified
10
10
1
1,621
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MatchPlayersAndTrainers.Code.Funs /-! # Specifications of `Aegis.MatchPlayersAndTrainers.match_players_and_trainers` LeetCode problem `maximum-matching-of-players-with-trainers`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.MatchPla...
15
smallest-subarrays-with-maximum-bitwise-or
2,411
Medium
[ "Bit Manipulation", "Array", "Binary Search", "Sliding Window" ]
You are given a 0-indexed array nums of length n, consisting of non-negative integers. For each index i from 0 to n - 1, you must determine the size of the minimum sized non-empty subarray of nums starting at i (inclusive) that has the maximum possible bitwise OR. In other words, let Bij be the bitwise OR of the subar...
smallestSubarrays(nums: list_int) -> list_int
pub fn smallest_subarrays(nums: &[i64]) -> Vec<i64>
Aegis.SmallestSubarrays.smallest_subarrays
pub fn smallest_subarrays(nums: &[i64]) -> Vec<i64> { let n = nums.len(); let bits = 64usize; let mut pos: Vec<i64> = Vec::new(); let mut b = 0usize; while b < bits { pos.push(-1); b += 1; } let mut ans: Vec<i64> = Vec::new(); let mut k = 0usize; while k < n { ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [smallest_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 li...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [smallest_subarrays]: function definitions module public import Aeneas public import Aegis.SmallestSubarrays.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false ...
import Aegis.SmallestSubarrays.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := 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, 2]]", "output": "[2, 1]" }, { "input": "[[1073741823, 1073741823, 1073741823]]", "output": "[1, 1, 1]" }, { "input": "[[8, 4, 2, 1]]", "output": "[4, 3, 2, 1]" }, { "input": "[[0, 0, 0, 0]]", "output": "[1, 1, 1, 1]" }, { "input": "[[8, 16, 32, 64...
102
false
102
verified
10
10
1
4,505
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.SmallestSubarrays.Code.Funs /-! # Specifications of `Aegis.SmallestSubarrays.smallest_subarrays` LeetCode problem `smallest-subarrays-with-maximum-bitwise-or`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.SmallestSubarrays def va...
12
minimum-money-required-before-transactions
2,412
Hard
[ "Greedy", "Array", "Sorting" ]
You are given a 0-indexed 2D integer array transactions, where transactions[i] = [costi, cashbacki]. The array describes transactions, where each transaction must be completed exactly once in some order. At any given moment, you have a certain amount of money. In order to complete transaction i, money >= costi must hol...
minimumMoney(transactions: list_list_int) -> int
pub fn minimum_money(transactions: &[Vec<i64>]) -> i64
Aegis.MinimumMoney.minimum_money
pub fn minimum_money(transactions: &[Vec<i64>]) -> i64 { let n: usize = transactions.len(); let mut total_loss: i64 = 0; let mut max_min: i64 = 0; let mut i: usize = 0; while i < n { let cost: i64 = transactions[i][0]; let cashback: i64 = transactions[i][1]; let diff: i64 =...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [minimum_money]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter....
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [minimum_money]: function definitions module public import Aeneas public import Aegis.MinimumMoney.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.MinimumMoney.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval aegisCas...
[ { "input": "[[[1000000000, 0], [0, 1000000000]]]", "output": "1000000000" }, { "input": "[[[3, 0], [0, 3]]]", "output": "3" }, { "input": "[[[1000000000, 500000000], [500000000, 250000000]]]", "output": "1250000000" }, { "input": "[[[1000000000, 0], [0, 1000000000]]]", "o...
109
false
109
verified
10
10
1
1,542
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MinimumMoney.Code.Funs /-! # Specifications of `Aegis.MinimumMoney.minimum_money` LeetCode problem `minimum-money-required-before-transactions`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.MinimumMoney open Aegis.MinimumMoney def e...
10
smallest-even-multiple
2,413
Easy
[ "Math", "Number Theory" ]
Given a positive integer n, return the smallest positive integer that is a multiple of both 2 and n.   Example 1: Input: n = 5 Output: 10 Explanation: The smallest multiple of both 5 and 2 is 10. Example 2: Input: n = 6 Output: 6 Explanation: The smallest multiple of both 6 and 2 is 6. Note that a number is a multip...
smallestEvenMultiple(n: int) -> int
pub fn smallest_even_multiple(n: i64) -> i64
Aegis.SmallestEvenMultiple.smallest_even_multiple
pub fn smallest_even_multiple(n: i64) -> i64 { if n % 2 == 0 { n } else { n * 2 } }
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [smallest_even_multiple]: type definitions module public import Aeneas @[expose] public 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 -- [smallest_even_multiple]: function definitions module public import Aeneas public import Aegis.SmallestEvenMultiple.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand...
import Aegis.SmallestEvenMultiple.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := 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]", "output": "6" }, { "input": "[100]", "output": "100" }, { "input": "[33]", "output": "66" }, { "input": "[75]", "output": "150" }, { "input": "[6]", "output": "6" }, { "input": "[2]", "output": "2" }, { "input": "[1]", ...
91
false
91
verified
10
10
1
59
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.SmallestEvenMultiple.Code.Funs /-! # Specifications of `Aegis.SmallestEvenMultiple.smallest_even_multiple` LeetCode problem `smallest-even-multiple`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.SmallestEvenMultiple /-- Whenever smal...
9
length-of-the-longest-alphabetical-continuous-substring
2,414
Medium
[ "String" ]
An alphabetical continuous string is a string consisting of consecutive letters in the alphabet. In other words, it is any substring of the string "abcdefghijklmnopqrstuvwxyz". For example, "abc" is an alphabetical continuous string, while "acb" and "za" are not. Given a string s consisting of lowercase letters only,...
longestContinuousSubstring(s: str) -> int
pub fn longest_continuous_substring(s: &[u8]) -> i64
Aegis.LongestContinuousSubstring.longest_continuous_substring
pub fn longest_continuous_substring(s: &[u8]) -> i64 { let n = s.len(); if n == 0 { return 0; } let mut best: i64 = 1; let mut cur: i64 = 1; let mut i: usize = 1; while i < n { if (s[i] as i64) == (s[i - 1] as i64) + 1 { cur = cur + 1; if cur > best ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [longest_continuous_substring]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [longest_continuous_substring]: function definitions module public import Aeneas public import Aegis.LongestContinuousSubstring.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter...
import Aegis.LongestContinuousSubstring.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO 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": "[\"zzzzzzzzz\"]", "output": "1" }, { "input": "[\"abxyz\"]", "output": "3" }, { "input": "[\"qrstuvwpqrstu\"]", "output": "7" }, { "input": "[\"mnopqrstuvwxyzz\"]", "output": "14" }, { "input": "[\"abcdefghijklmnopqrstuvwxyz\"]", "output": "26" }...
115
false
115
verified
10
10
1
651
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.LongestContinuousSubstring.Code.Funs /-! # Specifications of `Aegis.LongestContinuousSubstring.longest_continuous_substring` LeetCode problem `length-of-the-longest-alphabetical-continuous-substring`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namesp...
12
reverse-odd-levels-of-binary-tree
2,415
Medium
[ "Tree", "Depth-First Search", "Breadth-First Search", "Binary Tree" ]
Given the root of a perfect binary tree, reverse the node values at each odd level of the tree. For example, suppose the node values at level 3 are [2,1,3,4,7,11,29,18], then it should become [18,29,11,7,4,3,1,2]. Return the root of the reversed tree. A binary tree is perfect if all parent nodes have two children and...
reverseOddLevels(root: tree) -> tree
pub fn reverse_odd_levels(root: &Tree) -> Tree
Aegis.ReverseOddLevels.reverse_odd_levels
fn collect(t: &Tree, depth: usize, levels: &mut Vec<Vec<i64>>) { match t { Tree::Null => {} Tree::Node(v, l, r) => { while levels.len() <= depth { levels.push(Vec::new()); } levels[depth].push(*v); collect(&**l, depth + 1, levels); ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [reverse_odd_levels]: type definitions module public import Aeneas @[expose] public section 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 -- [reverse_odd_levels]: function definitions module public import Aeneas public import Aegis.ReverseOddLevels.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.ReverseOddLevels.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" deriving i...
[ { "input": "[[7, 13, 11]]", "output": "[7, 11, 13]" }, { "input": "[[2, 3, 5, 8, 13, 21, 34]]", "output": "[2, 5, 3, 8, 13, 21, 34]" }, { "input": "[[0, 1, 2, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2]]", "output": "[0, 2, 1, 0, 0, 0, 0, 2, 2, 2, 2, 1, 1, 1, 1]" }, { "input": "[[5, ...
16
false
16
verified
10
10
2
18,880
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.ReverseOddLevels.Code.Funs /-! # Specifications of `Aegis.ReverseOddLevels.reverse_odd_levels` LeetCode problem `reverse-odd-levels-of-binary-tree`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.ReverseOddLevels namespace AegisSpec.ReverseOddLe...
13
sum-of-prefix-scores-of-strings
2,416
Hard
[ "Trie", "Array", "String", "Counting" ]
You are given an array words of size n consisting of non-empty strings. We define the score of a string term as the number of strings words[i] such that term is a prefix of words[i]. For example, if words = ["a", "ab", "abc", "cab"], then the score of "ab" is 2, since "ab" is a prefix of both "ab" and "abc". Return a...
sumPrefixScores(words: list_str) -> list_int
pub fn sum_prefix_scores(words: &[Vec<u8>]) -> Vec<i64>
Aegis.SumPrefixScores.sum_prefix_scores
pub fn sum_prefix_scores(words: &[Vec<u8>]) -> Vec<i64> { let n = words.len(); // Flattened trie representation: // children[node * 26 + letter] = child node index, or -1 if absent. let mut children: Vec<i64> = Vec::new(); let mut counts: Vec<i64> = Vec::new(); // Create root node 0. let m...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [sum_prefix_scores]: type definitions module public import Aeneas @[expose] public section 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 -- [sum_prefix_scores]: function definitions module public import Aeneas public import Aegis.SumPrefixScores.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.SumPrefixScores.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := 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": "[[\"abcd\"]]", "output": "[4]" }, { "input": "[[\"xyz\", \"xy\", \"x\"]]", "output": "[6, 5, 3]" }, { "input": "[[\"aaaa\", \"aa\", \"a\"]]", "output": "[7, 5, 3]" }, { "input": "[[\"hello\", \"hell\", \"he\", \"h\"]]", "output": "[12, 11, 7, 4]" }, { ...
96
false
96
verified
10
10
1
3,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.SumPrefixScores.Code.Funs /-! # Specifications of `Aegis.SumPrefixScores.sum_prefix_scores` LeetCode problem `sum-of-prefix-scores-of-strings`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.SumPrefixScores abbrev Word := alloc.vec...
7
closest-fair-integer
2,417
Medium
[ "Math", "Enumeration" ]
You are given a positive integer n. We call an integer k fair if the number of even digits in k is equal to the number of odd digits in it. Return the smallest fair integer that is greater than or equal to n.   Example 1: Input: n = 2 Output: 10 Explanation: The smallest fair integer that is greater than or equal to 2...
closestFair(n: int) -> int
pub fn closest_fair(n: i64) -> i64
Aegis.ClosestFair.closest_fair
fn exists_ge(pos: usize, need_odd: i64, nd: &[i64], l: usize) -> bool { if pos > l { return false; } if need_odd < 0 { return false; } if need_odd > (l - pos) as i64 { return false; } if pos == l { return need_odd == 0; } let mut result = false; ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [closest_fair]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter.s...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [closest_fair]: function definitions module public import Aeneas public import Aegis.ClosestFair.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.ClosestFair.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval aegisCase...
[ { "input": "[100000]", "output": "100011" }, { "input": "[100]", "output": "1001" }, { "input": "[2222222]", "output": "10000111" }, { "input": "[13579]", "output": "100011" }, { "input": "[999999999]", "output": "1000001111" }, { "input": "[11]", ...
67
false
67
verified
10
10
2
27,257
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.ClosestFair.Code.Funs import Mathlib.Data.Nat.Digits.Defs /-! # Specifications of `Aegis.ClosestFair.closest_fair` LeetCode problem `closest-fair-integer`. Each `spec_<n>` theorem states one property of the function. -/ namespace AegisSpec.ClosestFair open Aeneas Aeneas.Std Result def digitsOf (n : Na...
10
sort-the-people
2,418
Easy
[ "Array", "Hash Table", "String", "Sorting" ]
You are given an array of strings names, and an array heights that consists of distinct positive integers. Both arrays are of length n. For each index i, names[i] and heights[i] denote the name and height of the ith person. Return names sorted in descending order by the people's heights.   Example 1: Input: names = ["...
sortPeople(names: list_str, heights: list_int) -> list_str
pub fn sort_people(names: &[Vec<u8>], heights: &[i64]) -> Vec<Vec<u8>>
Aegis.SortPeople.sort_people
fn build_order(heights: &[i64]) -> Vec<i64> { let n: usize = heights.len(); // Copy heights into an owned vec and build the identity index permutation. let mut h: Vec<i64> = Vec::new(); let mut order: Vec<i64> = Vec::new(); let mut i: usize = 0; while i < n { h.push(heights[i]); ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [sort_people]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter.st...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [sort_people]: function definitions module public import Aeneas public import Aegis.SortPeople.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.SortPeople.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := 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": "[[\"Zoe\", \"Lily\", \"Rose\"], [150, 145, 155]]", "output": "[\"Rose\", \"Zoe\", \"Lily\"]" }, { "input": "[[\"Qwen\", \"Alibaba\", \"Cloud\"], [200, 190, 180]]", "output": "[\"Qwen\", \"Alibaba\", \"Cloud\"]" }, { "input": "[[\"Ava\", \"Sophia\", \"Isabella\"], [160, 165, 1...
120
false
120
verified
10
10
2
17,022
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.SortPeople.Code.Funs /-! # Specifications of `Aegis.SortPeople.sort_people` LeetCode problem `sort-the-people`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.SortPeople open Aegis.SortPeople (sort_people) def isLetterByte (b : ...
8
longest-subarray-with-maximum-bitwise-and
2,419
Medium
[ "Bit Manipulation", "Brainteaser", "Array" ]
You are given an integer array nums of size n. Consider a non-empty subarray from nums that has the maximum possible bitwise AND. In other words, let k be the maximum value of the bitwise AND of any subarray of nums. Then, only subarrays with a bitwise AND equal to k should be considered. Return the length of the lon...
longestSubarray(nums: list_int) -> int
pub fn longest_subarray(nums: &[i64]) -> i64
Aegis.LongestSubarray.longest_subarray
pub fn longest_subarray(nums: &[i64]) -> i64 { let n = nums.len(); if n == 0 { return 0; } let mut max_val = nums[0]; let mut i = 1; while i < n { if nums[i] > max_val { max_val = nums[i]; } i += 1; } let mut best = 0; let mut cur = 0; ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [longest_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 lint...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [longest_subarray]: function definitions module public import Aeneas public import Aegis.LongestSubarray.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.LongestSubarray.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval aegis...
[ { "input": "[[1]]", "output": "1" }, { "input": "[[1, 2, 3, 4]]", "output": "1" }, { "input": "[[1048575, 1048575, 1048575, 1048575]]", "output": "4" }, { "input": "[[1048576, 1048576, 1048576, 1048575, 1048574]]", "output": "3" }, { "input": "[[5, 5, 5, 5, 5]]", ...
42
false
42
verified
10
10
1
1,350
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.LongestSubarray.Code.Funs /-! # Specifications of `Aegis.LongestSubarray.longest_subarray` LeetCode problem `longest-subarray-with-maximum-bitwise-and`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.LongestSubarray def elem (nums ...
12
find-all-good-indices
2,420
Medium
[ "Array", "Dynamic Programming", "Prefix Sum" ]
You are given a 0-indexed integer array nums of size n and a positive integer k. We call an index i in the range k <= i < n - k good if the following conditions are satisfied: The k elements that are just before the index i are in non-increasing order. The k elements that are just after the index i are in non-decreasi...
goodIndices(nums: list_int, k: int) -> list_int
pub fn good_indices(nums: &[i64], k: i64) -> Vec<i64>
Aegis.GoodIndices.good_indices
pub fn good_indices(nums: &[i64], k: i64) -> Vec<i64> { let n = nums.len(); let kk = k as usize; // left[i] = length of the longest non-increasing contiguous subarray ending at i. let mut left: Vec<i64> = Vec::new(); let mut i = 0; while i < n { if i == 0 { left.push(1); ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [good_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 -- [good_indices]: function definitions module public import Aeneas public import Aegis.GoodIndices.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.GoodIndices.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := 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, 1, 2], 2]", "output": "[]" }, { "input": "[[1, 2, 3, 4, 3, 2, 1], 2]", "output": "[]" }, { "input": "[[5, 4, 3, 4, 5], 1]", "output": "[1, 2, 3]" }, { "input": "[[1000000, 999999, 999998, 999997, 999996, 999995, 999994, 999993, 999992], 3]", "output": ...
101
false
101
verified
10
10
1
3,487
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.GoodIndices.Code.Funs /-! # Specifications of `Aegis.GoodIndices.good_indices` LeetCode problem `find-all-good-indices`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result ControlFlow Error open Aegis.GoodIndices (good_indices) namespace AegisSpec.GoodIndices ...
14
number-of-good-paths
2,421
Hard
[ "Tree", "Union Find", "Graph", "Array", "Hash Table", "Sorting" ]
There is a tree (i.e. a connected, undirected graph with no cycles) consisting of n nodes numbered from 0 to n - 1 and exactly n - 1 edges. You are given a 0-indexed integer array vals of length n where vals[i] denotes the value of the ith node. You are also given a 2D integer array edges where edges[i] = [ai, bi] deno...
numberOfGoodPaths(vals: list_int, edges: list_list_int) -> int
pub fn number_of_good_paths(vals: &[i64], edges: &[Vec<i64>]) -> i64
Aegis.NumberOfGoodPaths.number_of_good_paths
pub fn number_of_good_paths(vals: &[i64], edges: &[Vec<i64>]) -> i64 { let n = vals.len(); if n == 0 { return 0; } // Build adjacency list. let mut adj: Vec<Vec<i64>> = Vec::new(); let mut i = 0; while i < n { let row: Vec<i64> = Vec::new(); adj.push(row); i ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [number_of_good_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 ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [number_of_good_paths]: function definitions module public import Aeneas public import Aegis.NumberOfGoodPaths.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand fals...
import Aegis.NumberOfGoodPaths.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval aeg...
[ { "input": "[[1], []]", "output": "1" }, { "input": "[[2, 2, 2, 2], [[0, 1], [1, 2], [2, 3]]]", "output": "10" }, { "input": "[[10, 10, 10, 10], [[0, 1], [1, 2], [2, 3]]]", "output": "10" }, { "input": "[[2, 2, 2, 2, 2], [[0, 1], [1, 2], [2, 3], [3, 4]]]", "output": "15" ...
82
false
82
verified
10
10
1
13,468
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.NumberOfGoodPaths.Code.Funs /-! # Specifications of `Aegis.NumberOfGoodPaths.number_of_good_paths` LeetCode problem `number-of-good-paths`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result ControlFlow Error open Aegis.NumberOfGoodPaths namespace AegisSpec.Nu...
12
merge-operations-to-turn-array-into-a-palindrome
2,422
Medium
[ "Greedy", "Array", "Two Pointers" ]
You are given an array nums consisting of positive integers. You can perform the following operation on the array any number of times: Choose any two adjacent elements and replace them with their sum. For example, if nums = [1,2,3,1], you can apply one operation to make it [1,5,1]. Return the minimum number of o...
minimumOperations(nums: list_int) -> int
pub fn minimum_operations(nums: &[i64]) -> i64
Aegis.MinimumOperations.minimum_operations
pub fn minimum_operations(nums: &[i64]) -> i64 { let n = nums.len(); if n == 0 { return 0; } let mut left: usize = 0; let mut right: usize = n - 1; let mut left_sum: i64 = nums[left]; let mut right_sum: i64 = nums[right]; let mut operations: i64 = 0; while left < right { ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [minimum_operations]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option li...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [minimum_operations]: function definitions module public import Aeneas public import Aegis.MinimumOperations.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false ...
import Aegis.MinimumOperations.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval aeg...
[ { "input": "[[1]]", "output": "0" }, { "input": "[[1, 2]]", "output": "1" }, { "input": "[[1, 2, 2, 1]]", "output": "0" }, { "input": "[[1, 2, 3, 4]]", "output": "3" }, { "input": "[[1, 3, 3, 1]]", "output": "0" }, { "input": "[[5, 3, 3, 5]]", "out...
103
false
103
verified
10
10
1
1,166
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MinimumOperations.Code.Funs /-! # Specifications of `Aegis.MinimumOperations.minimum_operations` LeetCode problem `merge-operations-to-turn-array-into-a-palindrome`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.MinimumOperations namespace Aegi...
13
remove-letter-to-equalize-frequency
2,423
Easy
[ "Hash Table", "String", "Counting" ]
You are given a 0-indexed string word, consisting of lowercase English letters. You need to select one index and remove the letter at that index from word so that the frequency of every letter present in word is equal. Return true if it is possible to remove one letter so that the frequency of all letters in word are e...
equalFrequency(word: str) -> bool
pub fn equal_frequency(word: &[u8]) -> bool
Aegis.EqualFrequency.equal_frequency
pub fn equal_frequency(word: &[u8]) -> bool { let n = word.len(); let mut remove_at: usize = 0; while remove_at < n { let mut counts: Vec<i64> = Vec::new(); let mut k: usize = 0; while k < 26 { counts.push(0); k += 1; } let mut i: usize = 0; ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [equal_frequency]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linte...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [equal_frequency]: function definitions module public import Aeneas public import Aegis.EqualFrequency.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.EqualFrequency.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := 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": "[\"aabbccd\"]", "output": "true" }, { "input": "[\"aaabbbccc\"]", "output": "false" }, { "input": "[\"zazaza\"]", "output": "false" }, { "input": "[\"aaaaabbbbbcccc\"]", "output": "false" }, { "input": "[\"zzzzzzzz\"]", "output": "true" }, { ...
74
false
74
verified
10
10
1
1,686
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.EqualFrequency.Code.Funs /-! # Specifications of `Aegis.EqualFrequency.equal_frequency` LeetCode problem `remove-letter-to-equalize-frequency`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.EqualFrequency (equal_frequency) namespace AegisSpec.E...
11
bitwise-xor-of-all-pairings
2,425
Medium
[ "Bit Manipulation", "Brainteaser", "Array" ]
You are given two 0-indexed arrays, nums1 and nums2, consisting of non-negative integers. Let there be another array, nums3, which contains the bitwise XOR of all pairings of integers between nums1 and nums2 (every integer in nums1 is paired with every integer in nums2 exactly once). Return the bitwise XOR of all integ...
xorAllNums(nums1: list_int, nums2: list_int) -> int
pub fn xor_all_nums(nums1: &[i64], nums2: &[i64]) -> i64
Aegis.XorAllNums.xor_all_nums
pub fn xor_all_nums(nums1: &[i64], nums2: &[i64]) -> i64 { let mut xor1: i64 = 0; let mut xor2: i64 = 0; let mut i: usize = 0; while i < nums1.len() { xor1 = xor1 ^ nums1[i]; i += 1; } let mut j: usize = 0; while j < nums2.len() { xor2 = xor2 ^ nums2[j]; j +...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [xor_all_nums]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter.s...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [xor_all_nums]: function definitions module public import Aeneas public import Aegis.XorAllNums.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option li...
import Aegis.XorAllNums.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval aegisCase ...
[ { "input": "[[5], [5]]", "output": "0" }, { "input": "[[1000000000], [1000000000]]", "output": "0" }, { "input": "[[1000000000], [1000000000, 1000000000]]", "output": "0" }, { "input": "[[1, 2], [3, 4]]", "output": "0" }, { "input": "[[123456789], [987654321, 1122...
102
false
102
verified
10
10
1
469
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.XorAllNums.Code.Funs /-! # Specifications of `Aegis.XorAllNums.xor_all_nums` LeetCode problem `bitwise-xor-of-all-pairings`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.XorAllNums def vals (s : Slice Std.I64) : List Nat := s.val...
14
number-of-pairs-satisfying-inequality
2,426
Hard
[ "Binary Indexed Tree", "Segment Tree", "Array", "Binary Search", "Divide and Conquer", "Ordered Set", "Merge Sort" ]
You are given two 0-indexed integer arrays nums1 and nums2, each of size n, and an integer diff. Find the number of pairs (i, j) such that: 0 <= i < j <= n - 1 and nums1[i] - nums1[j] <= nums2[i] - nums2[j] + diff. Return the number of pairs that satisfy the conditions.   Example 1: Input: nums1 = [3,2,5], nums2 = [...
numberOfPairs(nums1: list_int, nums2: list_int, diff: int) -> int
pub fn number_of_pairs(nums1: &[i64], nums2: &[i64], diff: i64) -> i64
Aegis.NumberOfPairs.number_of_pairs
pub fn number_of_pairs(nums1: &[i64], nums2: &[i64], diff: i64) -> i64 { let n = nums1.len(); let mut src: Vec<i64> = Vec::new(); let mut i: usize = 0; while i < n { src.push(nums1[i] - nums2[i]); i += 1; } let mut dst: Vec<i64> = Vec::new(); i = 0; while i < n { ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [number_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 linte...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [number_of_pairs]: function definitions module public import Aeneas public import Aegis.NumberOfPairs.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_opt...
import Aegis.NumberOfPairs.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval aegisCa...
[ { "input": "[[3, -1], [-2, 2], -1]", "output": "0" }, { "input": "[[10000, -10000], [-10000, 10000], 20000]", "output": "0" }, { "input": "[[-10, -20, -30], [-1, -2, -3], -5]", "output": "0" }, { "input": "[[10, 20, 30], [1, 2, 3], 5]", "output": "3" }, { "input":...
99
false
99
verified
10
10
2
24,597
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.NumberOfPairs.Code.Funs /-! # Specifications of `Aegis.NumberOfPairs.number_of_pairs` LeetCode problem `number-of-pairs-satisfying-inequality`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std namespace AegisSpec.NumberOfPairs def entry (s : Slice I64) (k : ℕ)...
14
number-of-common-factors
2,427
Easy
[ "Math", "Enumeration", "Number Theory" ]
Given two positive integers a and b, return the number of common factors of a and b. An integer x is a common factor of a and b if x divides both a and b.   Example 1: Input: a = 12, b = 6 Output: 4 Explanation: The common factors of 12 and 6 are 1, 2, 3, 6. Example 2: Input: a = 25, b = 30 Output: 2 Explanation: Th...
commonFactors(a: int, b: int) -> int
pub fn common_factors(a: i64, b: i64) -> i64
Aegis.CommonFactors.common_factors
pub fn common_factors(a: i64, b: i64) -> i64 { let mut count: i64 = 0; let mut x: i64 = 1; while x <= a && x <= b { if a % x == 0 && b % x == 0 { count += 1; } x += 1; } count }
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [common_factors]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [common_factors]: function definitions module public import Aeneas public import Aegis.CommonFactors.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.CommonFactors.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := 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": "[7, 13]", "output": "1" }, { "input": "[500, 500]", "output": "12" }, { "input": "[42, 56]", "output": "4" }, { "input": "[999, 1000]", "output": "1" }, { "input": "[77, 14]", "output": "2" }, { "input": "[98, 42]", "output": "4" }, ...
107
false
107
verified
10
10
1
260
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.CommonFactors.Code.Funs /-! # Specifications of `Aegis.CommonFactors.common_factors` LeetCode problem `number-of-common-factors`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.CommonFactors def posDivisors (n : Int) : Finset Int :...
14
maximum-sum-of-an-hourglass
2,428
Medium
[ "Array", "Matrix", "Prefix Sum" ]
You are given an m x n integer matrix grid. We define an hourglass as a part of the matrix with the following form: Return the maximum sum of the elements of an hourglass. Note that an hourglass cannot be rotated and must be entirely contained within the matrix.   Example 1: Input: grid = [[6,2,1,3],[4,2,1,5],[9,2,8...
maxSum(grid: list_list_int) -> int
pub fn max_sum(grid: &[Vec<i64>]) -> i64
Aegis.MaxSum.max_sum
pub fn max_sum(grid: &[Vec<i64>]) -> i64 { let m = grid.len(); if m < 3 { return 0; } let n = grid[0].len(); if n < 3 { return 0; } let mut best: i64 = 0; let mut i: usize = 0; while i + 2 < m { let mut j: usize = 0; while j + 2 < n { l...
-- 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": "[[[0, 0, 0], [0, 1, 0], [0, 0, 0]]]", "output": "1" }, { "input": "[[[1000000, 1000000, 1000000], [1000000, 1000000, 1000000], [1000000, 1000000, 1000000]]]", "output": "7000000" }, { "input": "[[[1, 2, 3], [4, 5, 6], [7, 8, 9]]]", "output": "35" }, { "input": "[[...
65
false
65
verified
10
10
1
1,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.MaxSum.Code.Funs /-! # Specifications of `Aegis.MaxSum.max_sum` LeetCode problem `maximum-sum-of-an-hourglass`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.MaxSum open Aeneas Aeneas.Std Result open Aegis.MaxSum abbrev Grid := Slice...
15
maximum-deletions-on-a-string
2,430
Hard
[ "String", "Dynamic Programming", "String Matching", "Hash Function", "Rolling Hash" ]
You are given a string s consisting of only lowercase English letters. In one operation, you can: Delete the entire string s, or Delete the first i letters of s if the first i letters of s are equal to the following i letters in s, for any i in the range 1 <= i <= s.length / 2. For example, if s = "ababc", then in on...
deleteString(s: str) -> int
pub fn delete_string(s: &[u8]) -> i64
Aegis.DeleteString.delete_string
pub fn delete_string(s: &[u8]) -> i64 { let n = s.len(); if n == 0 { return 0; } let mut dp: Vec<i64> = Vec::new(); let mut t = 0; while t < n + 1 { dp.push(0); t += 1; } let mut next: Vec<i64> = Vec::new(); t = 0; while t < n + 1 { next.push(0);...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [delete_string]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter....
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [delete_string]: function definitions module public import Aeneas public import Aegis.DeleteString.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.DeleteString.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := 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": "[\"abababababababababababababababababababababababababababababababababababababababababababababababab\"]", "output": "48" }, { "input": "[\"aaabaab\"]", "output": "4" }, { "input": "[\"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\"]...
103
false
103
verified
10
10
1
11,856
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.DeleteString.Code.Funs /-! # Specifications of `Aegis.DeleteString.delete_string` LeetCode problem `maximum-deletions-on-a-string`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.DeleteString (delete_string) namespace AegisSpec.DeleteString ...
10
maximize-total-tastiness-of-purchased-fruits
2,431
Medium
[ "Array", "Dynamic Programming" ]
You are given two non-negative integer arrays price and tastiness, both arrays have the same length n. You are also given two non-negative integers maxAmount and maxCoupons. For every integer i in range [0, n - 1]: price[i] describes the price of ith fruit. tastiness[i] describes the tastiness of ith fruit. You want ...
maxTastiness(price: list_int, tastiness: list_int, maxAmount: int, maxCoupons: int) -> int
pub fn max_tastiness(price: &[i64], tastiness: &[i64], maxAmount: i64, maxCoupons: i64) -> i64
Aegis.MaxTastiness.max_tastiness
pub fn max_tastiness(price: &[i64], tastiness: &[i64], maxAmount: i64, maxCoupons: i64) -> i64 { if maxAmount < 0 || maxCoupons < 0 { return 0; } let amount_limit = maxAmount as usize; let coupon_limit = maxCoupons as usize; let cols = amount_limit + 1; let mut n = price.len(); if ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [max_tastiness]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter....
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [max_tastiness]: function definitions module public import Aeneas public import Aegis.MaxTastiness.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.MaxTastiness.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := 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, 5, 5], [10, 10, 10], 10, 0]", "output": "20" }, { "input": "[[1000, 1000, 1000], [1000, 1000, 1000], 1000, 1]", "output": "1000" }, { "input": "[[5, 10, 15], [3, 6, 9], 15, 0]", "output": "9" }, { "input": "[[100, 200, 300], [50, 60, 70], 150, 1]", "outpu...
111
false
111
verified
10
10
1
7,813
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MaxTastiness.Code.Funs /-! # Specifications of `Aegis.MaxTastiness.max_tastiness` LeetCode problem `maximize-total-tastiness-of-purchased-fruits`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.MaxTastiness def entry (s : Slice I64...
15
the-employee-that-worked-on-the-longest-task
2,432
Easy
[ "Array" ]
There are n employees, each with a unique id from 0 to n - 1. You are given a 2D integer array logs where logs[i] = [idi, leaveTimei] where: idi is the id of the employee that worked on the ith task, and leaveTimei is the time at which the employee finished the ith task. All the values leaveTimei are unique. Note tha...
hardestWorker(n: int, logs: list_list_int) -> int
pub fn hardest_worker(n: i64, logs: &[Vec<i64>]) -> i64
Aegis.HardestWorker.hardest_worker
pub fn hardest_worker(n: i64, logs: &[Vec<i64>]) -> i64 { let mut best_time: i64 = -1; let mut best_id: i64 = n; let mut previous_time: i64 = 0; let mut i: usize = 0; while i < logs.len() { let employee_id: i64 = logs[i][0]; let leave_time: i64 = logs[i][1]; let duration: i6...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [hardest_worker]: type definitions module public import Aeneas @[expose] public section 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 -- [hardest_worker]: function definitions module public import Aeneas public import Aegis.HardestWorker.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.HardestWorker.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval aegisCa...
[ { "input": "[2, [[0, 10], [1, 20]]]", "output": "0" }, { "input": "[3, [[0, 10], [1, 20], [2, 30]]]", "output": "0" }, { "input": "[3, [[0, 5], [1, 10], [2, 15]]]", "output": "0" }, { "input": "[5, [[0, 2], [1, 5], [0, 9]]]", "output": "0" }, { "input": "[3, [[0, ...
99
false
99
verified
10
10
1
617
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.HardestWorker.Code.Funs /-! # Specifications of `Aegis.HardestWorker.hardest_worker` LeetCode problem `the-employee-that-worked-on-the-longest-task`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.HardestWorker def vecInts (v : all...
6
find-the-original-array-of-prefix-xor
2,433
Medium
[ "Bit Manipulation", "Array" ]
You are given an integer array pref of size n. Find and return the array arr of size n that satisfies: pref[i] = arr[0] ^ arr[1] ^ ... ^ arr[i]. Note that ^ denotes the bitwise-xor operation. It can be proven that the answer is unique.   Example 1: Input: pref = [5,2,0,3,1] Output: [5,7,2,3,2] Explanation: From the ...
findArray(pref: list_int) -> list_int
pub fn find_array(pref: &[i64]) -> Vec<i64>
Aegis.FindArray.find_array
pub fn find_array(pref: &[i64]) -> Vec<i64> { let n = pref.len(); let mut arr: Vec<i64> = Vec::new(); if n == 0 { return arr; } arr.push(pref[0]); let mut i: usize = 1; while i < n { arr.push(pref[i - 1] ^ pref[i]); i += 1; } arr }
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [find_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.sty...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [find_array]: function definitions module public import Aeneas public import Aegis.FindArray.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.FindArray.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := 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": "[[13]]", "output": "[13]" }, { "input": "[[5, 2, 0, 3, 1]]", "output": "[5, 7, 2, 3, 2]" }, { "input": "[[0, 0, 0, 0, 0]]", "output": "[0, 0, 0, 0, 0]" }, { "input": "[[0, 1, 2, 3, 4]]", "output": "[0, 1, 3, 1, 7]" }, { "input": "[[10, 4, 6, 3, 5]]", ...
98
false
98
verified
10
10
1
319
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.FindArray.Code.Funs /-! # Specifications of `Aegis.FindArray.find_array` LeetCode problem `find-the-original-array-of-prefix-xor`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.FindArray def xorInt (a b : Int) : Int := ((a.toNat ^...
8
paths-in-matrix-whose-sum-is-divisible-by-k
2,435
Hard
[ "Array", "Dynamic Programming", "Matrix" ]
You are given a 0-indexed m x n integer matrix grid and an integer k. You are currently at position (0, 0) and you want to reach position (m - 1, n - 1) moving only down or right. Return the number of paths where the sum of the elements on the path is divisible by k. Since the answer may be very large, return it modulo...
numberOfPaths(grid: list_list_int, k: int) -> int
pub fn number_of_paths(grid: &[Vec<i64>], k: i64) -> i64
Aegis.NumberOfPaths.number_of_paths
pub fn number_of_paths(grid: &[Vec<i64>], k: i64) -> i64 { if k <= 0 { return 0; } let m: usize = grid.len(); if m == 0 { return 0; } let n: usize = grid[0].len(); if n == 0 { return 0; } let modv: i64 = 1000000007; let kk: usize = k as usize; let t...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [number_of_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 linte...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [number_of_paths]: function definitions module public import Aeneas public import Aegis.NumberOfPaths.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_opt...
import Aegis.NumberOfPaths.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval aegisCa...
[ { "input": "[[[0, 0]], 5]", "output": "1" }, { "input": "[[[100, 100], [100, 100]], 101]", "output": "0" }, { "input": "[[[100, 100], [100, 100]], 5]", "output": "2" }, { "input": "[[[1, 2, 3], [4, 5, 6]], 2]", "output": "3" }, { "input": "[[[10, 20, 30], [40, 50,...
74
false
74
verified
10
10
1
4,639
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.NumberOfPaths.Code.Funs /-! # Specifications of `Aegis.NumberOfPaths.number_of_paths` LeetCode problem `paths-in-matrix-whose-sum-is-divisible-by-k`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.NumberOfPaths def MOD : ℕ := 10000...
16
minimum-split-into-subarrays-with-gcd-greater-than-one
2,436
Medium
[ "Greedy", "Array", "Math", "Dynamic Programming", "Number Theory" ]
You are given an array nums consisting of positive integers. Split the array into one or more disjoint subarrays such that: Each element of the array belongs to exactly one subarray, and The GCD of the elements of each subarray is strictly greater than 1. Return the minimum number of subarrays that can be obtained af...
minimumSplits(nums: list_int) -> int
pub fn minimum_splits(nums: &[i64]) -> i64
Aegis.MinimumSplits.minimum_splits
fn gcd(mut a: i64, mut b: i64) -> i64 { while b != 0 { let r = a % b; a = b; b = r; } a } pub fn minimum_splits(nums: &[i64]) -> i64 { let n = nums.len(); if n == 0 { return 0; } let mut splits: i64 = 1; let mut current_gcd: i64 = nums[0]; let mut i...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [minimum_splits]: type definitions module public import Aeneas @[expose] public section 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_splits]: function definitions module public import Aeneas public import Aegis.MinimumSplits.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.MinimumSplits.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := 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": "[[100, 200, 300, 400]]", "output": "1" }, { "input": "[[30, 60, 90, 120]]", "output": "1" }, { "input": "[[18, 9, 6, 12]]", "output": "1" }, { "input": "[[4, 12, 6, 14]]", "output": "1" }, { "input": "[[30, 20, 10, 5]]", "output": "1" }, { ...
160
false
160
verified
10
10
1
1,517
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MinimumSplits.Code.Funs /-! # Specifications of `Aegis.MinimumSplits.minimum_splits` LeetCode problem `minimum-split-into-subarrays-with-gcd-greater-than-one`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.MinimumSplits open Aegis...
14
number-of-valid-clock-times
2,437
Easy
[ "String", "Enumeration" ]
You are given a string of length 5 called time, representing the current time on a digital clock in the format "hh:mm". The earliest possible time is "00:00" and the latest possible time is "23:59". In the string time, the digits represented by the ? symbol are unknown, and must be replaced with a digit from 0 to 9. Re...
countTime(time: str) -> int
pub fn count_time(time: &[u8]) -> i64
Aegis.CountTime.count_time
pub fn count_time(time: &[u8]) -> i64 { let mut ans: i64 = 0; let mut h: i64 = 0; while h < 24 { let h0: i64 = h / 10; let h1: i64 = h % 10; let mut m: i64 = 0; while m < 60 { let m0: i64 = m / 10; let m1: i64 = m % 10; if digit_ok(time[...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [count_time]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter.sty...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [count_time]: function definitions module public import Aeneas public import Aegis.CountTime.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.CountTime.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := 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": "[\"23:?0\"]", "output": "6" }, { "input": "[\"23:5?\"]", "output": "10" }, { "input": "[\"09:5?\"]", "output": "10" }, { "input": "[\"23:?9\"]", "output": "6" }, { "input": "[\"1?:?0\"]", "output": "60" }, { "input": "[\"00:??\"]", "out...
114
false
114
verified
10
10
1
1,643
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.CountTime.Code.Funs /-! # Specifications of `Aegis.CountTime.count_time` LeetCode problem `number-of-valid-clock-times`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.CountTime namespace AegisSpec.CountTime def byteAt (time : Slice U8) (i : Na...
15
minimize-maximum-of-array
2,439
Medium
[ "Greedy", "Array", "Binary Search", "Dynamic Programming", "Prefix Sum" ]
You are given a 0-indexed array nums comprising of n non-negative integers. In one operation, you must: Choose an integer i such that 1 <= i < n and nums[i] > 0. Decrease nums[i] by 1. Increase nums[i - 1] by 1. Return the minimum possible value of the maximum integer of nums after performing any number of operations...
minimizeArrayValue(nums: list_int) -> int
pub fn minimize_array_value(nums: &[i64]) -> i64
Aegis.MinimizeArrayValue.minimize_array_value
pub fn minimize_array_value(nums: &[i64]) -> i64 { let n = nums.len(); let mut sum: i64 = 0; let mut len: i64 = 0; let mut ans: i64 = 0; let mut i: usize = 0; while i < n { sum += nums[i]; len += 1; let value = (sum + len - 1) / len; if value > ans { ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [minimize_array_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 -- [minimize_array_value]: function definitions module public import Aeneas public import Aegis.MinimizeArrayValue.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand fal...
import Aegis.MinimizeArrayValue.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := 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, 1000000000]]", "output": "500000001" }, { "input": "[[1000000000, 1000000000]]", "output": "1000000000" }, { "input": "[[10, 1]]", "output": "10" }, { "input": "[[1000000000, 1]]", "output": "1000000000" }, { "input": "[[1, 1000000000, 1]]", "...
114
false
114
verified
10
10
1
675
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MinimizeArrayValue.Code.Funs /-! # Specifications of `Aegis.MinimizeArrayValue.minimize_array_value` LeetCode problem `minimize-maximum-of-array`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.MinimizeArrayValue def vals (s : Slice St...
8
largest-positive-integer-that-exists-with-its-negative
2,441
Easy
[ "Array", "Hash Table", "Two Pointers", "Sorting" ]
Given an integer array nums that does not contain any zeros, find the largest positive integer k such that -k also exists in the array. Return the positive integer k. If there is no such integer, return -1.   Example 1: Input: nums = [-1,2,-3,3] Output: 3 Explanation: 3 is the only valid k we can find in the array. E...
findMaxK(nums: list_int) -> int
pub fn find_max_k(nums: &[i64]) -> i64
Aegis.FindMaxK.find_max_k
pub fn find_max_k(nums: &[i64]) -> i64 { let n = nums.len(); let mut best: i64 = -1; let mut i: usize = 0; while i < n { let v = nums[i]; if v > 0 && v > best { let target = -v; let mut found = false; let mut j: usize = 0; while j < n { ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [find_max_k]: type definitions module public import Aeneas @[expose] public section 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_max_k]: function definitions module public import Aeneas public import Aegis.FindMaxK.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.FindMaxK.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval aegisCase "e...
[ { "input": "[[-1]]", "output": "-1" }, { "input": "[[1]]", "output": "-1" }, { "input": "[[1000, -1000]]", "output": "1000" }, { "input": "[[0, 1, -1]]", "output": "1" }, { "input": "[[-1, 2, -3, 3]]", "output": "3" }, { "input": "[[-5, -4, -3, -2, -1]...
116
false
116
verified
10
10
1
510
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.FindMaxK.Code.Funs /-! # Specifications of `Aegis.FindMaxK.find_max_k` LeetCode problem `largest-positive-integer-that-exists-with-its-negative`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.FindMaxK def Occurs (nums : Slice Std.I64)...
8
count-number-of-distinct-integers-after-reverse-operations
2,442
Medium
[ "Array", "Hash Table", "Math", "Counting" ]
You are given an array nums consisting of positive integers. You have to take each integer in the array, reverse its digits, and add it to the end of the array. You should apply this operation to the original integers in nums. Return the number of distinct integers in the final array.   Example 1: Input: nums = [1,13,...
countDistinctIntegers(nums: list_int) -> int
pub fn count_distinct_integers(nums: &[i64]) -> i64
Aegis.CountDistinctIntegers.count_distinct_integers
fn reverse_number(mut x: i64) -> i64 { let mut rev: i64 = 0; while x > 0 { rev = rev * 10 + (x % 10); x = x / 10; } rev } pub fn count_distinct_integers(nums: &[i64]) -> i64 { let n = nums.len(); let m = n * 2; let mut arr: Vec<i64> = Vec::new(); let mut i: usize = 0; ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [count_distinct_integers]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_opti...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [count_distinct_integers]: function definitions module public import Aeneas public import Aegis.CountDistinctIntegers.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashComma...
import Aegis.CountDistinctIntegers.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval...
[ { "input": "[[2, 2, 2]]", "output": "1" }, { "input": "[[987, 654, 321]]", "output": "6" }, { "input": "[[100, 200, 300]]", "output": "6" }, { "input": "[[123, 321, 111, 222]]", "output": "4" }, { "input": "[[100, 200, 300, 400]]", "output": "8" }, { "...
103
false
103
verified
10
10
2
8,769
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.CountDistinctIntegers.Code.Funs /-! # Specifications of `Aegis.CountDistinctIntegers.count_distinct_integers` LeetCode problem `count-number-of-distinct-integers-after-reverse-operations`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpe...
13
sum-of-number-and-its-reverse
2,443
Medium
[ "Math", "Enumeration" ]
Given a non-negative integer num, return true if num can be expressed as the sum of any non-negative integer and its reverse, or false otherwise.   Example 1: Input: num = 443 Output: true Explanation: 172 + 271 = 443 so we return true. Example 2: Input: num = 63 Output: false Explanation: 63 cannot be expressed as ...
sumOfNumberAndReverse(num: int) -> bool
pub fn sum_of_number_and_reverse(num: i64) -> bool
Aegis.SumOfNumberAndReverse.sum_of_number_and_reverse
fn reverse_number(mut n: i64) -> i64 { let mut rev: i64 = 0; while n > 0 { rev = rev * 10 + n % 10; n = n / 10; } rev } pub fn sum_of_number_and_reverse(num: i64) -> bool { let mut i: i64 = 0; while i <= num { if i + reverse_number(i) == num { return true; ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [sum_of_number_and_reverse]: type definitions module public import Aeneas @[expose] public 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 -- [sum_of_number_and_reverse]: function definitions module public import Aeneas public import Aegis.SumOfNumberAndReverse.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCom...
import Aegis.SumOfNumberAndReverse.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := 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": "[443]", "output": "true" }, { "input": "[181]", "output": "true" }, { "input": "[99999]", "output": "false" }, { "input": "[1001]", "output": "true" }, { "input": "[0]", "output": "true" }, { "input": "[63]", "output": "false" }, { ...
177
false
177
verified
10
10
1
514
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.SumOfNumberAndReverse.Code.Funs /-! # Specifications of `Aegis.SumOfNumberAndReverse.sum_of_number_and_reverse` LeetCode problem `sum-of-number-and-its-reverse`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.SumOfNumberAndReverse ...
7
count-subarrays-with-fixed-bounds
2,444
Hard
[ "Queue", "Array", "Sliding Window", "Monotonic Queue" ]
You are given an integer array nums and two integers minK and maxK. A fixed-bound subarray of nums is a subarray that satisfies the following conditions: The minimum value in the subarray is equal to minK. The maximum value in the subarray is equal to maxK. Return the number of fixed-bound subarrays. A subarray is a ...
countSubarrays(nums: list_int, minK: int, maxK: int) -> int
pub fn count_subarrays(nums: &[i64], minK: i64, maxK: i64) -> i64
Aegis.CountSubarrays.count_subarrays
pub fn count_subarrays(nums: &[i64], minK: i64, maxK: i64) -> i64 { let n = nums.len(); let mut ans: i64 = 0; let mut left: usize = 0; let mut last_min: usize = n; let mut last_max: usize = n; let mut i: usize = 0; while i < n { let x = nums[i]; if x < minK || x > maxK { ...
-- 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, 1, 1], 1, 1]", "output": "10" }, { "input": "[[10, 9, 8, 7, 6], 6, 10]", "output": "1" }, { "input": "[[1, 2, 3, 2, 1], 1, 3]", "output": "5" }, { "input": "[[10, 20, 30, 40, 50], 10, 50]", "output": "1" }, { "input": "[[1, 2, 3, 4, 5], 2, 4]",...
116
false
116
verified
10
10
1
4,843
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": 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-with-fixed-bounds`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.CountSubarrays noncomputable section open Cla...
14
determine-if-two-events-have-conflict
2,446
Easy
[ "Array", "String" ]
You are given two arrays of strings that represent two inclusive events that happened on the same day, event1 and event2, where: event1 = [startTime1, endTime1] and event2 = [startTime2, endTime2]. Event times are valid 24 hours format in the form of HH:MM. A conflict happens when two events have some non-empty inter...
haveConflict(event1: list_str, event2: list_str) -> bool
pub fn have_conflict(event1: &[Vec<u8>], event2: &[Vec<u8>]) -> bool
Aegis.HaveConflict.have_conflict
pub fn have_conflict(event1: &[Vec<u8>], event2: &[Vec<u8>]) -> bool { let s1_hour: i64 = ((event1[0][0] as i64) - 48) * 10 + ((event1[0][1] as i64) - 48); let s1_minute: i64 = ((event1[0][3] as i64) - 48) * 10 + ((event1[0][4] as i64) - 48); let e1_hour: i64 = ((event1[1][0] as i64...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [have_conflict]: type definitions module public import Aeneas @[expose] public section 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 -- [have_conflict]: function definitions module public import Aeneas public import Aegis.HaveConflict.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.HaveConflict.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval aegisCas...
[ { "input": "[[\"10:00\", \"11:00\"], [\"14:00\", \"15:00\"]]", "output": "false" }, { "input": "[[\"00:00\", \"23:59\"], [\"12:00\", \"12:01\"]]", "output": "true" }, { "input": "[[\"00:00\", \"23:59\"], [\"12:00\", \"12:00\"]]", "output": "true" }, { "input": "[[\"00:00\", \...
109
false
109
verified
10
10
1
1,840
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.HaveConflict.Code.Funs /-! # Specifications of `Aegis.HaveConflict.have_conflict` LeetCode problem `determine-if-two-events-have-conflict`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aeneas.Std.Result open Aegis.HaveConflict namespace AegisSpec.Ha...
7
number-of-subarrays-with-gcd-equal-to-k
2,447
Medium
[ "Array", "Math", "Number Theory" ]
Given an integer array nums and an integer k, return the number of subarrays of nums where the greatest common divisor of the subarray's elements is k. A subarray is a contiguous non-empty sequence of elements within an array. The greatest common divisor of an array is the largest integer that evenly divides all the ar...
subarrayGCD(nums: list_int, k: int) -> int
pub fn subarray_gcd(nums: &[i64], k: i64) -> i64
Aegis.SubarrayGcd.subarray_gcd
fn gcd(a: i64, b: i64) -> i64 { let mut x = a; let mut y = b; while y != 0 { let r = x % y; x = y; y = r; } x } pub fn subarray_gcd(nums: &[i64], k: i64) -> i64 { let n = nums.len(); let mut ans: i64 = 0; let mut i = 0; while i < n { let mut g: i64 =...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [subarray_gcd]: type definitions module public import Aeneas @[expose] public section 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 -- [subarray_gcd]: function definitions module public import Aeneas public import Aegis.SubarrayGcd.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.SubarrayGcd.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := 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], 7]", "output": "0" }, { "input": "[[1000000000, 2000000000, 3000000000, 4000000000], 1000000000]", "output": "7" }, { "input": "[[10, 20, 30, 40, 50], 10]", "output": "11" }, { "input": "[[7, 14, 21, 28, 35], 7]", "output": "11" }, { "input": "[[...
124
false
124
verified
10
10
1
940
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.SubarrayGcd.Code.Funs /-! # Specifications of `Aegis.SubarrayGcd.subarray_gcd` LeetCode problem `number-of-subarrays-with-gcd-equal-to-k`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.SubarrayGcd def i64Max : Int := 9223372036854...
11
minimum-cost-to-make-array-equal
2,448
Hard
[ "Greedy", "Array", "Binary Search", "Prefix Sum", "Sorting" ]
You are given two 0-indexed arrays nums and cost consisting each of n positive integers. You can do the following operation any number of times: Increase or decrease any element of the array nums by 1. The cost of doing one operation on the ith element is cost[i]. Return the minimum total cost such that all the eleme...
minCost(nums: list_int, cost: list_int) -> int
pub fn min_cost(nums: &[i64], cost: &[i64]) -> i64
Aegis.MinCost.min_cost
pub fn min_cost(nums: &[i64], cost: &[i64]) -> i64 { let n = nums.len(); if n == 0 { return 0; } let mut total: i64 = 0; let mut min_v: i64 = nums[0]; let mut max_v: i64 = nums[0]; let mut i: usize = 0; while i < n { total = total + cost[i]; if nums[i] < min_v { ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [min_cost]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter.style...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [min_cost]: function definitions module public import Aeneas public import Aegis.MinCost.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.un...
import Aegis.MinCost.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval aegisCase "ev...
[ { "input": "[[100000, 100000], [1000000, 1000000]]", "output": "0" }, { "input": "[[100000, 1000000], [100, 1]]", "output": "900000" }, { "input": "[[1, 1000000], [100000, 1]]", "output": "999999" }, { "input": "[[6, 1, 9], [2, 5, 7]]", "output": "46" }, { "input"...
109
false
109
verified
10
10
1
5,456
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MinCost.Code.Funs /-! # Specifications of `Aegis.MinCost.min_cost` LeetCode problem `minimum-cost-to-make-array-equal`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.MinCost open Aegis.MinCost def absI (z : Int) : Int := if z < 0 the...
16
destroy-sequential-targets
2,453
Medium
[ "Array", "Hash Table", "Counting" ]
You are given a 0-indexed array nums consisting of positive integers, representing targets on a number line. You are also given an integer space. You have a machine which can destroy targets. Seeding the machine with some nums[i] allows it to destroy all targets with values that can be represented as nums[i] + c * spac...
destroyTargets(nums: list_int, space: int) -> int
pub fn destroy_targets(nums: &[i64], space: i64) -> i64
Aegis.DestroyTargets.destroy_targets
pub fn destroy_targets(nums: &[i64], space: i64) -> i64 { let n = nums.len(); let mut max_val: i64 = 0; let mut i: usize = 0; while i < n { if nums[i] > max_val { max_val = nums[i]; } i += 1; } let base: i64 = max_val + 1; let mut keys: Vec<i64> = Vec::...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [destroy_targets]: type definitions module public import Aeneas @[expose] public section 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 -- [destroy_targets]: function definitions module public import Aeneas public import Aegis.DestroyTargets.Code.Types public import Aegis.DestroyTargets.Code.FunsExternal @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNames...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [destroy_targets]: external functions. -- This is a template file: rename it to "FunsExternal.lean" and fill the holes. module public import Aeneas public import Aegis.DestroyTargets.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error...
import Aegis.DestroyTargets.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := 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]", "output": "1000000000" }, { "input": "[[6, 2, 5], 100]", "output": "2" }, { "input": "[[1000000000, 1000000000, 1000000000], 1]", "output": "1000000000" }, { "input": "[[1000000000, 2000000000, 3000000000, 4000000000, 5000000000], 1000...
127
false
127
verified
10
10
1
3,551
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.DestroyTargets.Code.Funs /-! # Specifications of `Aegis.DestroyTargets.destroy_targets` LeetCode problem `destroy-sequential-targets`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Classical namespace AegisSpec.DestroyTargets def IsMultipleOf (space...
12
next-greater-element-iv
2,454
Hard
[ "Stack", "Array", "Binary Search", "Sorting", "Monotonic Stack", "Heap (Priority Queue)" ]
You are given a 0-indexed array of non-negative integers nums. For each integer in nums, you must find its respective second greater integer. The second greater integer of nums[i] is nums[j] such that: j > i nums[j] > nums[i] There exists exactly one index k such that nums[k] > nums[i] and i < k < j. If there is no s...
secondGreaterElement(nums: list_int) -> list_int
pub fn second_greater_element(nums: &[i64]) -> Vec<i64>
Aegis.SecondGreaterElement.second_greater_element
pub fn second_greater_element(nums: &[i64]) -> Vec<i64> { let n = nums.len(); let mut ans: Vec<i64> = Vec::new(); let mut i: usize = 0; while i < n { ans.push(-1); i += 1; } let mut s1: Vec<usize> = Vec::new(); let mut s2: Vec<usize> = Vec::new(); let mut tmp: Vec<usize...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [second_greater_element]: type definitions module public import Aeneas @[expose] public 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 -- [second_greater_element]: function definitions module public import Aeneas public import Aegis.SecondGreaterElement.Code.Types public import Aegis.SecondGreaterElement.Code.FunsExternal @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_opt...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [second_greater_element]: external functions. -- This is a template file: rename it to "FunsExternal.lean" and fill the holes. module public import Aeneas public import Aegis.SecondGreaterElement.Code.Types @[expose] public section open Aeneas Aeneas.Std Result Cont...
import Aegis.SecondGreaterElement.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := 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": "[[3, 3]]", "output": "[-1, -1]" }, { "input": "[[2, 1]]", "output": "[-1, -1]" }, { "input": "[[3, 3]]", "output": "[-1, -1]" }, { "input": "[[1, 2]]", "output": "[-1, -1]" }, { "input": "[[3, 2, 1]]"...
224
false
224
verified
10
10
1
5,007
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.SecondGreaterElement.Code.Funs /-! # Specifications of `Aegis.SecondGreaterElement.second_greater_element` LeetCode problem `next-greater-element-iv`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.SecondGreaterElement namespace AegisSpec.Se...
8
average-value-of-even-numbers-that-are-divisible-by-three
2,455
Easy
[ "Array", "Math" ]
Given an integer array nums of positive integers, return the average value of all even integers that are divisible by 3. Note that the average of n elements is the sum of the n elements divided by n and rounded down to the nearest integer.   Example 1: Input: nums = [1,3,6,10,12,15] Output: 9 Explanation: 6 and 12 are...
averageValue(nums: list_int) -> int
pub fn average_value(nums: &[i64]) -> i64
Aegis.AverageValue.average_value
pub fn average_value(nums: &[i64]) -> i64 { let mut sum: i64 = 0; let mut count: i64 = 0; let mut i: usize = 0; while i < nums.len() { let x = nums[i]; if x % 2 == 0 && x % 3 == 0 { sum += x; count += 1; } i += 1; } if count == 0 { ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [average_value]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter....
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [average_value]: function definitions module public import Aeneas public import Aegis.AverageValue.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.AverageValue.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := 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, 6, 18, 24, 30]]", "output": "19" }, { "input": "[[3, 9, 15, 21, 27]]", "output": "0" }, { "input": "[[36, 72, 108, 144, 180]]", "output": "108" }, { "input": "[[1, 2, 4, 7, 10]]", "output": "0" }, { "input": "[[300, 600, 900, 1200, 1500]]", "o...
124
false
124
verified
10
10
1
322
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.AverageValue.Code.Funs /-! # Specifications of `Aegis.AverageValue.average_value` LeetCode problem `average-value-of-even-numbers-that-are-divisible-by-three`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.AverageValue def Qualifies (...
15
minimum-addition-to-make-integer-beautiful
2,457
Medium
[ "Greedy", "Math" ]
You are given two positive integers n and target. An integer is considered beautiful if the sum of its digits is less than or equal to target. Return the minimum non-negative integer x such that n + x is beautiful. The input will be generated such that it is always possible to make n beautiful.   Example 1: Input: n =...
makeIntegerBeautiful(n: int, target: int) -> int
pub fn make_integer_beautiful(n: i64, target: i64) -> i64
Aegis.MakeIntegerBeautiful.make_integer_beautiful
fn digit_sum(mut x: i64) -> i64 { let mut s: i64 = 0; while x > 0 { s += x % 10; x /= 10; } s } pub fn make_integer_beautiful(n: i64, target: i64) -> i64 { let mut ans: i64 = 0; let mut base: i64 = 1; while digit_sum(n + ans) > target { let cur: i64 = n + ans; ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [make_integer_beautiful]: type definitions module public import Aeneas @[expose] public 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 -- [make_integer_beautiful]: function definitions module public import Aeneas public import Aegis.MakeIntegerBeautiful.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand...
import Aegis.MakeIntegerBeautiful.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := 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": "[1000000000000, 1]", "output": "0" }, { "input": "[1, 1]", "output": "0" }, { "input": "[99999, 5]", "output": "1" }, { "input": "[8888, 32]", "output": "0" }, { "input": "[888888888, 24]", "output": "1111112" }, { "input": "[467, 6]", ...
100
false
100
verified
10
10
1
3,832
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MakeIntegerBeautiful.Code.Funs /-! # Specifications of `Aegis.MakeIntegerBeautiful.make_integer_beautiful` LeetCode problem `minimum-addition-to-make-integer-beautiful`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.MakeIntegerBeautiful nam...
13
height-of-binary-tree-after-subtree-removal-queries
2,458
Hard
[ "Tree", "Depth-First Search", "Breadth-First Search", "Array", "Binary Tree" ]
You are given the root of a binary tree with n nodes. Each node is assigned a unique value from 1 to n. You are also given an array queries of size m. You have to perform m independent queries on the tree where in the ith query you do the following: Remove the subtree rooted at the node with the value queries[i] from ...
treeQueries(root: tree, queries: list_int) -> list_int
pub fn tree_queries(root: &Tree, queries: &[i64]) -> Vec<i64>
Aegis.TreeQueries.tree_queries
fn count_nodes(t: &Tree) -> i64 { match t { Tree::Null => 0, Tree::Node(_, left, right) => 1 + count_nodes(&**left) + count_nodes(&**right), } } fn flatten( t: &Tree, depth: i64, dep: &mut Vec<i64>, lc: &mut Vec<i64>, rc: &mut Vec<i64>, order: &mut Vec<i64>, ) { matc...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [tree_queries]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter.s...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [tree_queries]: function definitions module public import Aeneas public import Aegis.TreeQueries.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.TreeQueries.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := 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, 8, 9, 2, 1, 3, 7, 4, 6], [3, 2, 4, 8]]", "output": "[3, 2, 3, 2]" }, { "input": "[[6, 3, 9, 2, 5, 8, 10, 1, 4, 7, 11, 12], [6, 9, 3, 10, 2]]", "output": "[0, 3, 3, 3, 3]" }, { "input": "[[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15], [8, 12, 5, 1]]", "output": ...
22
false
22
verified
10
10
4
52,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.TreeQueries.Code.Funs /-! # Specifications of `Aegis.TreeQueries.tree_queries` LeetCode problem `height-of-binary-tree-after-subtree-removal-queries`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.TreeQueries namespace AegisSpec.TreeQueries na...
14
sort-array-by-moving-items-to-empty-space
2,459
Hard
[ "Greedy", "Array", "Sorting" ]
You are given an integer array nums of size n containing each element from 0 to n - 1 (inclusive). Each of the elements from 1 to n - 1 represents an item, and the element 0 represents an empty space. In one operation, you can move any item to the empty space. nums is considered to be sorted if the numbers of all the i...
sortArray(nums: list_int) -> int
pub fn sort_array(nums: &[i64]) -> i64
Aegis.SortArray.sort_array
pub fn sort_array(nums: &[i64]) -> i64 { let a = cost(nums, false); let b = cost(nums, true); if a < b { a } else { b } } fn cost(nums: &[i64], zero_at_end: bool) -> i64 { let n = nums.len(); let mut seen: Vec<i64> = Vec::new(); let mut i = 0; while i < n { seen.push(0); i ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [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.sty...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [sort_array]: function definitions module public import Aeneas public import Aegis.SortArray.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.SortArray.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := 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, 2, 3, 4]]", "output": "0" }, { "input": "[[1, 0, 2, 4, 3]]", "output": "2" }, { "input": "[[1, 2, 3, 4, 0]]", "output": "0" }, { "input": "[[2, 1, 0, 3, 4]]", "output": "1" }, { "input": "[[3, 2, 1, 0, 4]]", "output": "4" }, { "inpu...
161
false
161
verified
10
10
1
10,238
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.SortArray.Code.Funs /-! # Specifications of `Aegis.SortArray.sort_array` LeetCode problem `sort-array-by-moving-items-to-empty-space`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aeneas.Data.ListN namespace AegisSpec.SortArray def vals (nums : Sli...
12
apply-operations-to-an-array
2,460
Easy
[ "Array", "Two Pointers", "Simulation" ]
You are given a 0-indexed array nums of size n consisting of non-negative integers. You need to apply n - 1 operations to this array where, in the ith operation (0-indexed), you will apply the following on the ith element of nums: If nums[i] == nums[i + 1], then multiply nums[i] by 2 and set nums[i + 1] to 0. Otherwis...
applyOperations(nums: list_int) -> list_int
pub fn apply_operations(nums: &[i64]) -> Vec<i64>
Aegis.ApplyOperations.apply_operations
pub fn apply_operations(nums: &[i64]) -> Vec<i64> { let n = nums.len(); let mut a: Vec<i64> = Vec::new(); let mut i = 0usize; while i < n { a.push(nums[i]); i += 1; } let mut i = 0usize; while i + 1 < n { if a[i] == a[i + 1] { a[i] = a[i] * 2; ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [apply_operations]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option lint...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [apply_operations]: function definitions module public import Aeneas public import Aegis.ApplyOperations.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.ApplyOperations.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval aegis...
[ { "input": "[[0, 1]]", "output": "[1, 0]" }, { "input": "[[0, 0, 0, 0, 0]]", "output": "[0, 0, 0, 0, 0]" }, { "input": "[[2, 2, 2, 2, 2]]", "output": "[4, 4, 2, 0, 0]" }, { "input": "[[6, 5, 4, 3, 2, 1]]", "output": "[6, 5, 4, 3, 2, 1]" }, { "input": "[[1, 2, 3, 2...
123
false
123
verified
10
10
1
748
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.ApplyOperations.Code.Funs /-! # Specifications of `Aegis.ApplyOperations.apply_operations` LeetCode problem `apply-operations-to-an-array`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.ApplyOperations def ints (l : List Std.I64) ...
12
maximum-sum-of-distinct-subarrays-with-length-k
2,461
Medium
[ "Array", "Hash Table", "Sliding Window" ]
You are given an integer array nums and an integer k. Find the maximum subarray sum of all the subarrays of nums that meet the following conditions: The length of the subarray is k, and All the elements of the subarray are distinct. Return the maximum subarray sum of all the subarrays that meet the conditions. If no ...
maximumSubarraySum(nums: list_int, k: int) -> int
pub fn maximum_subarray_sum(nums: &[i64], k: i64) -> i64
Aegis.MaximumSubarraySum.maximum_subarray_sum
pub fn maximum_subarray_sum(nums: &[i64], k: i64) -> i64 { let n = nums.len(); if k <= 0 { return 0; } let k_usize = k as usize; if k_usize > n { return 0; } let mut max_val: i64 = 0; let mut i = 0; while i < n { if nums[i] > max_val { max_val =...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [maximum_subarray_sum]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [maximum_subarray_sum]: function definitions module public import Aeneas public import Aegis.MaximumSubarraySum.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand fal...
import Aegis.MaximumSubarraySum.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := 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": "[[4, 4, 4], 3]", "output": "0" }, { "input": "[[10, 20, 30, 40, 50], 1]", "output": "50" }, { "input": "[[1, 2, 3, 4, 5], 2]", "output": "9" }, { "input": "[[10, 20, 30, 40, 50], 5]", "output": "150" }, { "input": "[[100000, 100000, 100000, 100000, 100...
102
false
102
verified_partial
10
4
1
3,336
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MaximumSubarraySum.Code.Funs /-! # Specifications of `Aegis.MaximumSubarraySum.maximum_subarray_sum` LeetCode problem `maximum-sum-of-distinct-subarrays-with-length-k`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.MaximumSubarraySum...
10
total-cost-to-hire-k-workers
2,462
Medium
[ "Array", "Two Pointers", "Simulation", "Heap (Priority Queue)" ]
You are given a 0-indexed integer array costs where costs[i] is the cost of hiring the ith worker. You are also given two integers k and candidates. We want to hire exactly k workers according to the following rules: You will run k sessions and hire exactly one worker in each session. In each hiring session, choose th...
totalCost(costs: list_int, k: int, candidates: int) -> int
pub fn total_cost(costs: &[i64], k: i64, candidates: i64) -> i64
Aegis.TotalCost.total_cost
const BASE: i64 = 200001; // Insert `x` into ascending vector `h`, returning a fresh sorted vector. fn insert_sorted(h: Vec<i64>, x: i64) -> Vec<i64> { let m: usize = h.len(); let mut out: Vec<i64> = Vec::new(); let mut i: usize = 0; let mut inserted: bool = false; while i < m { if !inserte...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [total_cost]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter.sty...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [total_cost]: function definitions module public import Aeneas public import Aegis.TotalCost.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.TotalCost.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval aegisCase "...
[ { "input": "[[5, 5, 5, 5], 2, 2]", "output": "10" }, { "input": "[[1, 2, 4, 1], 3, 3]", "output": "4" }, { "input": "[[10, 10, 10, 10, 10], 4, 2]", "output": "40" }, { "input": "[[10, 10, 10, 10, 10], 5, 5]", "output": "50" }, { "input": "[[5, 4, 3, 2, 1], 5, 1]",...
99
false
99
verified
10
10
5
105,934
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.TotalCost.Code.Funs /-! # Specifications of `Aegis.TotalCost.total_cost` LeetCode problem `total-cost-to-hire-k-workers`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.TotalCost def vals (costs : Slice Std.I64) : List Int := costs.val...
14
minimum-total-distance-traveled
2,463
Hard
[ "Array", "Dynamic Programming", "Sorting" ]
There are some robots and factories on the X-axis. You are given an integer array robot where robot[i] is the position of the ith robot. You are also given a 2D integer array factory where factory[j] = [positionj, limitj] indicates that positionj is the position of the jth factory and that the jth factory can repair at...
minimumTotalDistance(robot: list_int, factory: list_list_int) -> int
pub fn minimum_total_distance(robot: &[i64], factory: &[Vec<i64>]) -> i64
Aegis.MinimumTotalDistance.minimum_total_distance
pub fn minimum_total_distance(robot: &[i64], factory: &[Vec<i64>]) -> i64 { let n = robot.len(); let m = factory.len(); let mut robots: Vec<i64> = Vec::new(); let mut i = 0; while i < n { robots.push(robot[i]); i += 1; } i = 1; while i < n { let key = robots[i];...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [minimum_total_distance]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_optio...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [minimum_total_distance]: function definitions module public import Aeneas public import Aegis.MinimumTotalDistance.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand...
import Aegis.MinimumTotalDistance.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := 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": "[[5, 1, 3], [[2, 3]]]", "output": "5" }, { "input": "[[10, -10, 0], [[0, 3]]]", "output": "20" }, { "input": "[[5, 5, 5, 5], [[5, 4]]]", "output": "0" }, { "input": "[[1, -1], [[-2, 1], [2, 1]]]", "output": "2" }, { "input": "[[5, 8, 15], [[10, 2], [16...
90
false
90
verified
10
10
1
6,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.MinimumTotalDistance.Code.Funs /-! # Specifications of `Aegis.MinimumTotalDistance.minimum_total_distance` LeetCode problem `minimum-total-distance-traveled`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.MinimumTotalDistance def ...
16
minimum-subarrays-in-a-valid-split
2,464
Medium
[ "Array", "Math", "Dynamic Programming", "Number Theory" ]
You are given an integer array nums. Splitting of an integer array nums into subarrays is valid if: the greatest common divisor of the first and last elements of each subarray is greater than 1, and each element of nums belongs to exactly one subarray. Return the minimum number of subarrays in a valid subarray splitt...
validSubarraySplit(nums: list_int) -> int
pub fn valid_subarray_split(nums: &[i64]) -> i64
Aegis.ValidSubarraySplit.valid_subarray_split
fn gcd_i64(mut a: i64, mut b: i64) -> i64 { while b != 0 { let r = a % b; a = b; b = r; } a } pub fn valid_subarray_split(nums: &[i64]) -> i64 { let n = nums.len(); if n == 0 { return -1; } let inf: i64 = 1_000_000; let mut dp: Vec<i64> = Vec::new(); ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [valid_subarray_split]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [valid_subarray_split]: function definitions module public import Aeneas public import Aegis.ValidSubarraySplit.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand fal...
import Aegis.ValidSubarraySplit.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval ae...
[ { "input": "[[2]]", "output": "1" }, { "input": "[[100000]]", "output": "1" }, { "input": "[[3, 5]]", "output": "2" }, { "input": "[[1, 2, 1]]", "output": "-1" }, { "input": "[[12, 15, 18]]", "output": "1" }, { "input": "[[1, 1, 1, 1]]", "output": ...
176
false
176
verified
10
10
1
3,024
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.ValidSubarraySplit.Code.Funs /-! # Specifications of `Aegis.ValidSubarraySplit.valid_subarray_split` LeetCode problem `minimum-subarrays-in-a-valid-split`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.ValidSubarraySplit open Aene...
15
number-of-distinct-averages
2,465
Easy
[ "Array", "Hash Table", "Two Pointers", "Sorting" ]
You are given a 0-indexed integer array nums of even length. As long as nums is not empty, you must repetitively: Find the minimum number in nums and remove it. Find the maximum number in nums and remove it. Calculate the average of the two removed numbers. The average of two numbers a and b is (a + b) / 2. For exam...
distinctAverages(nums: list_int) -> int
pub fn distinct_averages(nums: &[i64]) -> i64
Aegis.DistinctAverages.distinct_averages
pub fn distinct_averages(nums: &[i64]) -> i64 { let n = nums.len(); let mut v: Vec<i64> = Vec::new(); let mut idx: usize = 0; while idx < n { v.push(nums[idx]); idx += 1; } // Selection sort the copied array. let mut i: usize = 0; while i < n { let mut min_i: us...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [distinct_averages]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option lin...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [distinct_averages]: function definitions module public import Aeneas public import Aegis.DistinctAverages.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.DistinctAverages.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval aegi...
[ { "input": "[[1, 100]]", "output": "1" }, { "input": "[[50, 50, 50, 50]]", "output": "1" }, { "input": "[[1, 2, 3, 4]]", "output": "1" }, { "input": "[[5, 5, 5, 5]]", "output": "1" }, { "input": "[[0, 0, 0, 0]]", "output": "1" }, { "input": "[[0, 100, ...
113
false
113
verified
10
10
1
2,517
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.DistinctAverages.Code.Funs /-! # Specifications of `Aegis.DistinctAverages.distinct_averages` LeetCode problem `number-of-distinct-averages`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result Aegis.DistinctAverages namespace AegisSpec.DistinctAverages def va...
8
count-ways-to-build-good-strings
2,466
Medium
[ "Dynamic Programming" ]
Given the integers zero, one, low, and high, we can construct a string by starting with an empty string, and then at each step perform either of the following: Append the character '0' zero times. Append the character '1' one times. This can be performed any number of times. A good string is a string constructed by t...
countGoodStrings(low: int, high: int, zero: int, one: int) -> int
pub fn count_good_strings(low: i64, high: i64, zero: i64, one: i64) -> i64
Aegis.CountGoodStrings.count_good_strings
pub fn count_good_strings(low: i64, high: i64, zero: i64, one: i64) -> i64 { let modulo: i64 = 1000000007; let high_usize = high as usize; let low_usize = low as usize; let zero_usize = zero as usize; let one_usize = one as usize; let mut dp: Vec<i64> = Vec::new(); let mut i: usize = 0; ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [count_good_strings]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option li...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [count_good_strings]: function definitions module public import Aeneas public import Aegis.CountGoodStrings.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.CountGoodStrings.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := 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, 7, 1, 1]", "output": "224" }, { "input": "[100, 200, 10, 20]", "output": "28513" }, { "input": "[1, 5, 2, 3]", "output": "5" }, { "input": "[5, 10, 2, 4]", "output": "16" }, { "input": "[10, 15, 3, 2]", "output": "93" }, { "input": "[5,...
45
false
45
verified
10
10
1
2,010
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.CountGoodStrings.Code.Funs /-! # Specifications of `Aegis.CountGoodStrings.count_good_strings` LeetCode problem `count-ways-to-build-good-strings`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.CountGoodStrings namespace AegisSpec.CountGood...
9
number-of-subarrays-with-lcm-equal-to-k
2,470
Medium
[ "Array", "Math", "Number Theory" ]
Given an integer array nums and an integer k, return the number of subarrays of nums where the least common multiple of the subarray's elements is k. A subarray is a contiguous non-empty sequence of elements within an array. The least common multiple of an array is the smallest positive integer that is divisible by all...
subarrayLCM(nums: list_int, k: int) -> int
pub fn subarray_lcm(nums: &[i64], k: i64) -> i64
Aegis.SubarrayLcm.subarray_lcm
fn gcd(mut a: i64, mut b: i64) -> i64 { while b != 0 { let r = a % b; a = b; b = r; } a } pub fn subarray_lcm(nums: &[i64], k: i64) -> i64 { let n = nums.len(); let mut ans: i64 = 0; let mut i: usize = 0; while i < n { let mut l: i64 = 1; let mut j: ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [subarray_lcm]: type definitions module public import Aeneas @[expose] public section 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 -- [subarray_lcm]: function definitions module public import Aeneas public import Aegis.SubarrayLcm.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.SubarrayLcm.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := 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], 2]", "output": "0" }, { "input": "[[100, 100, 100], 100]", "output": "6" }, { "input": "[[5, 10, 15], 30]", "output": "2" }, { "input": "[[7, 7, 7, 7], 7]", "output": "10" }, { "input": "[[2, 4, 8, 16], 16]", "output": "4" }, { "input...
128
false
128
verified
10
10
1
1,220
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.SubarrayLcm.Code.Funs /-! # Specifications of `Aegis.SubarrayLcm.subarray_lcm` LeetCode problem `number-of-subarrays-with-lcm-equal-to-k`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.SubarrayLcm def vals (nums : Slice Std.I64) : Lis...
14
minimum-number-of-operations-to-sort-a-binary-tree-by-level
2,471
Medium
[ "Tree", "Breadth-First Search", "Binary Tree" ]
You are given the root of a binary tree with unique values. In one operation, you can choose any two nodes at the same level and swap their values. Return the minimum number of operations needed to make the values at each level sorted in a strictly increasing order. The level of a node is the number of edges along the ...
minimumOperations(root: tree) -> int
pub fn minimum_operations(root: &Tree) -> i64
Aegis.MinimumOperations.minimum_operations
fn collect_levels(t: &Tree, depth: usize, levels: &mut Vec<Vec<i64>>) { match t { Tree::Null => {} Tree::Node(v, l, r) => { if depth == levels.len() { levels.push(Vec::new()); } levels[depth].push(*v); collect_levels(&**l, depth + 1, le...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [minimum_operations]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option li...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [minimum_operations]: function definitions module public import Aeneas public import Aegis.MinimumOperations.Code.Types public import Aegis.MinimumOperations.Code.FunsExternal @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [minimum_operations]: external functions. -- This is a template file: rename it to "FunsExternal.lean" and fill the holes. module public import Aeneas public import Aegis.MinimumOperations.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow...
import Aegis.MinimumOperations.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval aeg...
[ { "input": "[[2, 3, 1]]", "output": "1" }, { "input": "[[1, 2, 3, 4, 5, 6]]", "output": "0" }, { "input": "[[1, 3, 2, 7, 6, 5, 4]]", "output": "3" }, { "input": "[[5, 6, 7, 8, 9, 10, 11]]", "output": "0" }, { "input": "[[10, 9, 8, 7, 6, 5, 4, 3, 2, 1]]", "outp...
61
false
61
verified
10
10
1
5,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.MinimumOperations.Code.Funs /-! # Specifications of `Aegis.MinimumOperations.minimum_operations` LeetCode problem `minimum-number-of-operations-to-sort-a-binary-tree-by-level`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result ControlFlow Error open Aegis.Mini...
12
maximum-number-of-non-overlapping-palindrome-substrings
2,472
Hard
[ "Greedy", "Two Pointers", "String", "Dynamic Programming" ]
You are given a string s and a positive integer k. Select a set of non-overlapping substrings from the string s that satisfy the following conditions: The length of each substring is at least k. Each substring is a palindrome. Return the maximum number of substrings in an optimal selection. A substring is a contiguou...
maxPalindromes(s: str, k: int) -> int
pub fn max_palindromes(s: &[u8], k: i64) -> i64
Aegis.MaxPalindromes.max_palindromes
pub fn max_palindromes(s: &[u8], k: i64) -> i64 { let n = s.len(); let kk = k as usize; let mut dp: Vec<i64> = Vec::new(); let mut i = 0usize; while i <= n { dp.push(0); i += 1; } let mut center = 0usize; while center < n { // Option to skip s[center]. i...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [max_palindromes]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linte...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [max_palindromes]: function definitions module public import Aeneas public import Aegis.MaxPalindromes.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.MaxPalindromes.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := 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": "[\"racecar\", 2]", "output": "1" }, { "input": "[\"mnoonm\", 2]", "output": "1" }, { "input": "[\"zzzzzz\", 1]", "output": "6" }, { "input": "[\"abcde\", 3]", "output": "0" }, { "input": "[\"abcdeedcba\", 2]", "output": "1" }, { "input": "[...
109
false
109
verified
10
10
1
13,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.MaxPalindromes.Code.Funs /-! # Specifications of `Aegis.MaxPalindromes.max_palindromes` LeetCode problem `maximum-number-of-non-overlapping-palindrome-substrings`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.MaxPalindromes namespace AegisSpec...
15
minimum-cost-to-buy-apples
2,473
Medium
[ "Graph", "Array", "Shortest Path", "Heap (Priority Queue)" ]
You are given a positive integer n representing n cities numbered from 1 to n. You are also given a 2D array roads, where roads[i] = [ai, bi, costi] indicates that there is a bidirectional road between cities ai and bi with a cost of traveling equal to costi. You can buy apples in any city you want, but some cities hav...
minCost(n: int, roads: list_list_int, appleCost: list_int, k: int) -> list_int
pub fn min_cost(n: i64, roads: &[Vec<i64>], appleCost: &[i64], k: i64) -> Vec<i64>
Aegis.MinCost.min_cost
pub fn min_cost(n: i64, roads: &[Vec<i64>], appleCost: &[i64], k: i64) -> Vec<i64> { let nn: usize = n as usize; let mut adj: Vec<Vec<i64>> = Vec::new(); let mut i: usize = 0; while i < nn { let row: Vec<i64> = Vec::new(); adj.push(row); i += 1; } let mut r: usize = 0; ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [min_cost]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter.style...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [min_cost]: function definitions module public import Aeneas public import Aegis.MinCost.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.un...
import Aegis.MinCost.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval aegisCase "ev...
[ { "input": "[2, [[1, 2, 1]], [10, 20], 1]", "output": "[10, 12]" }, { "input": "[3, [[1, 2, 5], [2, 3, 1], [3, 1, 2]], [2, 3, 1], 3]", "output": "[2, 3, 1]" }, { "input": "[4, [[1, 2, 4], [2, 3, 2], [2, 4, 5], [3, 4, 1], [1, 3, 4]], [56, 42, 102, 301], 2]", "output": "[54, 42, 48, 51...
69
false
69
verified
10
10
1
3,693
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MinCost.Code.Funs /-! # Specifications of `Aegis.MinCost.min_cost` LeetCode problem `minimum-cost-to-buy-apples`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Classical namespace AegisSpec.MinCost def roadCoords (r : alloc.vec.Vec Aeneas.Std...
13
number-of-unequal-triplets-in-array
2,475
Easy
[ "Array", "Hash Table", "Sorting" ]
You are given a 0-indexed array of positive integers nums. Find the number of triplets (i, j, k) that meet the following conditions: 0 <= i < j < k < nums.length nums[i], nums[j], and nums[k] are pairwise distinct. In other words, nums[i] != nums[j], nums[i] != nums[k], and nums[j] != nums[k]. Return the number o...
unequalTriplets(nums: list_int) -> int
pub fn unequal_triplets(nums: &[i64]) -> i64
Aegis.UnequalTriplets.unequal_triplets
pub fn unequal_triplets(nums: &[i64]) -> i64 { let n = nums.len(); let mut count: 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 { if nums[i] != nums[j] ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [unequal_triplets]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option lint...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [unequal_triplets]: function definitions module public import Aeneas public import Aegis.UnequalTriplets.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.UnequalTriplets.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := 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, 2, 3]]", "output": "1" }, { "input": "[[1, 2, 2, 3, 4]]", "output": "7" }, { "input": "[[1, 1, 1, 1, 1]]", "output": "0" }, { "input": "[[10, 20, 30, 40, 50]]", "output": "10" }, { "input": "[[1, 2, 3, 4, 5]]", "output": "10" }, { "inp...
74
false
74
verified
10
10
1
397
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.UnequalTriplets.Code.Funs /-! # Specifications of `Aegis.UnequalTriplets.unequal_triplets` LeetCode problem `number-of-unequal-triplets-in-array`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.UnequalTriplets namespace AegisSpec.UnequalTrip...
12
closest-nodes-queries-in-a-binary-search-tree
2,476
Medium
[ "Tree", "Depth-First Search", "Binary Search Tree", "Array", "Binary Search", "Binary Tree" ]
You are given the root of a binary search tree and an array queries of size n consisting of positive integers. Find a 2D array answer of size n where answer[i] = [mini, maxi]: mini is the largest value in the tree that is smaller than or equal to queries[i]. If a such value does not exist, add -1 instead. maxi is the ...
closestNodes(root: tree, queries: list_int) -> list_list_int
pub fn closest_nodes(root: &Tree, queries: &[i64]) -> Vec<Vec<i64>>
Aegis.ClosestNodes.closest_nodes
fn inorder(t: &Tree, out: Vec<i64>) -> Vec<i64> { match t { Tree::Null => out, Tree::Node(v, l, r) => { let mut out = inorder(&**l, out); out.push(*v); inorder(&**r, out) } } } pub fn closest_nodes(root: &Tree, queries: &[i64]) -> Vec<Vec<i64>> { ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [closest_nodes]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter....
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [closest_nodes]: function definitions module public import Aeneas public import Aegis.ClosestNodes.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.ClosestNodes.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := 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": "[[12, 5, 18, 2, 9, 15, 20, 1, 3, 7, 11, 13, 17, 19, 22], [6, 12, 23, 0]]", "output": "[[5, 7], [12, 12], [22, -1], [-1, 1]]" }, { "input": "[[10, 5, 15, 3, 7, 13, 18, 1, 4, 6, 8, 12, 14, 17, 19], [2, 9, 20, 11, 7]]", "output": "[[1, 3], [8, 10], [19, -1], [10, 12], [7, 7]]" }, { ...
38
false
38
verified
10
10
1
4,875
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.ClosestNodes.Code.Funs /-! # Specifications of `Aegis.ClosestNodes.closest_nodes` LeetCode problem `closest-nodes-queries-in-a-binary-search-tree`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.ClosestNodes namespace AegisSpec.ClosestNodes ...
19
minimum-fuel-cost-to-report-to-the-capital
2,477
Medium
[ "Tree", "Depth-First Search", "Breadth-First Search", "Graph" ]
There is a tree (i.e., a connected, undirected graph with no cycles) structure country network consisting of n cities numbered from 0 to n - 1 and exactly n - 1 roads. The capital city is city 0. You are given a 2D integer array roads where roads[i] = [ai, bi] denotes that there exists a bidirectional road connecting c...
minimumFuelCost(roads: list_list_int, seats: int) -> int
pub fn minimum_fuel_cost(roads: &[Vec<i64>], seats: i64) -> i64
Aegis.MinimumFuelCost.minimum_fuel_cost
pub fn minimum_fuel_cost(roads: &[Vec<i64>], seats: i64) -> i64 { let n = roads.len() + 1; 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; } i = 0; while i < roads.len() { le...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [minimum_fuel_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 lin...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [minimum_fuel_cost]: function definitions module public import Aeneas public import Aegis.MinimumFuelCost.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.MinimumFuelCost.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval aegis...
[ { "input": "[[], 1]", "output": "0" }, { "input": "[[[0, 1], [0, 2], [0, 3]], 5]", "output": "3" }, { "input": "[[[0, 1], [1, 2], [2, 3], [3, 4]], 3]", "output": "5" }, { "input": "[[[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6]], 4]", "output": "6" }, { "input":...
65
false
65
verified
10
10
1
4,048
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MinimumFuelCost.Code.Funs /-! # Specifications of `Aegis.MinimumFuelCost.minimum_fuel_cost` LeetCode problem `minimum-fuel-cost-to-report-to-the-capital`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.MinimumFuelCost namespace AegisSpec.Minimum...
13
number-of-beautiful-partitions
2,478
Hard
[ "String", "Dynamic Programming" ]
You are given a string s that consists of the digits '1' to '9' and two integers k and minLength. A partition of s is called beautiful if: s is partitioned into k non-intersecting substrings. Each substring has a length of at least minLength. Each substring starts with a prime digit and ends with a non-prime digit. Pr...
beautifulPartitions(s: str, k: int, minLength: int) -> int
pub fn beautiful_partitions(s: &[u8], k: i64, minLength: i64) -> i64
Aegis.BeautifulPartitions.beautiful_partitions
fn is_prime_digit(c: u8) -> bool { c == b'2' || c == b'3' || c == b'5' || c == b'7' } pub fn beautiful_partitions(s: &[u8], k: i64, minLength: i64) -> i64 { let n: usize = s.len(); let kk: usize = k as usize; let l: usize = minLength as usize; let modulo: i64 = 1000000007; let mut prev: Vec<i6...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [beautiful_partitions]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [beautiful_partitions]: function definitions module public import Aeneas public import Aegis.BeautifulPartitions.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand fa...
import Aegis.BeautifulPartitions.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := 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": "[\"52372938462673572\", 4, 2]", "output": "0" }, { "input": "[\"33333\", 1, 1]", "output": "0" }, { "input": "[\"23542185131\", 3, 3]", "output": "1" }, { "input": "[\"3312958\", 3, 1]", "output": "1" }, { "input": "[\"253179\", 2, 1]", "output": "...
117
false
117
verified
10
10
1
7,640
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.BeautifulPartitions.Code.Funs /-! # Specifications of `Aegis.BeautifulPartitions.beautiful_partitions` LeetCode problem `number-of-beautiful-partitions`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.BeautifulPartitions def IsAsciiDig...
14
maximum-xor-of-two-non-overlapping-subtrees
2,479
Hard
[ "Tree", "Depth-First Search", "Graph", "Trie" ]
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. The root of the tree is the node labeled 0. Each node has an associated value. You ar...
maxXor(n: int, edges: list_list_int, values: list_int) -> int
pub fn max_xor(n: i64, edges: &[Vec<i64>], values: &[i64]) -> i64
Aegis.MaxXor.max_xor
pub fn max_xor(n: i64, edges: &[Vec<i64>], values: &[i64]) -> i64 { if n < 2 { return 0; } let n_usize = values.len(); if n_usize < 2 { return 0; } // Build adjacency list. let mut adj: Vec<Vec<i64>> = Vec::new(); let mut i: usize = 0; while i < n_usize { ad...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [max_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_option linter.style....
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [max_xor]: function definitions module public import Aeneas public import Aegis.MaxXor.Code.Types public import Aegis.MaxXor.Code.FunsExternal @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option li...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [max_xor]: external functions. -- This is a template file: rename it to "FunsExternal.lean" and fill the holes. module public import Aeneas public import Aegis.MaxXor.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option lint...
import Aegis.MaxXor.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := 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": "[3, [[0, 1], [1, 2]], [4, 6, 1]]", "output": "0" }, { "input": "[4, [[0, 1], [0, 2], [1, 3]], [1, 1, 1, 1]]", "output": "3" }, { "input": "[4, [[0, 1], [0, 2], [0, 3]], [5, 1, 2, 3]]", "output": "3" }, { "input": "[4, [[0, 1], [0, 2], [0, 3]], [5, 10, 15, 20]]", ...
72
false
72
verified
10
10
1
17,325
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MaxXor.Code.Funs /-! # Specifications of `Aegis.MaxXor.max_xor` LeetCode problem `maximum-xor-of-two-non-overlapping-subtrees`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.MaxXor open Aegis.MaxXor def xorInt (a b : Int) : Int := ((...
10
minimum-cuts-to-divide-a-circle
2,481
Easy
[ "Geometry", "Math" ]
A valid cut in a circle can be: A cut that is represented by a straight line that touches two points on the edge of the circle and passes through its center, or A cut that is represented by a straight line that touches one point on the edge of the circle and its center. Some valid and invalid cuts are shown in the fi...
numberOfCuts(n: int) -> int
pub fn number_of_cuts(n: i64) -> i64
Aegis.NumberOfCuts.number_of_cuts
pub fn number_of_cuts(n: i64) -> i64 { if n == 1 { 0 } else if n % 2 == 0 { n / 2 } else { n } }
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [number_of_cuts]: type definitions module public import Aeneas @[expose] public section 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_cuts]: function definitions module public import Aeneas public import Aegis.NumberOfCuts.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.NumberOfCuts.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval aegisCas...
[ { "input": "[3]", "output": "3" }, { "input": "[100]", "output": "50" }, { "input": "[4]", "output": "2" }, { "input": "[99]", "output": "99" }, { "input": "[17]", "output": "17" }, { "input": "[2]", "output": "1" }, { "input": "[1]", "...
44
false
44
verified
10
10
1
207
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.NumberOfCuts.Code.Funs /-! # Specifications of `Aegis.NumberOfCuts.number_of_cuts` LeetCode problem `minimum-cuts-to-divide-a-circle`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.NumberOfCuts /-- The function returns a result r ...
12
difference-between-ones-and-zeros-in-row-and-column
2,482
Medium
[ "Array", "Matrix", "Simulation" ]
You are given a 0-indexed m x n binary matrix grid. A 0-indexed m x n difference matrix diff is created with the following procedure: Let the number of ones in the ith row be onesRowi. Let the number of ones in the jth column be onesColj. Let the number of zeros in the ith row be zerosRowi. Let the number of zeros in ...
onesMinusZeros(grid: list_list_int) -> list_list_int
pub fn ones_minus_zeros(grid: &[Vec<i64>]) -> Vec<Vec<i64>>
Aegis.OnesMinusZeros.ones_minus_zeros
pub fn ones_minus_zeros(grid: &[Vec<i64>]) -> Vec<Vec<i64>> { let m = grid.len(); if m == 0 { return Vec::new(); } let n = grid[0].len(); let mut ones_row: Vec<i64> = Vec::new(); let mut i = 0; while i < m { let row = &grid[i]; let mut cnt: i64 = 0; let mut j...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [ones_minus_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 lint...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [ones_minus_zeros]: function definitions module public import Aeneas public import Aegis.OnesMinusZeros.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.OnesMinusZeros.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval aegisC...
[ { "input": "[[[1]]]", "output": "[[2]]" }, { "input": "[[[0]]]", "output": "[[-2]]" }, { "input": "[[[1, 0], [0, 1]]]", "output": "[[0, 0], [0, 0]]" }, { "input": "[[[1, 1, 1], [1, 1, 1]]]", "output": "[[5, 5, 5], [5, 5, 5]]" }, { "input": "[[[0, 0, 0], [0, 0, 0]]...
67
false
67
verified
10
10
1
1,595
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.OnesMinusZeros.Code.Funs /-! # Specifications of `Aegis.OnesMinusZeros.ones_minus_zeros` LeetCode problem `difference-between-ones-and-zeros-in-row-and-column`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.OnesMinusZeros def grid...
14
minimum-penalty-for-a-shop
2,483
Medium
[ "String", "Prefix Sum" ]
You are given the customer visit log of a shop represented by a 0-indexed string customers consisting only of characters 'N' and 'Y': if the ith character is 'Y', it means that customers come at the ith hour whereas 'N' indicates that no customers come at the ith hour. If the shop closes at the jth hour (0 <= j <= n)...
bestClosingTime(customers: str) -> int
pub fn best_closing_time(customers: &[u8]) -> i64
Aegis.BestClosingTime.best_closing_time
pub fn best_closing_time(customers: &[u8]) -> i64 { let n = customers.len(); let mut total_y: i64 = 0; let mut i: usize = 0; while i < n { if customers[i] == b'Y' { total_y += 1; } i += 1; } // Penalty when closing at hour 0: all customers are missed. le...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [best_closing_time]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option lin...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [best_closing_time]: function definitions module public import Aeneas public import Aegis.BestClosingTime.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.BestClosingTime.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := 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": "[\"YNYNYN\"]", "output": "1" }, { "input": "[\"YNNYNYYNYN\"]", "output": "1" }, { "input": "[\"NNYNNYNNYNNYNN\"]", "output": "0" }, { "input": "[\"YYYYNNYYYYNNYYYYNNYYYYNNNN\"]", "output": "22" }, { "input": "[\"YNYYYYYYNY\"]", "output": "8" }, ...
152
false
152
verified
10
10
1
1,010
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.BestClosingTime.Code.Funs /-! # Specifications of `Aegis.BestClosingTime.best_closing_time` LeetCode problem `minimum-penalty-for-a-shop`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.BestClosingTime def byteY : Std.U8 := 89#u8 ...
8
count-palindromic-subsequences
2,484
Hard
[ "String", "Dynamic Programming" ]
Given a string of digits s, return the number of palindromic subsequences of s having length 5. Since the answer may be very large, return it modulo 109 + 7. Note: A string is palindromic if it reads the same forward and backward. A subsequence is a string that can be derived from another string by deleting some or no...
countPalindromes(s: str) -> int
pub fn count_palindromes(s: &[u8]) -> i64
Aegis.CountPalindromes.count_palindromes
pub fn count_palindromes(s: &[u8]) -> i64 { const MOD: i64 = 1000000007; let n = s.len(); if n < 5 { return 0; } // suf_pairs[k] stores counts of ordered pairs (i, j) with // k < i < j, flattened as first_digit * 10 + second_digit. let total = n * 100; let mut suf_pairs: Vec<i6...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [count_palindromes]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option lin...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [count_palindromes]: function definitions module public import Aeneas public import Aegis.CountPalindromes.Code.Types public import Aegis.CountPalindromes.Code.FunsExternal @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.du...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [count_palindromes]: external functions. -- This is a template file: rename it to "FunsExternal.lean" and fill the holes. module public import Aeneas public import Aegis.CountPalindromes.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow E...
import Aegis.CountPalindromes.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := 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": "[\"100100100\"]", "output": "34" }, { "input": "[\"9876543210\"]", "output": "0" }, { "input": "[\"54321012345\"]", "output": "30" }, { "input": "[\"12345678900987654321\"]", "output": "240" }, { "input": "[\"00000000000000000000\"]", "output": "15...
149
false
149
verified
10
10
1
6,128
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.CountPalindromes.Code.Funs /-! # Specifications of `Aegis.CountPalindromes.count_palindromes` LeetCode problem `count-palindromic-subsequences`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.CountPalindromes namespace AegisSpec.CountPalindr...
12
find-the-pivot-integer
2,485
Easy
[ "Math", "Prefix Sum" ]
Given a positive integer n, find the pivot integer x such that: The sum of all elements between 1 and x inclusively equals the sum of all elements between x and n inclusively. Return the pivot integer x. If no such integer exists, return -1. It is guaranteed that there will be at most one pivot index for the given in...
pivotInteger(n: int) -> int
pub fn pivot_integer(n: i64) -> i64
Aegis.PivotInteger.pivot_integer
pub fn pivot_integer(n: i64) -> i64 { let mut total: i64 = 0; let mut i: i64 = 1; while i <= n { total += i; i += 1; } let mut prefix: i64 = 0; let mut x: i64 = 1; while x <= n { prefix += x; let suffix: i64 = total - prefix + x; if prefix == suffix {...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [pivot_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 linter....
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [pivot_integer]: function definitions module public import Aeneas public import Aegis.PivotInteger.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.PivotInteger.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := 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": "[8]", "output": "6" }, { "input": "[3]", "output": "-1" }, { "input": "[4]", "output": "-1" }, { "input": "[1]", "output": "1" }, { "input": "[1000]", "output": "-1" }, { "input": "[10]", "output": "-1" }, { "input": "[625]", ...
52
false
52
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.PivotInteger.Code.Funs /-! # Specifications of `Aegis.PivotInteger.pivot_integer` LeetCode problem `find-the-pivot-integer`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.PivotInteger open Aegis.PivotInteger def isumAux (a : ℤ)...
8
append-characters-to-string-to-make-subsequence
2,486
Medium
[ "Greedy", "Two Pointers", "String" ]
You are given two strings s and t consisting of only lowercase English letters. Return the minimum number of characters that need to be appended to the end of s so that t becomes a subsequence of s. A subsequence is a string that can be derived from another string by deleting some or no characters without changing the ...
appendCharacters(s: str, t: str) -> int
pub fn append_characters(s: &[u8], t: &[u8]) -> i64
Aegis.AppendCharacters.append_characters
pub fn append_characters(s: &[u8], t: &[u8]) -> i64 { let n = s.len(); let m = t.len(); let mut i: usize = 0; let mut j: usize = 0; while i < n && j < m { if s[i] == t[j] { j += 1; } i += 1; } let mut result: i64 = 0; while j < m { result +=...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [append_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 set_option lin...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [append_characters]: function definitions module public import Aeneas public import Aegis.AppendCharacters.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.AppendCharacters.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := 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": "[\"abcdefgh\", \"ghijkl\"]", "output": "4" }, { "input": "[\"ababab\", \"bbba\"]", "output": "1" }, { "input": "[\"abcd\", \"xyz\"]", "output": "3" }, { "input": "[\"aaaa\", \"a\"]", "output": "0" }, { "input": "[\"abcd\", \"dbca\"]", "output": "3"...
153
false
153
verified
10
10
1
446
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.AppendCharacters.Code.Funs /-! # Specifications of `Aegis.AppendCharacters.append_characters` LeetCode problem `append-characters-to-string-to-make-subsequence`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.AppendCharacters def isLow...
12
remove-nodes-from-linked-list
2,487
Medium
[ "Stack", "Recursion", "Linked List", "Monotonic Stack" ]
You are given the head of a linked list. Remove every node which has a node with a greater value anywhere to the right side of it. Return the head of the modified linked list.   Example 1: Input: head = [5,2,13,3,8] Output: [13,8] Explanation: The nodes that should be removed are 5, 2 and 3. - Node 13 is to the right...
removeNodes(head: linkedlist) -> linkedlist
pub fn remove_nodes(head: &List) -> List
Aegis.RemoveNodes.remove_nodes
// The previous version matched on `&rest` and mutated outer locals inside the // arm, which the Aeneas context-matcher could not handle. Here we match the // recursively built suffix BY VALUE and consume it directly in each branch. pub fn remove_nodes(head: &List) -> List { match head { List::Nil => List...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [remove_nodes]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter.s...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [remove_nodes]: function definitions module public import Aeneas public import Aegis.RemoveNodes.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.RemoveNodes.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" deriving instan...
[ { "input": "[[5]]", "output": "[5]" }, { "input": "[[1, 2, 3, 4, 5]]", "output": "[5]" }, { "input": "[[10, 20, 30, 40, 50]]", "output": "[50]" }, { "input": "[[10, 5, 20, 3]]", "output": "[20, 3]" }, { "input": "[[3, 2, 1]]", "output": "[3, 2, 1]" }, { ...
108
false
108
verified
10
10
3
22,356
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.RemoveNodes.Code.Funs /-! # Specifications of `Aegis.RemoveNodes.remove_nodes` LeetCode problem `remove-nodes-from-linked-list`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.RemoveNodes open Aegis.RemoveNodes (remove_nodes) ab...
11
number-of-substrings-with-fixed-ratio
2,489
Medium
[ "Hash Table", "Math", "String", "Prefix Sum" ]
You are given a binary string s, and two integers num1 and num2. num1 and num2 are coprime numbers. A ratio substring is a substring of s where the ratio between the number of 0's and the number of 1's in the substring is exactly num1 : num2. For example, if num1 = 2 and num2 = 3, then "01011" and "1110000111" are rat...
fixedRatio(s: str, num1: int, num2: int) -> int
pub fn fixed_ratio(s: &[u8], num1: i64, num2: i64) -> i64
Aegis.FixedRatio.fixed_ratio
pub fn fixed_ratio(s: &[u8], num1: i64, num2: i64) -> i64 { let n: usize = s.len(); let len: usize = n + 1; // prefix value = num2 * (#zeros) - num1 * (#ones) // Two prefix positions form a valid substring exactly when their values are equal. let mut vals: Vec<i64> = Vec::new(); let mut prefix:...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [fixed_ratio]: type definitions module public import Aeneas @[expose] public section 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 -- [fixed_ratio]: function definitions module public import Aeneas public import Aegis.FixedRatio.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.FixedRatio.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := 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": "[\"0110011\", 1, 2]", "output": "4" }, { "input": "[\"01010101\", 2, 2]", "output": "16" }, { "input": "[\"111000\", 1, 1]", "output": "3" }, { "input": "[\"1100110011\", 2, 2]", "output": "16" }, { "input": "[\"00110011\", 2, 2]", "output": "10" ...
97
false
97
verified
10
10
1
6,409
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.FixedRatio.Code.Funs /-! # Specifications of `Aegis.FixedRatio.fixed_ratio` LeetCode problem `number-of-substrings-with-fixed-ratio`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.FixedRatio abbrev U8 := Aeneas.Std.U8 abbrev ByteSlic...
12
circular-sentence
2,490
Easy
[ "String" ]
A sentence is a list of words that are separated by a single space with no leading or trailing spaces. For example, "Hello World", "HELLO", "hello world hello world" are all sentences. Words consist of only uppercase and lowercase English letters. Uppercase and lowercase English letters are considered different. A se...
isCircularSentence(sentence: str) -> bool
pub fn is_circular_sentence(sentence: &[u8]) -> bool
Aegis.IsCircularSentence.is_circular_sentence
pub fn is_circular_sentence(sentence: &[u8]) -> bool { let n = sentence.len(); if n == 0 { return true; } let mut i: usize = 1; while i + 1 < n { if sentence[i] == b' ' { if sentence[i - 1] != sentence[i + 1] { return false; } } ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [is_circular_sentence]: type definitions module public import Aeneas @[expose] public section 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 -- [is_circular_sentence]: function definitions module public import Aeneas public import Aegis.IsCircularSentence.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand fal...
import Aegis.IsCircularSentence.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := 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": "[\"sentence ence sent\"]", "output": "false" }, { "input": "[\"hello olleh\"]", "output": "true" }, { "input": "[\"Aa Aa\"]", "output": "false" }, { "input": "[\"ab ba\"]", "output": "true" }, { "input": "[\"a\"]", "output": "true" }, { "in...
219
false
219
verified
10
10
1
612
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.IsCircularSentence.Code.Funs /-! # Specifications of `Aegis.IsCircularSentence.is_circular_sentence` LeetCode problem `circular-sentence`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.IsCircularSentence open Aegis.IsCircularSente...
8
divide-players-into-teams-of-equal-skill
2,491
Medium
[ "Array", "Hash Table", "Two Pointers", "Sorting" ]
You are given a positive integer array skill of even length n where skill[i] denotes the skill of the ith player. Divide the players into n / 2 teams of size 2 such that the total skill of each team is equal. The chemistry of a team is equal to the product of the skills of the players on that team. Return the sum of th...
dividePlayers(skill: list_int) -> int
pub fn divide_players(skill: &[i64]) -> i64
Aegis.DividePlayers.divide_players
pub fn divide_players(skill: &[i64]) -> i64 { let n = skill.len(); if n == 0 { return 0; } if n % 2 != 0 { return -1; } let mut counts: Vec<i64> = Vec::new(); let mut i: usize = 0; while i < 1001 { counts.push(0); i += 1; } let mut ok: bool = tru...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [divide_players]: type definitions module public import Aeneas @[expose] public section 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 -- [divide_players]: function definitions module public import Aeneas public import Aegis.DividePlayers.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.DividePlayers.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval aegisCa...
[ { "input": "[[3, 4]]", "output": "12" }, { "input": "[[1, 1, 2, 3]]", "output": "-1" }, { "input": "[[4, 4, 4, 4]]", "output": "32" }, { "input": "[[10, 10, 10, 10]]", "output": "200" }, { "input": "[[5, 5, 5, 5, 5, 5]]", "output": "75" }, { "input": "...
122
false
122
verified
10
10
2
4,229
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.DividePlayers.Code.Funs /-! # Specifications of `Aegis.DividePlayers.divide_players` LeetCode problem `divide-players-into-teams-of-equal-skill`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.DividePlayers namespace AegisSpec.DividePlayers def...
11
minimum-score-of-a-path-between-two-cities
2,492
Medium
[ "Depth-First Search", "Breadth-First Search", "Union Find", "Graph" ]
You are given a positive integer n representing n cities numbered from 1 to n. You are also given a 2D array roads where roads[i] = [ai, bi, distancei] indicates that there is a bidirectional road between cities ai and bi with a distance equal to distancei. The cities graph is not necessarily connected. The score of a ...
minScore(n: int, roads: list_list_int) -> int
pub fn min_score(n: i64, roads: &[Vec<i64>]) -> i64
Aegis.MinScore.min_score
pub fn min_score(n: i64, roads: &[Vec<i64>]) -> i64 { let nn = n as usize; let mut adj: Vec<Vec<i64>> = Vec::new(); let mut i: usize = 0; while i <= nn { let row: Vec<i64> = Vec::new(); adj.push(row); i += 1; } let mut r: usize = 0; while r < roads.len() { l...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [min_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 -- [min_score]: function definitions module public import Aeneas public import Aegis.MinScore.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.MinScore.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := 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": "[3, [[1, 2, 3], [2, 3, 1]]]", "output": "1" }, { "input": "[4, [[1, 2, 2], [1, 3, 4], [3, 4, 7]]]", "output": "2" }, { "input": "[3, [[1, 2, 5], [2, 3, 10], [1, 3, 7]]]", "output": "5" }, { "input": "[3, [[1, 2, 1], [2, 3, 2], [1, 3, 3]]]", "output": "1" }, ...
65
false
65
verified
10
10
1
2,631
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MinScore.Code.Funs /-! # Specifications of `Aegis.MinScore.min_score` LeetCode problem `minimum-score-of-a-path-between-two-cities`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.MinScore structure Road where a : Int b : Int ...
9
divide-nodes-into-the-maximum-number-of-groups
2,493
Hard
[ "Depth-First Search", "Breadth-First Search", "Union Find", "Graph" ]
You are given a positive integer n representing the number of nodes in an undirected graph. The nodes are labeled from 1 to n. You are also given a 2D integer array edges, where edges[i] = [ai, bi] indicates that there is a bidirectional edge between nodes ai and bi. Notice that the given graph may be disconnected. Div...
magnificentSets(n: int, edges: list_list_int) -> int
pub fn magnificent_sets(n: i64, edges: &[Vec<i64>]) -> i64
Aegis.MagnificentSets.magnificent_sets
pub fn magnificent_sets(n: i64, edges: &[Vec<i64>]) -> i64 { let n_usize = n as usize; if n_usize == 0 { return 0; } let mut adj: Vec<Vec<i64>> = Vec::new(); let mut i: usize = 0; while i < n_usize { adj.push(Vec::new()); i += 1; } let mut e: usize = 0; whil...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [magnificent_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 lint...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [magnificent_sets]: function definitions module public import Aeneas public import Aegis.MagnificentSets.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.MagnificentSets.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval aegis...
[ { "input": "[4, [[1, 2]]]", "output": "4" }, { "input": "[4, [[1, 2], [3, 4]]]", "output": "4" }, { "input": "[4, [[1, 2], [2, 3]]]", "output": "4" }, { "input": "[5, [[1, 2], [3, 4]]]", "output": "5" }, { "input": "[3, [[1, 2], [2, 3], [3, 1]]]", "output": "-...
83
false
83
verified
10
10
2
10,159
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MagnificentSets.Code.Funs /-! # Specifications of `Aegis.MagnificentSets.magnificent_sets` LeetCode problem `divide-nodes-into-the-maximum-number-of-groups`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.MagnificentSets namespace AegisSpec....
14
number-of-subarrays-having-even-product
2,495
Medium
[ "Array", "Math", "Dynamic Programming" ]
Given a 0-indexed integer array nums, return the number of subarrays of nums having an even product.   Example 1: Input: nums = [9,6,7,13] Output: 6 Explanation: There are 6 subarrays with an even product: - nums[0..1] = 9 * 6 = 54. - nums[0..2] = 9 * 6 * 7 = 378. - nums[0..3] = 9 * 6 * 7 * 13 = 4914. - nums[1..1] = 6...
evenProduct(nums: list_int) -> int
pub fn even_product(nums: &[i64]) -> i64
Aegis.EvenProduct.even_product
pub fn even_product(nums: &[i64]) -> i64 { let n = nums.len(); let n_i = n as i64; let total = n_i * (n_i + 1) / 2; let mut odd_subarrays: i64 = 0; let mut odd_run: i64 = 0; let mut i: usize = 0; while i < n { if nums[i] % 2 == 0 { odd_subarrays = odd_subarrays + odd_ru...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [even_product]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter.s...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [even_product]: function definitions module public import Aeneas public import Aegis.EvenProduct.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.EvenProduct.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := 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": "0" }, { "input": "[[2]]", "output": "1" }, { "input": "[[1, 2]]", "output": "2" }, { "input": "[[2, 1]]", "output": "2" }, { "input": "[[7, 3, 5]]", "output": "0" }, { "input": "[[100000, 99999, 99998, 99997]]", "outp...
84
false
84
verified
10
10
1
639
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.EvenProduct.Code.Funs /-! # Specifications of `Aegis.EvenProduct.even_product` LeetCode problem `number-of-subarrays-having-even-product`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.EvenProduct abbrev SliceI64 : Type := Aeneas.Std....
12
maximum-value-of-a-string-in-an-array
2,496
Easy
[ "Array", "String" ]
The value of an alphanumeric string can be defined as: The numeric representation of the string in base 10, if it comprises of digits only. The length of the string, otherwise. Given an array strs of alphanumeric strings, return the maximum value of any string in strs.   Example 1: Input: strs = ["alic3","bob","3","...
maximumValue(strs: list_str) -> int
pub fn maximum_value(strs: &[Vec<u8>]) -> i64
Aegis.MaximumValue.maximum_value
pub fn maximum_value(strs: &[Vec<u8>]) -> i64 { let mut best: i64 = 0; let mut i: usize = 0; while i < strs.len() { let s = &strs[i]; let mut all_digits: bool = true; let mut j: usize = 0; while j < s.len() { let c = s[j]; if c < b'0' || c > b'9' { ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [maximum_value]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter....
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [maximum_value]: function definitions module public import Aeneas public import Aegis.MaximumValue.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.MaximumValue.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := 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": "[[\"xyz\", \"xyzz\", \"xyzzz\", \"xyzzzz\"]]", "output": "6" }, { "input": "[[\"abc\", \"123\", \"a1b2c3\", \"000\"]]", "output": "123" }, { "input": "[[\"987654321\", \"abcdefg\", \"hijklmn\", \"000000000\"]]", "output": "987654321" }, { "input": "[[\"1\", \"01\"...
109
false
109
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.MaximumValue.Code.Funs /-! # Specifications of `Aegis.MaximumValue.maximum_value` LeetCode problem `maximum-value-of-a-string-in-an-array`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.MaximumValue (maximum_value) open Classical namespace Aegi...
10
maximum-star-sum-of-a-graph
2,497
Medium
[ "Greedy", "Graph", "Array", "Sorting", "Heap (Priority Queue)" ]
There is an undirected graph consisting of n nodes numbered from 0 to n - 1. You are given a 0-indexed integer array vals of length n where vals[i] denotes the value of the ith node. You are also given a 2D integer array edges where edges[i] = [ai, bi] denotes that there exists an undirected edge connecting nodes ai an...
maxStarSum(vals: list_int, edges: list_list_int, k: int) -> int
pub fn max_star_sum(vals: &[i64], edges: &[Vec<i64>], k: i64) -> i64
Aegis.MaxStarSum.max_star_sum
pub fn max_star_sum(vals: &[i64], edges: &[Vec<i64>], k: i64) -> i64 { let n = vals.len(); let mut adj: Vec<Vec<i64>> = Vec::new(); let mut i = 0usize; while i < n { let row: Vec<i64> = Vec::new(); adj.push(row); i += 1; } let mut e = 0usize; while e < edges.len() {...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [max_star_sum]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter.s...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [max_star_sum]: function definitions module public import Aeneas public import Aegis.MaxStarSum.Code.Types public import Aegis.MaxStarSum.Code.FunsExternal @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [max_star_sum]: external functions. -- This is a template file: rename it to "FunsExternal.lean" and fill the holes. module public import Aeneas public import Aegis.MaxStarSum.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_op...
import Aegis.MaxStarSum.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := 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], [], 0]", "output": "-5" }, { "input": "[[1, 2, 3], [[0, 1], [1, 2]], 0]", "output": "3" }, { "input": "[[1, 2, 3], [[0, 1], [1, 2]], 0]", "output": "3" }, { "input": "[[1, 2, 3], [[0, 1], [1, 2]], 1]", "output": "5" }, { "input": "[[5, -2, 3, 1]...
107
false
107
verified
10
10
1
1,746
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MaxStarSum.Code.Funs /-! # Specifications of `Aegis.MaxStarSum.max_star_sum` LeetCode problem `maximum-star-sum-of-a-graph`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result set_option maxHeartbeats 1000000 namespace AegisSpec.MaxStarSum open scoped BigOpe...
12
frog-jump-ii
2,498
Medium
[ "Greedy", "Array", "Binary Search" ]
You are given a 0-indexed integer array stones sorted in strictly increasing order representing the positions of stones in a river. A frog, initially on the first stone, wants to travel to the last stone and then return to the first stone. However, it can jump to any stone at most once. The length of a jump is the abso...
maxJump(stones: list_int) -> int
pub fn max_jump(stones: &[i64]) -> i64
Aegis.MaxJump.max_jump
pub fn max_jump(stones: &[i64]) -> i64 { let n = stones.len(); let mut ans = stones[1] - stones[0]; let mut i: usize = 0; while i + 2 < n { let jump = stones[i + 2] - stones[i]; if jump > ans { ans = jump; } i += 1; } ans }
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [max_jump]: type definitions module public import Aeneas @[expose] public section 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_jump]: function definitions module public import Aeneas public import Aegis.MaxJump.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.un...
import Aegis.MaxJump.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := 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": "[[0, 3, 9]]", "output": "9" }, { "input": "[[0, 10, 15, 20, 25]]", "output": "15" }, { "input": "[[0, 2, 5, 6, 7]]", "output": "5" }, { "input": "[[0, 10, 15, 25, 30]]", "output": "15" }, { "input": "[[0, 10, 20, 30, 40]]", "output": "20" }, { ...
106
false
106
verified
10
10
1
967
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MaxJump.Code.Funs /-! # Specifications of `Aegis.MaxJump.max_jump` LeetCode problem `frog-jump-ii`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.MaxJump def vals (stones : Slice Std.I64) : List ℤ := stones.val.map (fun x => x.val) d...
8
delete-greatest-value-in-each-row
2,500
Easy
[ "Array", "Matrix", "Sorting", "Simulation", "Heap (Priority Queue)" ]
You are given an m x n matrix grid consisting of positive integers. Perform the following operation until grid becomes empty: Delete the element with the greatest value from each row. If multiple such elements exist, delete any of them. Add the maximum of deleted elements to the answer. Note that the number of column...
deleteGreatestValue(grid: list_list_int) -> int
pub fn delete_greatest_value(grid: &[Vec<i64>]) -> i64
Aegis.DeleteGreatestValue.delete_greatest_value
pub fn delete_greatest_value(grid: &[Vec<i64>]) -> i64 { let m = grid.len(); if m == 0 { return 0; } let mut rows: Vec<Vec<i64>> = Vec::new(); let mut i: usize = 0; while i < m { let src = &grid[i]; let len = src.len(); let mut row: Vec<i64> = Vec::new(); ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [delete_greatest_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 -- [delete_greatest_value]: function definitions module public import Aeneas public import Aegis.DeleteGreatestValue.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand f...
import Aegis.DeleteGreatestValue.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := 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]]]", "output": "10" }, { "input": "[[[5, 3], [9, 7]]]", "output": "16" }, { "input": "[[[1, 2, 4], [3, 3, 1]]]", "output": "8" }, { "input": "[[[5, 3], [9, 7], [2, 6]]]", "output": "16" }, { "input": "[[[1, 2], [3, 4], [5, 6]]]", "output": "1...
93
false
93
verified
10
10
1
1,563
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.DeleteGreatestValue.Code.Funs /-! # Specifications of `Aegis.DeleteGreatestValue.delete_greatest_value` LeetCode problem `delete-greatest-value-in-each-row`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.DeleteGreatestValue open A...
10
longest-square-streak-in-an-array
2,501
Medium
[ "Array", "Hash Table", "Binary Search", "Dynamic Programming", "Sorting" ]
You are given an integer array nums. A subsequence of nums is called a square streak if: The length of the subsequence is at least 2, and after sorting the subsequence, each element (except the first element) is the square of the previous number. Return the length of the longest square streak in nums, or return -1 if...
longestSquareStreak(nums: list_int) -> int
pub fn longest_square_streak(nums: &[i64]) -> i64
Aegis.LongestSquareStreak.longest_square_streak
fn integer_sqrt(x: i64) -> i64 { if x < 2 { return x; } let mut lo: i64 = 1; let mut hi: i64 = x; while lo <= hi { let mid: i64 = lo + (hi - lo) / 2; if mid <= x / mid { lo = mid + 1; } else { hi = mid - 1; } } hi } pub fn l...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [longest_square_streak]: type definitions module public import Aeneas @[expose] public section 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 -- [longest_square_streak]: function definitions module public import Aeneas public import Aegis.LongestSquareStreak.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand f...
import Aegis.LongestSquareStreak.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := 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": "[[4, 16, 256, 65536]]", "output": "4" }, { "input": "[[6, 36, 1296, 46656]]", "output": "3" }, { "input": "[[7, 49, 2401, 117649]]", "output": "3" }, { "input": "[[10, 100, 10000, 1000000]]", "output": "3" }, { "input": "[[5, 25, 625, 390625]]", "o...
99
false
99
verified
10
10
1
9,095
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.LongestSquareStreak.Code.Funs /-! # Specifications of `Aegis.LongestSquareStreak.longest_square_streak` LeetCode problem `longest-square-streak-in-an-array`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.LongestSquareStreak namespace AegisSpec...
12
maximum-number-of-points-from-grid-queries
2,503
Hard
[ "Breadth-First Search", "Union Find", "Array", "Two Pointers", "Matrix", "Sorting", "Heap (Priority Queue)" ]
You are given an m x n integer matrix grid and an array queries of size k. Find an array answer of size k such that for each integer queries[i] you start in the top left cell of the matrix and repeat the following process: If queries[i] is strictly greater than the value of the current cell that you are in, then you g...
maxPoints(grid: list_list_int, queries: list_int) -> list_int
pub fn max_points(grid: &[Vec<i64>], queries: &[i64]) -> Vec<i64>
Aegis.MaxPoints.max_points
fn merge_sort_by_key(vals: &Vec<i64>, idx_in: Vec<usize>) -> Vec<usize> { let n = idx_in.len(); let mut idx = idx_in; let mut buf: Vec<usize> = Vec::new(); let mut t = 0; while t < n { buf.push(idx[t]); t += 1; } if n < 2 { return idx; } let mut width = 1; ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [max_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.sty...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [max_points]: function definitions module public import Aeneas public import Aegis.MaxPoints.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.MaxPoints.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := 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]], [500000, 1000000, 1500000]]", "output": "[0, 0, 1]" }, { "input": "[[[1, 10], [10, 1]], [5, 15]]", "output": "[1, 4]" }, { "input": "[[[5, 2, 1], [1, 1, 2]], [3]]", "output": "[0]" }, { "input": "[[[1000000, 1000000], [1000000, 1000000]], [1000000, 9...
103
false
103
verified
10
10
2
16,670
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MaxPoints.Code.Funs /-! # Specifications of `Aegis.MaxPoints.max_points` LeetCode problem `maximum-number-of-points-from-grid-queries`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.MaxPoints abbrev Grid := Slice (alloc.vec.Vec I64) ...
13
bitwise-or-of-all-subsequence-sums
2,505
Medium
[ "Bit Manipulation", "Brainteaser", "Array", "Math" ]
Given an integer array nums, return the value of the bitwise OR of the sum of all possible subsequences in the array. A subsequence is a sequence that can be derived from another sequence by removing zero or more elements without changing the order of the remaining elements.   Example 1: Input: nums = [2,1,0,3] Output...
subsequenceSumOr(nums: list_int) -> int
pub fn subsequence_sum_or(nums: &[i64]) -> i64
Aegis.SubsequenceSumOr.subsequence_sum_or
pub fn subsequence_sum_or(nums: &[i64]) -> i64 { let mut ans: i64 = 0; let mut sum: i64 = 0; let n = nums.len(); let mut i: usize = 0; while i < n { let x = nums[i]; ans = ans | x; sum = sum + x; ans = ans | sum; i = i + 1; } ans }
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [subsequence_sum_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 li...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [subsequence_sum_or]: function definitions module public import Aeneas public import Aegis.SubsequenceSumOr.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.SubsequenceSumOr.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := 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": "[[1000000000]]", "output": "1000000000" }, { "input": "[[0, 0, 0]]", "output": "0" }, { "input": "[[1000000000, 500000000, 250000000]]", "output": "2147483520" }, { "input": "[[1, 3, 7, 15]]", "output": "31" }, { "input": "[[2, 1, 0, 3]]", "output"...
84
false
84
verified
10
10
1
7,746
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.SubsequenceSumOr.Code.Funs /-! # Specifications of `Aegis.SubsequenceSumOr.subsequence_sum_or` LeetCode problem `bitwise-or-of-all-subsequence-sums`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.SubsequenceSumOr namespace AegisSpec.Subsequence...
13
count-pairs-of-similar-strings
2,506
Easy
[ "Bit Manipulation", "Array", "Hash Table", "String", "Counting" ]
You are given a 0-indexed string array words. Two strings are similar if they consist of the same characters. For example, "abca" and "cba" are similar since both consist of characters 'a', 'b', and 'c'. However, "abacba" and "bcfd" are not similar since they do not consist of the same characters. Return the number o...
similarPairs(words: list_str) -> int
pub fn similar_pairs(words: &[Vec<u8>]) -> i64
Aegis.SimilarPairs.similar_pairs
pub fn similar_pairs(words: &[Vec<u8>]) -> i64 { let n = words.len(); let mut count: i64 = 0; let mut i: usize = 0; while i < n { let mut j: usize = i + 1; while j < n { if are_similar(&words[i], &words[j]) { count = count + 1; } j = j...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [similar_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 -- [similar_pairs]: function definitions module public import Aeneas public import Aegis.SimilarPairs.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.SimilarPairs.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := 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": "[[\"nba\", \"cba\", \"dba\"]]", "output": "0" }, { "input": "[[\"aabb\", \"ab\", \"ba\"]]", "output": "3" }, { "input": "[[\"abc\", \"def\", \"ghi\"]]", "output": "0" }, { "input": "[[\"abcdefghijklmnopqrstuvwxyz\", \"zyxwvutsrqponmlkjihgfedcba\", \"mnopqrstuvwxyz...
101
false
101
verified
10
10
1
1,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.SimilarPairs.Code.Funs /-! # Specifications of `Aegis.SimilarPairs.similar_pairs` LeetCode problem `count-pairs-of-similar-strings`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.SimilarPairs def wordAt (words : Slice (alloc.vec.Vec S...
8