license: apache-2.0
tags:
- code-similarity
- parallel-corpus
- competitive-programming
- code-retrieval
- C
- Rust
pretty_name: C-to-Rust Parallel Semantic Similarity Corpus
size_categories:
- 1K<n<10K
Dataset Card for C-to-Rust Parallel Semantic Similarity Corpus
Dataset Summary
The C-to-Rust Parallel Semantic Similarity Corpus is a curated dataset consisting of 1,886 aligned, function-level C and Rust code pairs. It was developed to evaluate cross-language semantic similarity and functional equivalence between a traditional legacy language (C) and a modern memory-safe language (Rust).
The source code snippets are drawn from accepted competitive programming submissions across Project CodeNet, xCodeEval, and The Algorithms. Every pair shares identical algorithmic logic, has been validated to compile under modern environments (GCC C17 and Rust 1.94.0), and is filtered to ensure functional correctness.
Dataset Structure
The dataset is distributed as a single JSONL file where each row represents an aligned problem pair.
Data Fields
problem_id(string): A zero-padded sequential identifier spanning0001to1886.problem_description(string): The full natural language problem statement provided by the source platform.c_code(string): The normalized, fully functional C implementation.rust_code(string): The normalized, fully functional Rust implementation.difficulty(string): The alignment difficulty tier assigned to the pair (easy,medium, orhard).
Dataset Creation & Curation
Filtering and Preprocessing Pipeline
- Functional Correctness: Restricted exclusively to submissions marked as "Accepted" by online judges to guarantee true semantic alignment.
- Compilation Validation: Submissions were strictly compiled locally using GCC (C17 standard) and Rust 1.94.0 to eliminate syntax errors or compiler drift.
- Code Normalization: Dead code, redundant macros, comments, and explicit Rust
#[allow(...)]attributes were systematically stripped. Code layouts were standardized usingclang-formatandrustfmt. - Function Inlining: Core logic was restricted to a single function block, and all function identifiers were normalized to
solutionto eliminate superficial retrieval shortcuts. - Semantic Diversity: The final corpus contains a diverse set of unique problems with no overlapping duplicates, providing a clean benchmark for cross-language evaluation.
Difficulty Categorization
Difficulty tiers were empirically mapped using zero-shot cosine similarity scores from the SFR-Embedding-Code-400M_R model. Quantile thresholds at the 25th and 75th percentiles partition the dataset:
- Easy (25%): Similarity $\ge 0.868$
- Medium (50%): Similarity between $0.781$ and $0.868$
- Hard (25%): Similarity $< 0.781$ (Representing heavy syntax/paradigm divergence)
Associated Paper
The complete academic paper detailing the methodology, curation pipeline, and evaluation results for this dataset is available directly within this repository:
- 📄 Read the Paper:
c-rust-parallel-corpus.pdf
Please refer to the paper for in-depth insights into the dataset's design choices and baseline benchmarks.
Citation Information
@proceedings{hejlek2026creating,
title={Creating a Parallel C to Rust Corpus for Semantic Similarity Evaluation},
author={Hejlek, Vojtěch},
year={2026},
organization={Instituto de Ciências Matemáticas e de Computação, Universidade de São Paulo (ICMC/USP)},
note={Advisor: Alneu de Andrade Lopes, Coadvisor: Leonardo Jesus Almeida}
}