Harryxun/stf_run huggingface dataset:
import itertools
import numpy as np
H, W = map(int, input().split())
arr = []
for _ in range(H):
    S = input().split()
    S = [int(s) for s in S]
    arr.append(S)
x = list(itertools.combinations(arr,2))
count = 0
for i in range(len(x)):
    vec_a = np.array(x[i][0])
    vec_b = np.array(x[i][1])
    d = np.linalg.norm(vec_a - vec_b)
    d2 = int(d)
    if d == d2:
        count+=1
print(count)
print()

### FIXED CODE ###

a, b, c = map(int, input().split())
if a*b <= c:
    print(a*b)
else:
    print(c)
print()
from fractions import gcd
n,m=map(int,input().split())
print(3*(n-gcd(n,m))

### FIXED CODE ###

from fractions import gcd
n,m=map(int,input().split())
print(3*(n-gcd(n,m)))
def main():
    s=input()
    string=('dream','erase')

    i=0
    n=len(s)
    while i<n:
        st=s[i:i+5]
        if st==string[0]:
            i+=5
            st=s[i:i+2]
            if st=='er':
                if s[i+2]!='a':
                    i+=2
        
        elif st==string[1]:
            i+=5
            if s[i]=='r':
                i+=1
        
        else:
            print('NO')
            exit()
    print('YES')
if  __name__=='__main__':
    main()

### FIXED CODE ###

def main():
    s=input()
    string=('dream','erase')

    i=0
    n=len(s)
    while i<n:
        st=s[i:i+5]
        if st==string[0]:
            i+=5
            st=s[i:i+2]
            if st=='er':
                if i+2==n:
                    break
                if s[i+2]!='a':
                    i+=2
        
        elif st==string[1]:
            i+=5
            if i==n:
                break
            if s[i]=='r':
                i+=1
        
        else:
            print('NO')
            exit()
    print('YES')
if  __name__=='__main__':
    main()
#16D8101014F Kurume Ryunosuke 久留米竜之介 2018/5/16 Python3
n = int(input())
box = set()

for _ in range(n):
    tmp,mozi= input().split()
    
    if tmp == "find":
        if word in box:
            print("yes")
        else:
            print("no")
    else:
        box.add(mozi)


### FIXED CODE ###

#16D8101014F Kurume Ryunosuke 久留米竜之介 2018/5/16 Python3
n = int(input())
box = set()

for _ in range(n):
    tmp,mozi= input().split()
    
    if tmp == "find":
        if mozi in box:
            print("yes")
        else:
            print("no")
    else:
        box.add(mozi)
from math import gcd
n = int(input())
A = [list(map(int, input().split())) for _ in range(n)]
for i in range(n):
    a,b,c,d = A[i]
    g = gcd(b,d)
    if a < b or b > d or b-g+(a%g)>c:
        print('No')
    else:
        print('Yes')
 


### FIXED CODE ###

from fractions import gcd
n = int(input())
A = [list(map(int, input().split())) for _ in range(n)]
for i in range(n):
    a,b,c,d = A[i]
    g = gcd(b,d)
    if a < b or b > d or b-g+(a%g)>c:
        print('No')
    else:
        print('Yes')
from scipy.special import comb

def solve(n,m):
    maxdiv = int(m**0.5)
    l = []
    tmp = 2
    num = 0
    while tmp <= maxdiv:
        if m % tmp == 0:
            m /= tmp
            num += 1
        else:
            tmp += 1
            if num != 0:
                l.append(num)
                num = 0
    if m != 1:
        l.append(1)
    res = 1
    for div in l:
        tmp = comb(n+div-1,div,exact=True)%(10**9+7)
        res = res * tmp % (10**9+7)
    return int(res)
        

if __name__ == '__main__':
    n,m = map(int,input().split())
    print(solve(n,m))

### FIXED CODE ###

# from scipy.misc import comb

def cmb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result

def solve(n,m):
    maxdiv = int(m**0.5)
    l = []
    tmp = 2
    num = 0
    while tmp <= maxdiv:
        if m % tmp == 0:
            m /= tmp
            num += 1
        else:
            tmp += 1
            if num != 0:
                l.append(num)
                num = 0
    if m != 1:
        l.append(1)
    res = 1
    for div in l:
        tmp = cmb(n+div-1,div)%(10**9+7)
        res = res * tmp % (10**9+7)
    return int(res)
        

if __name__ == '__main__':
    n,m = map(int,input().split())
    print(solve(n,m))
N, K = map(int, input().split())
 
tmp = [0] * N
 
for i in range(K):
  input()
  for j in map(int, input().split()):
 	tmp[j-1] |= 1 
print(sum(tmp))


### FIXED CODE ###

N, K = map(int, input().split())
 
tmp = set()
 
for i in range(K):
  input()
  tmp |= set(map(int, input().split()))
 
print(len(set(range(1, N+1)) - tmp))
n=int(input())
s=input()
c=0
for i in range(1,n):
    x, y = S[:i], S[i:]
    c = max(c, len(set(x) & set(y)))
print(c)


### FIXED CODE ###

n=int(input())
s=input()
c=0
for i in range(1,n):
  x=set(s[:i])
  y=set(s[i:])
  a = len(x & y)
  if a > c:
    c = a
print(c)
N=list(input())
S=[int(t) for t in N]
T=sum(s)
if T%9==0:
  print('Yes')
else :
  print("No")

### FIXED CODE ###

N=list(input())
NN=[int(t) for t in N]
T=sum(NN)
if T%9==0:
    print("Yes")
else :
    print("No")
import math

n=int(input())
f=list()
p=list()
ans=-10**10
for i in range(n):
    f.append(list(map(int,input().split())))
for i in range(n):
    p.append(list(map(int,input().split())))
for i in range(1,1<<10):
    shop=list()
    cnt=[0]*n
    tmp=0
    for j in range(10):
        if i&(1<<j):
            shop.append(j)
    for s in range(n):
        for p in shop:
            if(f[s][p]==1):
                cnt+=1
        tmp+=p[s][cnt[s]]
    ans=max(ans,tmp)
print(ans)

### FIXED CODE ###

import math

n=int(input())
f=list()
p=list()
ans=-10**10
for i in range(n):
    f.append(list(map(int,input().split())))
for i in range(n):
    p.append(list(map(int,input().split())))
for i in range(1,1<<10):
    shop=list()
    cnt=[0]*n
    tmp=0
    for j in range(10):
        if i>>j&1:
            shop.append(j)
    for s in range(n):
        for k in shop:
            if(f[s][k]==1):
                cnt[s]+=1
        tmp+=p[s][cnt[s]]
    ans=max(ans,tmp)
print(ans)
n, k = map(int, input().split())
lis = []
for i in range(ki):
    lis.append(input().split())
lis2 = []
j = 1
while j < ki:
    for j in li[i]:
        li2.append(j)
    j += 2
lis2 = set(lis2)
print(n - len(lis2))


### FIXED CODE ###

n, k = map(int, input().split())
li = []
for x in range(k*2):
    li.append(input().split())
li2 = []
i = 1
while i < k*2:
    for j in li[i]:
        li2.append(j)
    i += 2
li2 = set(li2)
print(n - len(li2))
N = int(input())
A = list(map(int,input().split()))
for i in range(N)
    if A[i] % 2 != 0:
      A.remove(i)
      continue
    else:
      continue
for i in range(N)
   if A[i] % 3 != 0 and A[i] % 5 != 0:
      print('DENIED')
      break
    else:
      continue
print('APRROVED')     
    

### FIXED CODE ###

N = int(input())
Af = list(map(int,input().split()))
A = list()
for i in range(N):
  if Af[i] % 2 == 0:
      A.append(Af[i])
      continue
  else:
      continue
for i in range(len(A)):
  if A[i] % 3 != 0 and A[i] % 5 != 0:
      print('DENIED')
      import sys
      sys.exit()
  if A[i] % 3 == 0 or A[i] % 5 == 0:
      continue 
print('APPROVED')
# coding: utf-8
# Your code here!
n=input().rstrip().split(" ")
for i in range(4):
    n[i]=int(n[i])
S=n[0]*n[1]
senter=[n[0]/2,n[1]/2]#1
dis=[n[2],n[3]]#2
a=senter[1]-dis[1]
b=dis[0]-senter[0]
if(senter[1]=dis[1] and senter[0]=dis[0]):
    print(str(S/2) 1)
else:
    print(4 0)

### FIXED CODE ###

# coding: utf-8
# Your code here!
n=input().rstrip().split(" ")
for i in range(4):
    n[i]=int(n[i])
S=n[0]*n[1]
senter=[n[0]/2,n[1]/2]#1
dis=[n[2],n[3]]#2
a=senter[1]-dis[1]
b=dis[0]-senter[0]
if(senter[1]==dis[1] and senter[0]==dis[0]):
    print(str(S/2) +" "+str(1))
else:
    print(str(S/2) +  " "+ str(0))
N=int(input())
X=list(map(int, input().split()))
Y=list(map(int, input().split()))
Z=X-Y
Z=Z[Z>0]
print(sum(Z))

### FIXED CODE ###

import numpy as np
N=int(input())
X=list(map(int, input().split()))
Y=list(map(int, input().split()))
Z=np.zeros(N)
for i in range(N):
  Z[i]=X[i]-Y[i]
print('{:.0f}'.format(sum(Z[np.where(Z>0)])))
import sys
import numpy as np


def solve(sequence):

    sequence.sort()

    max_v = sequence[-1]

    dp = [True] * (max_v + 1)

    previous = -1
    for v in sequence:
        if v == previous:
            dp[v] = False
            continue

        previous = v

        if not dp[v]:
            continue

        for iv in range(2 * v, max_v+1, v):
            dp[iv] = False

    count = 0
    for v in sequence:
        if dp[v]:
            count += 1

    return count


if sys.argv[-1] == 'ONLINE_JUDGE':
    from numba.pycc import CC
    cc = CC('my_module')
    cc.export('main', '(i8[::1])')(solve)
    cc.compile()
    exit()


from my_module import solve


def main():
    _ = input()
    sequence = np.array(input().split(), np.int64)
    print(solve(sequence))


if __name__ == "__main__":
    main()


### FIXED CODE ###

# import sys
# readline = sys.stdin.readline
# generator = (readline().strip() for _ in range(N))

# import numpy as np
# from itertools import permutations
# from itertools import combinations
# from itertools import combinations_with_replacement

# import heapq
# from collections import deque

# N, M = map(int, input().split())
# sequence = list(map(int, input().split()))
# queries = (input() for _ in range(N))


def solve():
    N = int(input())
    sequence = list(map(int, input().split()))

    sequence.sort()

    max_v = sequence[-1]

    dp = [True] * (max_v + 1)

    previous = -1
    for v in sequence:
        if v == previous:
            dp[v] = False
            continue

        previous = v

        if not dp[v]:
            continue

        for iv in range(2 * v, max_v+1, v):
            dp[iv] = False

    count = 0
    for v in sequence:
        if dp[v]:
            count += 1

    return count


def main():
    print(solve())


if __name__ == "__main__":
    main()
A,B=map(int,input().split())
import math
def lcm(x, y):
    return (x * y) // math.gcd(x, y)

print(lcm(A, B))

### FIXED CODE ###

A,B=map(int,input().split())
import fractions
def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)
 
print(lcm(A, B))
n,k=map(int, input().split())
x,neg,pos=[],[],[]
for i in input().split():
	i = int(i)
	x.append(i)
	if i < 0:
		neg.append(i)
	else:
		pos.append(i)
neg.reverse()

ans=[]

if len(neg) >= k:
	ans.append(-neg[k-1])
if len(pos) >= k:
	ans.append(pos[k-1])

for i in range(1, k):
	j = k - i
	if i >= len(neg) or j >= len(pos):
		continue
	ans.append(pos[j-1] - neg[i-1] + min(pos[j-1], -neg[i-1]))

print(min(ans))


### FIXED CODE ###

n,k=map(int, input().split())
x,neg,pos=[],[],[]
for i in input().split():
	i = int(i)
	x.append(i)
	if i < 0:
		neg.append(i)
	else:
		pos.append(i)
neg.reverse()

ans=[]

if len(neg) >= k:
	ans.append(-neg[k-1])
if len(pos) >= k:
	ans.append(pos[k-1])

for i in range(1, k):
	j = k - i
	if i > len(neg) or j > len(pos):
		continue
	ans.append(pos[j-1] - neg[i-1] + min(pos[j-1], -neg[i-1]))

print(min(ans))
N = int(input())
array = list(map(int, input().split()))
if array[0] == 1:
    print(0)
    exit()
array.sort()
index = array.index(2)
count = 1
count_old = array.count(1)
ans = 1
first = array[index]
for i in range(index,N-1):
    if first != array[i+1]:
        ans *= count_old ** count
        count_old = count
        count = 1
    else:
        count += 1
    first = array[i+1]
    ans %= 998244353
ans *= count_old ** count
ans %= 998244353
print(ans)

### FIXED CODE ###

N = int(input())
array = list(map(int, input().split()))
if array[0] != 0:
    print(0)
    exit()
array.sort()
if 1 in array and len(set(array[1:])) == 1:
    print(1)
    exit()
if not (2 in array):
    print(0)
    exit()
if 0 in array[1:]:
    print(0)
    exit()
index = array.index(2)
count = 1
count_old = array.count(1)
ans = 1
first = array[index]
for i in range(index,N-1):
    if first != array[i+1]:
        if first != array[i+1] - 1:
            print(0)
            exit()
        ans *= count_old ** count
        count_old = count
        count = 1
    else:
        count += 1
    first = array[i+1]
    ans %= 998244353
ans *= count_old ** count
ans %= 998244353
print(ans)
n, m = map(int, input().split())
a = input().split() 

a = sum(int(i) for i in a)

asobi = n -a
if asobi => 0:
  print(asobi)
else:
  print(-1)

### FIXED CODE ###

n, m = map(int, input().split())
a = input().split() 

a = sum(int(i) for i in a)

asobi = n -a
if asobi >= 0:
  print(asobi)
else:
  print(-1)
s = input()
o = ""
c = 'keyence'
j = 0
l = []
for i in range(len(s)):
    if(s[i] == c[j]):
        j += 1
        l.append(i)
c = 0
l.append(len(s))
for i in range(len(l) - 1):
    if(l[i+1]-l[i] > 1):c += 1
if(c > 1 or len(l) != 8):print('NO')
else:print('YES')

### FIXED CODE ###

s = input()
t = 'keyence'
if(s[:7] == t or s[-7:] == t):
    print('YES')
else:
    for i in range(7):
        if(s[:i+1] == t[:i+1] and s[-7+i+1:] == t[-7+i+1:]):
            print('YES')
            exit()
    print('NO')
import itertools
N,L,*s = open(0).read().split()
x = list(map(lambda x:"".join(x), itertools.permutations(s, int(N))))
min_str = x[0]
for s in x[1:]:
  if s < min_str:
    min_str = s
print(min_str)

### FIXED CODE ###

N,L,*s = open(0).read().split()
print("".join(sorted(s)))
r = int(input())
int(a) = 3*r*r
print(a)


### FIXED CODE ###

r = int(input())**2*3
print(r)
n,a,b,c=map(int,input().split())
ans=[]
for i in range(n):
    s=input()
    if s=="AB":
        if a>b:
            a-=1
            b+=1
            ans.append("A")
        else:
            a+=1
            b-=1
            ans.append("B")
    elif s=="AC":
        if a>c:
            a-=1
            c+=1
            ans.append("A")
        else:
            a+=1
            c-=1
            ans.append("C")
    else:
        if b>c:
            b-=1
            c+=1
            ans.append("B")
        else:
            b+=1
            c-=1
            ans.append("C")
    if a<0 or b<0 or c<0:
        ans.clear()
if len(ans)==0:
    print("No")
else:
    print("Yes")
    for i in range(n):
        print(ans[i])


### FIXED CODE ###

n,a,b,c=map(int,input().split())
ans=[]
slist=[]
for i in range(n):
    s=input()
    slist.append(s)
for i in range(n):
    s=slist[i]
    if s=="AB":
        if a==0:
            a+=1
            b-=1
            ans.append("A")
        elif b==0:
            a-=1
            b+=1
            ans.append("B")
        elif slist[(i+1)%n]=="AB":
            if a>b:
                a-=1
                b+=1
                ans.append("B")
            else:
                a+=1
                b-=1
                ans.append("A")
        elif slist[(i+1)%n]=="AC":
            a+=1
            b-=1
            ans.append("A")
        else:
            a-=1
            b+=1
            ans.append("B")
    elif s=="AC":
        if a==0:
            a+=1
            c-=1
            ans.append("A")
        elif c==0:
            a-=1
            c+=1
            ans.append("C")
        elif slist[(i+1)%n]=="AC":
            if a>c:
                a-=1
                c+=1
                ans.append("C")
            else:
                a+=1
                c-=1
                ans.append("A")
        elif slist[(i+1)%n]=="AB":
            a+=1
            c-=1
            ans.append("A")
        else:
            a-=1
            c+=1
            ans.append("C")
    else:
        if b==0:
            b+=1
            c-=1
            ans.append("B")
        elif c==0:
            b-=1
            c+=1
            ans.append("C")
        elif slist[(i+1)%n]=="BC":
            if b>c:
                b-=1
                c+=1
                ans.append("C")
            else:
                b+=1
                c-=1
                ans.append("B")
        elif slist[(i+1)%n]=="AC":
            c+=1
            b-=1
            ans.append("C")
        else:
            c-=1
            b+=1
            ans.append("B")
    if a<0 or b<0 or c<0:
        ans.clear()
        break
if len(ans)==0:
    print("No")
else:
    print("Yes")
    for i in range(n):
        print(ans[i])
password = input().split()
pw = set(password)
if len(password) != len(pw):
  print("Bad")
  break
print("Good")


### FIXED CODE ###

password = list(input())
if password[0] == password[1] or password[1] == password[2] or password[2] == password[3]:
  print("Bad")
else:
  print("Good")
a = input()
return a + a ** a + a ** a ** a

### FIXED CODE ###

a = int(input())
b = a + a ** 2 + a ** 3
print(b)
s = input().strip()

flag = 0
ok_list = ['A', 'T', 'C', 'G']

max_len = 0
start, end, i = 0, 0, 0

while i < len(s):
    if s[i] in ok_list:
        l = 0
        while s[i] in ok_list:
            i += 1
            l += 1

        if l > max_len:
            max_len = l

    else:
         i += 1

print(max_len)

### FIXED CODE ###

s = input().strip()

ok_list = ['A', 'T', 'C', 'G']

max_len, i = 0, 0

while i < len(s):
    if s[i] in ok_list:
        l = 0
        while i < len(s) and s[i] in ok_list:
            i += 1
            l += 1

        if l > max_len:
            max_len = l

    else:
         i += 1

print(max_len)
int()=A,B,T
print((T//A)*B)


### FIXED CODE ###

a,b,t=map(int, input().split())

print(t//a*b)
a,b,c=map(int,input().split())
if a==b and b==c and a%2=0:
    print(-1)
else:
    ans=0
    while a%2==0 ans b%2==0 and c%2==0:
        tmp=a
        tmp2=b
        a=(b+c)//2
        b=(c+tmp)//2
        c=(tmp+tmp2)//2
        ans+=1
    print(ans)

### FIXED CODE ###

a,b,c=map(int,input().split())
if a==b and b==c and a%2==0:
    print(-1)
else:
    ans=0
    while a%2==0 and b%2==0 and c%2==0:
        tmp=a
        tmp2=b
        a=(b+c)//2
        b=(c+tmp)//2
        c=(tmp+tmp2)//2
        ans+=1
    print(ans)
import sympy
sympy.divisors(10**9)

num = 24

def make_divisors(n):
    lower_divisors , upper_divisors = [], []
    i = 1
    while i*i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)
        i += 1
    return lower_divisors + upper_divisors[::-1]

l = make_divisors(num)
cnt = 0

for z in l[1:]:
    if num == 1:
        break
    elif num % z == 0:
        num /= z
        cnt += 1

print(cnt)

### FIXED CODE ###

n = int(input())

def factorize(n):
    fct = []  # prime factor
    b, e = 2, 0  # base, exponent
    while b * b <= n:
        while n % b == 0:
            n = n // b
            e = e + 1
        if e > 0:
            fct.append((b, e))
        b, e = b + 1, 0
    if n > 1:
        fct.append((n, 1))
    return fct

f = factorize(n)
ans = 0
for i,j in f:
    ans += int((-1+pow(1+8*j,0.5))/2)
print(ans)
n, k = map(int, input().split())

ans="NO"
if n%2==0:
    if k<=n//2:
        ans="YES"
else:
    if K<=(n+1)//2:
        ans="YES"
print(ans)

### FIXED CODE ###

n, k = map(int, input().split())
ans = "NO"
if (n+1)//2 >= k:
    ans = "YES"
print(ans)
ERGTHJKJKJREbv ffffffs bboiuyazxcvbnm,.,mnbvcvbnjmk,l.kjhgfxzxcbnbvcxzxcvbgvcx

### FIXED CODE ###

suma = sum(list(map(int, input().split())))
if suma >= 22:
  print("bust")
else:
  print("win")
def main():
  n, m = map(int, input().split())
  l = list(map(int, input(.split())))
  ans = n - sum(l)
  if ans < 0:
      ans = -1
  print(ans)

if __name__ == '__main__':
  main()

### FIXED CODE ###

def main():
  n, m = map(int, input().split())
  l = list(map(int, input().split()))
  ans = n - sum(l)
  if ans < 0:
      ans = -1
  print(ans)

if __name__ == '__main__':
  main()
A, B = map(int, input())
if A * B % 2 == 0:
  print('No')
  exit()
print('Yes')

### FIXED CODE ###

A, B = map(int, input().split())
if A * B % 2 == 0:
  print('No')
  exit()
print('Yes')
N, C, K = map(int, input().split())
T = list(int(input()) for i in range(N))
T.sort()
bus = 1
passenger = 0
limit = T[0] + K
for i in range(N):
    if T[i] <= limit and passenger < c:
        passenger += 1
    else:
        bus += 1
        limit = T[i]+K
        passenger = 1
print(bus)

### FIXED CODE ###

N, C, K = map(int, input().split())
T = list(int(input()) for i in range(N))
T.sort()
bus = 1
passenger = 0
limit = T[0] + K
for i in range(N):
    if T[i] <= limit and passenger < C:
        passenger += 1
    else:
        bus += 1
        limit = T[i]+K
        passenger = 1
print(bus)
def croad():
    n,k = map(int,input().split())
    x = list(map(int,input().split()))
    y = []
    for i in range(n-1):
        y.append(x[i+1]-x[i])
    y.sort()
    y.reverse()
    while k>1:
        y.pop(0)
        k -= 1
    print(sum(y))

a = int(input())
for i in range(a):
    croad()


### FIXED CODE ###

def croad():
    n,k = map(int,input().split())
    x = list(map(int,input().split()))
    y = []
    for i in range(n-1):
        y.append(x[i+1]-x[i])
    y.sort()
    y.reverse()
    while k>1 and len(y)>0:
        y.pop(0)
        k -= 1
    print(sum(y))

a = int(input())
for i in range(a):
    croad()
N == input()
if N % 2 == 0:
  print(N/2)
else:
  print((N+1)/2)

### FIXED CODE ###

N = int(input())
if N % 2 == 0:
  print(int(N/2))
else:
  print(int((N+1)/2))
from collections import Counter
n=int(input())
s=input().split()
k=collections.Counter(s).c.most_common()
l=[]
for i in k:
    if  i[1]==i[0][1]:
      l.append(i[0])
l.sort()
for i in l:
    print(i)

### FIXED CODE ###

import collections

N=int(input())
S=[]
for i in range(N):
	S.append(input())
M=collections.Counter(S)
A=max(M.values())
tmp=[]
for i,j in M.items():
	if j==A:
		tmp.append(i)
ans=sorted(tmp)
for i in range(len(ans)):
	print(ans[i])
S = input()

flag = False
if S[0] != 'A':
    print('WA')
    quit()
elif S.count('C') != 1:
    print('WA')
    quit()
elif S[2] == 'C' or S[-2] == 'C':
    c_index = S.index('C')
    if c_index == 2:
        disc = S[1] + S[3:]
    elif c_index == len(S) - 2:
        disc = S[1:len(S) - 2] + S[-1]
alpha = 'abcdefghijklmnopqrstuvwxyz'
for i in range(len(disc)):
    if not disc[i] in alpha:
        print('WA')
        quit()
    else:
        continue
print('AC')
#print(disc)

### FIXED CODE ###

S = input()

C_S = S[2 : len(S) - 1]

#flag = True
if S[0] != 'A':
    #flag = False
    print('WA')
    quit()
    #break
if not 'C' in C_S and C_S.count('C') != 1:
    #flag = False
    #break
    print('WA')
    quit()
c_index = S.index('C')
alpha = 'abcdefghijklmnopqrstuvwxyz'
for i in range(len(S)):
    if i == 0 or i == c_index:
        continue
    elif S[i] not in alpha:
        #flag = False
        #break
        print('WA')
        quit()
    else:
        continue
print('AC')
# -*- coding: utf-8 -*-
num = [0,2,5,5,4,5,6,3,7,6]
#      0,1,2,3,4,5,6,7,8,9
n,m = map(int, input().split())
al = list(map(int, input().split()))

INF = 10**18
dp = [-INF for _ in range(n+1)]
dp[0] = 0

for i in range(1,n+1):
    for a in al:
        if i-num[a]>=0:
            dp[i] = max(dp[i], dp[i-num[a]]+1)

res = []
al.sort(reverse=True)

while n>0:
    for a in al:
        if dp[n-num[a]]==dp[n]-1:
            res.append(str(a))
            n -= num[a]
            break

print("".join(res))


### FIXED CODE ###

# -*- coding: utf-8 -*-
num = [0,2,5,5,4,5,6,3,7,6]
#      0,1,2,3,4,5,6,7,8,9

def f(n,al):
    INF = 10**18
    dp = [-INF for _ in range(n+1)]
    dp[0] = 0

    for i in range(1,n+1):
        for a in al:
            if i-num[a]>=0:
                dp[i] = max(dp[i], dp[i-num[a]]+1)

    res = []
    al.sort(reverse=True)

    while n>0:
        for a in al:
            if n-num[a]>=0 and dp[n-num[a]]==dp[n]-1:
                res.append(str(a))
                n -= num[a]
                break

    return "".join(res)

if __name__ == '__main__':
    n,m = map(int, input().split())
    al = list(map(int, input().split()))
    print(f(n,al))

    # from random import shuffle
    # for _ in range(1000):
    #     n = 10000
    #     m = 5
    #     al = list(range(1,10))
    #     shuffle(al)
    #     al = al[:m]
    #     f(n,al)