{"raw_statement":[{"iden":"statement","content":"Stepan has the newest electronic device with a display. Different digits can be shown on it. Each digit is shown on a seven-section indicator like it is shown on the picture below.\n\n<center>![image](https://espresso.codeforces.com/1b26f8faef5a8a5117060246d28eb2aea6e5ebe8.png)</center>So, for example, to show the digit 3 on the display, 5 sections must be highlighted; and for the digit 6, 6 sections must be highlighted.\n\nThe battery of the newest device allows to highlight at most _n_ sections on the display.\n\nStepan wants to know the maximum possible integer number which can be shown on the display of his newest device. Your task is to determine this number. Note that this number must not contain leading zeros. Assume that the size of the display is enough to show any integer."},{"iden":"input","content":"The first line contains the integer _n_ (2 ≤ _n_ ≤ 100 000) — the maximum number of sections which can be highlighted on the display."},{"iden":"output","content":"Print the maximum integer which can be shown on the display of Stepan's newest device."},{"iden":"examples","content":"Input\n\n2\n\nOutput\n\n1\n\nInput\n\n3\n\nOutput\n\n7"}],"translated_statement":[{"iden":"statement","content":"Stepan 拥有一款最新电子设备，其显示屏可以显示不同的数字。每个数字通过一个七段指示器显示，如下图所示。\n\n例如，要在显示屏上显示数字 #cf_span[3]，需要点亮 #cf_span[5] 段；而显示数字 #cf_span[6] 则需要点亮 #cf_span[6] 段。\n\n该设备的电池最多允许点亮 #cf_span[n] 段。\n\nStepan 想知道，在显示屏上能显示的最大整数是多少。你的任务是确定这个数字。注意，这个数字不能包含前导零。假设显示屏的尺寸足以显示任意大的整数。\n\n第一行包含整数 #cf_span[n] (#cf_span[2 ≤ n ≤ 100 000]) —— 显示屏上可点亮的最大段数。\n\n请输出 Stepan 最新设备显示屏上能显示的最大整数。"},{"iden":"input","content":"第一行包含整数 #cf_span[n] (#cf_span[2 ≤ n ≤ 100 000]) —— 显示屏上可点亮的最大段数。"},{"iden":"output","content":"请输出 Stepan 最新设备显示屏上能显示的最大整数。"},{"iden":"examples","content":"输入\n2\n输出\n1\n\n输入\n3\n输出\n7"}],"sample_group":[],"show_order":[],"formal_statement":"Let $ c_d $ denote the number of segments required to display digit $ d \\in \\{0, 1, 2, \\dots, 9\\} $, with:\n\n$$\n\\begin{align*}\nc_0 &= 6, & c_1 &= 2, & c_2 &= 5, \\\\\nc_3 &= 5, & c_4 &= 4, & c_5 &= 5, \\\\\nc_6 &= 6, & c_7 &= 3, & c_8 &= 7, & c_9 &= 6.\n\\end{align*}\n$$\n\nGiven an integer $ n $ (with $ 2 \\leq n \\leq 100{,}000 $), find the maximum integer (in decimal representation, without leading zeros) such that the total number of segments used to display all its digits is at most $ n $.\n\n**Objective:** Maximize the integer value (lexicographically) under the constraint:\n\n$$\n\\sum_{i=1}^{k} c_{d_i} \\leq n,\n$$\n\nwhere $ d_1 d_2 \\dots d_k $ is the decimal representation of the number, $ d_1 \\ne 0 $, and $ k \\geq 1 $.\n\n---\n\n**Key Insight:**  \nTo maximize the integer:\n\n1. **Maximize the number of digits**: Use as many digits as possible, since a number with more digits is larger than one with fewer (no leading zeros).\n2. **Greedy left-to-right digit selection**: For each position, choose the **largest possible digit** $ d $ such that the remaining segments can still form a valid number with the remaining digits.\n\nLet $ m = \\min_{d \\in \\{0,\\dots,9\\}} c_d = c_1 = 2 $.  \nThen the **maximum number of digits** is $ \\left\\lfloor \\frac{n}{2} \\right\\rfloor $.\n\nWe construct the number digit by digit from left to right:\n\n- For position $ i $ (starting from left), try digits from 9 down to 1 (for first digit) or 9 down to 0 (for subsequent digits).\n- For candidate digit $ d $, check if $ c_d \\leq \\text{remaining\\_segments} $ and $ \\text{remaining\\_segments} - c_d \\geq 2 \\cdot (\\text{remaining\\_positions} - 1) $.\n- Choose the largest such $ d $, subtract $ c_d $ from remaining segments, and proceed.\n\nThis greedy construction yields the lexicographically largest number under the segment constraint.","simple_statement":null,"has_page_source":false}