Harryxun/stf_run huggingface dataset:
x,n = map(int,input().split())
a = []
if n != 0 : a = list(map(int,input().split()))
tmp = 114514
ret = -114514
for i in range(-10,110):
  if not i in a and abs(x-i) < tmp
  ret = i
  tmp = abs(x-i)
print(ret)

### FIXED CODE ###

x,n = map(int,input().split())
a = []
if n != 0 : a = list(map(int,input().split()))
tmp = 114514
ret = -114514
for i in range(-10,110):
  if not i in a and abs(x-i) < tmp:
    ret = i
    tmp = abs(x-i)
print(ret)
def main():
  s = input()
  t = input()
  a = len(s)

  if len(s) > 10 or len(s) < 1:
    print('no')
  else:
    if t[0:a] != s:
      print('no')
    else:
      if len(t) == len(s) + 1:
        print('yes')

main()

### FIXED CODE ###

a,b,c,k = map(int,input().split())

if a >= k:
  print(k)
else:
  if a + b >= k:
    print(a)
  else:
    print(2 * a + b - k)
n = int(input())

for i in range(1, 10):
  for j in range(1, 10):
    if i * j ==n n:
      print('Yes')
      exit()
print('No')

### FIXED CODE ###

import sys
n = int(input())

for i in range(1, 10):
  for j in range(1, 10):
    if i * j == n:
      print('Yes')
      sys.exit()
print('No')
n = list(map(int,input().split()))
print((n[0]*n[1]+1)//2)

### FIXED CODE ###

a = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
n = int(input())
print(a[n-1])
n, k, x, y = int(input().split()) for _ in range(4)
print(k * x + (n - k) * y)

### FIXED CODE ###

n,k,x,y=(int(input()) for i in range(4))
if n - k > 0:
  ans = k * x + (n - k) * y
else:
  ans = n * x
print(ans)
a, b = map(int(input().split())
print(b // a + (((b % a) // a) + 1))

### FIXED CODE ###

from math import ceil
a, b = map(int, input().split())
print(ceil((b - 1) / (a - 1)))
x=input()
i=1
while x!=0:
    print("Case {}:{}".format(i,x))
    x=input()
    i+=1

### FIXED CODE ###

x=int(input())
i=1
while x!=0:
    print("Case %d: %s" %(i,x))
    x=int(input())
    i+=1
N = int(input())

l = list(range(1,N+1)) ## 1~Nのリスト
I = list(range(1,N+1))

a = l.pop(0)
l.append(a)

print(sum([x % y for (x,y) in zip(I, l)]))




### FIXED CODE ###

N  =int(input())
print(N*(N-1)//2)
x=list(input())
y=list(input())+''
for a, b in zip(x, y):
  print(a+b, end='')

### FIXED CODE ###

x=list(input())
y=list(input())+['']
for a, b in zip(x, y):
  print(a+b, end='')
import bisect
n =int(input())
l =list(map(int, input().split()))
l.sort()
total = 0
for i in range(n-2):
  for j in range(i+1, n-1):
    tmp = bisect.bisect_left(l,l[i]+L[j])
    total += tmp - j - 1
print(total)

### FIXED CODE ###

import bisect
n =int(input())
l =list(map(int, input().split()))
l.sort()
total = 0
for i in range(n-2):
  for j in range(i+1, n-1):
    tmp = bisect.bisect_left(l,l[i]+l[j])
    total += tmp - j - 1
print(total)
N,M=map(int,input().split())
N=[[0,0]]*(N+1)
if M==0:
  print(0,0)
else:
  penalty=0
  win=0
  for j in range(M):
    L=list(map(str,input().split()))
    m=int(L[0])
    if L[1]=="WA":
      if N[m]!=1:
        penalty+=1
      else:
        continue
    else:
      if N[m]!=1:
        N[m]=1
        win+=1
      else:
        continue
print(win,penalty)
    
  

### FIXED CODE ###

n,m=map(int,input().split())
ps=[list(input().split()) for i in range(m)]
pen=[0]*n
rig=[0]*n

for i in range(m):
  if ps[i][1] == "AC":
    rig[int(ps[i][0])-1]=1
  else:
    if rig[int(ps[i][0])-1] == 0:
      pen[int(ps[i][0])-1]+=1

cnt1,cnt2=0,0
for i in range(n):
  if rig[i]==1:
    cnt1+=rig[i]
    cnt2+=pen[i]
    
print(str(cnt1)+" "+str(cnt2))
import heapq

X,Y,Z,K = map(int, input().split())
A = map(int, input().split())
B = map(int, input().split())
C = map(int, input().split())

A.sort(reverse = True)
B.sort(reverse = True)
C.sort(reverse = True)

h = []

heapq.heappush(h, (A[0]+B[0]+C[0], 0,0,0))

result = []

for _ in range(K):
	value, i,j,k = heapq.heappop(h)
    result.append(value)
    if i < X-1:
    	heapq.heappush(h, (A[i+1]+B[j]+C[k],i,j,k))
    if j < Y-1 and i == 0:
      	heapq.heappush(h, (A[i]+B[j+1]+C[k],i,j+1,k))
    if k < Z-1 and i == 0 and j == 0:
      	heapq.heappush(h, (A[i]+B[j]+C[k+1],i,j,k+1))
        
for v in result:
	print(v)

### FIXED CODE ###

import heapq

X,Y,Z,K = map(int, input().split())
A = [int(x) for x in  input().split()]
B = [int(x) for x in  input().split()]
C = [int(x) for x in  input().split()]

A.sort(reverse = True)
B.sort(reverse = True)
C.sort(reverse = True)

h = []

heapq.heappush(h, (-A[0]-B[0]-C[0], 0,0,0))

result = []
used = set()

for _ in range(K):
    value, i,j,k = heapq.heappop(h)
    result.append(-value)
    if i < X-1 and (i+1,j,k) not in used:
        heapq.heappush(h, (-A[i+1]-B[j]-C[k],i+1,j,k))
        used.add((i+1,j,k))
    if j < Y-1 and (i,j+1,k) not in used:
        heapq.heappush(h, (-A[i]-B[j+1]-C[k],i,j+1,k))
        used.add((i,j+1,k))
    if k < Z-1 and (i,j,k+1) not in used:
        heapq.heappush(h, (-A[i]-B[j]-C[k+1],i,j,k+1))
        used.add((i,j,k+1))
        
for v in result:
    print(v)
import collections
import math

n = int(input())
m = 0
mod = 10 ** 6 + 7
c = []
d = []
frac = {}
tmp = 0
for _ in range(n):
    a, b = map(int, input().split())
    if a == 0 and b == 0:
        tmp += 1
        m += 1
        continue
    try:
        if a == 0:
            frac['0'] += 1
        elif b == 0:
            frac['inf'] += 1
        else:
            gcd = abs(math.gcd(a, b))
            sign = a * b // abs(a * b)
            a = sign * abs(a) // gcd
            b = abs(b) // gcd
            frac['{}/{}'.format(a, b)] += 1
    except KeyError:
        if a == 0:
            frac['0'] = 1
        elif b == 0:
            frac['inf'] = 1
        else:
            gcd = abs(math.gcd(a, b))
            sign = a * b // abs(a * b)
            a = sign * abs(a) // gcd
            b = abs(b) // gcd
            frac['{}/{}'.format(a, b)] = 1

n -= tmp

def inverse(key):
    if key[0] != '-':
        a, b = key.split('/')
        return '-{}/{}'.format(b, a)
    else:
        a, b = key[1:].split('/')
        return '{}/{}'.format(b, a)

for key, value in frac.items():
    if key == '0': continue
    if key != 'inf' and key[0] == '-': continue
    try:
        if key == float('inf'):
            d.append(frac['inf'])
        else:
            d.append(frac[inverse(key)])
        c.append(value)
    except KeyError:
        continue

ans = pow(2, n - sum(c) - sum(d), mod)
for i, j in zip(c, d):
    tmp = (pow(2, i, mod) + pow(2, j, mod) - 1)
    ans = (ans * (pow(2, i, mod) + pow(2, j, mod) - 1)) % mod
ans = ans * (m + 1) - 1

print(ans)

### FIXED CODE ###

import collections
import math

n = int(input())
m = 0
mod = 10 ** 9 + 7
c = []
d = []
frac = []

for _ in range(n):
    a, b = map(int, input().split())
    if a == 0 and b == 0:
        n -= 1
        m += 1
        continue
    if a == 0:
        frac.append('0/1')
    elif b == 0:
        frac.append(('1/0'))
    else:
        gcd = abs(math.gcd(a, b))
        sign = 1 if a * b > 0 else -1
        a = sign * abs(a) // gcd
        b = abs(b) // gcd
        frac.append('{}/{}'.format(a, b))

frac = collections.Counter(frac)

def inverse(key):
    if key == '0/1':
        return '1/0'
    elif key == '1/0':
        return '0/1'
    elif key[0] != '-':
        a, b = key.split('/')
        return '-{}/{}'.format(b, a)
    else:
        a, b = key[1:].split('/')
        return '{}/{}'.format(b, a)

for key, value in frac.items():
    if key[0] == '-' or key[0] == '0': continue
    if frac[inverse(key)] > 0:
        c.append(value)
        d.append(frac[inverse(key)])

ans = pow(2, n - sum(c) - sum(d), mod)
for i, j in zip(c, d):
    tmp = (pow(2, i, mod) + pow(2, j, mod) - 1) % mod
    ans = ans * tmp % mod
ans = (ans - 1 + m) % mod

print(ans)
N, W = [int(i) for i in input().split()]
weight, value = [0]*110000, [0]*110000

for i in range(N):
    w, v = [int(i) for i in input().split()]
    weight[i] = w; value[i] = v;

dp = [[0 for _ in range(110)] for _ in range(100100)]

for i in range(N):
    for j in range(W+1):
        if (j-weight[i] >= 0):
            dp[i+1][j] = max(dp[i+1][j], dp[i][j-weight[i]] + value[i])
        dp[i+1][j] = max(dp[i+1][j], dp[i][j])

print(dp[N][W])

### FIXED CODE ###

N, W = [int(i) for i in input().split()]
weight, value = [], []

for i in range(N):
    w, v = [int(i) for i in input().split()]
    weight.append(w); value.append(v);
weight.append(0)
value.append(0)

dp = [[0 for _ in range(W+1)] for _ in range(N+1)]

for i in range(N):
    for j in range(W+1):
        if (j-weight[i] >= 0):
            dp[i+1][j] = max(dp[i+1][j], dp[i][j-weight[i]] + value[i])
        dp[i+1][j] = max(dp[i+1][j], dp[i][j])

print(dp[N][W])
n = int(input())
a = list(map(int, input().split()))


count = 0
i=0
while(i <= len(a)):
    if a[i] % 2 == 0:
        count += 1
        a[i] = int(a[i] // 2)
        continue
    else:
        i += 1

print(count)

### FIXED CODE ###

N = int(input())
a_li = list(map(int,input().split()))
         
cnt = 0
for i in a_li:
    while i % 2 == 0:
        cnt += 1
        i //= 2
        if i % 2 != 0:
            break
        
print(cnt)
sen = [A,B,C]
print(sen)
sen.sort()
print(sen)
if sen == [5,5,7]:
	print("YES")
else:
	print("NO")

### FIXED CODE ###

# -*- coding: utf-8 -*-

A, B, C = map(int, (input().split()))

sen = [A, B, C]
x = max(sen)
y = min(sen)
if x == 7 and y == 5 and sum(sen) - x - y == 5:
    print("YES")
else:
    print("NO")
N = int(input())
a = list(map(int, input().split()))
if N%2==0:
  print(a[N/2]-a[N/2-1])
else:
  print(0)

### FIXED CODE ###

N = int(input())
a = list(map(int, input().split()))
a.sort()
if N%2==0:
  print(a[int(N/2)]-a[int(N/2-1)])
else:
  print(0)
import collections
n = int(input())
v = list(map(int,input().split()))
v_odd = []
v_even = []
for i,v in enumerate(v):
    if i % 2:
        v_even.append(v)
    else:
        v_odd.append(v)
odd_n = len(v_odd)
even_n = len(v_even)
v_odd = collections.Counter(v_odd)
v_odd = sorted(v_odd.items(), key=lambda x:x[1],reverse=True)
v_even = collections.Counter(v_even)
v_even = sorted(v_even.items(), key=lambda x:x[1],reverse=True)

if v_odd[0] == v_even[0]:
    if v_odd[1][1] < v_even[1][1]:
        v_even.pop(0)
    elif v_odd[1][1] > v_even[1][1]:
        v_odd.pop(0)

num = v_odd[0][0]

ans = odd_n-v_odd[0][1]
st = 0
for i,v in v_even:
    if num == i:
        continue
    else:
        st = v
        break
print(ans+(even_n-st))

### FIXED CODE ###

import collections
n = int(input())
v = list(map(int,input().split()))
v_odd = []
v_even = []
for i,v in enumerate(v):
    if i % 2:
        v_even.append(v)
    else:
        v_odd.append(v)
odd_n = len(v_odd)
even_n = len(v_even)
v_odd = collections.Counter(v_odd)
v_odd = sorted(v_odd.items(), key=lambda x:x[1],reverse=True)
v_even = collections.Counter(v_even)
v_even = sorted(v_even.items(), key=lambda x:x[1],reverse=True)

if v_odd[0] == v_even[0] and 2 <= len(v_odd) and 2 <= len(v_even):
    if v_odd[1][1] < v_even[1][1]:
        v_even.pop(0)
    elif v_odd[1][1] > v_even[1][1]:
        v_odd.pop(0)

num = v_odd[0][0]

ans = odd_n-v_odd[0][1]
st = 0
for i,v in v_even:
    if num == i:
        continue
    else:
        st = v
        break
print(ans+(even_n-st))
r = int(input())
a = r*r*3.1415926535897932
b = r*2*3.1415926535897932
print('%s %s'%(a,b))

### FIXED CODE ###

r = float(input())
import math
a = r*r*math.pi
b = r*2*math.pi
print('%s %s'%(a,b))
s = input()
n = int(input())

for i in range(len(s)):
    if s[i] != "1":
        print(s[i])
        break
        
    else:
        k -= 1
        if k == 0:
            print(1)
            break


### FIXED CODE ###

s = input()
k = int(input())

for i in range(len(s)):
    if s[i] != "1":
        print(s[i])
        break
        
    else:
        k -= 1
        if k == 0:
            print(1)
            break
N = int(input()) 
s = list(map(int, input().split()))
A = 0
for i in range (N - 1):
  if s[i] == i:
    continue
  else:
    A+=1
if A <= 2 or:
  print('YES')
else:
  print('NO')

### FIXED CODE ###

N = int(input()) 
s = list(map(int, input().split()))
A = 0
for i in range (N):
  if s[i] != i+1:
    A+=1
if A <= 2 :
  print('YES')
else:
  print('NO')
N,K=list(map(int,input().split()))
S=input()
if S[K-1]=='A':
    S[K-1]='a'
if S[K-1]=='B':
    S[K-1]='b'
if S[K-1]=='C':
    S[K-1]='c'
print(S)

### FIXED CODE ###

N,K=list(map(int,input().split()))
S=list(input())
if S[K-1]=='A':
    S[K-1]="a"
if S[K-1]=='B':
    S[K-1]='b'
if S[K-1]=='C':
    S[K-1]='c'
print(''.join(S))
n = int(input())
A = list(map(int, input().split()))

pre = [0]*(n+1)
pre_list = [e for e in A[:n]]
heapq.heapify(pre_list)
pre_sum = sum(pre_list)
pre[0] = pre_sum
for i in range(n, 2*n):
    small = heapq.heappushpop(pre_list, A[i])
    pre_sum += A[i] - small
    pre[i-n+1] = pre_sum

suf = [0]*(n+1)
suf_list = [-e for e in A[2*n:]]
heapq.heapify(suf_list)
suf_sum = -sum(suf_list)
suf[-1] = suf_sum
for i in range(2*n-1, n-1, -1):
    large = -heapq.heappushpop(suf_list, A[i])
    suf_sum += A[i] - large
    suf[i-n] = suf_sum

# print(pre)
# print(suf)

print(max([pre[i] - suf[i] for i in range(n+1)]))


### FIXED CODE ###

import heapq

n = int(input())
A = list(map(int, input().split()))

pre = [0]*(n+1)
pre_list = [e for e in A[:n]]
heapq.heapify(pre_list)
pre_sum = sum(pre_list)
pre[0] = pre_sum
for i in range(n, 2*n):
    small = heapq.heappushpop(pre_list, A[i])
    pre_sum += A[i] - small
    pre[i-n+1] = pre_sum

suf = [0]*(n+1)
suf_list = [-e for e in A[2*n:]]
heapq.heapify(suf_list)
suf_sum = -sum(suf_list)
suf[-1] = suf_sum
for i in range(2*n-1, n-1, -1):
    large = -heapq.heappushpop(suf_list, -A[i])
    suf_sum += A[i] - large
    suf[i-n] = suf_sum

# print(pre)
# print(suf)

print(max([pre[i] - suf[i] for i in range(n+1)]))
from fractions import gcd

n = int(input())
e = [int(i) for i in input().split()] 


answer = 5000000000000000000000000000000000

e.sort(reverse=True)
for i in range(0,n-2):
    for j in e[i+1:n-1]:
        if gcd(e[i],j) < answer:
            answer = gcd(e[i],j)
            
print(answer)

### FIXED CODE ###

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

if b % a == 0:
    print(a + b)
else :
    print(b - a)
A,V=map(int,input().split())
B,W=map(int,input().split())
T=int(input())

eva=False

pl=abs(B-A)
ve=V-W

if pl<=ve*T and 0<pl:
    if ve>0:
        eva=True
if eva:
    print("YES")
else:
    print("NO")

### FIXED CODE ###

S=str(input())

print(S[:3])
import math
import collections
import copy
import sys

n = int(input())

a = list(map(int,input().split()))

sCheck = math.gcd(a[0],a[1])
if n == 2:
    if sCheck == 1:
        print("pairwise coprime")
    else:
        print("not coprime")
    sys.exit()
else:
    for i in range(2,n):
        sCheck = math.gcd(sCheck,a[i])


beforeQ = collections.deque([i for i in range(2,10**6 + 1)])
D = dict()
p = 2
D[2] = 2
D[1] = 1

while p < math.sqrt(10**6):
    afterQ = collections.deque()
    while len(beforeQ) > 0:        
        k = beforeQ.popleft()
        if k % p != 0:
            afterQ.append(k)
        else:
            D[k] = p
    beforeQ = copy.copy(afterQ)
    p = beforeQ.popleft()
    D[p] = p
    
ansSet = set()
count = 0

for i in a:
    k = i
    kSet = set()
    while k != 1:
        if D[k] in ansSet:
            if not(D[k] in kSet):
                count = 1
                break
        else:
            ansSet.add(D[k])
            kSet.add(D[k])
        k = k // D[k]

if count == 0:
    print("pairwise coprime")
elif sCheck == 1:
    print("setwise coprime")
else:
    print("not coprime")

### FIXED CODE ###

import math
import collections
import copy
import sys

n = int(input())

a = list(map(int,input().split()))

limit = 10 ** 6

sCheck = math.gcd(a[0],a[1])
if n == 2:
    if sCheck == 1:
        print("pairwise coprime")
    else:
        print("not coprime")
    sys.exit()
else:
    for i in range(2,n):
        sCheck = math.gcd(sCheck,a[i])


beforeQ = collections.deque([int(i) for i in range(3,(limit + 1))])
D = dict()
p = 2
D[2] = 2
D[1] = 1

while p < math.sqrt(limit):
    afterQ = collections.deque()
    while len(beforeQ) > 0:        
        k = beforeQ.popleft()
        if k % p != 0:
            afterQ.append(k)
        else:
            D[k] = p
    beforeQ = copy.copy(afterQ)
    p = beforeQ.popleft()
    D[p] = p
while len(beforeQ) > 0:
    k = beforeQ.popleft()
    D[k] = k
    
ansSet = set()
count = 0

for i in a:
    k = i
    kSet = set()
    while k != 1:
        if D[k] in ansSet:
            if not(D[k] in kSet):
                count = 1
                break
        else:
            ansSet.add(D[k])
            kSet.add(D[k])
        k = int(k // D[k])
    if count == 1:
        break

if count == 0:
    print("pairwise coprime")
elif sCheck == 1:
    print("setwise coprime")
else:
    print("not coprime")
S = list(input())
if S[0] != "A":
  S.insert(0,"A")
if S[4] != "A":
  S.insert(4,"A")
if S[6] != "A":
  S.insert(6,"A")
if S[-1] != "A":
  S.append("A")
s = ""
for i in S:
  s += i
print("YES" if s == "AKIHABARA" else "NO")

### FIXED CODE ###

S = list(input())
if S[0] != "A":
  S.insert(0,"A")
if len(S) < 5:
  print("NO")
  exit()
if S[4] != "A":
  S.insert(4,"A")
if len(S) < 7:
  print("NO")
  exit()
if S[6] != "A":
  S.insert(6,"A")
if len(S) < 5:
  print("NO")
  exit()
if len(S) < 8:
  print("NO")
  exit()
if S[-1] != "A":
  S.append("A")
s = ""
for i in S:
  s += i
print("YES" if s == "AKIHABARA" else "NO")
r = input()
print(r**2*3)

### FIXED CODE ###

r =int(input())
print(3*r**2)
N,M = map(int,input().split())
Alist = list(map(int, input().strip().split()))
r = list(range(len(Alist)))
r[0] = Alist[0]
for i in range(1,len(Alist)-1):
    r[i] = r[i-1] + Alist[i]
for i in range(len(r)):
    r[i] = r[i]%M
p = [0] * M
for i in range(len(r)):
    p[r[i]] = p[r[i]] + 1
def kaijou(n):
    if n == 0:
        return 1
    else:
        v = n
        for i in range(1,n):
            v = v*i
        return v      
def combi(n):
    if n == 0:
        return 0
    if n == 1:
        return 0
    else:
        return kaijou(n)/((kaijou(n-2))*2)
s = 0
for i in range(len(p)):
    s = s + combi(p[i])
s = s + p[0]
print(int(s))

### FIXED CODE ###

N,M = map(int,input().split())
Alist = list(map(int, input().strip().split()))
r = [0]*N
r[0] = Alist[0]
for i in range(1,len(Alist)):
    r[i] = r[i-1] + Alist[i]
for i in range(len(r)):
    r[i] = r[i]%M
r.sort()
p = []
m = 0
for i in range(len(r)-1):
    m = m+1
    if r[i] != r[i+1]:
        p.append(m)
        m = 0
    if i == len(r)-2:
        p.append(m+1)
x = 0
for i  in range(len(r)):
    if r[i] == 0:
        x = x +1
def combi(n):
    if n == 0:
        return 0
    if n == 1:
        return 0
    else:
        return (n*(n-1))/2
s = 0
for i in range(len(p)):
    s = s + combi(p[i])
s = s + x
print(int(s))
def printing(a_start, a_2, n):
  a_3 = []
  mod_list = []
  
  for i in range(len(a_2)):
    if (a_2[i][1] % a_start[1] not in mod_list) and (a_2[i][1] % a_start[1] != 0):
      a_3.append(a_2[i])
      mod_list.append(a_2[i][1] % a_start[1])
  
  a_3.sort(key=lambda x: x[1], reverse=True)
  if len(a_3) >= 2:
    if a_start[0] + a_3[-1][0] < n and a_3[0][0] < a3[1][0] and a_3[1][0] > a_start[0]:
      a_3.pop(0)

  ans = ""
  while n % a_start[1] != 0:
    for i in range(len(a_3)):
      if n % a_start[1] >= a_3[i][1] % a_start[1]:
        n -= a_3[i][1]
        ans += str(a_3[i][0])
        break
      elif n % a_start[1] == 0:
        break
    else:
      n -= a_3[0][1]
      ans += str(a_3[0][0])
      
  ans = ans + str(a_start[0]) * (n // a_start[1])
  ans_list = sorted([ans[i] for i in range(len(ans))], reverse=True)
  print(''.join(ans_list))

  
def main():
  N, M = map(int, input().split())
  a = list(map(int, input().split()))
  a.sort(reverse=True)
  num = [0, 2, 5, 5, 4, 5, 6, 3, 7, 6]
  a_list = []
  a_2 = []
  
  for i in range(M):
    if num[a[i]] not in a_list:
      a_2.append([a[i], num[a[i]]])
      a_list.append(num[a[i]])

  a_2.sort(key=lambda x: x[1])
  a_start = a_2.pop(0)
  printing(a_start, a_2, N)
      

if __name__ == '__main__':
  main()

### FIXED CODE ###

def printing(a_start, a_2, n):

    a_3 = []
    mod_list = []
    for i in range(len(a_2)):
        if a_2[i][1] % a_start[1] not in mod_list and a_2[i][1] % a_start[1] != 0:
            a_3.append(a_2[i])
            mod_list.append(a_2[i][1] % a_start[1])
    a_3.sort(key=lambda x: x[1], reverse=True)


    if len(a_3) >= 2:
        if a_start[0] + a_3[-1][0] < n and a_3[0][0] < a_3[1][0] and a_3[1][0] > a_start[0]:
            a_3.pop(0)


    ans = ""
    while n % a_start[1] != 0:
        for i in range(len(a_3)):
            if n % a_start[1] >= a_3[i][1] % a_start[1]:
                n -= a_3[i][1]
                ans += str(a_3[i][0])
                break
            elif n % a_start[1] == 0:
                break
        else:
            n -= a_3[0][1]
            ans += str(a_3[0][0])

    ans = ans + str(a_start[0]) * (n // a_start[1])
    ans_list = sorted([ans[i] for i in range(len(ans))], reverse=True)
    print("".join(ans_list))

def main():
    n, m = [int(i) for i in input().split()]
    a = sorted([int(i) for i in input().split()], reverse=True)
    number = [0, 2, 5, 5, 4, 5, 6, 3, 7, 6]
    a_list = []
    a_2 = []

    for i in range(m):
        if number[a[i]] not in a_list:
            a_2.append([a[i], number[a[i]]])
            a_list.append(number[a[i]])
    a_2.sort(key=lambda x: x[1])
    a_start = a_2.pop(0)
    printing(a_start, a_2, n)

main()
import numpy as np
N,K = map(int, input().split())
p = 10 ** 9 + 7
A = list(map(int, input().split()))
A_np = np.array(A)
A_pos = A_np[A_np>=0]
A_neg = A_np[A_np<0]
judge = False
s = 1
if len(A_pos) > 0:
  if N > K:
    judge = True
  else:
    if len(A_neg) % 2 == 0:
      judge = True    
else:
  if (K % 2) == 0:
    judge = True
if judge == True:
  A_pos = np.sort(A_pos)[::-1]
  A_neg = np.sort(A_neg)
  if (K % 2) == 1:
    s = A_pos[0]
    A_pos = A_pos[1:]
    K = K - 1
  K = int(K / 2)
  stack = np.array([])
  for n in range(0,int(len(A_pos)/2)):
    stack = np.append(stack, (A_pos[2*n]*A_pos[2*n+1]) % p)
    if n == K:
      break
  for n in range(0,int(len(A_neg)/2)):
    stack = np.append(stack, (A_neg[2*n]*A_neg[2*n+1]) % p)
    if n == K:
      break
  stack = np.sort(stack)[::-1]
  for n in range(0,K):
    s = (s * stack[n]) % p
else:
  Index = np.sort(abs(A_np))
  A_sort = A_np[Index-1]
  for n in range(0,K):
    s = (s * A_sort[n]) % p
print(int(s))
  

### FIXED CODE ###

import math
N = int(input())
print(math.ceil(N/1000)*1000-N)
a, b, m = map(int, input().split())
a_price = list(map(int, input().split()))
b_price = list(map(int, input().split()))
coupon = []
for _ in range(m):
  coupon.append(list(map(int, input().split())))
  
a_copy = a_price.copy()
b_copy = b_price.copy()
a_min = a_copy.sort()[0]
b_min = b_copy.sort()[0]
min = a_min + b_min
totals = [min]
for list in coupon:
  tmp = a_list[list[0]-1] + b_list[list[1]-1] - list[2]
  totals.append(tmp)

totals.sort()
ans = totals[0]

print(ans)


### FIXED CODE ###

a, b, m = map(int, input().split())
a_price = list(map(int, input().split()))
b_price = list(map(int, input().split()))
coupon = []
for _ in range(m):
    coupon.append(list(map(int, input().split())))

a_copy = a_price.copy()
a_copy.sort()
b_copy = b_price.copy()
b_copy.sort()
a_min = a_copy[0]
b_min = b_copy[0]
min = a_min + b_min
totals = [min]
for list in coupon:
    tmp = a_price[list[0] - 1] + b_price[list[1] - 1] - list[2]
    totals.append(tmp)

totals.sort()
ans = totals[0]

print(ans)
t = int(input())
x = int(input())
print(t/x)

### FIXED CODE ###

t,x = map(int, input().split())
print(t/x)