Harryxun/stf_run huggingface dataset:
import numpy as np
import math
from functools import reduce

N,M = map(int,input().split())
A = np.array(list(map(int,input().split())))
A = A // 2

def lcmb(x,y):
    return (x*y)//math.gcd(x,y)
def lcm(L):
    return reduce(lcmb, L, 1)
    
T = lcm(A)
m = M//T
if m%2 == 0:
    ans = m//2
else:
    ans = m//2 + 1
print(ans)

### FIXED CODE ###

import numpy as np
import fractions
from functools import reduce

N,M = map(int,input().split())
A = np.array(list(map(int,input().split())))
A = A // 2

def lcmb(x,y):
    return (x*y)//fractions.gcd(x,y)
def lcm(L):
    return reduce(lcmb, L, 1)
    
T = lcm(A)

flg = False
for a in A:
    if (T//a)%2 == 0:
        flg = True
        break

m = M//T
if flg:
    ans = 0
elif m%2 == 0:
    ans = m//2
else:
    ans = m//2 + 1
print(ans)
import collections
N, K = map(int, input().split())
A = list(map(int, input().split()))
if K in A:
    print("POSSIBLE")
else:
    diff = collections.defaultdict(int)
    A.sort()
    idx = N - 1
    if K > A[-1]:
        print("IMPOSSIBLE")
    else:
        for i in range(N-1):
            if A[i] > K and idx == N - 1:
                idx = i
            diff[A[i+1] - A[i]] += 1

        diff_list = list(diff.keys())
        if 1 in diff_list:
            print("POSSIBLE")
            exit(0)
        diff_list.sort()

        for i in range(idx, N):
            for j in range(len(diff_list)):
                if (K - A[i]) % diff_list[j] == 0:
                    print("POSSIBLE")
                    exit(0)
        print("IMPOSSIBLE")


### FIXED CODE ###

import collections
N, K = map(int, input().split())
A = list(map(int, input().split()))
if K in A:
    print("POSSIBLE")
    exit(0)
else:
    diff = collections.defaultdict(int)
    A.sort()
    idx = N - 1
    if K > A[-1]:
        print("IMPOSSIBLE")
        exit(0)
    else:
        for i in range(N-1):
            if A[i] > K and idx == N - 1:
                idx = i
            if A[i+1] - A[i] != 0:
                diff[A[i+1] - A[i]] += 1

        diff_list = list(diff.keys())
        if 1 in diff_list:
            print("POSSIBLE")
            exit(0)
        else:
            diff_list.sort()
            for i in range(idx, N):
                for j in range(len(diff_list)):
                    if (K - A[i]) % diff_list[j] == 0:
                        print("POSSIBLE")
                        exit(0)
            print("IMPOSSIBLE")
            exit(0)
# coding: utf-8
n,m=map(int,input().split())
data=[]
dic={}
muki={}
kita={}
for i in range(1,n+1):
    dic[i]=0
    muki[i]=[(-1,0)]
    kita[i]=0

for i in range(m):
    a,b,c=map(int,input().split())
    if muki[a][0]!=(-1,0):
        muki[a].append((b,c))
    else:
        muki[a]=[(b,c)]
def check(moto):
    for p in muki[moto]:
        if kita[p[0]]==0 or dic[p[0]]<dic[moto]+p[1]:
            dic[p[0]]=dic[moto]+p[1]
            kita[p[0]]+=1
    tmp=muki[moto]
    muki[moto]=[(-2,0)]
    for p in tmp:
        if muki[p[0]][0][0]==-2:
            print('inf')
            exit()
        elif muki[p[0]][0][0]!=-1:
            check(p[0])
check(1)
print(dic[n])


### FIXED CODE ###

# coding: utf-8
n,m=map(int,input().split())
edge=[]
for i in range(m):
    a,b,c=map(int,input().split())
    edge.append((a-1,b-1,-c))
inf=99999999999999999999
d=[inf for i in range(n)]
d[0]=0
count=0
while count<n+1:
    count+=1
    if count==n:
        tmp=d[n-1]
    update=False
    for i in range(m):
        f,t,cost=edge[i]
        if(d[t]>d[f]+cost):
            d[t]=d[f]+cost
            update=True
    if count==n and tmp!=d[n-1]:
        print('inf')
        break
    if not update:
        print(-d[n-1])
        break
else:
    print(-d[n-1])
H,W=map(int,input().split())

a=[[0]*W for i in range(H)]
b=[[0]*W for i in range(H)]


for i in range(H):
	a[i]=input().split(",")

for j in range(1,W):
	b[0][j]=b[0][j-1]+int(not(a[0][j]==a[0][j-1]))

for i in range(1,H):
	b[i][0]=b[i-1][0]+int(not(a[i-1][0]==a[i][0]))
	for j in range(1,W):
		b[i][j]=min(b[i-1][j]+int(not(a[i-1][j]==a[i][j])),b[i][j-1]+int(not(a[i][j-1]==a[i][j])))
	
print(b[H-1][W-1])


### FIXED CODE ###

H,W=map(int,input().split())

a=[[0]*W for i in range(H)]
b=[[0]*W for i in range(H)]

#print(b)

for i in range(H):
	a[i]=list(input())
#print(a)
    
for j in range(1,W):
	b[0][j]=b[0][j-1]+int(not(a[0][j]==a[0][j-1]))

for i in range(1,H):
	b[i][0]=b[i-1][0]+int(not(a[i-1][0]==a[i][0]))
	for j in range(1,W):
		b[i][j]=min(b[i-1][j]+int(not(a[i-1][j]==a[i][j])),b[i][j-1]+int(not(a[i][j-1]==a[i][j])))

if(a[0][0]=="." and a[H-1][W-1]=="."):
	print(int(b[H-1][W-1]/2))
elif(a[0][0]=="#" and a[H-1][W-1]=="#"):
  print(int(b[H-1][W-1]/2+1))
else:
  print(int((b[H-1][W-1]+1)/2))
#print(int(b[H-1][W-1]/2))
N = int(input())
A = list(map(int, input().split()))
m = sum(A) // 2
n = 0
for i in range(N):
  if n < m:
    n += A[i]
  elif n >= m and i != N-1:
    a = i
    break
  elif n >= m and i == N - 1:
    a = i
if a == 0:
  print(abs(A[a]-sum(A[a:])))
elif abs(sum(A[:a-1]) - sum(A[a-1:])) > abs(sum(A[:a]) - sum(A[a:])):
  print(abs(sum(A[:a]) - sum(A[a:])))
else:
  print(abs(sum(A[:a-1]) - sum(A[a-1:])))

### FIXED CODE ###

N = int(input())
A = list(map(int, input().split()))
m = sum(A) // 2
n = 0
if N > 2:
  for i in range(N):
    if n < m:
      n += A[i]
    elif n >= m and i == N - 1:
      a = i
    elif n >= m and i != N - 1:
      a = i
      break
  if a == 0:
    print(abs(A[a]-sum(A[a:])))
  elif abs(sum(A[:a-1]) - sum(A[a-1:])) > abs(sum(A[:a]) - sum(A[a:])):
    print(abs(sum(A[:a]) - sum(A[a:])))
  else:
    print(abs(sum(A[: a - 1]) - sum(A[a - 1 :])))
else:
  print(abs(A[0]-A[1]))
n = int(input())
a = list(map(int,input().split()))
l = []
for i in range(n+1):
    for j in range(n+1):
        l.append(abs(a[i]-a[j]))
print(max(l))

### FIXED CODE ###

n = int(input())
l = list(map(int,input().split()))
print(max(l)-min(l))
n=int(input())
a=()
ans=1e12
l=int(n**0.5)+2
for i in range(1,l):
  if i in a:
    continue
  elif n%i==0:
    a.append(i)
    a.append(n//i)
    ans=min(ans,(i+n//i-2))
print(ans) 

### FIXED CODE ###

n=int(input())
a=[]
ans=1e12
l=int(n**0.5)+2
for i in range(1,l):
  if n%i==0 and i not in a:
    a.append(i)
    a.append(n//i)
    ans=min(ans,(i+n//i-2))
print(ans)
N,W = map(int,input().split())
w,v = [0]*N,[0]*N
for i in range(N):
    w[i],v[i] = map(int,input().split())
    
dp = [[0]*(W+1) for i in range(N+1)]

for i in range(N):
    for j in range(W+1):
        if j >= w[i]:
            dp[i+1][j] = max(dp[i][j-w[i]]+v[i],dp[i][j])
        else:
            dp[i+1][j] = dp[i][j]
            
print(dp[N][W])

### FIXED CODE ###

N,W = map(int,input().split())
w,v = [0]*N,[0]*N
for i in range(N):
    w[i],v[i] = map(int,input().split())
    
dp = [[10**9+1]*(sum(v)+1) for i in range(N+1)]
dp[0][0] = 0

#v[i]を使うかどうか
for i in range(N):
    #価値がjのときの最小の重さ総量
    for j in range(sum(v)+1):
        if j >= v[i]:
            dp[i+1][j] = min(dp[i][j-v[i]]+w[i],dp[i][j])
        else:
            dp[i+1][j] = dp[i][j]
            
ans = 0

for i in range(sum(v)+1):
    if dp[N][i] <= W:
        ans = max(ans,i)
print(ans)
n, k = map(int, input().split())
A_list  =[]
nuske = np.zeros(n)
import numpy as np
for _ in range(k): 
    d = input()
    a = list(map(int, input().split()))
    for i in a:
        nuske[ i-1] +=1

p =0

for i in range(len(nuske)):
    if nuske[i] ==0:
        p+=1

print(p)


### FIXED CODE ###

n, k = map(int, input().split())
A_list  =[]
import numpy as np
nuske = np.zeros(n)

for _ in range(k): 
    d = input()
    a = list(map(int, input().split()))
    for i in a:
        nuske[ i-1] +=1

p =0

for i in range(len(nuske)):
    if nuske[i] ==0:
        p+=1

print(p)
import numpy as np
N, K, Q  = map(int, input().split())
score = np.zeros(N)
for i in range(Q):
  num = int(input())
  score[num] += 1

for i in range(N):
  if score[i] > Q-K:
    print('Yes')
  else:
    print('No')

### FIXED CODE ###

import numpy as np
N, K, Q  = map(int, input().split())
score = np.zeros(N)
for i in range(Q):
  num = int(input())
  score[num-1] += 1

for i in range(N):
  if score[i] > Q-K:
    print('Yes')
  else:
    print('No')
a,b=map(int(input().split())
if a==3,b==1 :
  print(2)
elif a==1,b==2 :
  print(3)
elif a==2,b==3 :
  print(1)

### FIXED CODE ###

a=int(input())
b=int(input())
if a==3 and b==1 :
  print(2)
elif a==1 and b==2 :
  print(3)
elif a==2 and b==3 :
  print(1)
elif a==3 and b==2 :
  print(1)
elif a==1 and b==3 :
  print(2)
elif a==2 and b==1 :
  print(3)
import sys
# 再帰上限を引き上げる
sys.setrecursionlimit(10**6)

####
# DFS(深さ優先探索

count = 0
def dfs(graph, v, seen):
    #print(seen)
    # Falseがない、つまり頂点が1個しかない場合は、1を返す
    if not False in seen:
        global count
        count +=1
        return
    
    # 頂点Vから行ける頂点を全探索
    for i in graph[v]:
        # 行ける場所はTrueである。
        if seen[i]:
            continue
        
        # いったんTrueにして
        seen[i] = True
        # 探索したら
        dfs(graph, i, seen)
        # 戻す
        seen[i] = False
        
    return
        
        

####

M, N = map(int, input().split())

# グラフを作る
graph = [[] for i in range(N)]
#print(graph)

for i in range(M):
    a, b = map(int, input().split())
    # index番号にあわせたいので、1引く
    a -= 1
    b -= 1
    graph[a].append(b)
    graph[b].append(a)
    
seen = [False for i in range(M)]
seen[0] = True
#print(seen)

dfs(graph, 0, seen)

# 全探索できた数を表示
print(count)

### FIXED CODE ###

import sys

# 再帰上限を引き上げる
sys.setrecursionlimit(10**6)

count = 0
def dfs(graph, v, seen):

    if not False in seen:
        global count
        count += 1
        return

    # 頂点vから行ける頂点を全探索
    for i in graph[v]:
        if seen[i]:
            continue
        seen[i] = True
        dfs(graph, i, seen)
        seen[i] = False
    
    return

# ここから本文
N, M = map(int, input().split())

# グラフ構造を作る
graph = [[] for i in range(N)]
for i in range(M):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    graph[a].append(b)
    graph[b].append(a)

seen = [False for i in range(N)]
seen[0] = True
dfs(graph, 0, seen)

print(count)
import sys
S0=raw_input()
T=list(raw_input())

l=len(T)


ans=""
for i in range(len(S0)-l+1):
	S1=list(S0)
	for j in range(l):
		#print i+j,j,S1[i+j],T[j]
		if S1[i+j]!=T[j] and S1[i+j]!="?":
			#print "break"
			break
	else:
		#print "else"
		for j in range(l):
			S1[i+j]=T[j]
		S_tmp=(''.join(S1)).replace('?','a')
		#print ans
		#print S_tmp
		if ans=="":
			ans=S_tmp
		if S_tmp < ans:
			ans=S_tmp
			
	
if S0==''.join(S1):
	print "UNRESTORABLE"
	sys.exit()
	

print ans



### FIXED CODE ###

import sys
S0=raw_input()
T=list(raw_input())

l=len(T)

if len(S0)<len(T):
	print "UNRESTORABLE"
	sys.exit()


ans=""
for i in range(len(S0)-l+1):
	S1=list(S0)
	#print S1
	for j in range(l):
		#print i+j,j,S1[i+j],T[j]
		if S1[i+j]!=T[j] and S1[i+j]!="?":
			#print "break"
			break
	else:
		#print "else"
		for j in range(l):
			S1[i+j]=T[j]
		S_tmp=(''.join(S1)).replace('?','a')
		#print ans
		#print S_tmp
		if ans=="":
			ans=S_tmp
		if S_tmp < ans:
			ans=S_tmp
			
	
if ans=="":
	print "UNRESTORABLE"
	sys.exit()
else:
	print ans
from collections import defaultdict
N, K = map(int, input().split())
a_bs = [tuple(map(int, input().split())) for _ in range(N - 1)]

def culc_tree(t, used_num):
    tree[t][1] = False
    global answer
    k = K - used_num
    print(t, k)
    answer = (answer * k) % (10 ** 9 + 7)
    childs = [next_ for next_ in tree[t][0] if tree[next_][1]]
    for i, child in enumerate(childs, 2):
        culc_tree(child, i)


tree = defaultdict(lambda: [[], True])
for a, b in a_bs:
    tree[a][0].append(b)
    tree[b][0].append(a)

answer = K
tree[1][1] = False
for i, child in enumerate(tree[1][0], 1):
    culc_tree(child, i)
print(answer)

### FIXED CODE ###

import sys
from collections import defaultdict

sys.setrecursionlimit(10**5)

N, K = map(int, input().split())
a_bs = [tuple(map(int, input().split())) for _ in range(N - 1)]

def culc_tree(t, used_num):
    tree[t][1] = False
    global answer
    k = K - used_num
    answer = (answer * k) % (10 ** 9 + 7)
    childs = [next_ for next_ in tree[t][0] if tree[next_][1]]
    for i, child in enumerate(childs, 2):
        culc_tree(child, i)


tree = defaultdict(lambda: [[], True])
for a, b in a_bs:
    tree[a][0].append(b)
    tree[b][0].append(a)

answer = K
tree[1][1] = False
for i, child in enumerate(tree[1][0], 1):
    culc_tree(child, i)
print(answer)
import sys
from functools import lru_cache

sys.setrecursionlimit(10000)
@lru_cache(maxsize = None)
def rec(i,j,k):
    if k == N or i == N - 1 or j == N - 1:
        return
    tmp = dp[i][j] + A[k][0] * abs(A[k][1] - i)
    dp[i+1][j] = tmp if tmp > dp[i+1][j] else dp[i+1][j]
    tmp = dp[i][j] + A[k][0] * abs(A[k][1] - N + j + 1)
    dp[i][j+1] = tmp if tmp > dp[i][j+1] else dp[i][j+1]
    rec(i + 1, j, k + 1)
    rec(i, j + 1, k + 1)
    
N = int(input())
A = sorted([(int(j),i) for i, j in enumerate(input().split())])[::-1]

dp = [[0 for _ in range(N)] for _ in range(N)]
rec(0, 0, 0)
ans = -1
for i in range(4):
    for j in range(4):
        if dp[i][j] > ans:
            ans = dp[i][j]
print(ans)

### FIXED CODE ###

from collections import deque

N = int(input())
A = sorted([(int(j),i) for i, j in enumerate(input().split())])[::-1]
d = deque([(0,0)])
dp = [[0 for _ in range(N + 1)] for _ in range(N + 1)]
while(len(d)>0):
    i, j = d.pop()
    if i + j > N - 1:
        continue
    tmp = dp[i][j] + A[i+j][0] * abs(A[i+j][1] - i)
    if tmp > dp[i+1][j]:
        if dp[i+1][j] == 0:
            d.appendleft((i+1,j))
        dp[i+1][j] = tmp
    tmp = dp[i][j] + A[i+j][0] * abs(A[i+j][1] - N + j + 1)
    if tmp > dp[i][j+1]:
        if dp[i][j+1] == 0:
            d.appendleft((i,j+1))
        dp[i][j+1] = tmp
        
ans = -1
for i in range(N):
    for j in range(N):
        if dp[i][j] > ans:
            ans = dp[i][j]
print(ans)
package main

import (
	"fmt"
	"strconv"
)

func main() {
	var inputLine string
	fmt.Scan(&inputLine)
	runeS := []rune(inputLine)
	var nums []int
	for _, c := range runeS {
		n, _ := strconv.Atoi(string(c))
		nums = append(nums, n)
	}

	var temp int
	var s string
	for i := 0; i < (1 << uint(len(nums)-1)); i++ {
		temp = nums[0]
		s = strconv.Itoa(nums[0])
		for j := 0; j < (len(nums) - 1); j++ {
			if (i>>uint(j))&1 == 1 {
				temp += nums[j+1]
				s += "+" + strconv.Itoa(nums[j+1])
			} else {
				temp -= nums[j+1]
				s += "-" + strconv.Itoa(nums[j+1])
			}
		}
		if temp == 7 {
			s += "=7"
			fmt.Println(s)
			break
		}
	}
}


### FIXED CODE ###

S = input()

for i in range(1 << (len(S)-1)):
    temp = int(S[0])
    ans = str(S[0])
    for j in range(len(S)-1):
        if ((i >> j) & 1) == 1:
            temp -= int(S[j+1])
            ans = ans + '-' + str(S[j+1])
        else:
            temp += int(S[j+1])
            ans = ans + '+' + str(S[j+1])
    if temp == 7:
        break
print(ans+'=7')
# 今日の曜日を表す文字列 S が与えられます。
# Sは SUN,MON,TUE,WED,THU,FRI,SAT のいずれかであり、
# それぞれ日曜日、月曜日、火曜日、水曜日、木曜日、金曜日、土曜日を表します。
# 次の日曜日 (あす以降) が何日後か求めてください。

# 入力: 入力は以下の形式で標準入力から与えられる。
# S
# 出力: 次の日曜日が何日後か出力せよ。

week = input()
if week == 'SAT':
    result = 1
elif week == 'FRI':
    result = 2
elif week == 'THU':
    result = 3
elif week == 'WED':
    result = 4
elif week == 'TUS':
    result = 5
elif week == 'MON':
    result = 6
elif week == 'SUN':
    result = 7

print(result)

### FIXED CODE ###

# 今日の曜日を表す文字列 S が与えられます。
# Sは SUN,MON,TUE,WED,THU,FRI,SAT のいずれかであり、
# それぞれ日曜日、月曜日、火曜日、水曜日、木曜日、金曜日、土曜日を表します。
# 次の日曜日 (あす以降) が何日後か求めてください。

# 入力: 入力は以下の形式で標準入力から与えられる。
# S
# 出力: 次の日曜日が何日後か出力せよ。

week = input()
if week == 'SAT':
    result = 1
elif week == 'FRI':
    result = 2
elif week == 'THU':
    result = 3
elif week == 'WED':
    result = 4
elif week == 'TUE':
    result = 5
elif week == 'MON':
    result = 6
elif week == 'SUN':
    result = 7

print(result)
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time, copy,bisect
#from operator import itemgetter
#from heapq import heappush, heappop
#import numpy as np
#from scipy.sparse.csgraph import breadth_first_order, depth_first_order, shortest_path, floyd_warshall, dijkstra, bellman_ford, johnson
#from scipy.sparse import csr_matrix
#from decimal import Decimal, ROUND_HALF_UP, ROUND_HALF_EVEN
import sys

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

stdin = sys.stdin

ni = lambda: int(ns())
nf = lambda: float(ns())
na = lambda: list(map(int, stdin.readline().split()))
nb = lambda: list(map(float, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces

X, N = na()
p = na()
kouho = []
for i in range(1, 101):
    if i in p:
        continue
    kouho.append((abs(X - i), i))
print(min(kouho)[1])

### FIXED CODE ###

import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time, copy,bisect
#from operator import itemgetter
#from heapq import heappush, heappop
#import numpy as np
#from scipy.sparse.csgraph import breadth_first_order, depth_first_order, shortest_path, floyd_warshall, dijkstra, bellman_ford, johnson
#from scipy.sparse import csr_matrix
#from decimal import Decimal, ROUND_HALF_UP, ROUND_HALF_EVEN
import sys

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

stdin = sys.stdin

ni = lambda: int(ns())
nf = lambda: float(ns())
na = lambda: list(map(int, stdin.readline().split()))
nb = lambda: list(map(float, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces

X, N = na()
p = na()
kouho = []
for i in range(-100, 200):
    if i in p:
        continue
    kouho.append((abs(X - i), i))
print(min(kouho)[1])
def another(s):
  if s == 'D':
    return 'H'
  else:
    return 'D'

a, b = map(int, input().split())
if a == 'H':
  print(b)
else:
  print(another(b))

### FIXED CODE ###

def another(s):
  if s == 'D':
    return 'H'
  else:
    return 'D'

a, b = input().split()
if a == 'H':
  print(b)
else:
  print(another(b))
N,M = map(int, input().split())
candidate = [-1]*N
flag = False
if N == 1:
  if M == 0:
    candidate = [0]
  else:
    s_temp,c_temp = map(int, input().split())
    candidate = [c_temp]
else:
  for i in range(M):
    s_temp,c_temp = map(int, input().split())
    s_temp = s_temp - 1
    if candidate[s_temp] == -1:
      candidate[s_temp] = c_temp
    elif candidate[s_temp] == c_temp:
      pass
    elif candidate[s_temp] != c_temp:
      flag = True
      break
if flag == True:
  print(-1)
else:
  print(int(''.join(map(str, candidate))))

### FIXED CODE ###

N, M = map(int, input().split())
flag = True
ex = [-1]*N
for i in range(M):
  S,C = map(int, input().split())
  if ex[S-1]==-1 or ex[S-1]==C:
    ex[S-1] = C
  else:
    flag = False
    break
if N>1 and ex[0]==0:
  flag = False
if flag:
  for i in range(1,N):
    if ex[i]==-1:
      ex[i] = 0
  if ex[0]==-1 and N>1:
    ex[0] = 1
  elif ex[0]==-1:
    ex[0] = 0
  print(int("".join(map(str, ex))))
else:
  print(-1)
a, b, c ,d = map(int, input().split())
attack = True
win = True

while True:
	if attack:
		c -= b
		attack = False
		if c < 0:
			break
	else:
		a -= d
		attack = True
		if a < 0:
			win = False 
			break


print("Yes") if win else print('No')



### FIXED CODE ###

s, w = map(int, input().split())

print("unsafe") if (s <= w) else print("safe")
n = int(input())
a = 1
s = list(map(int, input().split()))
if 0 in s:
    print(0)
    exit()
for i in s:
    a*=s[i]
    if a>10**18:
        print(-1)
        exit()
else:
    print(a)

### FIXED CODE ###

n = int(input())
a = 1
s = list(map(int, input().split()))
if 0 in s:
    print(0)
    exit()
for i in s:
    a*=i
    if a>10**18:
        print(-1)
        exit()
else:
    print(a)
from functools import lru_cache
def sub():
    N, M = [int(e) for e in input().split()]
    As = [e for e in input().split()]

    d_cost = {
            "1": 2,
            "2": 5,
            "3": 5,
            "4": 4,
            "5": 5,
            "6": 6,
            "7": 3,
            "8": 7,
            "9": 6,
            }
    
    
    NINF = -10**12
    @lru_cache(maxsize=None)   
    def dp(a_life):
        if a_life == 0:
            return 0
        cc = [a_life - d_cost[a] for a in As]
        cc = [c for c in cc if c >= 0]
        if len(cc) == 0:
            return NINF
        buf = [dp(c) + 1 for c in cc]
        return max(buf)
    
    Lmax = dp(N)
    
    life = N
    buf = []
    for i in range(Lmax):
        oks = [a for a in As if dp(life - d_cost[a]) == Lmax - (i+1)]
        a_selected = max(oks)
        buf.append(a_selected)
        life = life - d_cost[a_selected]
    print("".join(buf))


sub()






### FIXED CODE ###

def sub(N, M, As):

    d_cost = {
            "1": 2,
            "2": 5,
            "3": 5,
            "4": 4,
            "5": 5,
            "6": 6,
            "7": 3,
            "8": 7,
            "9": 6,
            }
    
    NINF = -10**6
    dp_table = [NINF for _ in range(N+1)]
    dp_table[0] = 0
    for i in range(N):
        if dp_table[i] < 0:
            continue
        for a in As:
            cost = i + d_cost[a]
            if cost <= N:
                dp_table[cost] = max(dp_table[cost], dp_table[i] + 1)

    Lmax = dp_table[N]

    life = N
    buf = []
    for i in range(Lmax):
        oks = []
        for a in As:
            if life - d_cost[a] < 0:
                continue
            if dp_table[life - d_cost[a]] == dp_table[life] - 1:
                oks.append(a)
        # oks = [a for a in As if dp_table[life - d_cost[a]] == dp_table[life] - 1 and life - d_cost[a] >= 0]
        a_selected = max(oks)
        buf.append(a_selected)
        life = life - d_cost[a_selected]
    print("".join(buf))
            

if __name__ == "__main__":
    N, M = [int(e) for e in input().split()]
    As = [e for e in input().split()]
    sub(N, M, As)
h, w = map(int, input())
a = [list(input()) for i in range(h)]

row = [False] * h
col = [False] * w

for i in range(h):
    for j in range(w):
        if a[i][j] == "#":
            row[i] = True
            col[j] = True

for i in range(h):
    if row[i]:
        ans = ""
        for j in range(w):
            if col[j]:
                ans.join(a[i][j])
        print(ans)

### FIXED CODE ###

h, w = map(int, input().split())
a = [list(input()) for i in range(h)]

row = [False] * h
col = [False] * w

for i in range(h):
    for j in range(w):
        if a[i][j] == "#":
            row[i] = True
            col[j] = True

for i in range(h):
    if row[i]:
        for j in range(w):
            if col[j]:
                print(a[i][j], end = "")#改行しない
        print()#改行
a,b,c = map(int(), input().split())
k = int(input())
kk=2**k
m = max(a,b,c)
al = a+b+c-m+kk*m
print(al)

### FIXED CODE ###

a,b=map(int,input().split())
if b>=a:
  print(a)
else:
  print(a-1)
import sys

def main():
  a,b,c = map(lambda x: int(x), input().split())
  k = int(input())

  for _ in range(k):
      if b <= a:
          b = 2 * b
          continue
      if c <= b:
          c = 2 * c
          continue
      print('Yes')
      sys.exit()

  if (a < b) & (b < c):
      print('Yes')
      sys.exit()
  print('No')

if __name__ == '__main__':
    main()

### FIXED CODE ###

print(10 - int(input())//200)
h,w = map(int, input().split())
if max(h,w) >= 3:
  if h >= w :
    ans = w*min(1,(h%3))
  else:
    ans = h*min(1,(w%3))
for i in range(1,h):
  ans_ = max(i*w,(h-i)*(w+(w%2))//2) - min(i*w,(h-i)*(w-(w%2))//2)
  ans = min(ans,ans_)
for i in range(1,w):
  ans_ = max(i*h,(w-i)*(h+(h%2))//2) - min(i*h,(w-i)*(h-(h%2))//2)
  ans = min(ans,ans_)
print(ans)

### FIXED CODE ###

h,w = map(int, input().split())
ans = 1000000000
if max(h,w) >= 3:
  if h >= w :
    ans = w*min(1,(h%3))
  else:
    ans = h*min(1,(w%3))
if h%3 == 0:
  ans = 0
if w%3 == 0:
  ans = 0
for i in range(1,h):
  ans_ = max(i*w,(h-i)*(w+(w%2))//2) - min(i*w,(h-i)*(w-(w%2))//2)
  ans = min(ans,ans_)
for i in range(1,w):
  ans_ = max(i*h,(w-i)*(h+(h%2))//2) - min(i*h,(w-i)*(h-(h%2))//2)
  ans = min(ans,ans_)
print(ans)