{"problem":{"name":"G. BF Calculator","description":{"content":"In this problem you will write a simple generator of Brainfuck ([https://en.wikipedia.org/wiki/Brainfuck](https://en.wikipedia.org/wiki/Brainfuck)) calculators. You are given an arithmetic expression","description_type":"Markdown"},"platform":"Codeforces","limit":{"time_limit":2000,"memory_limit":65536},"difficulty":"None","is_remote":true,"is_sync":true,"sync_url":null,"sign":"CF784G"},"statements":[{"statement_type":"Markdown","content":"In this problem you will write a simple generator of Brainfuck ([https://en.wikipedia.org/wiki/Brainfuck](https://en.wikipedia.org/wiki/Brainfuck)) calculators.\n\nYou are given an arithmetic expression consisting of integers from 0 to 255 and addition/subtraction signs between them. Output a Brainfuck program which, when executed, will print the result of evaluating this expression.\n\nWe use a fairly standard Brainfuck interpreter for checking the programs:\n\n*   30000 memory cells.\n*   memory cells store integers from 0 to 255 with unsigned 8-bit wraparound.\n*   console input (_,_ command) is not supported, but it's not needed for this problem.\n\n## Input\n\nThe only line of input data contains the arithmetic expression. The expression will contain between 2 and 10 operands, separated with arithmetic signs plus and/or minus. Each operand will be an integer between 0 and 255, inclusive. The calculations result is guaranteed to be an integer between 0 and 255, inclusive (results of intermediary calculations might be outside of these boundaries).\n\n## Output\n\nOutput a Brainfuck program which, when executed, will print the result of evaluating this expression. The program must be at most 5000000 characters long (including the non-command characters), and its execution must be complete in at most 50000000 steps.\n\n[samples]\n\n## Note\n\nYou can download the source code of the Brainfuck interpreter by the link [http://assets.codeforces.com/rounds/784/bf.cpp](//assets.codeforces.com/rounds/784/bf.cpp). We use this code to interpret outputs.","is_translate":false,"language":"English"},{"statement_type":"Markdown","content":"在本题中，你需要编写一个简单的 Brainfuck（https://en.wikipedia.org/wiki/Brainfuck）计算器生成器。\n\n你将获得一个算术表达式，由 0 到 255 的整数以及它们之间的加号/减号组成。请输出一个 Brainfuck 程序，该程序在执行时会打印出该表达式的计算结果。\n\n我们使用一个相当标准的 Brainfuck 解释器来检查程序：\n\n输入数据仅有一行，包含该算术表达式。表达式将包含 2 到 10 个操作数，由加号和/或减号分隔。每个操作数均为 0 到 255（含）之间的整数。计算结果保证为 0 到 255（含）之间的整数（中间计算结果可能超出此范围）。\n\n请输出一个 Brainfuck 程序，该程序在执行时会打印出该表达式的计算结果。程序长度不得超过 5000000 个字符（包括非命令字符），且执行步数不得超过 50000000 步。\n\n你可以通过链接 http://assets.codeforces.com/rounds/784/bf.cpp 下载 Brainfuck 解释器的源代码。我们使用此代码来解释你的输出。\n\n## Input\n\n输入数据仅有一行，包含该算术表达式。表达式将包含 2 到 10 个操作数，由加号和/或减号分隔。每个操作数均为 0 到 255（含）之间的整数。计算结果保证为 0 到 255（含）之间的整数（中间计算结果可能超出此范围）。\n\n## Output\n\n请输出一个 Brainfuck 程序，该程序在执行时会打印出该表达式的计算结果。程序长度不得超过 5000000 个字符（包括非命令字符），且执行步数不得超过 50000000 步。\n\n[samples]\n\n## Note\n\n你可以通过链接 http://assets.codeforces.com/rounds/784/bf.cpp 下载 Brainfuck 解释器的源代码。我们使用此代码来解释你的输出。","is_translate":true,"language":"Chinese"},{"statement_type":"Markdown","content":"Given an arithmetic expression $ E = a_1 \\oplus_1 a_2 \\oplus_2 \\cdots \\oplus_{n-1} a_n $, where each $ a_i \\in \\{0, 1, \\dots, 255\\} $ and each $ \\oplus_i \\in \\{+, -\\} $, and the result $ R = E \\in \\{0, 1, \\dots, 255\\} $, construct a Brainfuck program that:\n\n- Initializes a tape of non-negative integers (all zero except as needed),\n- Writes the value $ a_1 $ to cell 0,\n- For each subsequent operand $ a_i $ and operator $ \\oplus_i $:\n  - If $ \\oplus_i = + $, add $ a_i $ to the current result in cell 0,\n  - If $ \\oplus_i = - $, subtract $ a_i $ from the current result in cell 0,\n- Outputs the final value in cell 0 as an ASCII character (i.e., prints the byte value).\n\nThe program must compute $ R $ using only Brainfuck commands (`>`, `<`, `+`, `-`, `[`, `]`, `.`, `,`), operate within 50,000,000 steps, and be at most 5,000,000 characters long.\n\n**Objective:** Generate a Brainfuck program that computes $ R $ and outputs it via `.`.","is_translate":false,"language":"Formal"}],"meta":{"iden":"CF784G","tags":[],"sample_group":[["2+3","++>\n+++>\n<\\[<+>-\\]<\n++++++++++++++++++++++++++++++++++++++++++++++++."],["9-7","+++++++++>\n+++++++>\n<\\[<->-\\]<\n++++++++++++++++++++++++++++++++++++++++++++++++."]],"created_at":"2026-03-03 11:00:39"}}