MegaCode: A Repository-Level Dataset for Long-Context Code Reasoning
Wenyang LuoShuang SunYiwen HuFei BaiYanzipeng GaoShuo WangHongyu LuXin ZhaoJi-Rong Wen
Wenyang Luo
Shuang Sun
Yiwen Hu
Fei Bai
Yanzipeng Gao
Shuo Wang
Hongyu Lu
Xin Zhao
Ji-Rong Wen
+9
We introduce MegaCode, a 300B-token repository-level corpus designed for structured code reasoning and long-context modeling. Unlike snippet-based corpora, it preserves full project structure—build scripts, configuration files, and inter-file links—via a multi-stage pipeline combining deduplication, rule-based filtering, and model-based quality assessment. Models pretrained on MegaCode outperform those trained on flattened datasets on code reasoning and long-context benchmarks, and adding repo-relevant information (LSP, repo structure, summary) further helps. The dataset, pipeline, and evaluation suite are released.

ACL Anthology · October 2026