Harryxun/stf_run huggingface dataset:
def abc106_d():
    n, m, q = map(int, input().split())
    table = [[0]*(n+1) for _ in range(n+1)]
    for _ in range(m):
        l, r = map(int, input().split())
        table[l][r] += 1
    query = [tuple(map(int, input().split())) for _ in range(q)]

    dp = [[-1]*(n+1) for _ in range(n+1)]

    def calc(l, r):
        nonlocal dp
        if l == 0 or r == 0: return 0
        if dp[l][r] != -1: return dp[l][r]
        res = calc(l-1, r) + calc(l, r-1) - calc(l-1, r-1) + table[l][r]
        dp[l][r] = res
        return res

    for p, q in query:
        ans = calc(q, q) - calc(q, p-1) - calc(p-1, q) + calc(p-1, p-1)
        print(ans)

if __name__ == '__main__':
    abc106_d()

### FIXED CODE ###

import sys
sys.setrecursionlimit(10010010)

def abc106_d():
    n, m, q = map(int, input().split())
    table = [[0]*(n+1) for _ in range(n+1)]
    for _ in range(m):
        l, r = map(int, input().split())
        table[l][r] += 1
    query = [tuple(map(int, input().split())) for _ in range(q)]

    dp = [[-1]*(n+1) for _ in range(n+1)]

    def calc(l, r):
        nonlocal dp
        if l == 0 or r == 0: return 0
        if dp[l][r] != -1: return dp[l][r]
        res = calc(l-1, r) + calc(l, r-1) - calc(l-1, r-1) + table[l][r]
        dp[l][r] = res
        return res

    for p, q in query:
        ans = calc(q, q) - calc(q, p-1) - calc(p-1, q) + calc(p-1, p-1)
        print(ans)

if __name__ == '__main__':
    abc106_d()
n,w = map(int,input().split())
ls = [list(map(int,input().split())) for _ in range(n)]
dp = [[0]*(w+1) for _ in range(n+1)]
for i in range(n):
    for p in range(w+1):
        if p >= ls[i][0]:
            dp[i+1][p] = max(dp[i][p],dp[i][p-ls[i][0]]+ls[i][1])
        else:
            dp[i+1][p] = dp[i][p]
print(dp[n][w])

### FIXED CODE ###

n,w = map(int,input().split())
ls = [list(map(int,input().split())) for _ in range(n)]
inf = float("inf")
dp = [[inf]*(100000+1) for _ in range(n+1)]
dp[0][0] = 0
ans = 0
for i in range(n):
    for v in range(100001):
        if v - ls[i][1] >= 0:
            dp[i+1][v] = min(dp[i][v],dp[i][v-ls[i][1]]+ls[i][0])
        else:
            dp[i+1][v] = dp[i][v]
for j in range(100001):
    if dp[n][j] <= w:
        ans = j
print(ans)
import math
a,b,h = map(int,input().split())
ans = math.floor((a + b) * h / 2)
print(ans)


### FIXED CODE ###

a,b,h = [int(input()) for i in range(3)]
print((a + b) * h // 2)
a,b=map(int,input())
print(a+b/2)

### FIXED CODE ###

a,b=map(int,input().split())
print(a+b//2)
N=input("enter a number")
list=[]
order=True
check=True
pos=0
temp=0
counter=0
numbers=input("enter the permutation as n digit number")
for number in numbers:
    list.append(int(number))
p0=list[0]


for n in range(1,len(list)):
    #checking is the given permutatoin is in ascendig order or no
    if p0<list[n]:
        p0=list[n]
    else:
        order=False

if order==True:
    print("the given permutation is in ascending order")
if order==False:
    for i in range(1,len(list)+1):
        if i==list[i-1]:
            pass
        else:
            counter+=1
            temp=list[i-1]
            pos=list.index(i)           #swap
            list[i-1]=list[pos]
            list[pos]=temp
if counter==1:
    print("Yes we can sort it in ascending order")
else:
    print("No it cant be sorted in one step")



### FIXED CODE ###

n=int(input());lista_1=[];contador=0;index=0
lista=list(map(int,input().split()))
for i in range(1,n+1):
    lista_1.append(i)
for j in lista:
    aaa=lista_1[index]
    if(j!=aaa):
        contador=contador+1
    index=index+1
if(contador<=2):
    print('YES')
else:
    print('NO')
import math

r=int(input())
print(r*r*math.pi, 2*r*math.pi)

### FIXED CODE ###

import math
r = float(input())
print(r**2*math.pi, 2*r*math.pi)
H = input()
A = input()

if H%A == 0:
  print(H/A)
else:
  print(H/A + 1)

### FIXED CODE ###

H, A = map(int, input().split())
if H%A == 0:
    ans = int(H/A)
    print(ans)
else:
    ans = int(H/A) + 1
    print(ans)
# a.py
# N = int(input()) #ここで標準入力
# # print (type(N),N) 

# print(N*N*N)
#### ##################
# b.py
man=0
N = int(input()) #ここで標準入力
A = [input().split() for i in range(3)]
# print(A)
# B全部たす
for i in range(N):
   man=man+int(A[1][i])
#例外処理
for i in range(N-1):
   if(A[0][i]<=A[0][i+1]):
      # print(man)
      cn=int(A[0][i])
      man=man+int(A[2][cn-1])
      # print (cn)

print(man)

### FIXED CODE ###

# a.py
# N = int(input()) #ここで標準入力
# # print (type(N),N) 

# print(N*N*N)
#### ##################
# b.py
man=0
N = int(input()) #ここで標準入力
A = [input().split() for i in range(3)]
# print(A)
# B全部たす
for i in range(N):
   man=man+int(A[1][i])
   # if (i!=N):

#例外処理
for i in range(N-1):
   # if(A[0][i]<=A[0][i+1]):    # 食べる順が i -> i+1 の時
   if(int(A[0][i+1]) == int(A[0][i])+1):
      # print(man)
      ryori_i=int(A[0][i])
      man_c=int(A[2][ryori_i-1])
      man=man+man_c
      # print (cn)

print(man)
import sys
sys.setrecursionlimit(10*10)

def dfs(pos, not_pos, tree_dict, ans_li, length):
  n_li = tree_dict[pos]
  for n, w in n_li:
    if n == not_pos:
      continue
    new_length = length+w
    if new_length%2 == 0:
      ans_li[n] = 0
    else:
      ans_li[n] = 1
    ans = dfs(n, pos, tree_dict, ans_li, new_length)
  return ans_li

def run():
  N = int(input())
  tree_dict = {}
  ans_li = [0]*(N+1)
  for n in range(N-1):
    u, v, w = map(int, input().split())
    tree_dict.setdefault(u, []).append((v, w))
    tree_dict.setdefault(v, []).append((u, w))
  length = 0
  ans = dfs(1, -1, tree_dict, ans_li, length)
  for a in ans[1:]:
    print(a)
    

if __name__ == '__main__':
  run()

### FIXED CODE ###

import sys
sys.setrecursionlimit(500*500)

def dfs(pos, not_pos, tree_dict, ans_li, length):
  n_li = tree_dict[pos]
  for n, w in n_li:
    if n == not_pos:
      continue
    new_length = length+w
    if new_length%2 == 0:
      ans_li[n] = 0
    else:
      ans_li[n] = 1
    ans = dfs(n, pos, tree_dict, ans_li, new_length)
  return ans_li

def run():
  N = int(input())
  tree_dict = {}
  ans_li = [0]*(N+1)
  for n in range(N-1):
    u, v, w = map(int, input().split())
    tree_dict.setdefault(u, []).append((v, w))
    tree_dict.setdefault(v, []).append((u, w))
  length = 0
  ans = dfs(1, -1, tree_dict, ans_li, length)
  for a in ans[1:]:
    print(a)
    

if __name__ == '__main__':
  run()
from itertools import permutations

INF = float('inf')
n, m, R = list(map(int, input().split()))
r = list(map(int, input().split()))
dist = [[INF]*(n+1) for _ in range(n+1)]
for i in range(1, n+1):
    dist[i][i] = 0
for i in range(m):
    a, b, c = map(int, input().split())
    dist[a][b] = c
    dist[b][a] = c

for k in range(n):
    for i in r:
        for j in r:
            dist[i][j] = min(dist[i][j], dist[i][k]+dist[k][j])
# for d in dist: print(d)

ans = INF
for p in permutations(r):
    ans_ = 0
    for i in range(R-1):
        ans_ += dist[p[i]][p[i+1]]
    ans = min(ans, ans_)
print(int(ans))


### FIXED CODE ###

from itertools import permutations

INF = float('inf')
n, m, R = list(map(int, input().split()))
r = list(map(int, input().split()))
dist = [[INF]*(n+1) for _ in range(n+1)]
for i in range(1, n+1):
    dist[i][i] = 0
for i in range(m):
    a, b, c = map(int, input().split())
    dist[a][b] = c
    dist[b][a] = c

from scipy.sparse import csgraph
dist = csgraph.floyd_warshall(dist)
# for k in range(n):
#     for i in range(n):
#         for j in range(n):
#             dist[i][j] = min(dist[i][j], dist[i][k]+dist[k][j])
# for d in dist: print(d)

ans = INF
for p in permutations(r):
    ans_ = 0
    for i in range(R-1):
        ans_ += dist[p[i]][p[i+1]]
    ans = min(ans, ans_)
print(int(ans))
n = int(input())
a = list(map(int, input().split()))
j = 0
d = 0
c0 = 0
l = sorted(list(set(a)))
for i in l:
    if i == j+1:
        j = i
        if i in a[c0:]:
            for 
            c = a[c0:].index(i)+(n-len(a[c0:]))
        else:break
        if c >= c0:
            d += 1
            c0 = c
        else:break
    else:break
print(n-d if d !=0 else -1)

### FIXED CODE ###

from collections import deque
n = int(input())
a = list(map(int, input().split()))
a = deque(a)
d = 0
i = 1
for _ in range(n):
    b = a.popleft()
    if i == b:
        d +=1
        i += 1
        
print(n-d if d !=0 else -1)
a,b,n = map(int, input().split())
x = (b-1,n)
print(int(a*x/b))

### FIXED CODE ###

a,b,n = map(int, input().split())
x = min(b-1,n)
print(int(a*x/b))
x = input()
a, b = x.split()
if 1 <= a <= 100 and 1 <= b <= 100:
    c = a * b
    d = 2(a + b)
    print(c''d)   

### FIXED CODE ###

a,b = map(int,input().split())
x = a * b
y = 2 * a + 2 * b
print('{} {}'.format(x,y))
k, n = map(int,input().split())
a = [int(x) for x in input().split()]
b = [0] *(n)
for i in range(n-1):
    b[i] =a[i+1]-a[i]
b[n] = a[0] + k - a[n-1]

print(k - max(b))


### FIXED CODE ###

k, n = map(int,input().split())
a = [int(x) for x in input().split()]
b = []
for i in range(n-1):
    b.append(a[i+1]-a[i])
b.append(a[0] + k - a[n-1])

print(k - max(b))
a = input()
b = input()

multi = int(a) * int(b)

if multi %2 == 0:
    print("答え:Even")
else:
    print("答え:Odd")


### FIXED CODE ###

a,b = (int(x) for x in input().split())

multi = a * b

if multi %2 == 0:
    print("Even")
else:
    print("Odd")
N, M = map(int, input().split(" "))

def f():
    S = {}
    for _ in range(M):
        s, c = map(int, input().split(" "))
        if S.get(s) is not None and S.get(s) != c:
            
            return -1
        S[s] = min([S.get(s, 10000), c])

    digit = max(S.keys())

    if S[digit] == 0:
        return -1

    N = []
    for i in range(digit):
        N.append(str(S.get(i + 1, 0)))

    return "".join(N)

print(f())

### FIXED CODE ###

def f():
    N, M = map(int, input().split(" "))
    S = {}
    for _ in range(M):
        s, c = map(int, input().split(" "))
        if S.get(s) is not None and S.get(s) != c:
            return -1
        S[s] = min([S.get(s, 10000), c])

    l = []
    for i in range(1000):
        str_i = str(i)
        if len(str_i) != N:
            continue

        flag = all([
            int(str_i[k - 1]) == v
            for k, v in S.items()
        ])
    
        if flag:
            l.append(i)

    if not l:
        return -1
    
    return min(l)

print(f())
A, B, K = map(int, input().split())
print([i for i in range(1, max(A,B)+1) if A % i == 0 && B % i == 0][K-1])

### FIXED CODE ###

A, B, K = map(int, input().split())
print([i for i in reversed(range(1, max(A,B)+1)) if A % i == 0 and B % i == 0][K-1])
from collections import defaultdict
N = int(input())

res = 0
freq = defaultdict(int)

for i in range(1, N):
    si = str(i)
    freq[f'{si[0]}{si[-1]}'] += 1
    
for i in range(1, N):
    si = str(i)
    res += freq[f'{si[-1]}{si[0]}']
        
print(res)

### FIXED CODE ###

from collections import defaultdict
N = int(input())

res = 0
freq = defaultdict(int)

for i in range(1, N+1):
    si = str(i)
    freq['{}{}'.format(si[0], si[-1])] += 1
    
for i in range(1, N+1):
    si = str(i)
    res += freq['{}{}'.format(si[-1], si[0])]
        
print(res)
def solve():
  n,a = (int(i) for i in input().split())
  x = list(int(i) for i in input().split())
  tp = max(x)
  dp = [[[0 for i in range(n*tp +1)] for j in range(n+1)] for k in range(n+1)]
  query = a*n
  dp[0][0][0] = 1
  for i in range(1,n+1):
    for j in range(n+1):
      for k in range(n*tp +1):
        #選ばない
        dp[i][j][k] = dp[i-1][j][k]
        if x[i-1] <= k and j > 0:
         dp[i][j][k] += dp[i-1][j-1][k-x[i-1]]
        
  ans = 0
  for j in range(1,n+1):
    ans += dp[n][j][j*a]
  #print(dp)
  print(ans)
  
  
  
  
  
  
solve()

### FIXED CODE ###

def solve():
  n,a = (int(i) for i in input().split())
  x = list(int(i) for i in input().split())
  tp = max(x)
  if tp < a:
    print(0)
    exit()
  
  dp = [[[0 for i in range(n*tp +1)] for j in range(n+1)] for k in range(n+1)]
  query = a*n
  dp[0][0][0] = 1
  for i in range(1,n+1):
    for j in range(n+1):
      for k in range(n*tp +1):
        #選ばない
        dp[i][j][k] = dp[i-1][j][k]
        if x[i-1] <= k and j > 0:
         dp[i][j][k] += dp[i-1][j-1][k-x[i-1]]
        
  ans = 0
  for j in range(1,n+1):
    ans += dp[n][j][j*a]
  #print(dp)
  print(ans)
  
  
  
  
  
  
solve()
N = int(input())
As = sorted(list(map(int, input().split())))

if As[0] == As[1]:
  count = 0
else:
  count = 1
  
for i in range(1, N):
  count_sub = 0
  for j in range(i):
    if As[i] % As[j] == 0:
      count_sub += 1
  if count_sub == 0:
    count += 1
    
print(count)

### FIXED CODE ###

N = int(input())
As = sorted(list(map(int, input().split())))

sieve = [True] * 1000001

prev = 0

for i in range(N):
    if As[i] == prev:
        sieve[As[i]] = False
        continue
    else:
        prev = As[i]
        try:
            for j in range(2, 1000000 // prev + 1):
                sieve[prev * j] = False
        except:
            continue

count = 0
As = list(set(As))
for i in range(len(As)):
    if sieve[As[i]] is True:
        count += 1
        
print(count)
from itertools import accumulate
from math import*
from collections import deque
from collections import defaultdict
from itertools import permutations
from heapq import*
from collections import Counter
from itertools import*
from bisect import bisect_left,bisect_right
from copy import deepcopy
inf = 10**18
mod = 10**9+7
from functools import reduce
import sys
sys.setrecursionlimit(10**7)

input()
d = Counter(map(int,input().split()))
input()
t = Counter(map(int,input().split()))
d.subtract(t)
if -d:
    print("NO")
else:
    print("YES")

### FIXED CODE ###

from itertools import accumulate
from math import*
from collections import deque
from collections import defaultdict
from itertools import permutations
from heapq import*
from collections import Counter
from itertools import*
from bisect import bisect_left,bisect_right
from copy import deepcopy
inf = 10**18
mod = 10**9+7
from functools import reduce
import sys
sys.setrecursionlimit(10**7)

input()
d = Counter(map(int,input().split()))
input()
t = Counter(map(int,input().split()))
d.subtract(t)
if -d:
    print("NO")
else:
    print("YES")
n=int(input())
a=list(int,input().split(), for _ in range(0,n))
x=max(a)
y=a.index(x)
del a[y]
z=max(a)

for i in range(0,n):
  if i!=y:
    print(x)
  else:
    print(z)
  


### FIXED CODE ###

r=int(input())
print(3*(r**2))
A, B = map(int, input().split())
l = list(range(A,B))
l += [B]
l = [list("{:0>40}".format(format(i, 'b'))) for i in l]

import numpy as np
l = np.array(l)

ans = ''
for i in range(40):
    if np.sum(l[:, i] == '1') % 2 == 1:
        ans += '1'
    else:
        ans += '0'
print(int(ans, 2))

### FIXED CODE ###

# A, B = map(int, input().split())
# l = list(range(A,B))
# l += [B]
# l = [list("{:0>42}".format(format(i, 'b'))) for i in l]

# import numpy as np
# l = np.array(l)

# ans = ''
# for i in range(42):
#     if np.sum(l[:, i] == '1') % 2 == 1:
#         ans += '1'
#     else:
#         ans += '0'
# print(int(str(ans), 2))

A, B = map(int, input().split())
def xor(x):
    mod = x % 4
    if mod == 0:
        return x
    elif mod == 1:
        return 1
    elif mod == 2:
        return x ^ 1
    elif mod == 3:
        return 0
print(xor(A-1) ^ xor(B))
X, K, D = map(int, input().split())
X=abs(X)
if X==0 and K%2==0:
    ans=0
elif X==0 and K%2==1:
    ans=D
elif D>=X and K%2==0:
    ans=X
elif D>=X and K%2==1:
    ans=D-X
elif X>0 and D<X :
    if K*D<X:
        ans=X-K*D
    else:
        for i in range(1,K):
            if X-i*D<0:
                if (K-i)%2==0:
                    ans=X-(i-1)*D
                    break
                else:
                    ans=i*D-X
                    break
print(ans)

### FIXED CODE ###

X, K, D = map(int, input().split())
X=abs(X)
if D>=X and K%2==0:
    ans=X
elif D>=X and K%2==1:
    ans=D-X
elif D<X and K*D<X:
    ans=X-K*D
else:
    ans=X%D
    if (X-ans)%2!=K%2:
        ans=D-ans
print(ans)
S = list(input())

s = ''
count = 0
while S:
    if s == S[-1]:
        if len(S) >= 2:
            S.pop()
            S.pop()
            s = S.pop()
            count+=2
        else:
            break        
    else:
        s = S.pop()
        count+=1
        
print(count)

### FIXED CODE ###

S = list(input())

s = ''
count = 0
while S:
    if s == S[-1]:
        if len(S) >= 2:
            S.pop()
            S.pop()
            s = ''
            count+=1
        else:
            break        
    else:
        s = S.pop()
        count+=1
        
print(count)
#https://abc010.contest.atcoder.jp/tasks/abc010_4
#http://kmjp.hatenablog.jp/entry/2014/06/08/0900

#よくわからない最大フロー用のdfs---------------------------------

num=201 #今回のnの最大値100*2+1

def dfs(cur):
	global vis
	global EE
	vis[cur] = 1

	if cur==num:
		return 1

	for i in range(num+1):
		if vis[i]==0 and EE[cur][i]>0 and dfs(i) > 0:
			EE[cur][i] -= 1
			EE[i][cur] += 1
			return 1
	return 0
#--------------------------------------------------------------

#今回の問題分（インプット～隣接リストの作成）------------------

n=int(input())
s=[]
ss=[]
for i in range(n):
    s.append([int(i) for i in input().split()])
for i in range(n):
    ss.append([int(i) for i in input().split()])
#s.sort(key=lambda x:(x[0],x[1]))
#ss.sort(key=lambda x:(x[0],x[1]))

pair=[]
for i in range(len(s)):
    right=[]
    for j in range(n):    
        if s[j][0]<ss[i][0] and s[j][1]<ss[i][1]:
            right.append(j)
    pair.append(right)
#pair.sort(key=lambda x:len(x))

#print(pair)

#------------------------------------------------------------

#BFSにぶち込む用のグラフ作成---------------------------------

EE = [[0 for x in range(num+1)] for y in range(num+11)]
vis = [0] * (num+1)

for i in range(len(pair)): #1から最大100　始点s（番号0）から青い点への辺
	EE[0][i+1] = 1
#	EE[i+1][0] = 1

for i in range(n): #101から最大200　赤い点から終点t（番号201）への辺
	EE[i+101][num] = 1

for i in range(len(pair)): #青い点（番号1～100に振り直し）から　赤い点（番号101～200）への辺
    for j in range(len(pair[i])):
        node1, node2 = i+1,pair[i][j]+101
#        EE[node1][node2] = EE[node2][node1] = 1　なんでこれダメなんだろう
        EE[node1][node2] = 1

#風呂～～--------------------------------------------------

flow=0
while 1:
    for i in range(0, num+1):
        vis[i] = 0
    if dfs(0) == 0:
        break
    flow += 1

print (flow)

#----------------------------------------------------------


### FIXED CODE ###

a,b,c=[int(i) for i in input().split()]

if a+b>=c:
    print("Yes")
else:
    print("No")
n,k=map(int,input().split())
a=list(map(int,input().split()))
for i in range(n):
  if a[i]==1:
    x=i
    y=n-1-i
import math

print(math.ceil(n-1,k))

### FIXED CODE ###

n,k=map(int,input().split())
a=list(map(int,input().split()))
for i in range(n):
  if a[i]==1:
    x=i
    y=n-1-i
import math

print(math.ceil((n-1)/(k-1)))
import sys,queue,math,copy,itertools,bisect,collections,heapq

def main():
    sys.setrecursionlimit(10**7)
    INF = 10**18
    MOD = 10**9 + 7
    LI = lambda : [int(x) for x in sys.stdin.readline().split()]
    NI = lambda : int(sys.stdin.readline())
    SI = lambda : sys.stdin.readline().rstrip()

    N,M,V,P = LI()
    A = LI()
    A.sort()

    ans = 0
    ac = list(itertools.accumulate(A))
    bi = bisect.bisect_left(A,A[N-P+1])
    for i in range(N):
        if i >= N-P:
            ans += 1
            continue
        if M+A[i] < A[N-P]: continue
        if V <= P:
            ans += 1
            continue

        w = ((N-P-i) * (M+A[i])) - (ac[N-P] - ac[i])
        if w >= M * (V-P-i):
            ans += 1
    print(ans)
if __name__ == '__main__':
    main()

### FIXED CODE ###

import sys,queue,math,copy,itertools,bisect,collections,heapq

def main():
    sys.setrecursionlimit(10**7)
    INF = 10**18
    MOD = 10**9 + 7
    LI = lambda : [int(x) for x in sys.stdin.readline().split()]
    NI = lambda : int(sys.stdin.readline())
    SI = lambda : sys.stdin.readline().rstrip()

    N,M,V,P = LI()
    A = LI()
    A.sort()

    ans = 0
    ac = list(itertools.accumulate(A))
    for i in range(N):
        if i >= N-P:
            ans += 1
            continue
        if M+A[i] < A[N-P]: continue
        if V <= P:
            ans += 1
            continue

        w = ((N-P-i) * (M+A[i])) - (ac[N-P] - ac[i])
        if w >= M * (V-P-i):
            ans += 1
    print(ans)
if __name__ == '__main__':
    main()
# C
import numpy as np

inp = input().split(' ')
N, M = int(inp[0]), int(inp[1])

inps = input().split(' ')
H = np.array([int(inps[i]) for i in range(len(inps))])
AB = []
for i in range(M):
    inps = input().split(' ')
    AB.append(set([int(inps[0]), int(inps[1])]))
    
def get_height(els):
    return H[els[0]-1] > H[els[1]-1]

def get_height_sum(arr):
    if not arr:
        return 1
    return np.prod(list(map(get_height, arr)))

def tmp(arr_arr):
    return (list(map(get_height_sum, arr_arr)))
    return sum(list(map(get_height_sum, arr_arr)))

connected = [[[i+1] + list(ab - {i+1}) for ab in AB if i+1 in ab] for i in range(N)]

print(int(tmp(connected)))

### FIXED CODE ###

# C
N, M = map(int, input().split())
H = list(map(int, input().split()))

A = [0] * N
for i in range(M):
    a, b = map(int, input().split())
    A[a-1] = max(A[a-1], H[b-1])
    A[b-1] = max(A[b-1], H[a-1])
    
res = sum([H[i] > A[i] for i in range(N)])
print(res)
X=int(input())
Y=int(input())
Z=int(input())

if(X+Y+Z>=22):
    print("bust")
else:
    print("win")

### FIXED CODE ###

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

if a+b+c <= 21:
    print("win")
else:
    print("bust")
a,b=map(int,input()split())
print("{}".format(max((a+b),(a-b),(a*b))))

### FIXED CODE ###

a,b=map(int,input().split())
print("{}".format(max((a+b),(a-b),(a*b))))
n = int(input())

if n == 2:
	a = int(input())
    b = int(input())
    print(a + b)
else:
	print('Hello World')

### FIXED CODE ###

n = int(input())

if n == 2:
  a = int(input())
  b = int(input())
  print(a + b)
else:
  print('Hello World')
a,b = (int(x) for x in input().split(" "))
int(c) = (int(a) - int(b))
if c > ('-1'):
    print int(c)
elif int(c) < ('-1'):
    print('0')

### FIXED CODE ###

X, t = map(int, input().split())
x = X - t
 
if x > 0:
    print(x)
else:
    print(0)
N = input()
K = input()
lists = []
A = 0

for i in range(int(N)):
  lists.append((input()))
 
lists.sort()
 
A = sum(lists[:K])
 
print(A)

### FIXED CODE ###

N,K = input().split()
lists = []
B = 0

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

lists.sort()
#print(lists)

for j in range(int(K)):
  B += int(lists[j])
 
print(B)
n,m=map(int,input().split())
s=input()
ans=[]
def f(i,j):
    if i==0:
        return
    if j>i:
        j=i
    while s[i-j]=="1":
        j-=1
    if j==0:
        print(-1)
        quit()
    ans.append(j)
    f(i-j,m)
f(n,m)
print(" ".join(map(str,ans[::-1])))

### FIXED CODE ###

import sys
sys.setrecursionlimit(10**6)
n,m=map(int,input().split())
s=input()
ans=[]
def f(i,j):
    if i==0:
        print(" ".join(map(str,ans[::-1])))
        return
    if j>i:
        j=i
    while s[i-j]=="1":
        j-=1
    if j==0:
        print(-1)
        return
    ans.append(j)
    f(i-j,m)
f(n,m)
from math import floor
from decimal import Decimal
a,b = map(Dicimal, input().split())
c = a*b
print(floor(c))

### FIXED CODE ###

from math import floor
from decimal import Decimal
a,b = map(Decimal, input().split())
c = a*b
print(floor(c))
a = list(input())
if a[0] = 9 or a[1] = 9:
  print(Yes)
else:
  print(No)
  

### FIXED CODE ###

a = list(input())
if a[0] == "9" or a[1] == "9":
  print("Yes")
else:
  print("No")
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]
inf=float("inf")
dp=[-1*inf]*(n+1)
dp[0]=0
for i in range(1,n+1):
    for j in range(m):
        dp[i]=max(dp[i],dp[i-num[a[j]]]+1)
ans=[]
x=dp[n]
for i in range(x):
    for j in range(m):
        if dp[n-num[a[j]]]==dp[n]-1:
            ans.append(a[j])
            n-=num[a[j]]
            break
print("".join(list(map(str,ans))))


### FIXED CODE ###

n,m=map(int,input().split())
a=list(map(int,input().split()))
a.sort(reverse=True)
nums=[0,2,5,5,4,5,6,3,7,6]
dp=[-1]*(n+1)
dp[0]=0
for i in range(1,n+1):
    for x in a:
        if i-nums[x]>=0:
            dp[i]=max(dp[i-nums[x]]+1,dp[i])
k=dp[n]
ans=[]
for i in range(k):
    for x in a:
        if n-nums[x]<0:
            continue
        if dp[n-nums[x]]==dp[n]-1:
            n-=nums[x]
            ans.append(x)
            break
print("".join(list(map(str,ans))))