Complexity-Based Code Embeddings
This study addresses the challenge of effectively transforming source code into numerical embeddings suitable for machine learning. To this end, the authors propose r-Complexity, a novel code embedding method grounded in program dynamic behavior and a generalized complexity function. The approach generates representations by analyzing runtime execution traces across diverse inputs, eschewing reliance on syntactic code structure and thereby achieving strong algorithmic generalization. Evaluated on a real-world, multi-label dataset comprising 11 categories of solutions from the Codeforces platform, the proposed embeddings—when paired with an XGBoost classifier—demonstrate significant performance gains, attaining high average F1 scores. These results substantiate the effectiveness and practical utility of r-Complexity for semantic modeling of source code.