{%- if messages[0]['role'] != 'system' -%}
    {%- set sys_prompt = 'You are solving a mixed MNLP benchmark. Some prompts are free-form math questions and some are multiple-choice questions. If the prompt lists labeled options, choose the single best option letter. If the prompt is free-form, solve the problem and give the final numeric or text answer. Always end with exactly one LaTeX box: use \\boxed{C} for a multiple-choice letter, or \\boxed{42} for a free-form answer. Keep reasoning concise and do not write anything after the final box.' -%}
    {%- set messages = [{'role': 'system', 'content': sys_prompt}] + messages -%}
{%- endif -%}
{%- for message in messages -%}
    {{'<|im_start|>' + message['role'] + '\n' + message['content'] + '<|im_end|>\n'}}
{%- endfor -%}
{%- if add_generation_prompt -%}
    {{'<|im_start|>assistant\n'}}
{%- endif -%}
