Datasets:
Upload README.md with huggingface_hub
Browse files
README.md
CHANGED
|
@@ -1,35 +1,110 @@
|
|
| 1 |
---
|
| 2 |
-
|
| 3 |
-
|
| 4 |
-
-
|
| 5 |
-
|
| 6 |
-
-
|
| 7 |
-
|
| 8 |
-
-
|
| 9 |
-
|
| 10 |
-
-
|
| 11 |
-
|
| 12 |
-
-
|
| 13 |
-
|
| 14 |
-
-
|
| 15 |
-
dtype: string
|
| 16 |
-
- name: optimization
|
| 17 |
-
dtype: string
|
| 18 |
-
- name: compiler
|
| 19 |
-
dtype: string
|
| 20 |
-
- name: assembly
|
| 21 |
-
dtype: string
|
| 22 |
-
- name: compilation_success
|
| 23 |
-
dtype: bool
|
| 24 |
-
splits:
|
| 25 |
-
- name: train
|
| 26 |
-
num_bytes: 49696480
|
| 27 |
-
num_examples: 7056
|
| 28 |
-
download_size: 8106173
|
| 29 |
-
dataset_size: 49696480
|
| 30 |
-
configs:
|
| 31 |
-
- config_name: default
|
| 32 |
-
data_files:
|
| 33 |
-
- split: train
|
| 34 |
-
path: data/train-*
|
| 35 |
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
---
|
| 2 |
+
license: apache-2.0
|
| 3 |
+
task_categories:
|
| 4 |
+
- text-generation
|
| 5 |
+
language:
|
| 6 |
+
- en
|
| 7 |
+
tags:
|
| 8 |
+
- assembly
|
| 9 |
+
- c
|
| 10 |
+
- leetcode
|
| 11 |
+
- compiler
|
| 12 |
+
- code
|
| 13 |
+
size_categories:
|
| 14 |
+
- 1K<n<10K
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 15 |
---
|
| 16 |
+
|
| 17 |
+
# LeetCode Assembly Dataset
|
| 18 |
+
|
| 19 |
+
441 LeetCode problems solved in C, compiled to assembly across **4 architectures** and **4 optimization levels** using GCC via the [Godbolt Compiler Explorer](https://godbolt.org) API.
|
| 20 |
+
|
| 21 |
+
## Dataset Summary
|
| 22 |
+
|
| 23 |
+
| Stat | Value |
|
| 24 |
+
|------|-------|
|
| 25 |
+
| Total rows | 7,056 |
|
| 26 |
+
| Unique problems | 441 |
|
| 27 |
+
| Architectures | x86-64, AArch64, MIPS64, RISC-V 64 |
|
| 28 |
+
| Optimization levels | -O0, -O1, -O2, -O3 |
|
| 29 |
+
| Compiler | GCC 15.2 |
|
| 30 |
+
| Compilation success rate | 100% |
|
| 31 |
+
| Difficulty split | Easy: 98, Medium: 259, Hard: 84 |
|
| 32 |
+
|
| 33 |
+
Each problem has **16 assembly variants** (4 architectures x 4 optimization levels), making this useful for studying how the same algorithm compiles differently across ISAs and optimization settings.
|
| 34 |
+
|
| 35 |
+
## Schema
|
| 36 |
+
|
| 37 |
+
| Column | Type | Description |
|
| 38 |
+
|--------|------|-------------|
|
| 39 |
+
| `problem_id` | int | LeetCode problem number |
|
| 40 |
+
| `problem_title` | string | Problem name (e.g. "Two Sum") |
|
| 41 |
+
| `difficulty` | string | Easy, Medium, or Hard |
|
| 42 |
+
| `c_source` | string | Complete C source code |
|
| 43 |
+
| `source_repo` | string | GitHub repo the solution came from |
|
| 44 |
+
| `architecture` | string | Target ISA: `x86-64`, `aarch64`, `mips64`, `riscv64` |
|
| 45 |
+
| `optimization` | string | GCC optimization flag: `-O0`, `-O1`, `-O2`, `-O3` |
|
| 46 |
+
| `compiler` | string | Compiler version used |
|
| 47 |
+
| `assembly` | string | Compiled assembly output |
|
| 48 |
+
| `compilation_success` | bool | Whether compilation succeeded |
|
| 49 |
+
|
| 50 |
+
## Usage
|
| 51 |
+
|
| 52 |
+
```python
|
| 53 |
+
from datasets import load_dataset
|
| 54 |
+
|
| 55 |
+
ds = load_dataset("ronantakizawa/leetcode-assembly", split="train")
|
| 56 |
+
|
| 57 |
+
# Get all x86-64 assembly at -O2
|
| 58 |
+
x86_O2 = ds.filter(lambda r: r["architecture"] == "x86-64" and r["optimization"] == "-O2")
|
| 59 |
+
|
| 60 |
+
# Compare the same problem across architectures
|
| 61 |
+
two_sum = ds.filter(lambda r: r["problem_id"] == 1 and r["optimization"] == "-O2")
|
| 62 |
+
for row in two_sum:
|
| 63 |
+
print(f"--- {row['architecture']} ---")
|
| 64 |
+
print(row["assembly"][:200])
|
| 65 |
+
print()
|
| 66 |
+
```
|
| 67 |
+
|
| 68 |
+
## Sources
|
| 69 |
+
|
| 70 |
+
C solutions were collected from three open-source GitHub repositories of pure-C LeetCode solutions:
|
| 71 |
+
|
| 72 |
+
- [vli02/leetcode](https://github.com/vli02/leetcode) (383 solutions)
|
| 73 |
+
- [begeekmyfriend/leetcode](https://github.com/begeekmyfriend/leetcode) (215 solutions)
|
| 74 |
+
- [lennylxx/leetcode](https://github.com/lennylxx/leetcode) (159 solutions)
|
| 75 |
+
|
| 76 |
+
After deduplication, 441 unique problems remained. Solutions are self-contained C files using only the standard library (no C++ STL), producing clean and readable assembly output.
|
| 77 |
+
|
| 78 |
+
## Compilation Details
|
| 79 |
+
|
| 80 |
+
Assembly was generated using the [Godbolt Compiler Explorer](https://godbolt.org) public API with the following settings:
|
| 81 |
+
|
| 82 |
+
| Architecture | Compiler ID | Syntax |
|
| 83 |
+
|-------------|-------------|--------|
|
| 84 |
+
| x86-64 | `cg152` (GCC 15.2) | Intel |
|
| 85 |
+
| AArch64 | `carm64g1520` (GCC 15.2) | Native |
|
| 86 |
+
| MIPS64 | `cmips64g1520` (GCC 15.2) | Native |
|
| 87 |
+
| RISC-V 64 | `rv64-cgcc1520` (GCC 15.2) | Native |
|
| 88 |
+
|
| 89 |
+
Compiler flags: `-std=gnu89 -w -include stdio.h -include stdlib.h -include string.h -include stdbool.h -include limits.h -include math.h -include stdint.h -include ctype.h`
|
| 90 |
+
|
| 91 |
+
Assembly output filters: directives removed, comments removed, labels preserved, symbols demangled.
|
| 92 |
+
|
| 93 |
+
## Potential Use Cases
|
| 94 |
+
|
| 95 |
+
- Training or evaluating models on C-to-assembly translation
|
| 96 |
+
- Studying how optimization levels affect generated code
|
| 97 |
+
- Cross-architecture assembly comparison and analysis
|
| 98 |
+
- Assembly language education and reference
|
| 99 |
+
- Compiler behavior research
|
| 100 |
+
|
| 101 |
+
## Build Pipeline
|
| 102 |
+
|
| 103 |
+
The dataset was built with an automated Python pipeline:
|
| 104 |
+
|
| 105 |
+
1. **Extract**: Clone repos, extract `.c` files, normalize unicode, deduplicate by problem ID
|
| 106 |
+
2. **Metadata**: Enrich with LeetCode problem titles and difficulty from HuggingFace
|
| 107 |
+
3. **Compile**: Send each solution to Godbolt API across all architecture/optimization combinations (with SQLite checkpointing for resumability)
|
| 108 |
+
4. **Publish**: Build HuggingFace Dataset and push to Hub
|
| 109 |
+
|
| 110 |
+
Source code for the pipeline is available at [github.com/ronantakizawa/leetcodeassembly](https://github.com/ronantakizawa/leetcodeassembly).
|