Language: C

s = list(map(int, input().split()))
t = list(map(int, input().split()))


num=[2,5,5,4,5,6,3,7,6]
aru=[0,0,0,0,0,0,0,0,0,0]
n=s[0]


lista=[]
minm=[8,7]
minflag=0;
for i in range(len(t)):
    if(t[i]==1):
        lista.append([1,2])
        aru[1]=1
        if(minflag==0):
            minm=[1,2]
            minflag=1
for i in range(len(t)):
    if(t[i]==7):
        lista.append([7,3])
        aru[7]=1
        if(minflag==0):
            minm=[7,3]
            minflag=1
        
for i in range(len(t)):
    if(t[i]==4):
        lista.append([4,4])
        aru[4]=1
        if(minflag==0):
            minm=[4,4]
            minflag=1
        
flag=[0,0,0]
for i in range(len(t)):
    if(t[i]==5):
        flag[0]=1
        aru[5]=1
    if(t[i]==3):
        flag[1]=1
        aru[3]=1
    if(t[i]==2):
        flag[2]=1
        aru[2]=1
if(flag[0]==1):
    lista.append([5,5])
    if(minflag==0):
        minm=[5,5]
        minflag=1
elif(flag[1]==1):
    lista.append([3,5])
    if(minflag==0):
        minm=[3,5]
        minflag=1
elif(flag[1]==1):
    lista.append([2,5])
    if(minflag==0):
        minm=[2,5]
        minflag=1

flag=[0,0]
for i in range(len(t)):
    if(t[i]==9):
        flag[0]=1
        aru[9]=1
    if(t[i]==6):
        flag[1]=1
        aru[6]=1
if(flag[0]==1):
    lista.append([9,6])
    if(minflag==0):
        minm=[9,6]
        minflag=1
elif(flag[1]==1):
    lista.append([6,6])
    if(minflag==0):
        minm=[6,6]
        minflag=1

for i in range(len(t)):
    if(t[i]==8):
        aru[8]=1
        lista.append([8,7])

nn=n
d=0
while(nn>=minm[1]):
    nn-=minm[1]
    d+=1

sch=minm[1]
saigo=minm[0]
while(nn>=1):
    sch+=1
    if(sch==3):
        if(saigo<7):
            saigo=7
    elif(sch==4):
        if(saigo<4):
            saigo=4
    elif(sch==5):
        if(saigo<5):
            saigo=5
    elif(sch==6):
        saigo=9
    elif(sch==7):
        if(saigo<8):
            saigo=8
    
    nn-=1;
    
ans=""
for i in range(d-1):
    ans+=str(minm[0])
ans+=str(saigo)
print(ans)



##a



Compiler output:
main.c:1:1: warning: data definition has no type or storage class
    1 | s = list(map(int, input().split()))
      | ^
main.c:1:1: error: type defaults to 'int' in declaration of 's' [-Wimplicit-int]
main.c:1:5: error: implicit declaration of function 'list' [-Wimplicit-function-declaration]
    1 | s = list(map(int, input().split()))
      |     ^~~~
main.c:1:10: error: implicit declaration of function 'map' [-Wimplicit-function-declaration]
    1 | s = list(map(int, input().split()))
      |          ^~~
main.c:1:14: error: expected expression before 'int'
    1 | s = list(map(int, input().split()))
      |              ^~~
main.c:2:1: error: expected ',' or ';' before 't'
    2 | t = list(map(int, input().split()))
      | ^
main.c:13:1: error: expected identifier or '(' before 'for'
   13 | for i in range(len(t)):
      | ^~~
main.c:114:1: warning: data definition has no type or storage class
  114 | ans=""
      | ^~~
main.c:114:1: error: type defaults to 'int' in declaration of 'ans' [-Wimplicit-int]
main.c:114:5: error: initialization of 'int' from 'char *' makes integer from pointer without a cast [-Wint-conversion]
  114 | ans=""
      |     ^~
main.c:114:5: error: initializer element is not computable at load time
main.c:115:1: error: expected ',' or ';' before 'for'
  115 | for i in range(d-1):
      | ^~~
main.c:122:1: error: stray '##' in program
  122 | ##a
      | ^~