Teaching Language Models to Think in Code

arXiv cs.CL Papers

Summary

This paper introduces ThinC (Thinking in Code), a framework where language models use code blocks exclusively for reasoning after a brief natural language planning step, outperforming existing tool-integrated reasoning baselines on math benchmarks.

arXiv:2605.07237v1 Announce Type: new Abstract: Tool-integrated reasoning (TIR) has emerged as a dominant paradigm for mathematical problem solving in language models, combining natural language (NL) reasoning with code execution. However, this interleaved setup has three key limitations: code often acts as a post-hoc verifier, intermediate NL computations are error-prone, and NL and code play overlapping rather than clearly distinct roles. We propose ThinC (Thinking in Code), a framework in which code itself serves as the reasoner rather than as a tool invoked by NL. A ThinC trajectory begins with a brief NL planning step, after which all reasoning unfolds through code blocks connected only by their execution outputs. We distill 12.2k code-centric trajectories from a teacher model and train ThinC-1.7B and ThinC-4B with supervised fine-tuning followed by reinforcement learning. ThinC-4B consistently outperforms every TIR baseline on five competition-level math benchmarks and even surpasses the much larger Qwen3-235B-A22B-Thinking. Further analysis shows that ThinC reasons through code: 99.2% of its final answers are grounded in interpreter output, and the model recovers reliably from code execution failures without intermediate NL reasoning. Our code and models will be released soon.
Original Article
View Cached Full Text

Cached at: 05/11/26, 06:55 AM

# Teaching Language Models to Think in Code
Source: [https://arxiv.org/html/2605.07237](https://arxiv.org/html/2605.07237)
Hyeon Hwang Korea University Seoul, South Korea hyeon\-hwang@korea\.ac\.kr&Jiwoo Lee Korea University Seoul, South Korea second\.author@example\.com&Jaewoo Kang Korea University, AIGEN Sciences Seoul, South Korea kangj@korea\.ac\.kr

###### Abstract

Tool\-integrated reasoning \(TIR\) has emerged as a dominant paradigm for mathematical problem solving in language models, combining natural language \(NL\) reasoning with code execution\. However, this interleaved setup has three key limitations: code often acts as a post\-hoc verifier, intermediate NL computations are error\-prone, and NL and code play overlapping rather than clearly distinct roles\. We proposeThinC\(Thinking in Code\), a framework in which code itself serves as the reasoner rather than as a tool invoked by NL\. AThinCtrajectory begins with a brief NL planning step, after which all reasoning unfolds through code blocks connected only by their execution outputs\. We distill12\.212\.2k code\-centric trajectories from a teacher model and trainThinC\-1\.7B andThinC\-4B with supervised fine\-tuning followed by reinforcement learning\.ThinC\-4B consistently outperforms every TIR baseline on five competition\-level math benchmarks and even surpasses the much larger Qwen3\-235B\-A22B\-Thinking\. Further analysis shows thatThinCreasons through code:99\.2%99\.2\\%of its final answers are grounded in interpreter output, and the model recovers reliably from code execution failures without intermediate NL reasoning\. Our code and models will be released soon\.

## 1Introduction

Recent advances in reinforcement learning \(RL\) over long chains of thought\[[19](https://arxiv.org/html/2605.07237#bib.bib3)\]have substantially enhanced the mathematical reasoning capabilities of Large Language Models \(LLMs\), leading to powerful natural\-language \(NL\) reasoners such as OpenAI o1\[[9](https://arxiv.org/html/2605.07237#bib.bib4)\]and DeepSeek\-R1\[[7](https://arxiv.org/html/2605.07237#bib.bib5)\]\. Despite this progress, mathematical reasoning remains challenging for NL reasoners, particularly on problems requiring precise multi\-step computation, where even a single arithmetic error can invalidate the entire reasoning process\.

To make computation reliable, prior work has increasingly incorporated executable code into the reasoning process\. Prompting\-based approaches such as PAL\[[5](https://arxiv.org/html/2605.07237#bib.bib21)\]and PoT\[[2](https://arxiv.org/html/2605.07237#bib.bib20)\]generate Python programs that solve mathematical problems end\-to\-end, delegating precise computation to a code interpreter\. These methods demonstrated the reliability of code for mathematical computation and symbolic expression, but remain limited to single\-pass program generation without iterative interaction with execution results\. To combine the complementary strengths of NL reasoning and code execution, subsequent work introducedtool\-integrated reasoning \(TIR\)\[[6](https://arxiv.org/html/2605.07237#bib.bib1),[18](https://arxiv.org/html/2605.07237#bib.bib2)\], where NL handles high\-level planning while code performs precise computation\. TIR interleave NL reasoning with code execution over multiple turns, enabling iterative refinement and intermediate verification through interpreter feedback\. Recent work has further expanded this paradigm along several directions\. ReTool\[[4](https://arxiv.org/html/2605.07237#bib.bib8)\]uses RL to optimize tool\-use strategies, ASTER\[[23](https://arxiv.org/html/2605.07237#bib.bib6)\]emphasizes dense tool interaction throughout reasoning, and Tool\-Star\[[3](https://arxiv.org/html/2605.07237#bib.bib13)\]extends TIR to collaborative reasoning across multiple tools\.

However, as shown in Figure[1](https://arxiv.org/html/2605.07237#S1.F1), TIR’s interleaved reasoning paradigm suffers from three recurring structural limitations\.First, the model often completes a derivation in NL first and then runs code only to confirm it; code becomes a post\-hoc verifier rather than a reasoner, contributing no new computation\.Second, when the model carries out arithmetic or algebraic steps in NL, a wrong value can be copied into the next code block as a hard\-coded constant\. The interpreter cannot detect the mistake, and the error silently affects the final answer\.Third, although NL reasoning excels at high\-level planning and code can serve as a reasoner for precise mathematical expression and computation, interleaved TIR fails to separate these roles, leaving the two to do the same job\. The NL reasoning lays out the algorithm step by step, taking on work that code is better suited for, while the code that follows merely transcribes the NL reasoning\.

![Refer to caption](https://arxiv.org/html/2605.07237v1/x1.png)Figure 1:Three structural limitations of interleaved tool\-integrated reasoning\.\(A\) Post\-hoc tool verification: the model completes a derivation in NL and runs code only to confirm the answer, so the interpreter performs no new computation\.\(B\) Unreliable NL\-based computation: an NL arithmetic error propagates silently into the next code block as a hard\-coded constant\.\(C\) Misallocated Reasoning Roles: the NL reasoning describes the very algorithm that the subsequent code re\-implements\.To address these limitations, we proposeThinC\(Thinking in Code\), a training framework in which code itself serves as the reasoner rather than as a tool driven by NL reasoning\. AThinCreasoning begins with a single brief planning step in NL that frames the strategy, after which all reasoning unfolds through code blocks connected only by their execution outputs\. This structure resolves the three limitations by design: code performs derivations rather than verifying NL conclusions, every intermediate value is produced by the interpreter and therefore verified, and NL is restricted to high\-level planning while code carries out all reasoning\. We realize this paradigm in three stages: trajectory distillation from a teacher model via few\-shot prompting to construct the12\.212\.2kThinC\-SFT dataset, supervised fine\-tuning \(SFT\) to establish the code\-centric behavior prior, and RL with verifiable rewards\[[16](https://arxiv.org/html/2605.07237#bib.bib14)\]to strengthen problem\-solving\.

We evaluateThinCat two scales,ThinC\-1\.7B andThinC\-4B, built on Qwen3\-1\.7B and Qwen3\-4B\-Thinking\-2507\[[20](https://arxiv.org/html/2605.07237#bib.bib11)\]respectively, across five competition\-level math benchmarks \(AIME 2024–2026, HMMT 2025, and BeyondAIME\[[14](https://arxiv.org/html/2605.07237#bib.bib12)\]\)\.ThinC\-1\.7B reaches42\.8%42\.8\\%average accuracy, exceeding Qwen3\-1\.7B by10\.610\.6percentage points\.ThinC\-4B reaches78\.1%\\mathbf\{78\.1\\%\}, surpassing every TIR baseline in our evaluation and exceeding Qwen3\-235B\-A22B\-Thinking, a much larger NL reasoner, on four of the five benchmarks\. Further analysis shows thatThinC\-4B reasons in a genuinely code\-centric manner, with99\.2%\\mathbf\{99\.2\\%\}of its final answers grounded in interpreter output rather than generated through NL reasoning\. This behavior also makesThinCrobust when initial code executions fail, while interleaved TIR baselines degrade sharply\.

Our contributions are as follows\.

- •We proposeThinC, a training framework that teaches language models to treat code as the primary reasoner for mathematical problem solving rather than as a tool called by NL reasoning\.ThinCconsists of trajectory distillation, SFT, and RL with verifiable rewards\.
- •We present theThinC\-SFT dataset of12\.212\.2k code\-centric trajectories, together with two trained models,ThinC\-1\.7B andThinC\-4B\.ThinC\-4B reaches78\.1%\\mathbf\{78\.1\\%\}average accuracy across five competition\-level math benchmarks, outperforming both all TIR baselines and the much larger Qwen3\-235B\-A22B\-Thinking\.
- •We provide comprehensive analyses showing thatThinC\-4B reasons in a genuinely code\-centric manner at inference time, and identify robustness to early code execution failures as a concrete consequence of this structure\.

## 2Preliminaries

### 2\.1Tool\-Integrated Reasoning

TIR augments a language model with one or more external tools that can be invoked during generation, such as code interpreters, search engines, or symbolic solvers\. Solving a problem in TIR is a*multi\-turn*process: the model alternates between generating text and invoking tools, conditioning each subsequent action on the tool’s output\. In this work, we focus on the mathematical reasoning setting, where the tool is a Python interpreterℰ\\mathcal\{E\}and each turn consists of a natural\-language*thought block*t∈𝒯t\\in\\mathcal\{T\}, a*code block*c∈𝒞c\\in\\mathcal\{C\}generated by the model, and an*execution output*o=ℰ​\(c\)o=\\mathcal\{E\}\(c\)produced deterministically by the interpreter and appended to the context as a non\-trainable observation\. Given a problemqq, the standard interleaved TIR paradigm produces trajectories of the form

τTIR=\(q,t1,c1,o1,t2,c2,o2,…,tN,cN,oN,a\),\\tau\_\{\\mathrm\{TIR\}\}=\(q,\\,t\_\{1\},c\_\{1\},o\_\{1\},\\,t\_\{2\},c\_\{2\},o\_\{2\},\\,\\ldots,\\,t\_\{N\},c\_\{N\},o\_\{N\},\\,a\),\(1\)whereNNis the number of turns andaais the final answer\. All recent TIR systems\[[6](https://arxiv.org/html/2605.07237#bib.bib1),[4](https://arxiv.org/html/2605.07237#bib.bib8),[23](https://arxiv.org/html/2605.07237#bib.bib6)\]follow this structure\.

### 2\.2Supervised Fine\-Tuning

Supervised fine\-tuning \(SFT\) adapts a pre\-trained LLM to a target behavior by training on demonstration trajectories with a next\-token prediction objective\. In TIR, demonstrations are typically distilled from a stronger teacher model, and the choice of trajectories directly shapes the tool\-use patterns that the model learns to produce\[[22](https://arxiv.org/html/2605.07237#bib.bib9),[4](https://arxiv.org/html/2605.07237#bib.bib8),[23](https://arxiv.org/html/2605.07237#bib.bib6)\]\. Given a dataset𝒟SFT\\mathcal\{D\}\_\{\\mathrm\{SFT\}\}of trajectories, the SFT objective is

ℒSFT​\(θ\)=−𝔼τ∼𝒟SFT​\[∑k=1\|τ\|mk​log⁡πθ​\(xk∣x<k\)\],\\mathcal\{L\}\_\{\\mathrm\{SFT\}\}\(\\theta\)=\-\\mathbb\{E\}\_\{\\tau\\sim\\mathcal\{D\}\_\{\\mathrm\{SFT\}\}\}\\\!\\left\[\\sum\_\{k=1\}^\{\|\\tau\|\}m\_\{k\}\\log\\pi\_\{\\theta\}\(x\_\{k\}\\mid x\_\{<k\}\)\\right\],\(2\)wherexkx\_\{k\}is thekk\-th token ofτ\\tauandmk∈\{0,1\}m\_\{k\}\\in\\\{0,1\\\}is a per\-token loss mask\. Prior TIR work commonly setsmk=0m\_\{k\}=0for tool execution output tokens, restricting supervision to model\-generated tokens only\. We find no significant performance difference between the two choices and therefore usemk=1m\_\{k\}=1for all tokens in this work\.

### 2\.3Reinforcement Learning with Verifiable Rewards

For RL training in TIR, verifiable rewards are commonly used: each problem has a known ground\-truth answera⋆​\(q\)a^\{\\star\}\(q\), and a trajectory receives reward

r​\(τ\)=𝟏​\[a​\(τ\)=a⋆​\(q\)\],r\(\\tau\)=\\mathbf\{1\}\[a\(\\tau\)=a^\{\\star\}\(q\)\],\(3\)wherea​\(τ\)a\(\\tau\)is the answer extracted fromτ\\tau\. Exact\-match verification removes the need for a learned reward model\.

Group Relative Policy Optimization \(GRPO\)\[[16](https://arxiv.org/html/2605.07237#bib.bib14)\]is a critic\-free policy gradient algorithm widely used in this setting\. For each problemqq, GRPO samples a group ofGGtrajectories\{τ\(g\)\}g=1G\\\{\\tau^\{\(g\)\}\\\}\_\{g=1\}^\{G\}from the current policyπθ\\pi\_\{\\theta\}, and computes a group\-relative advantage from their rewards:

A\(g\)=r​\(τ\(g\)\)−μqσq,μq=1G​∑g=1Gr​\(τ\(g\)\),σq2=1G​∑g=1G\(r​\(τ\(g\)\)−μq\)2\.A^\{\(g\)\}=\\frac\{r\(\\tau^\{\(g\)\}\)\-\\mu\_\{q\}\}\{\\sigma\_\{q\}\},\\quad\\mu\_\{q\}=\\frac\{1\}\{G\}\\sum\_\{g=1\}^\{G\}r\(\\tau^\{\(g\)\}\),\\quad\\sigma\_\{q\}^\{2\}=\\frac\{1\}\{G\}\\sum\_\{g=1\}^\{G\}\\\!\\left\(r\(\\tau^\{\(g\)\}\)\-\\mu\_\{q\}\\right\)^\{2\}\.\(4\)Following DAPO\[[21](https://arxiv.org/html/2605.07237#bib.bib17)\], we adopt two modifications to the standard GRPO objective:*token\-level normalization*across the entire group rather than per\-trajectory averaging, and*asymmetric clipping*withϵlow<ϵhigh\\epsilon\_\{\\mathrm\{low\}\}<\\epsilon\_\{\\mathrm\{high\}\}that allows larger positive policy updates\. The resulting clipped surrogate objective is

𝒥​\(θ\)=𝔼q,\{τ\(g\)\}​\[1∑g\|τ\(g\)\|​∑g=1G∑k=1\|τ\(g\)\|min⁡\(ρk\(g\)​A\(g\),clip​\(ρk\(g\),1−ϵlow,1\+ϵhigh\)​A\(g\)\)\],\\mathcal\{J\}\(\\theta\)=\\mathbb\{E\}\_\{q,\\,\\\{\\tau^\{\(g\)\}\\\}\}\\\!\\left\[\\frac\{1\}\{\\sum\_\{g\}\|\\tau^\{\(g\)\}\|\}\\sum\_\{g=1\}^\{G\}\\sum\_\{k=1\}^\{\|\\tau^\{\(g\)\}\|\}\\min\\\!\\left\(\\rho\_\{k\}^\{\(g\)\}A^\{\(g\)\},\\,\\mathrm\{clip\}\\\!\\left\(\\rho\_\{k\}^\{\(g\)\},1\{\-\}\\epsilon\_\{\\mathrm\{low\}\},1\{\+\}\\epsilon\_\{\\mathrm\{high\}\}\\right\)A^\{\(g\)\}\\right\)\\right\],\(5\)whereρk\(g\)=πθ​\(τk\(g\)∣q,τ<k\(g\)\)/πθold​\(τk\(g\)∣q,τ<k\(g\)\)\\rho\_\{k\}^\{\(g\)\}=\\pi\_\{\\theta\}\(\\tau\_\{k\}^\{\(g\)\}\\mid q,\\tau\_\{<k\}^\{\(g\)\}\)/\\pi\_\{\\theta\_\{\\mathrm\{old\}\}\}\(\\tau\_\{k\}^\{\(g\)\}\\mid q,\\tau\_\{<k\}^\{\(g\)\}\)is the per\-token importance ratio\.

## 3ThinC: Teaching Models to Think in Code

We presentThinC, a training framework that teaches language models to treat code itself as the reasoner for mathematical problem solving rather than as a tool invoked by natural language\.ThinCconsists of three components: \(1\) a code\-centric trajectory format in which code itself serves as the reasoner \(Section[3\.1](https://arxiv.org/html/2605.07237#S3.SS1)\); \(2\) a distillation and supervised fine\-tuning procedure that induces this format in a student model \(Section[3\.2](https://arxiv.org/html/2605.07237#S3.SS2)\); and \(3\) a multi\-stage reinforcement learning procedure that further refines the resulting policy \(Section[3\.3](https://arxiv.org/html/2605.07237#S3.SS3)\)\.

### 3\.1ThinCReasoning

In interleaved TIR \(Eq\.[1](https://arxiv.org/html/2605.07237#S2.E1)\), an NL reasoner carries out the derivation and calls code as a tool\.ThinCtreats code itself as the reasoner\. Code is a natural fit for this role because programming languages, like mathematics, are symbolic systems\. Variables, operations, and functions in a program correspond directly to mathematical objects, allowing each reasoning step to be expressed and executed precisely\.

AThinCtrajectory takes the form

τThinC=\(q,t1,c1,o1,c2,o2,…,cN,oN,a\),\\tau\_\{\\mathrm\{ThinC\}\}=\(q,\\,t\_\{1\},\\,c\_\{1\},o\_\{1\},\\,c\_\{2\},o\_\{2\},\\,\\ldots,\\,c\_\{N\},o\_\{N\},\\,a\),\(6\)wheret1t\_\{1\}is constrained to express*strategy*, a high\-level plan for solving the problem, rather than any step\-by\-step derivation of the answer\. Unlike prior multi\-turn TIR frameworks, which interleave thought and code at each step, our code\-centric formulation uses a single initial thoughtt1t\_\{1\}to specify the overall solution strategy, and all subsequent reasoning is carried out through code\. Each code blockcic\_\{i\}builds on the execution outputs of the preceding blocks,o1,…,oi−1o\_\{1\},\\ldots,o\_\{i\-1\}, and the final answeraais obtained from the final execution outputoNo\_\{N\}\.

This simple structural change, illustrated in Figure[2](https://arxiv.org/html/2605.07237#S3.F2), resolves the three limitations of interleaved TIR identified in Section[1](https://arxiv.org/html/2605.07237#S1)by construction:

- •Tool as a reasoner\.No thought block precedescic\_\{i\}fori≥2i\\geq 2, so each code block directly performs a derivation step rather than acting as a post\-hoc verifier, making the interpreter an integral part of the reasoning process\.
- •Verified intermediates\.All intermediate values are produced through the interpreterℰ\\mathcal\{E\}, ensuring they are verified by construction and eliminating unverified numerical computation in NL\.
- •Specialized roles\.NL is restricted to high\-level planning int1t\_\{1\}, while code carries out all subsequent reasoning, restoring the role separation that interleaved TIR fails to maintain\.

### 3\.2Supervised Fine\-tuning: Establishing Code\-Centric Behavior

To train models to reason through code, we distillThinCtrajectories from a strong teacher model and use them as supervised fine\-tuning data\.

Following prior work\[[23](https://arxiv.org/html/2605.07237#bib.bib6)\], we draw problems from Skywork\-OR1\[[8](https://arxiv.org/html/2605.07237#bib.bib15)\]and OpenMathReasoning\[[11](https://arxiv.org/html/2605.07237#bib.bib16)\], restricted to English\-language problems with positive integer answers\. We sample one trajectory per problem from Qwen3\.5\-27B using a33\-shot prompt that demonstrates the structure of Eq\.[6](https://arxiv.org/html/2605.07237#S3.E6)\(full prompt in Appendix[B](https://arxiv.org/html/2605.07237#A2)\)\. We retain a distilled trajectory only if it \(i\) is correct, \(ii\) executes every code block without interpreter error, \(iii\) contains at least three code blocks, and \(iv\) spends less than50%50\\%of its tokens in the planning thought \(\|t1\|/\|τ\|<0\.5\|t\_\{1\}\|/\|\\tau\|<0\.5\)\. Criteria \(iii\) and \(iv\) together enforce the code\-centric structure ofThinCreasoning\. Filtering yields theThinC\-SFT dataset of12,20012\{,\}200trajectories\.

We fine\-tune two base models, Qwen3\-1\.7B and Qwen3\-4B\-Thinking\-2507, onThinC\-SFT using the SFT objective in Eq\.[2](https://arxiv.org/html/2605.07237#S2.E2), with a context length of 32K, learning rate7×10−67\\times 10^\{\-6\}with cosine schedule, global batch size1616, and33epochs\. We refer to the resulting checkpoints asThinC\-1\.7B\-SFT andThinC\-4B\-SFT\.

![Refer to caption](https://arxiv.org/html/2605.07237v1/x2.png)Figure 2:Comparison of interleaved TIR \(left\) andThinC\(right\)\. The three rows pair the structural limitations from Section[1](https://arxiv.org/html/2605.07237#S1)with howThinCavoids each\.\(Top\)Interleaved TIR has NL describe the algorithm step by step before code re\-implements that description, with NL and code doing the same job;ThinCrestricts NL to high\-level planning and lets code perform the derivation\.\(Middle\)Interleaved TIR runs code as a post\-hoc verifier of an NL\-derived answer; inThinC, code is the primary solver\.\(Bottom\)An NL arithmetic error propagates into the next code block as a hard\-coded constant, leading interleaved TIR to the wrong final answer;ThinCcomputes every intermediate value through the interpreter and reaches the correct answer\.
### 3\.3Reinforcement Learning

Starting from the SFT checkpoints, we further refine the policy using GRPO\[[16](https://arxiv.org/html/2605.07237#bib.bib14)\]on DAPO\-Math\-17k\[[21](https://arxiv.org/html/2605.07237#bib.bib17)\]\. Following DAPO\[[21](https://arxiv.org/html/2605.07237#bib.bib17)\], we optimize the token\-level policy gradient objective with Clip\-Higher \(ϵlow=0\.20\\epsilon\_\{\\mathrm\{low\}\}=0\.20,ϵhigh=0\.28\\epsilon\_\{\\mathrm\{high\}\}=0\.28\) and no KL divergence penalty, with a rollout prompt batch size of128128andG=8G=8trajectories per prompt\.

We train in three stages with increasing context budget; one epoch over the prompt set corresponds to roughly140140optimization steps\.*Stage 1*runs for280280steps \(two epochs\) on the full prompt set with a context length of 16K tokens and up to2020tool calls per trajectory\.*Stage 2*continues with the same context and tool budget but filters out problems whose Stage 1 policy already solves with100%100\\%pass rate, since these contribute zero group\-relative advantage \(Eq\.[4](https://arxiv.org/html/2605.07237#S2.E4)\); it runs for120120steps, ending at step400400\.*Stage 3*begins at step400400with the same difficulty filtering, expanding the context to 32K and the tool budget to4040to allow longer trajectories on harder problems\. We refer to the final checkpoints asThinC\-1\.7B andThinC\-4B\.

## 4Experiments

### 4\.1Experimental Setup

Table 1:Comparison on AIME 2024, AIME 2025, AIME 2026, HMMT 2025 February, BeyondAIME, and their arithmetic mean\. Scores are reported as avg@1616\(mean per\-problem accuracy averaged across problems\) under a3232K\-token inference budget\. Smaller numbers indicate 95% confidence intervals\. Asterisk \(∗\) denotes models prompted to use the Python interpreter without further training\. Qwen3\.5\-27B is the teacher model used for distillation, evaluated with the same33\-shot prompt used duringThinC\-SFT dataset generation\.Bold: best;underline: second\-best\.#### Benchmarks\.

We evaluate on five competition\-level mathematical reasoning benchmarks: AIME 2024, AIME 2025, AIME 2026, HMMT 2025 February, and BeyondAIME\[[14](https://arxiv.org/html/2605.07237#bib.bib12)\]\.

#### Baselines\.

We compareThinCto two groups of baselines\. The first is*NL\-only reasoners*: Qwen3\-1\.7B and Qwen3\-4B\-Thinking\-2507\[[20](https://arxiv.org/html/2605.07237#bib.bib11)\]\(our base models\), OpenReasoning\-Nemotron\-7B\[[1](https://arxiv.org/html/2605.07237#bib.bib18)\], gpt\-oss\-20B\[[12](https://arxiv.org/html/2605.07237#bib.bib19)\], and Qwen3\-235B\-A22B\-Thinking\[[20](https://arxiv.org/html/2605.07237#bib.bib11)\]\. The second is*tool\-integrated reasoners*: CoRT\-1\.5B\[[10](https://arxiv.org/html/2605.07237#bib.bib7)\], DemyAgent\-4B\[[22](https://arxiv.org/html/2605.07237#bib.bib9)\], ASTER\-4B\[[23](https://arxiv.org/html/2605.07237#bib.bib6)\], rStar2\-Agent\-14B\[[15](https://arxiv.org/html/2605.07237#bib.bib10)\], and ReTool\-32B\[[4](https://arxiv.org/html/2605.07237#bib.bib8)\]\. We additionally evaluate Qwen3\-1\.7B and Qwen3\-4B\-Thinking\-2507, our base models prompted to use the Python interpreter without additional training, to separate the effect ofThinCtraining from those of the underlying base model and the tool\-use prompt\. We also report results for Qwen3\.5\-27B with our33\-shot demonstration, as this model is used as the teacher for trajectory distillation\.

#### Evaluation Protocol\.

For each benchmark, we sample1616trajectories per problem under a3232K\-token inference budget and report the average accuracy \(avg@1616\)\. We sampleThinCwith temperature0\.60\.6and top\-pp1\.01\.0, and follow the sampling parameters recommended by each baseline’s original publication or official release\. All models are evaluated with a Python interpreter providing access to the standard library \(includingitertoolsandcollections\) and the scientific computing librariesnumpy,scipy, andsympy\. All baselines are run in the same environment\.

### 4\.2Main Results

#### ThinCdelivers consistent gains at both scales\.

As shown in Table[1](https://arxiv.org/html/2605.07237#S4.T1),ThinC\-4B achieves the strongest overall result, with an average score of78\.1%78\.1\\%and the best performance on four of the five benchmarks\. It outperforms all tool\-integrated reasoning baselines, including substantially larger systems such as rStar2\-Agent\-14B and ReTool\-32B\. In addition, it surpasses Qwen3\-235B\-A22B\-Thinking, the strongest open\-source NL\-only reasoner in our comparison, by2\.92\.9points on average\. The advantage is particularly large on the more challenging benchmarks, HMMT25 and BeyondAIME\. Remarkably,ThinC\-4B also exceeds its distillation teacher, Qwen3\.5\-27B with our33\-shot demonstration, on all five benchmarks by13\.413\.4points on average, despite being much smaller\. The same pattern holds at the smaller scale:ThinC\-1\.7B reaches42\.8%42\.8\\%, outperforming both Qwen3\-1\.7B \(32\.2%32\.2\\%\), Qwen3\-1\.7B∗\(29\.8%29\.8\\%\), and CoRT\-1\.5B \(25\.7%25\.7\\%\)\. Together, these results indicate thatThinCtraining yields consistent gains across scales beyond those obtained from tool\-use prompting alone\.

#### ThinCreasoning outperforms interleaved TIR\.

To isolate the effect of the reasoning format, we treat ASTER\-4B as a natural ablation baseline for the interleaved approach\. The two systems share a base model\(Qwen3\-4B\-thinkning\-2507\), teacher capacity, and RL pipeline, differing primarily in trajectory structure\. Under these matched conditions,ThinC\-4B exceeds ASTER\-4B on every benchmark by an average of4\.14\.1points\. The gain comes with lower inference cost, asThinC\-4B requires fewer tool calls per trajectory \(6\.16\.1vs\.11\.111\.1\) and produces shorter responses \(13\.513\.5k vs\.15\.415\.4k tokens; see Appendix[C](https://arxiv.org/html/2605.07237#A3)\)\. Code\-centric reasoning therefore delivers higher accuracy over interleaved TIR, while naturally reducing inference overhead\.

### 4\.3SFT Cold\-Start and RL Training Dynamics

![Refer to caption](https://arxiv.org/html/2605.07237v1/x3.png)Figure 3:Training dynamics\. \(a\) Benchmark avg@16 after SFT \(light\) and after RL \(dark\) forThinC\-1\.7B andThinC\-4B across five math benchmarks\. \(b\) AIME 2024 avg@16 over RL training steps\. \(c\) Average response length over RL training steps\. Shaded regions in \(b\) and \(c\) denote the three RL stages\.#### SFT establishes the format; RL drives the gains\.

After SFT,ThinC\-4B\-SFT reaches48\.1%48\.1\\%on average, below both the teacher Qwen3\.5\-27B \(64\.7%64\.7\\%\) and the tool\-prompted base model \(62\.9%62\.9\\%\);ThinC\-1\.7B reaches18\.1%18\.1\\%, also below its base \(30\.2%30\.2\\%\)\. This drop is by design: SFT teaches the model to reason in theThinCformat, not to maximize accuracy\. RL produces the benchmark gains, adding29\.929\.9points at44B and24\.624\.6points at1\.71\.7B \(Figure[3](https://arxiv.org/html/2605.07237#S4.F3)a\) and lifting both policies well above their bases and teachers\.

#### RL improves the policy steadily throughout training\.

Figures[3](https://arxiv.org/html/2605.07237#S4.F3)b,c plot validation accuracy and response length on AIME 2024 over RL steps\. Both scales show smooth, near\-monotonic accuracy climbs with no plateau or collapse, and the three\-stage curriculum \(Section[3\.3](https://arxiv.org/html/2605.07237#S3.SS3)\) is visible as a mild inflection at each stage boundary\. Notably,ThinC\-4B’s response length stays in the77K–1111K range throughout RL, even when Stage 3 expands the context budget to3232K\. AIME 2024 accuracy meanwhile climbs from63\.5%63\.5\\%at the SFT checkpoint to88\.3%88\.3\\%at the end of RL\. The1\.71\.7B model relies more on the extra context, with response length roughly doubling in Stage 3\.

### 4\.4DoesThinCActually Think in Code?

We next verify that the trained model exhibitsThinCreasoning at inference time, as defined in Section[3\.1](https://arxiv.org/html/2605.07237#S3.SS1), rather than simply imitating the format of the training trajectories\. Figure[4](https://arxiv.org/html/2605.07237#S4.F4)comparesThinC\-4B with five TIR baselines on AIME 2024–2026, HMMT 2025, and BeyondAIME using two complementary metrics\. We consider both metrics together because they capture different aspects of code\-centric reasoning\. One measures how extensively code is used throughout the reasoning trajectory, while the other measures whether the final answer is grounded in interpreter outputs\. Taken together, they provide a more complete view of whether a model not only writes code during reasoning, but also relies on execution outputs to produce its final answer\.

![Refer to caption](https://arxiv.org/html/2605.07237v1/x4.png)Figure 4:Code\-centric reasoning behavior measured on overall benchmarks\. \(a\) Average lines of code per trajectory\. \(b\) Code\-grounded answer rate, the fraction of trajectories whose final answer appears in the output of some code block\.ThinC\-4B leads on both metrics\.#### ThinCshifts the reasoning process to code\.

ThinCwrites an average of349349lines of code per sample \(Figure[4](https://arxiv.org/html/2605.07237#S4.F4)a\), substantially more than ASTER \(102102\), CoRT \(4040\), and ReTool \(261261\)\. Notably, ASTER and CoRT are the two TIR systems most explicitly designed to strengthen tool use, while ReTool is the strongest baseline on this metric\. These results show thatThinCmakes substantially heavier use of code throughout the reasoning trajectory\. We next examine whether this code also serves as the primary driver of reasoning, rather than merely accompanying an NL derivation\.

#### ThinCanswers are grounded in code execution\.

We next examine whether the final answer of each trajectory appears in the execution output of at least one code block \(Figure[4](https://arxiv.org/html/2605.07237#S4.F4)b\)\.ThinC\-4B satisfies this condition in99\.2%99\.2\\%of trajectories, compared with88\.4%88\.4\\%for ReTool and74\.3%74\.3\\%for rStar2\. Several other baselines are lower still, indicating that a large fraction of their final answers are generated through NL reasoning rather than code execution\. As a result, they bypass the interpreter and remain vulnerable to the arithmetic and algebraic errors discussed in Section[1](https://arxiv.org/html/2605.07237#S1), where even a single NL mistake can corrupt the result\.ThinClargely removes this failure mode by design: because its trajectory format contains no NL channel between code blocks, the final answer must be derived from interpreter output\. Appendix[A](https://arxiv.org/html/2605.07237#A1)traces a representativeThinC\-4B rollout that makes this pattern concrete\. On AIME 2026 Problem 3, the model’st1t\_\{1\}contains only an algebraic restructuring of the problem \(a\+b\+a​b=\(a\+1\)​\(b\+1\)−1a\+b\+ab=\(a\{\+\}1\)\(b\{\+\}1\)\-1\); the answer is then computed and cross\-validated through multiple code\-driven turns, with the model auditing and refining its own loop logic entirely within the next code block rather than via NL reasoning between blocks\.

### 4\.5CanThinCRecover from Code Failures Without NL Reasoning?

ThinC’s code\-centric design raises a natural question about robustness: "With no NL reasoning between code blocks, what happens when a code execution fails?" Interleaved TIR can absorb the failure in NL reasoning and reframe the next attempt;ThinCcannot\. Whether this hurts robustness or helps it is an empirical question we test here\.

We measure this with*Recovery@kk*: among trajectories whose firstkkcode blocks all raise an interpreter error, the fraction that still arrives at the correct final answer\. We compute the metric on AIME 2024–2026, HMMT 2025, and BeyondAIME, sweepingkkfrom11to55\.

![Refer to caption](https://arxiv.org/html/2605.07237v1/x5.png)Figure 5:Recovery@kkunder initial code failures\.ThinCremains substantially more robust as early execution failures accumulate\.#### Interleaved baselines degrade withkk;ThinC\-4B stays robust\.

Every interleaved TIR system loses ground as initial failures accumulate \(Figure[5](https://arxiv.org/html/2605.07237#S4.F5)\)\. ASTER drops from52\.1%52\.1\\%atk=1k=1to18\.5%18\.5\\%atk=5k=5; rStar2\-Agent collapses from39\.1%39\.1\\%to0%0\\%; ReTool, DemyAgent, and CoRT decline along similar trajectories\.ThinC, in contrast, stays in a narrow6464–69%69\\%band acrossk=1,2,3k=1,2,3, before declining to54\.5%54\.5\\%atk=4k=4and33\.3%33\.3\\%atk=5k=5\. Even atk=5k=5, it recovers nearly2×2\\timesas often as any interleaved baseline\.

#### Partial robustness from the format, the rest from RL\.

Our SFT data is filtered to retain only trajectories that execute every code block without error, so recovery from failures is not directly demonstrated during SFT\. Even so,ThinC\-4B\-SFT already exceeds most interleaved baselines, recovering in42\.9%42\.9\\%of trajectories atk=1k=1and19\.1%19\.1\\%atk=5k=5\. Only ASTER surpasses it, and only atk≤2k\\leq 2\. The code\-centric format, therefore, confers some robustness even before RL\. RL on top of this prior lifts recovery by another2020\+ points acrossk=1,2,3k=1,2,3, accounting for most ofThinC’s gap over the interleaved baselines\.

## 5Discussion and Conclusion

We introduceThinC, a code\-centric approach to TIR in which the model reasons directly in code after a brief NL planning step\.ThinC\-4B reaches78\.1%78\.1\\%on five competition\-level math benchmarks, outperforming all baselines\. Two findings explain the gain:99\.2%99\.2\\%of final answers come from interpreter output rather than NL, andThinCmaintains6464–69%69\\%recovery through three consecutive code failures where interleaved baselines degrade sharply\.

Several limitations remain\. Due to computational constraints, our experiments are restricted to1\.71\.7B and44B parameters, and our evaluation is confined to competition\-level mathematics\. WhetherThinCscales to larger models, and whether the code\-centric format extends to other tool\-integrated reasoning domains, are natural directions for future work\.

## References

- \[1\]W\. U\. Ahmad, S\. Narenthiran, S\. Majumdar, A\. Ficek, S\. Jain, J\. Huang, V\. Noroozi, and B\. Ginsburg\(2025\)OpenCodeReasoning: advancing data distillation for competitive coding\.External Links:2504\.01943,[Link](https://arxiv.org/abs/2504.01943)Cited by:[§4\.1](https://arxiv.org/html/2605.07237#S4.SS1.SSS0.Px2.p1.1)\.
- \[2\]W\. Chen, X\. Ma, X\. Wang, and W\. W\. Cohen\(2023\)Program of thoughts prompting: disentangling computation from reasoning for numerical reasoning tasks\.Transactions on Machine Learning Research\.Note:External Links:ISSN 2835\-8856,[Link](https://openreview.net/forum?id=YfZ4ZPt8zd)Cited by:[§1](https://arxiv.org/html/2605.07237#S1.p2.1)\.
- \[3\]G\. Dong, Y\. Chen, X\. Li, J\. Jin, H\. Qian, Y\. Zhu, H\. Mao, G\. Zhou, Z\. Dou, and J\. Wen\(2025\)Tool\-star: empowering llm\-brained multi\-tool reasoner via reinforcement learning\.External Links:2505\.16410,[Link](https://arxiv.org/abs/2505.16410)Cited by:[§1](https://arxiv.org/html/2605.07237#S1.p2.1)\.
- \[4\]J\. Feng, S\. Huang, X\. Qu, G\. Zhang, Y\. Qin, B\. Zhong, C\. Jiang, J\. Chi, and W\. Zhong\(2025\)ReTool: reinforcement learning for strategic tool use in llms\.External Links:2504\.11536,[Link](https://arxiv.org/abs/2504.11536)Cited by:[§1](https://arxiv.org/html/2605.07237#S1.p2.1),[§2\.1](https://arxiv.org/html/2605.07237#S2.SS1.p1.7),[§2\.2](https://arxiv.org/html/2605.07237#S2.SS2.p1.1),[§4\.1](https://arxiv.org/html/2605.07237#S4.SS1.SSS0.Px2.p1.1)\.
- \[5\]L\. Gao, A\. Madaan, S\. Zhou, U\. Alon, P\. Liu, Y\. Yang, J\. Callan, and G\. Neubig\(2023\)PAL: program\-aided language models\.External Links:2211\.10435,[Link](https://arxiv.org/abs/2211.10435)Cited by:[§1](https://arxiv.org/html/2605.07237#S1.p2.1)\.
- \[6\]Z\. Gou, Z\. Shao, Y\. Gong, yelong shen, Y\. Yang, M\. Huang, N\. Duan, and W\. Chen\(2024\)ToRA: a tool\-integrated reasoning agent for mathematical problem solving\.InThe Twelfth International Conference on Learning Representations,External Links:[Link](https://openreview.net/forum?id=Ep0TtjVoap)Cited by:[§1](https://arxiv.org/html/2605.07237#S1.p2.1),[§2\.1](https://arxiv.org/html/2605.07237#S2.SS1.p1.7)\.
- \[7\]D\. Guo, D\. Yang, H\. Zhang, J\. Song, P\. Wang, Q\. Zhu, R\. Xu, R\. Zhang, S\. Ma, X\. Bi,et al\.\(2025\)Deepseek\-r1: incentivizing reasoning capability in llms via reinforcement learning\.arXiv preprint arXiv:2501\.12948\.Cited by:[§1](https://arxiv.org/html/2605.07237#S1.p1.1)\.
- \[8\]J\. He, J\. Liu, C\. Y\. Liu, R\. Yan, C\. Wang, P\. Cheng, X\. Zhang, F\. Zhang, J\. Xu, W\. Shen,et al\.\(2025\)Skywork open reasoner 1 technical report\.arXiv preprint arXiv:2505\.22312\.Cited by:[§3\.2](https://arxiv.org/html/2605.07237#S3.SS2.p2.4)\.
- \[9\]A\. Jaech, A\. Kalai, A\. Lerer, A\. Richardson, A\. El\-Kishky, A\. Low, A\. Helyar, A\. Madry, A\. Beutel, A\. Carney,et al\.\(2024\)Openai o1 system card\.arXiv preprint arXiv:2412\.16720\.Cited by:[§1](https://arxiv.org/html/2605.07237#S1.p1.1)\.
- \[10\]C\. Li, Z\. Tang, Z\. Li, M\. Xue, K\. Bao, T\. Ding, R\. Sun, B\. Wang, X\. Wang, J\. Lin, and D\. Liu\(2025\)Teaching language models to reason with tools\.External Links:2510\.20342,[Link](https://arxiv.org/abs/2510.20342)Cited by:[§4\.1](https://arxiv.org/html/2605.07237#S4.SS1.SSS0.Px2.p1.1)\.
- \[11\]I\. Moshkov, D\. Hanley, I\. Sorokin, S\. Toshniwal, C\. Henkel, B\. Schifferer, W\. Du, and I\. Gitman\(2025\)Aimo\-2 winning solution: building state\-of\-the\-art mathematical reasoning models with openmathreasoning dataset\.arXiv preprint arXiv:2504\.16891\.Cited by:[§3\.2](https://arxiv.org/html/2605.07237#S3.SS2.p2.4)\.
- \[12\]OpenAI\(2025\)Gpt\-oss\-120b & gpt\-oss\-20b model card\.External Links:2508\.10925,[Link](https://arxiv.org/abs/2508.10925)Cited by:[§4\.1](https://arxiv.org/html/2605.07237#S4.SS1.SSS0.Px2.p1.1)\.
- \[13\]D\. Rein, B\. L\. Hou, A\. C\. Stickland, J\. Petty, R\. Y\. Pang, J\. Dirani, J\. Michael, and S\. R\. Bowman\(2024\)GPQA: a graduate\-level google\-proof q&a benchmark\.InFirst Conference on Language Modeling,External Links:[Link](https://openreview.net/forum?id=Ti67584b98)Cited by:[Appendix D](https://arxiv.org/html/2605.07237#A4.p1.2)\.
- \[14\]B\. Seed, J\. Chen, T\. Fan, X\. Liu, L\. Liu, Z\. Lin, M\. Wang, C\. Wang, X\. Wei, W\. Xu,et al\.\(2025\)Seed1\. 5\-thinking: advancing superb reasoning models with reinforcement learning\.arXiv preprint arXiv:2504\.13914\.Cited by:[§1](https://arxiv.org/html/2605.07237#S1.p5.4),[§4\.1](https://arxiv.org/html/2605.07237#S4.SS1.SSS0.Px1.p1.1)\.
- \[15\]N\. Shang, Y\. Liu, Y\. Zhu, L\. L\. Zhang, W\. Xu, X\. Guan, B\. Zhang, B\. Dong, X\. Zhou, B\. Zhang, Y\. Xin, Z\. Miao, S\. Li, F\. Yang, and M\. Yang\(2025\)RStar2\-agent: agentic reasoning technical report\.External Links:2508\.20722,[Link](https://arxiv.org/abs/2508.20722)Cited by:[§4\.1](https://arxiv.org/html/2605.07237#S4.SS1.SSS0.Px2.p1.1)\.
- \[16\]Z\. Shao, P\. Wang, Q\. Zhu, R\. Xu, J\. Song, X\. Bi, H\. Zhang, M\. Zhang, Y\. Li, Y\. Wu,et al\.\(2024\)Deepseekmath: pushing the limits of mathematical reasoning in open language models\.arXiv preprint arXiv:2402\.03300\.Cited by:[§1](https://arxiv.org/html/2605.07237#S1.p4.1),[§2\.3](https://arxiv.org/html/2605.07237#S2.SS3.p2.4),[§3\.3](https://arxiv.org/html/2605.07237#S3.SS3.p1.4)\.
- \[17\]G\. Sheng, C\. Zhang, Z\. Ye, X\. Wu, W\. Zhang, R\. Zhang, Y\. Peng, H\. Lin, and C\. Wu\(2024\)HybridFlow: a flexible and efficient rlhf framework\.arXiv preprint arXiv: 2409\.19256\.Cited by:[Appendix E](https://arxiv.org/html/2605.07237#A5.p1.1)\.
- \[18\]K\. Wang, H\. Ren, A\. Zhou, Z\. Lu, S\. Luo, W\. Shi, R\. Zhang, L\. Song, M\. Zhan, and H\. Li\(2024\)MathCoder: seamless code integration in LLMs for enhanced mathematical reasoning\.InThe Twelfth International Conference on Learning Representations,External Links:[Link](https://openreview.net/forum?id=z8TW0ttBPp)Cited by:[§1](https://arxiv.org/html/2605.07237#S1.p2.1)\.
- \[19\]J\. Wei, X\. Wang, D\. Schuurmans, M\. Bosma, brian ichter, F\. Xia, E\. H\. Chi, Q\. V\. Le, and D\. Zhou\(2022\)Chain of thought prompting elicits reasoning in large language models\.InAdvances in Neural Information Processing Systems,A\. H\. Oh, A\. Agarwal, D\. Belgrave, and K\. Cho \(Eds\.\),External Links:[Link](https://openreview.net/forum?id=_VjQlMeSB_J)Cited by:[§1](https://arxiv.org/html/2605.07237#S1.p1.1)\.
- \[20\]A\. Yang, A\. Li, B\. Yang, B\. Zhang, B\. Hui, B\. Zheng, B\. Yu, C\. Gao, C\. Huang, C\. Lv, C\. Zheng, D\. Liu, F\. Zhou, F\. Huang, F\. Hu, H\. Ge, H\. Wei, H\. Lin, J\. Tang, J\. Yang, J\. Tu, J\. Zhang, J\. Yang, J\. Yang, J\. Zhou, J\. Zhou, J\. Lin, K\. Dang, K\. Bao, K\. Yang, L\. Yu, L\. Deng, M\. Li, M\. Xue, M\. Li, P\. Zhang, P\. Wang, Q\. Zhu, R\. Men, R\. Gao, S\. Liu, S\. Luo, T\. Li, T\. Tang, W\. Yin, X\. Ren, X\. Wang, X\. Zhang, X\. Ren, Y\. Fan, Y\. Su, Y\. Zhang, Y\. Zhang, Y\. Wan, Y\. Liu, Z\. Wang, Z\. Cui, Z\. Zhang, Z\. Zhou, and Z\. Qiu\(2025\)Qwen3 technical report\.External Links:2505\.09388,[Link](https://arxiv.org/abs/2505.09388)Cited by:[§1](https://arxiv.org/html/2605.07237#S1.p5.4),[§4\.1](https://arxiv.org/html/2605.07237#S4.SS1.SSS0.Px2.p1.1)\.
- \[21\]Q\. Yu, Z\. Zhang, R\. Zhu, Y\. Yuan, X\. Zuo, Y\. Yue, W\. Dai, T\. Fan, G\. Liu, L\. Liu, X\. Liu, H\. Lin, Z\. Lin, B\. Ma, G\. Sheng, Y\. Tong, C\. Zhang, M\. Zhang, W\. Zhang, H\. Zhu, J\. Zhu, J\. Chen, J\. Chen, C\. Wang, H\. Yu, Y\. Song, X\. Wei, H\. Zhou, J\. Liu, W\. Ma, Y\. Zhang, L\. Yan, M\. Qiao, Y\. Wu, and M\. Wang\(2025\)DAPO: an open\-source llm reinforcement learning system at scale\.External Links:2503\.14476,[Link](https://arxiv.org/abs/2503.14476)Cited by:[§E\.2](https://arxiv.org/html/2605.07237#A5.SS2.p1.2),[§2\.3](https://arxiv.org/html/2605.07237#S2.SS3.p2.5),[§3\.3](https://arxiv.org/html/2605.07237#S3.SS3.p1.4)\.
- \[22\]Z\. Yu, L\. Yang, J\. Zou, S\. Yan, and M\. Wang\(2025\)Demystifying reinforcement learning in agentic reasoning\.External Links:2510\.11701,[Link](https://arxiv.org/abs/2510.11701)Cited by:[§2\.2](https://arxiv.org/html/2605.07237#S2.SS2.p1.1),[§4\.1](https://arxiv.org/html/2605.07237#S4.SS1.SSS0.Px2.p1.1)\.
- \[23\]X\. Zhang, Q\. He, Z\. Zheng, Z\. Zhang, X\. He, and D\. Li\(2026\)ASTER: agentic scaling with tool\-integrated extended reasoning\.External Links:2602\.01204,[Link](https://arxiv.org/abs/2602.01204)Cited by:[§1](https://arxiv.org/html/2605.07237#S1.p2.1),[§2\.1](https://arxiv.org/html/2605.07237#S2.SS1.p1.7),[§2\.2](https://arxiv.org/html/2605.07237#S2.SS2.p1.1),[§3\.2](https://arxiv.org/html/2605.07237#S3.SS2.p2.4),[§4\.1](https://arxiv.org/html/2605.07237#S4.SS1.SSS0.Px2.p1.1)\.
- \[24\]Y\. Zheng, R\. Zhang, J\. Zhang, Y\. Ye, Z\. Luo, Z\. Feng, and Y\. Ma\(2024\)LlamaFactory: unified efficient fine\-tuning of 100\+ language models\.InProceedings of the 62nd Annual Meeting of the Association for Computational Linguistics \(Volume 3: System Demonstrations\),Bangkok, Thailand\.External Links:[Link](http://arxiv.org/abs/2403.13372)Cited by:[Appendix E](https://arxiv.org/html/2605.07237#A5.p1.1)\.

## Appendix ACase Study: AThinC\-4B Trajectory on AIME 2026 Problem 3

To illustrate the structural pattern ofThinC, we walk through one full rollout onAIME 2026 Problem 3\. The trajectory shows how a single brief strategic plan in NL transitions into a sequence of code\-centric reasoning steps, each conditioned on the previous interpreter output, with the final answer emerging from code execution rather than from NL\-level computation\.

### A\.1Problem

> Find the number of integers less than or equal to100100that are equal toa\+b\+a​ba\+b\+abfor some choice of distinct positive integersaaandbb\.

The reference answer is70\\boxed\{70\}\.

### A\.2Stage 1 — Strategic Planning \(t1t\_\{1\}\)

The single<think\>block contains no numerical computation\. It performs one algebraic restructuring of the problem—factoringa\+b\+a​b=\(a\+1\)​\(b\+1\)−1a\+b\+ab=\(a\{\+\}1\)\(b\{\+\}1\)\-1—and specifies the resulting search problem to be solved in code\.

<think\>I need to find the number of integers≤100\\leq 100that can be written asa\+b\+a​ba\+b\+abwhereaaandbbare distinct positive integers\.Let me think about this expression:a\+b\+a​b=\(a\+1\)​\(b\+1\)−1a\+b\+ab=\(a\{\+\}1\)\(b\{\+\}1\)\-1\.So I need to find how many integersn≤100n\\leq 100satisfyn=\(a\+1\)​\(b\+1\)−1n=\(a\{\+\}1\)\(b\{\+\}1\)\-1for some distinct positive integersa,ba,b\. This meansn\+1=\(a\+1\)​\(b\+1\)n\+1=\(a\{\+\}1\)\(b\{\+\}1\)wherea,b≥1a,b\\geq 1anda≠ba\\neq b\.Letm=a\+1m=a\{\+\}1,n′=b\+1n^\{\\prime\}=b\{\+\}1\. Thenm,n′≥2m,n^\{\\prime\}\\geq 2,m≠n′m\\neq n^\{\\prime\}, andm⋅n′=n\+1m\\cdot n^\{\\prime\}=n\+1\. So I need to count how many values ofn≤100n\\leq 100can be written asm⋅n′−1m\\cdot n^\{\\prime\}\-1wherem,n′≥2m,n^\{\\prime\}\\geq 2,m≠n′m\\neq n^\{\\prime\}, andm⋅n′≤101m\\cdot n^\{\\prime\}\\leq 101\.Actually, let me just brute force this\. Sinceaaandbbare distinct positive integers, let me iterate over possible values and check which sums are≤100\\leq 100\.Let me write code to compute this directly\.

This realises the roleThinCreserves fort1t\_\{1\}\(Section[3\.1](https://arxiv.org/html/2605.07237#S3.SS1)\): a high\-level strategic plan, not a step\-by\-step derivation\. Three properties of this think block illustrate the design intent:

1. 1\.No arithmetic in NL\.The model never evaluates an expression or enumerates a case manually\. The think channel is used purely for symbolic restructuring of the problem\.
2. 2\.Search\-space specification\.It fixes the exact constraints \(m,n′≥2m,n^\{\\prime\}\\geq 2,m≠n′m\\neq n^\{\\prime\},m⋅n′≤101m\\cdot n^\{\\prime\}\\leq 101\) before any code is written, providing a clean starting point for the code blocks that follow\.
3. 3\.Single transition to code\.The block ends with one sentence \(“Let me write code to compute this directly”\) and from this point onward, NL does not return: every subsequent reasoning step is carried out inside a<python\>block\.

### A\.3Stage 2 — Code\-Centric Reasoning

The remainder of the rollout consists of five<python\>/<result\>exchanges\. Each code block builds on the execution outputs of the preceding blocks, as prescribed by Eq\.[6](https://arxiv.org/html/2605.07237#S3.E6), and every reasoning step—including self\-correction, structural verification, and independent re\-derivation—is performed in code\.

#### Turn 1: Initial brute force\.

The model implements a direct enumeration with an earlybreakthat it pre\-emptively flags as potentially incorrect\.

<python\>Turn 1[⬇](data:text/plain;base64,IyAoYSsxKShiKzEpIC0gMSAtLSBicnV0ZSBmb3JjZSBvdmVyIGRpc3RpbmN0IChhLGIpCnJlc3VsdHMgPSBzZXQoKQpmb3IgYSBpbiByYW5nZSgxLCAxMDApOgogICAgZm9yIGIgaW4gcmFuZ2UoYSsxLCAxMDApOiAgICAgIyBiID4gYSB0byBrZWVwIHBhaXJzIGRpc3RpbmN0CiAgICAgICAgbiA9IGEgKyBiICsgYSpiCiAgICAgICAgaWYgbiA8PSAxMDA6CiAgICAgICAgICAgIHJlc3VsdHMuYWRkKG4pCiAgICAgICAgZWxpZiBuID4gMTAwOgogICAgICAgICAgICBicmVhayAgICAgICAgICAgICAgICAgIyBwb3RlbnRpYWxseSBwcmVtYXR1cmUgLS0gcmV2aXNpdGVkIG5leHQgdHVybgpwcmludChmIk51bWJlciBvZiBkaXN0aW5jdCB2YWx1ZXM6IHtsZW4ocmVzdWx0cyl9Iik=)results=set\(\)forainrange\(1,100\):forbinrange\(a\+1,100\):n=a\+b\+a\*bifn<=100:results\.add\(n\)elifn\>100:breakprint\(f"Numberofdistinctvalues:\{len\(results\)\}"\)

<result\>Number of distinct values: 70

#### Turn 2: Self\-correction in code\.

Conditioning on Turn 1’s output, the model revisits its loop bound and formalises the monotonicity argument \(n=a\+b​\(1\+a\)n=a\+b\(1\{\+\}a\)is monotone inbbfor fixedaa\) directly as a code comment, then reruns with the corrected condition\. The audit and fix occur entirely within the code lines; no NL reasoning between blocks is required\.

<python\>Turn 2[⬇](data:text/plain;base64,IyBGb3IgZml4ZWQgYSwgbiA9IGEgKyBiKDErYSkgaXMgbW9ub3RvbmUgaW4gYi4KIyBTbyBgYnJlYWtgIGlzIGp1c3RpZmllZCAtLSBidXQgb25seSBhZnRlciB3ZSBoaXQgbiA+IDEwMCwgbm90IGVhcmxpZXIuCnJlc3VsdHMgPSBzZXQoKQpmb3IgYSBpbiByYW5nZSgxLCAxMDApOgogICAgZm9yIGIgaW4gcmFuZ2UoMSwgMTAwKToKICAgICAgICBpZiBhID09IGI6IGNvbnRpbnVlCiAgICAgICAgbiA9IGEgKyBiICsgYSpiCiAgICAgICAgaWYgbiA+IDEwMDogYnJlYWsKICAgICAgICByZXN1bHRzLmFkZChuKQpwcmludChmIk51bWJlciBvZiBkaXN0aW5jdCB2YWx1ZXM6IHtsZW4ocmVzdWx0cyl9IikKcHJpbnQoIkFsbCB2YWx1ZXMgc29ydGVkOiIsIHNvcnRlZChyZXN1bHRzKSk=)results=set\(\)forainrange\(1,100\):forbinrange\(1,100\):ifa==b:continuen=a\+b\+a\*bifn\>100:breakresults\.add\(n\)print\(f"Numberofdistinctvalues:\{len\(results\)\}"\)print\("Allvaluessorted:",sorted\(results\)\)

<result\>Number of distinct values: 70 All values sorted: \[5, 7, 9, 11, 13, 14, 15, 17, 19, 20, 21, 23, 25, 26, 27, 29, 31, 32, 33, 34, 35, 37, 38, 39, 41, 43, 44, 45, 47, 49, 50, 51, 53, 54, 55, 56, 57, 59, 61, 62, 63, 64, 65, 67, 68, 69, 71, 73, 74, 75, 76, 77, 79, 80, 81, 83, 84, 85, 86, 87, 89, 90, 91, 92, 93, 94, 95, 97, 98, 99\]

#### Turn 3: Structural sanity check\.

The model decomposes the result by parity to confirm there is no off\-by\-one error in the value set\.

<python\>Turn 3[⬇](data:text/plain;base64,dmFsdWVzID0gc29ydGVkKHJlc3VsdHMpCm9kZHMgID0gW3YgZm9yIHYgaW4gdmFsdWVzIGlmIHYgJSAyID09IDFdCmV2ZW5zID0gW3YgZm9yIHYgaW4gdmFsdWVzIGlmIHYgJSAyID09IDBdCnByaW50KGYiQ291bnQ6IHtsZW4odmFsdWVzKX0iKQpwcmludChmIk9kZDoge2xlbihvZGRzKX0sIEV2ZW46IHtsZW4oZXZlbnMpfSIp)values=sorted\(results\)odds=\[vforvinvaluesifv%2==1\]evens=\[vforvinvaluesifv%2==0\]print\(f"Count:\{len\(values\)\}"\)print\(f"Odd:\{len\(odds\)\},Even:\{len\(evens\)\}"\)

<result\>Count: 70 Odd: 48, Even: 22

#### Turn 4: Independent re\-derivation\.

The model re\-implements the count in the dual formulation\(u,v\)=\(a\+1,b\+1\)\(u,v\)=\(a\{\+\}1,b\{\+\}1\)and verifies that it matches Turn 2\.

<python\>Turn 4[⬇](data:text/plain;base64,IyBNZXRob2QgMjogZW51bWVyYXRlICh1LCB2KSB3aXRoIHUsIHYgPj0gMiwgdSAhPSB2LCB1KnYgPD0gMTAxLgpyZXN1bHRzMiA9IHNldCgpCmZvciB1IGluIHJhbmdlKDIsIDEwMik6CiAgICBmb3IgdiBpbiByYW5nZSgyLCAxMDIpOgogICAgICAgIGlmIHUgPT0gdjogY29udGludWUKICAgICAgICBpZiB1ICogdiA8PSAxMDE6CiAgICAgICAgICAgIG4gPSB1ICogdiAtIDEKICAgICAgICAgICAgaWYgbiA8PSAxMDA6CiAgICAgICAgICAgICAgICByZXN1bHRzMi5hZGQobikKcHJpbnQoZiJNZXRob2QgMiBjb3VudDoge2xlbihyZXN1bHRzMil9IikKcHJpbnQoZiJTYW1lIGFzIG1ldGhvZCAxPyB7bGVuKHJlc3VsdHMyKSA9PSA3MH0iKQ==)results2=set\(\)foruinrange\(2,102\):forvinrange\(2,102\):ifu==v:continueifu\*v<=101:n=u\*v\-1ifn<=100:results2\.add\(n\)print\(f"Method2count:\{len\(results2\)\}"\)print\(f"Sameasmethod1?\{len\(results2\)==70\}"\)

<result\>Method 2 count: 70 Same as method 1? True

#### Turn 5: Complement audit\.

As a final empirical check, the model lists the3030values in\{1,…,100\}\\\{1,\\dots,100\\\}that are*not*attained\.

<python\>Turn 5[⬇](data:text/plain;base64,bWlzc2luZyA9IFtpIGZvciBpIGluIHJhbmdlKDEsIDEwMSkgaWYgaSBub3QgaW4gdmFsdWVzXQpwcmludChmIk1pc3NpbmcgdmFsdWVzIChmaXJzdCAxMCk6IHttaXNzaW5nWzoxMF19IikKcHJpbnQoZiJUb3RhbCBtaXNzaW5nOiB7bGVuKG1pc3NpbmcpfSIpCnByaW50KGYiVG90YWwgcHJlc2VudDoge2xlbih2YWx1ZXMpfSIp)missing=\[iforiinrange\(1,101\)ifinotinvalues\]print\(f"Missingvalues\(first10\):\{missing\[:10\]\}"\)print\(f"Totalmissing:\{len\(missing\)\}"\)print\(f"Totalpresent:\{len\(values\)\}"\)

<result\>Missing values \(first 10\): \[1, 2, 3, 4, 6, 8, 10, 12, 16, 18\] Total missing: 30 Total present: 70

<answer\><answer\>The final answer is70\\boxed\{70\}</answer\>

### A\.4What This Trajectory Illustrates

The rollout exhibits, in a single sample, the four behaviours that theThinCformat establishes by construction:

Strategy\-onlyt1t\_\{1\}\.The think channel carries a single algebraic insight \(a\+b\+a​b=\(a\+1\)​\(b\+1\)−1a\+b\+ab=\(a\{\+\}1\)\(b\{\+\}1\)\-1\) and the search constraints, with no arithmetic performed in NL\. This realises theThinCconstraint thatt1t\_\{1\}expresses strategy rather than derivation \(Section[3\.1](https://arxiv.org/html/2605.07237#S3.SS1)\)\.

Code as the reasoner\.Every reasoning step from Turn 1 onward is performed in code\. Self\-correction \(Turn 2\), structural verification \(Turn 3\), independent re\-derivation \(Turn 4\), and complement audit \(Turn 5\) all occur within<python\>blocks; NL appears only as inline code comments and never between code blocks\.

Conditioning on execution outputs\.Turn 2’s repair is grounded in the model’s audit of Turn 1’s output\. Each subsequent turn similarly conditions ono<io\_\{<i\}, consistent with the formal trajectory structure in Eq\.[6](https://arxiv.org/html/2605.07237#S3.E6)\.

Code\-grounded final answer\.The committed answer \(7070\) appears in the interpreter output of Turns 2,44, and55, rather than being generated in NL\.

This rollout is the qualitative correlate of the quantitative gap betweenThinC\-4B and interleaved TIR baselines in Table[1](https://arxiv.org/html/2605.07237#S4.T1)and the99\.2%99\.2\\%code\-grounded answer rate reported in Section[4\.4](https://arxiv.org/html/2605.07237#S4.SS4): the policy has learned to confine NL to strategic planning and to carry out all subsequent reasoning in code\.

## Appendix BFew\-Shot Prompt for Trajectory Distillation

### B\.1Few\-Shot Prompt for Trajectory Distillation

This appendix presents the full33\-shot prompt used to elicitThinCtrajectories from the teacher model \(Qwen3\.5\-27B\)\.

Few\-shot prompt[⬇](data:text/plain;base64,WW91IGFyZSBhIG1hdGggcHJvYmxlbSBzb2x2ZXIgdGhhdCB3b3JrcyBleGNsdXNpdmVseSB0aHJvdWdoIFB5dGhvbgpjb2RlIGV4ZWN1dGlvbi4KClJ1bGVzOgoxLiBXcml0ZSBQeXRob24gY29kZSBpbn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0aCBQPShhLzMsMCksIFE9KGEvNCxzcXJ0KDMpYS80KSwgUj0oNWEvNixzcXJ0KDMpYS82KQppbXBvcnQgc3ltcHkgYXMgc3AKZnJvbSBzeW1weSBpbXBvcnQgc3FydCwgQWJzCmEgPSBzcC5TeW1ib2woJ2EnLCBwb3NpdGl2ZT1UcnVlKQpQID0gKHNwLlJhdGlvbmFsKDEsMykqYSwgMCkKUSA9IChzcC5SYXRpb25hbCgxLDQpKmEsIHNxcnQoMykvNCphKQpSID0gKHNwLlJhdGlvbmFsKDUsNikqYSwgc3FydCgzKS82KmEpCmFyZWEgPSBBYnMoUFswXSooUVsxXS1SWzFdKSArIFFbMF0qKFJbMV0tUFsxXSkgKyBSWzBdKihQWzFdLVFbMV0pKSAvIDIKYXJlYSA9IHNwLnNpbXBsaWZ5KGFyZWEpCnByaW50KGYiYXJlYSBQUVIgPSB7YXJlYX0iKQo8L3B5dGhvbj4KPHJlc3VsdD4KYXJlYSBQUVIgPSA1KnNxcnQoMykqYSoqMi83Mgo8L3Jlc3VsdD4KPHB5dGhvbj4KIyBTdWJzdGl0dXRlIGFeMiA9IDQ4KnNxcnQoMykgZnJvbSB0aGUgZmlyc3Qgc3RlcAppbXBvcnQgc3ltcHkgYXMgc3AKYXJlYV9QUVIgPSA1ICogc3Auc3FydCgzKSAqIDQ4ICogc3Auc3FydCgzKSAvIDcyCnByaW50KGYiYXJlYSBQUVIgPSB7c3Auc2ltcGxpZnkoYXJlYV9QUVIpfSIpCjwvcHl0aG9uPgo8cmVzdWx0PgphcmVhIFBRUiA9IDEwCjwvcmVzdWx0Pgo8YW5zd2VyPiBUaGUgZmluYWwgYW5zd2VyIGlzIFxcYm94ZWR7MTB9IDwvYW5zd2VyPgo=)YouareamathproblemsolverthatworksexclusivelythroughPythoncodeexecution\.Rules:1\.WritePythoncodeinside<python\></python\>tags\.Youwillreceiveexecutionresultsinside<result\></result\>tags\.2\.Eachcodeblockrunsinaseparateprocess\.VariablesdoNOTpersistbetweenturns\.Re\-defineorhardcodevaluesfrompreviousresults\.3\.Youmaythinkfreelybeforethefirstcodeblock,butyourfinaloutputtotheusermustbeONLY<python\>blocksandone<answer\>block\.4\.Embedyourreasoningasconcisecommentsinsidethecode\.Eachcodeblockshouldcontainshortcommentsexplaining:whatyouarecomputingandwhy,basedonpreviousresults\.5\.Solveproblemsstepbystep:computeintermediateresultsineachcodeblock,observetheoutput,thendecidewhattocomputenextbasedonthoseresults\.Eachblockshouldadvancethesolutionbyonelogicalstep\.6\.Whenyouhavethefinalanswer,provideitinside<answer\>Thefinalansweris\\boxed\{answer\}</answer\>\.CRITICAL:EachcodeblockisexecutedinacompletelyfreshPythonprocess\.YouMUSTre\-importlibrariesandre\-defineallvariablesineverycodeblock\.Usehardcodedvaluesfromprevious<result\>outputs,notvariablenames\.Herearesomeexamples:Question:Findthesmallestpositiveinteger$k$withthefollowingproperty:ifeachcellofa$100\\\\times100$gridisdyedwithonecolorandthenumberofcellsofeachcolorisnotmorethan$104$,thenthereisa$k\\\\times1$or$1\\\\timesk$rectanglethatcontainscellsofatleastthreedifferentcolors\.Output:<python\>\#100x100grid,eachcolorusedatmost104times\#Minimumnumberofdistinctcolorsrequiredbypigeonholeimportmathtotal\_cells=100\*100max\_per\_color=104min\_colors=math\.ceil\(total\_cells/max\_per\_color\)print\(f"totalcells:\{total\_cells\},mincolorsneeded:\{min\_colors\}"\)</python\><result\>totalcells:10000,mincolorsneeded:97</result\><python\>\#Ifeverykconsecutivecellsinarowhave<=2colors,\#colorsmustformcontiguousblocks\.\#Intermediateblocksneedwidth\>=k\-1topreventak\-windowspanning3blocks\.\#Somaxcolorsperrow=floor\(\(100\-2\)/\(k\-1\)\)\+2\#\(firstandlastblockcanbewidth1,eachintermediateblock\>=k\-1\)forkinrange\(10,15\):max\_colors\_per\_row=\(100\-2\)//\(k\-1\)\+2print\(f"k=\{k\}:maxcolorsperrow=\{max\_colors\_per\_row\}"\)</python\><result\>k=10:maxcolorsperrow=12k=11:maxcolorsperrow=11k=12:maxcolorsperrow=10k=13:maxcolorsperrow=10k=14:maxcolorsperrow=9</result\><python\>\#Constructionattempt:dividegridintosxsblocks,onecolorperblock\.\#Blocksizes\>=k\-1satisfiesbothrowandcolumnconstraints\.\#Eachcoloroccupiess^2cells,needs^2<=104\.importmathforsinrange\(9,13\):num\_colors=math\.ceil\(100/s\)\*\*2cells\_per\_color=s\*sprint\(f"block\{s\}x\{s\}:colors=\{num\_colors\},cells\_per\_color=\{cells\_per\_color\},feasible=\{cells\_per\_color<=104\}"\)</python\><result\>block9x9:colors=144,cells\_per\_color=81,feasible=Trueblock10x10:colors=100,cells\_per\_color=100,feasible=Trueblock11x11:colors=100,cells\_per\_color=121,feasible=Falseblock12x12:colors=81,cells\_per\_color=144,feasible=False</result\><python\>\#s=10works\(100<=104\)\.Verify:build10x10blockgrid,\#checkevery11\-windowinallrowsandcolumnshas<=2colorsfromcollectionsimportCountergrid=\[\[0\]\*100for\_inrange\(100\)\]color=0forbiinrange\(10\):forbjinrange\(10\):forrinrange\(bi\*10,\(bi\+1\)\*10\):forcinrange\(bj\*10,\(bj\+1\)\*10\):grid\[r\]\[c\]=colorcolor\+=1counts=Counter\(grid\[r\]\[c\]forrinrange\(100\)forcinrange\(100\)\)\#checkall11\-windowsinrowsrow\_ok=all\(len\(set\(grid\[r\]\[c:c\+11\]\)\)<=2forrinrange\(100\)forcinrange\(90\)\)\#checkall11\-windowsincolumnscol\_ok=all\(len\(set\(grid\[r2\]\[c\]forr2inrange\(r,r\+11\)\)\)<=2forcinrange\(100\)forrinrange\(90\)\)print\(f"k=11row:\{’PASS’ifrow\_okelse’FAIL’\},col:\{’PASS’ifcol\_okelse’FAIL’\}"\)print\(f"colors:\{len\(counts\)\},maxpercolor:\{max\(counts\.values\(\)\)\}"\)</python\><result\>k=11row:PASS,col:PASScolors:100,maxpercolor:100</result\><python\>\#Same10x10blocks:checkk=12\.Blocksize10<12\-1=11,\#soa12\-windowcrossingtwoblockboundarieswillsee3colors\.grid=\[\[0\]\*100for\_inrange\(100\)\]color=0forbiinrange\(10\):forbjinrange\(10\):forrinrange\(bi\*10,\(bi\+1\)\*10\):forcinrange\(bj\*10,\(bj\+1\)\*10\):grid\[r\]\[c\]=colorcolor\+=1found=Noneforrinrange\(100\):forcinrange\(89\):iflen\(set\(grid\[r\]\[c:c\+12\]\)\)\>=3:found=\(r,c,grid\[r\]\[c:c\+12\]\)breakiffound:breakprint\(f"k=12window:row=\{found\[0\]\},start=\{found\[1\]\},cells=\{found\[2\]\}"\)</python\><result\>k=12window:row=0,start=9,cells=\[0,1,1,1,1,1,1,1,1,1,1,2\]</result\><python\>\#Fork=12,anyblockcoloringneedsbothdimensions\>=11\.\#Exhaustivelycheck:norectanglewithbothdims\>=11hasarea<=104\.importmathfeasible=\[\]forpinrange\(11,105\):forqinrange\(11,105\):ifp\*q<=104:feasible\.append\(\(p,q,math\.ceil\(100/p\)\*math\.ceil\(100/q\)\)\)iffeasible:forp,q,ncinfeasible:print\(f"\{p\}x\{q\}:colors=\{nc\}"\)else:print\(f"noblockwithbothdims\>=11fitsin104\(min11x11=\{11\*11\}\)"\)</python\><result\>noblockwithbothdims\>=11fitsin104\(min11x11=121\)</result\><answer\>Thefinalansweris\\\\boxed\{12\}</answer\>Question:IntheCartesiancoordinatesystem\\\\\(xOy\\\\\),theareaoftheregioncorrespondingtothesetofpoints\\\\\(K=\\\\\{\(x,y\)\\\\mid\(\|x\|\+\|3y\|\-6\)\(\|3x\|\+\|y\|\-6\)\\\\leq0\\\\\}\\\\\)is\_\_\_\_\_\_\_\_\.Output:<python\>\#\(f1\)\(f2\)<=0meansexactlyoneoff1<=0,f2<=0\#RegionA:\|x\|\+3\|y\|<=6\-\>\|x\|/6\+\|y\|/2<=1,area=2\*a\*b=2\*6\*2\#RegionB:\|3x\|\+\|y\|<=6\-\>\|x\|/2\+\|y\|/6<=1,area=2\*a\*b=2\*2\*6fromsympyimportRational,solve,symbolsx,y=symbols\(’xy’\)area\_A=2\*6\*2area\_B=2\*2\*6print\(f"areaA:\{area\_A\},areaB:\{area\_B\}"\)</python\><result\>areaA:24,areaB:24</result\><python\>\#Findwherethetwoboundariesintersectinthefirstquadrant\#x\+3y=6and3x\+y=6fromsympyimportsymbols,solvex,y=symbols\(’xy’\)sol=solve\(\[x\+3\*y\-6,3\*x\+y\-6\],\[x,y\]\)print\(f"intersectionofboundaries:\{sol\}"\)</python\><result\>intersectionofboundaries:\{x:3/2,y:3/2\}</result\><python\>\#FirstquadrantintersectionregionA∩Bhasvertices:\#\(0,0\),\(2,0\)from\|3x\|\+\|y\|=6,\(3/2,3/2\)fromboundarycrossing,\(0,2\)from\|x\|\+3\|y\|=6\#Computeareaviashoelace,thenmultiplyby4forallquadrantsfromsympyimportRationalpts=\[\(0,0\),\(2,0\),\(Rational\(3,2\),Rational\(3,2\)\),\(0,2\)\]n=len\(pts\)s=0foriinrange\(n\):j=\(i\+1\)%ns\+=pts\[i\]\[0\]\*pts\[j\]\[1\]\-pts\[j\]\[0\]\*pts\[i\]\[1\]area\_q1=abs\(s\)/2area\_intersection=4\*area\_q1print\(f"firstquadrant:\{area\_q1\},totalintersection:\{area\_intersection\}"\)</python\><result\>firstquadrant:3,totalintersection:12</result\><python\>\#K=symmetricdifferenceofAandB=A\+B\-2\*\(A∩B\)area\_A=24area\_B=24area\_intersection=12area\_K=area\_A\+area\_B\-2\*area\_intersectionprint\(f"areaK=\{area\_K\}"\)</python\><result\>areaK=24</result\><answer\>Thefinalansweris\\\\boxed\{24\}</answer\>Question:TheareaofanequilateraltriangleABCis36\.PointsP,Q,RarelocatedonBC,AB,andCArespectively,suchthatBP=1/3BC,AQ=QB,andPRisperpendiculartoAC\.FindtheareaoftrianglePQR\.Output:<python\>\#Equilateraltrianglearea=\(sqrt\(3\)/4\)\*s^2=36,solveforsidelengthimportsympyassps=sp\.Symbol\(’s’,positive=True\)side=sp\.solve\(sp\.sqrt\(3\)/4\*s\*\*2\-36,s\)print\(f"side:\{side\[0\]\},side^2:\{sp\.simplify\(side\[0\]\*\*2\)\}"\)</python\><result\>side:4\*3\*\*\(3/4\),side^2:48\*sqrt\(3\)</result\><python\>\#Placetriangle:Batorigin,Cat\(a,0\),Aat\(a/2,a\*sqrt\(3\)/2\)\#PonBCwithBP=1/3BC,QismidpointofAB\(AQ=QB\)importsympyasspfromsympyimportsqrt,Rational,Matrixa=sp\.Symbol\(’a’,positive=True\)B=Matrix\(\[0,0\]\)C=Matrix\(\[a,0\]\)A=Matrix\(\[a/2,a\*sqrt\(3\)/2\]\)P=B\+Rational\(1,3\)\*\(C\-B\)Q=\(A\+B\)/2print\(f"P=\{P\.T\}"\)print\(f"Q=\{Q\.T\}"\)</python\><result\>P=Matrix\(\[\[a/3,0\]\]\)Q=Matrix\(\[\[a/4,sqrt\(3\)\*a/4\]\]\)</result\><python\>\#RonCA:R=A\+t\*\(C\-A\)\.FindtsuchthatPRisperpendiculartoAC\.importsympyasspfromsympyimportsqrt,Rational,Matrixa,t=sp\.symbols\(’at’,positive=True\)A=Matrix\(\[a/2,a\*sqrt\(3\)/2\]\)C=Matrix\(\[a,0\]\)P=Matrix\(\[a/3,0\]\)R=A\+t\*\(C\-A\)AC=C\-APR=R\-P\#PR·AC=0forperpendicularityt\_val=sp\.solve\(PR\.dot\(AC\),t\)\[0\]R\_val=A\+t\_val\*\(C\-A\)print\(f"t=\{t\_val\}"\)print\(f"R=\{sp\.simplify\(R\_val\)\.T\}"\)</python\><result\>t=2/3R=Matrix\(\[\[5\*a/6,sqrt\(3\)\*a/6\]\]\)</result\><python\>\#AreaofPQRusingshoelaceformulawithP=\(a/3,0\),Q=\(a/4,sqrt\(3\)a/4\),R=\(5a/6,sqrt\(3\)a/6\)importsympyasspfromsympyimportsqrt,Absa=sp\.Symbol\(’a’,positive=True\)P=\(sp\.Rational\(1,3\)\*a,0\)Q=\(sp\.Rational\(1,4\)\*a,sqrt\(3\)/4\*a\)R=\(sp\.Rational\(5,6\)\*a,sqrt\(3\)/6\*a\)area=Abs\(P\[0\]\*\(Q\[1\]\-R\[1\]\)\+Q\[0\]\*\(R\[1\]\-P\[1\]\)\+R\[0\]\*\(P\[1\]\-Q\[1\]\)\)/2area=sp\.simplify\(area\)print\(f"areaPQR=\{area\}"\)</python\><result\>areaPQR=5\*sqrt\(3\)\*a\*\*2/72</result\><python\>\#Substitutea^2=48\*sqrt\(3\)fromthefirststepimportsympyassparea\_PQR=5\*sp\.sqrt\(3\)\*48\*sp\.sqrt\(3\)/72print\(f"areaPQR=\{sp\.simplify\(area\_PQR\)\}"\)</python\><result\>areaPQR=10</result\><answer\>Thefinalansweris\\\\boxed\{10\}</answer\>

## Appendix CTool Call and Response Length per Benchmark

This section reports the average number of tool calls per trajectory and the average response length on each evaluation benchmark\.

### C\.1Tool Calls by Benchmark

![Refer to caption](https://arxiv.org/html/2605.07237v1/x6.png)Figure 6:Average tool calls per benchmark\. We compare how often models invoke the Python interpreter across AIME 2024–2026, HMMT 2025 February, and BeyondAIME\.
### C\.2Response Length by Benchmark

![Refer to caption](https://arxiv.org/html/2605.07237v1/x7.png)Figure 7:Average response length per benchmark\. We report the mean trajectory length across AIME 2024–2026, HMMT 2025 February, and BeyondAIME\.

## Appendix DOOD Generalization

We evaluateThinC\-4B on GPQA\-Diamond\[[13](https://arxiv.org/html/2605.07237#bib.bib26)\], a graduate\-level science benchmark covering physics, chemistry, and biology, as an out\-of\-distribution \(OOD\) test\. Table[2](https://arxiv.org/html/2605.07237#A4.T2)reports avg@16 and best@16 accuracy\.ThinC\-4B leads on both metrics, exceeding ASTER\-4B by3\.13\.1points on avg@16 and the base model by7\.67\.6points on best@16, suggesting that the code\-centric reasoning format generalizes more effectively than the interleaved alternative beyond the mathematical training domain\.

Table 2:GPQA\-Diamond accuracy \(%\)\. Best per column inbold\.
## Appendix ETraining Details

All training runs use a single node with8×8\\timesNVIDIA H200 GPUs\. We perform SFT using the LLaMA\-Factory framework\[[24](https://arxiv.org/html/2605.07237#bib.bib23)\]and RL using the verl framework\[[17](https://arxiv.org/html/2605.07237#bib.bib24)\]\. BothThinC\-1\.7B andThinC\-4B share identical hyperparameter configurations at each training stage\.

### E\.1Supervised Fine\-Tuning

Table 3:SFT hyperparameters forThinC\-1\.7B\-SFT andThinC\-4B\-SFT\.
### E\.2Reinforcement Learning

Following DAPO\[[21](https://arxiv.org/html/2605.07237#bib.bib17)\], we apply token\-level loss normalization across the rollout group, asymmetric clipping withϵlow=0\.20\\epsilon\_\{\\mathrm\{low\}\}=0\.20andϵhigh=0\.28\\epsilon\_\{\\mathrm\{high\}\}=0\.28, and disable the KL penalty\. Table[4](https://arxiv.org/html/2605.07237#A5.T4)lists the full hyperparameter configuration along with the three\-stage curriculum\.

Table 4:RL hyperparameters forThinC\-1\.7B andThinC\-4B\.

Similar Articles

Reasoning, Code, or Both? How Large Language Models Handle Variations in Math Questions

arXiv cs.AI

This paper evaluates three approaches (pure chain-of-thought reasoning, single-shot code execution, and iterative code execution) on 1,000 GSM-Symbolic problems using Claude Haiku 4.5, finding that chain-of-thought is the most robust to perturbation, while code execution does not improve reasoning robustness on grade-school math problems.

Think Multilingual, Not Harder: A Data-Efficient Framework for Teaching Reasoning Models to Code-Switch

arXiv cs.CL

This paper introduces a data-efficient fine-tuning framework for teaching reasoning models to code-switch (mix languages) effectively, demonstrating that strategic code-switching can improve reasoning capabilities for lower-resource languages. The work analyzes code-switching behaviors in large language models across diverse languages, tasks, and domains, then develops interventions to promote beneficial code-switching patterns.

Reasoning Models Don't Just Think Longer, They Move Differently

arXiv cs.CL

This paper investigates whether reasoning-trained language models simply allocate more compute (longer chains of thought) or follow qualitatively different internal trajectories by analyzing hidden-state trajectory geometry across code, math, and SAT domains. After correcting for generation length, they find that reasoning-trained models exhibit distinct trajectory geometry—most clearly in code—indicating reasoning training changes how computation unfolds, not just how much is used.