Harryxun/stf_run huggingface dataset:
#! env/bin/local python3
# -*- coding: utf-8 -*-

import numpy as np

inputs: list = []

while True:
    try:
        inputs.append([int(i) for i in input().split()])
    except EOFError:
        break

h, w = inputs[0]
c = inputs[1: 11]
a = inputs[11:]

number_of_edge = 10
number_of_node = 10

for k in range(number_of_node):
    for i in range(number_of_node):
        for j in range(number_of_node):
            c[i][j] = min(c[i][j], c[i][k] + c[k][j])

target = []
for ca in a:
    target += ca
# delete -1
target = [ta for ta in target if np.abs(ta) != 1]
results = 0
for t in target:
    results += c[t][1]

print(results)



### FIXED CODE ###

#! env/bin/local python3
# -*- coding: utf-8 -*-

import numpy as np

inputs = []

while True:
    try:
        inputs.append([int(i) for i in input().split()])
    except EOFError:
        break

h, w = inputs[0]
c = inputs[1: 11]
a = inputs[11:]

number_of_edge = 10
number_of_node = 10

for k in range(number_of_node):
    for i in range(number_of_node):
        for j in range(number_of_node):
            c[i][j] = min(c[i][j], c[i][k] + c[k][j])

target = []
for ca in a:
    target += ca

target = [ta for ta in target if np.abs(ta) != 1]
results = 0
for t in target:
    results += c[t][1]

print(results)
n=int(input())
a=list(map(int,input().split()))
aset=list(set(a))
ans=0
alist=[0]*n
for j in aset:
    k=a.count(j)
    alist[j]=k
    ans+=(k*(k-1))//2
for u in a:
    print(ans-alist[u]+1)

### FIXED CODE ###

n=int(input())
a=list(map(int,input().split()))
aset=list(set(a))
ans=0
al=[0]*200000
for i in a:
    al[i]+=1
for j in aset:
    k=al[j]
    ans+=(k*(k-1))//2
for u in a:
    print(ans-al[u]+1)
index_list = []
	for cube_index in range(1, len(cubes)):
		if cube_index not in index_list and cubes[cube_index] == cubes[cube_index - 1]:
			index_list.append(cube_index - 1)
			index_list.append(cube_index)
	l = len(index_list)
	for i in reversed(index_list):
		cubes.pop(i)
	return (cubes, l)


cubes = input()
for c in cubes:
	if c not in ['0', '1']:
		exit(0)
cube_list = []
for cube in cubes:
	cube_list.append(cube)
l = len(cube_list)
k = 0
while (l != 0):
	cubes, l = next_check(cube_list)
	k += l
print(k)

### FIXED CODE ###

S = input()

num_0 = S.count('0')
num_1 = S.count('1')

print(min(num_0, num_1)*2)
aaaa = input()
A = [int(x) for x in input().split()]


for i in range(len(A)-1):
  s1 = sum(A[:i+1])
  s2 = sum(A[i+1:])
  if s1 >= s2:
    print(abs(s1-s2))
    break

### FIXED CODE ###

A = [int(x) for x in input().split()]

print(sum(sorted(A)[:-1]))
h,w = map(int,input().split())
a = ['#'*(w+2)]+['#'+input()+'#' for _ in range(h)]+['#'*(w+2)]
ans = 0
while True:
    l = []
    for i in range(1,h+1):
        for j in range(1,w+1):
            if a[i][j]=='#':
                l += [i,j]
    if len(l)==h*w:
        break
    ans += 1
    for l_ in l:
        a[l_[0]-1] = a[l_[0]-1][:l_[1]]+'#'+a[l_[0]-1][l_[1]+1:]
        a[l_[0]] = a[l_[0]][:l_[1]-1]+'###'+a[l_[0]][l_[1]+2:]
        a[l_[0]+1] = a[l_[0]+1][:l_[1]]+'#'+a[l_[0]+1][l_[1]+1:]
print(ans)

### FIXED CODE ###

h,w = map(int,input().split())
a = [input() for _ in range(h)]
ans = 0
queue = []
for i in range(h):
    for j in range(w):
        if a[i][j]=='#':
            queue.append([i,j])
from collections import deque
queue = deque(queue)
dxy = [(0,1), (0,-1), (1,0), (-1,0)]
dp = [[10**4]*w for _ in range(h)]
for i,j in queue:
    dp[i][j] = 0
while len(queue):
    y,x = queue.popleft()
    d = dp[y][x]
    for dx,dy in dxy:
        nx, ny = x+dx, y+dy
        if not 0<=nx<=w-1:
            continue
        elif not 0<=ny<=h-1:
            continue
        elif dp[ny][nx]<=d+1:
            continue
        dp[ny][nx] = d+1
        queue.append((ny,nx))
print(max([max(dp[row]) for row in range(h)]))
W,H,x,y,r = map(int,raw_input().split())

if (r <= x <= W-r) AND (r < y < H-r):
    print"Yes"
else:
    print"No"

### FIXED CODE ###

W,H,x,y,r = map(int,raw_input().split())

if (r <= x <= W - r) and (r <= y <= H - r):
    print "Yes"
else:
    print "No"
while True:
	input = raw_input()
	splited = input.split()
	num = int(splited[0])+int(splited[1])
	print len(str(num))

### FIXED CODE ###

while True:
	try:
		a,b = map(int, raw_input().split())
		print len(str(a+b))
	except EOFError:
		break
A, B, C = map(int, input().split())
print(B + min(A+B+1, c))

### FIXED CODE ###

A, B, C = map(int, input().split())
print(B + min(A+B+1, C))
#include <iostream>
using namespace std;
int main(void){
    int n,i,j;
    
    cin >> n;
    int a[n];
    
    for(i=0;i<n;i++){
        cin >> a[i];
    }
    

    
    for(j=n-1;j>=0;j--){
        if(j==0)
            cout << a[j] << endl;
        else
            cout << a[j] << " ";
    }
    
}



### FIXED CODE ###

n = int(input())
numbers = list(map(int,input().split()))
for i in range(n):
  if i==0:
    print(numbers[n-1],end="")
  else:
    print("",numbers[n-1-i],end="")
print()
S = list(map(int,input().split()))
price = 700 + list.count('○')
print(price)

### FIXED CODE ###

print((input().count("o"))*100+700)
N = int(input())
H = list(map(int,input().split()))
counts = []



for r in range(N-1):
    i=r
    count=0
    while H[i] >= H[i+1]:
        count+=1
        i+=1
        if i == N-1:
            break
    
    counts.append(count)




print(max(counts))

### FIXED CODE ###

N = int(input())
H = list(map(int,input().split()))
max1 = 0
count = 0

for i in range(N-1):
    if H[i] >= H[i+1]:
        count += 1
    else:
        count = 0
    
    if count > max1:
        max1 += 1
print(max1)
a,b,c = input().split()
if('YES' if a[-1]==b[0] and b[-1]==c[0] else 'NO')

### FIXED CODE ###

a,b,c = input().split()
print('YES' if a[-1]==b[0] and b[-1]==c[0] else 'NO')
import sys
N, M = map(int, input().split())
MOD = 10 ** 9 + 7
NMAX = 10 ** 5
sys.setrecursionlimit(NMAX+1)

memo = [None for _ in range(NMAX+1)]
def fibo(n):
    if memo[n]:
        return memo[n]
    if n == 0:
        return 0
    elif n < 3:
        return 1
    else:
        return fibo(n-1) + fibo(n-2)

nc = 1
b = 0
for i in range(M):
    a = int(input())
    nc = (nc * fibo(a - b)) % MOD
    b = a + 1

nc = (nc * fibo(N + 1 - b)) % MOD

print(nc)


### FIXED CODE ###

import sys
N, M = map(int, input().split())
MOD = 10 ** 9 + 7

NG = [False for _ in range(N+1)]
for _ in range(M):
    NG[int(input())] = True

dp = [None for _ in range(N+1)]
dp[0] = 1
dp[1] = 0 if NG[1] else 1
for i in range(2, N+1):
    if NG[i]:
        dp[i] = 0
    else:
        dp[i] = (dp[i-2] + dp[i-1]) % MOD

print(dp[-1])
a = input()
b = input()

q = a/b
r = a%b
q_f = float(a)/float(b)

print q,, r, q_f

### FIXED CODE ###

a,b = map(float, raw_input().split())

if b > 10**6:
  f = 0.0
else:
  f = a/b

d = int(a/b)
r = int(a%b)


print d, r, f
N,K,C=map(int,input().split())
SL=input()
SR=SL[::-1]
Left=[]
Right=[]
Last=-N
Rast=-N
cL=cR=0
for i in range(N):
    if SL[i]=="o" and i-Last>C and cL<=K:
        Left.append(i)
        Last=i
        cL+=1
    if SR[i]=="o" and i-Rast>C and cR<=K:
        Right.append(N-i-1)
        Rast=i
        cR+=1
Right=Right[::-1]

ans=[]

for k in range(K):
    if Left[k]==Right[k]:
        ans.append(Left[k]+1)

if len(ans)==0:
    print()
else:
    for a in ans:
        print(a)

### FIXED CODE ###

N,K,C=map(int,input().split())
SL=input()
SR=SL[::-1]
Left=[]
Right=[]
Last=-N-1
Rast=-N-1
cL=cR=0
for i in range(N):
    if SL[i]=="o" and i-Last>C and cL<=K:
        Left.append(i)
        Last=i
        cL+=1
    if SR[i]=="o" and i-Rast>C and cR<=K:
        Right.append(N-i-1)
        Rast=i
        cR+=1
Right=Right[::-1]

ans=[]
for k in range(K):
    if Left[k]==Right[k]:
        ans.append(Left[k]+1)

if len(ans)==0:
    print()
else:
    for a in ans:
        print(a)
n, m = list(map(int, input().split()))
    item_votes = list(map(int, input().split()))
    total = sum(item_votes)

    selected = []
    isSelected = False

    req = 1 / (4 * m)
    for item in item_votes:
        if item / total >= req:
            selected.append(item)

        if len(selected) == m:
            isSelected = True
            print("Yes")
            break

    if not isSelected:
        print("No")


popularVote()

### FIXED CODE ###

def popularVote():
    n, m = list(map(int, input().split()))
    item_votes = list(map(int, input().split()))
    total = sum(item_votes)

    selected = []
    isSelected = False

    req = 1 / (4 * m)
    for item in item_votes:
        if item / total >= req:
            selected.append(item)

        if len(selected) == m:
            isSelected = True
            print("Yes")
            break

    if not isSelected:
        print("No")


popularVote()
a, b, k = [int(x) for x in input().split()]
lst = list(range(a, b + 1))
res = []
res.extend(lst[:k])
res.extend(lst[-k:])
res = sorted(list(set(res)))
print(*res, sep='\n')


### FIXED CODE ###

a, b, k = [int(x) for x in input().split()]
r = range(a, b + 1)
for i in sorted(set(r[:k]) | set(r[-k:])):
    print(i)
f=t//5
tt=t//3
ff=t//15
f=(f*(f+1)//2 )*5
tt=(tt*(tt+1)//2 )*3
ff =(ff*(ff+1)//2 )*15
print(t*(t+1)//2 - f -tt +ff)


### FIXED CODE ###

t = int(input())
f=t//5
tt=t//3
ff=t//15
f=(f*(f+1)//2 )*5
tt=(tt*(tt+1)//2 )*3
ff =(ff*(ff+1)//2 )*15
print(t*(t+1)//2 - f -tt +ff)
def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

mod = 10**9+7 #出力の制限
N = 10**4
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル

for i in range( 2, N + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )



n = int(input()) 
n += 1
N = n
a = list(map(int,input().split()))

x = y = 0
b = [-1 for i in range(n)]
for i in range(len(a)):
    if b[a[i]] != -1:
        x = b[a[i]]
        y = i
        break 
    else:
        b[a[i]] = i

for k in range(1,n+1):
    print((cmb(N,k,mod)-cmb(N+x-y-1,k-1,mod))%mod)

### FIXED CODE ###

def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

mod = 10**9+7 #出力の制限
N = 10**5+5
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル

for i in range( 2, N + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )



n = int(input()) 
n += 1
a = list(map(int,input().split()))

x = y = 0
b = [-1 for i in range(n)]
for i in range(len(a)):
    if b[a[i]] != -1:
        x = b[a[i]]
        y = i
        break 
    else:
        b[a[i]] = i

for k in range(1,n+1):
    print((cmb(n,k,mod)-cmb(n+x-y-1,k-1,mod))%mod)
def search(M, l, walkable):
    i, j = (l.pop(0))
    nexts = []
    if i !=0:
        nexts.append((i-1, j))
    if i != len(M)-1:
        nexts.append((i+1, j))
    if j != 0:
        nexts.append((i, j-1))
    if j != len(M[0])-1:
        nexts.append((i, j+1))

    for nex in nexts:
        x, y = nex
        if M[x][y] == '.' and not nex in walkable:
            l.append(nex)
            walkable.append(nex)

inp = ''
while '0 0' != (inp = input()):
    i, j = [int(x) for x in inp.split()]
    M = [input() for i in range(j)]
    l = []
    for n in len(M):
        if '@' in M[n]:
            l.append((n, M[n].find('@')))

    walkable = []
    while l:
        search(M, l, walkable)
    print(len(walkable)+1)

### FIXED CODE ###

import queue

def solve(w, h):
    q = queue.Queue()
    m = [['#' for i in range(w+2)] for j in range(h+2)]
    for i in range(h):
        inp = input()
        for j in range(w):
            m[i+1][j+1] = inp[j]
            if m[i+1][j+1] == '@':
                start = [i+1,j+1]
    q.put(start)
    c = 1
    while not q.empty():
        cur = q.get()
        XY = [(1,0), (-1, 0), (0, 1), (0, -1)]
        for x, y in XY:
            cx = cur[0]+x
            cy = cur[1]+y
            if m[cx][cy] == '.':
                m[cx][cy] = '#'
                q.put([cx, cy])
                c+=1
    return c

while True:
    w, h = [int(i) for i in input().split()]
    if w == 0 and h == 0:
        break
    print(solve(w,h))
a,b,n = map(int, input().split())

if b-1>n:
  start = n
else:
  start = (b-1)*(n//(b-1))

ans = 0

for i in range(start, n+1):
  ans = max(ans, (a*i//b)-a*(i//b))

print(ans)

### FIXED CODE ###

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

if b==1:
  print(0)
else:  
  if b-1>n:
    x = n
  else:
    x = (b-1)*(n//(b-1))

  ans = max(a*x//b-a*(x//b), a*n//b-a*(n//b))

  print(ans)
N,K=map(int,input().split())
a=list(map(int,input().split()))
L=[]
for i in range(N):
    for j in range(i+1,N+1):
        L.append(sum(a[i:j]))

L.sort(reverse=True)
M=[]
#print(L)

for j in range(31):
    if 2**(31-j)<=L[0]:
        if 2**(31-j)<=L[K-1]:
            for l in range(N):
                if L[l]>=2**(31-j):
                    M.append(L[l])
            break
        else:
            for k in range(N):
                L[k]=L[k]%(2**(31-j))
            L.sort(reverse=True)
            
ans=0
#print(M)
#print(31-j)
for a in range(31-j):
    if len(M)<K:
        break
    M.sort(reverse=True)
    if M[K-1]>=2**(31-j-a):
        ans+=2**(31-j-a)
        for b in range(len(M)):
            if M[b]>=2**(31-j-a):
                M[b]%=2**(31-j-a)
            else:
                del M[b]
    
        
print(ans)


### FIXED CODE ###

N,K=map(int,input().split())
l=list(map(int,input().split()))
L=[0]
for i in range(N):
    L.append(L[-1]+l[i])
#print(L)
A=[]
for i in range(N):
    for j in range(i+1,N+1):
        A.append(L[j]-L[i])
#print(A)
B=[]
for i in range(len(A)):
    B.append(format(A[i],'040b'))
#print(B)


for i in range(40):
    cnt=0
    for j in B:
        if j[i]=="1":
            cnt+=1
    if cnt>=K:
        S=i
        break

ans=2**(39-S)
C=[]
for j in B:
    if j[S]=="1":
        C.append(j)
        
#print(ans)
#print(C)

for i in range(S+1,40):
    D=[]
    for j in C:
        if j[i]=="1":
            D.append(j)
    if len(D)>=K:
        ans+=2**(39-i)
        C=D
print(ans)
if A == 1 and B == 1:
    print(2)
elif A>0 and B>0 or A<0 and B==0:
    print(A*B)
elif A>=0 and B<0 or A==0 and B<0:
    print(A-B)
else:
    print(A+B)

### FIXED CODE ###

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

if A == 1 and B == 1:
    print(2)
elif A > 1 and B == 1:
    print(A+B)
elif A == 1 and B > 1:
    print(A+B)
elif A < 0 and B < 0:
    print(A*B)
elif A > 0 and B <= 0:
    print(A-B)
elif A <= 0 and B > 0:
    print(A+B) 
else:
    print(A*B)
a = input()
if a.count(9)==1 or a.count(9)==2:
  print("Yes")
else:
  print("No")



### FIXED CODE ###

a = str(input())
if a.count("9")==1 or a.count("9")==2:
  print("Yes")
else:
  print("No")
L, R = map(int, input().split())

LARGE = 10 ** 9 + 7


def get_l(vl, le_r):
    # vl <= L <= R <= 2 ** le_r - 1
    res_ = 0

    if vl == 0:
        res_ += pow(2, le_r, LARGE)
        vl = 1
    for l_ in range(le_r):
        if vl % (2 ** (l_ + 1)) != 0:
            le_total = le_r - bin(vl).count("1")
            res_ += pow(3, l_, LARGE) * pow(2, le_total - l_, LARGE)
            res_ %= LARGE
            vl += 2 ** l_
    return res_


def get_r(vr):
    # 0 <= L <= R <= vr
    if vr == 0:
        return 1
    elif vr == 1:
        return 2
    l_ = 0
    while True:
        if 2 ** (l_ + 1) - 1 > vr:
            break
        l_ += 1

    return (pow(3, l_, LARGE) + 2 * get_r(vr - 2 ** l_)) % LARGE


res = 0
le = 0
left = 2 ** le
right = 2 ** (le + 1) - 1


while True:
    if right < L:
        pass
    elif L <= left <= right <= R:
        res += pow(3, le, LARGE)
    elif R < left:
        break
    elif left <= L <= right <= R:
        res += get_l(L, le + 1)
    elif L <= left <= R <= right:
        res += get_r(R - left)
    else:
        # left <= L <= R <= right:
        # find mid
        mid = left
        for le2 in range(le - 1, -1, -1):
            if L < mid + 2 ** le2 <= R:
                res += get_l(L - mid, le2)
                res += get_r(R - mid)
            elif mid + 2 ** le2 <= L:
                mid += 2 ** le2
            else:
                pass

    res %= LARGE
    le += 1
    left *= 2
    right *= 2
    right += 1

print(res)


### FIXED CODE ###


LARGE = 10 ** 9 + 7

# flag_x : left < x
# flag_y : y < right
# flag_z : msb


def f(pos, flag_x, flag_y, flag_z, memo, left, right):
    if pos == -1:
        return 1
    if memo[pos][flag_x][flag_y][flag_z] != -1:
        return memo[pos][flag_x][flag_y][flag_z]
    ret = 0
    # x 0, y 0
    if flag_x or left[pos] == '0':
        ret += f(pos - 1, flag_x, 1 if right[pos] == '1' else flag_y, flag_z, memo, left, right)
    # x 0, y 1
    if (flag_x or left[pos] == '0') and (flag_y or right[pos] == '1') and flag_z:
        ret += f(pos - 1, flag_x, flag_y, flag_z, memo, left, right)
    # x 1, y 1
    if flag_y or right[pos] == '1':
        ret += f(pos - 1, 1 if left[pos] == '0' else flag_x, flag_y, 1, memo, left, right)
    ret %= LARGE
    memo[pos][flag_x][flag_y][flag_z] = ret
    return ret


def solve_greed_f(L, R):

    res_g = 0

    for i in range(L, R + 1):
        for j in range(i, R + 1):
            if j % i == j ^ i:
                res_g += 1

    return res_g


def main():

    ll, rr = map(int, input().split())

    left = '{:060b}'.format(ll)[::-1]
    right = '{:060b}'.format(rr)[::-1]

    memo = [[[[-1 for m in range(2)] for k in range(2)] for j in range(2)] for i in range(60)]

    res = f(59, 0, 0, 0, memo, left, right)

    print(res)


if __name__ == "__main__":
    main()
s = input
count=0
for i in range(3):
    if s[i]==s[i+1]:
        count+=1
    else:
        count==0
    
    if count==2:
        print("Yes")
        exit()
print("No")

### FIXED CODE ###

s = input()
if (s[0]==s[1] and s[1]==s[2]) or (s[1]==s[2] and s[2]==s[3]):
    print("Yes")
else:
    print("No")
def theather():
  total = 0
  try:
    N = int(input())
    l_r = (list(map(lambda x: int(x), input().split(' '))) for _ in range(N))
  except:
    return
  if not (1 <= N and N <= 1000): return
  for l, r in l_r:
    if 1 <= l and l <= 100000 or 1 <= r and r <= 100000:
      total += r - l + 1
    else:
      return
  print(total)

if __name__ == "__main__":
  theater()

### FIXED CODE ###

def theater():
    total = 0
    try:
        N = int(input())
        l_r = (list(map(lambda x: int(x), input().split(' '))) for elem in range(N))
    except:
        return
    if not (1 <= N and N <= 1000): return
    for l, r in l_r:
        if 1 <= l and l <= 100000 or 1 <= r and r <= 100000:
            total += r - l + 1
        else:
            return
    print(total)

if __name__ == "__main__":
    theater()
S = str(input())

left = -2
right = -2

for i in range(max(1, len(S)-2)):
    if S[i] == S[i+1]:
        left = i
        right = i+1
        break
    if S[i] == S[i+2]:
        left = i
        right = i+2
        break
    if S[i+1] == S[i+2]:
        left = i+1
        right = i+2
        break

print(left+1, right+1)


### FIXED CODE ###

S = str(input())

left = -2
right = -2

for i in range(max(1, len(S)-2)):
    if S[i] == S[i+1]:
        left = i
        right = i+1
        break
    if len(S) == 2:
        break
    if S[i] == S[i+2]:
        left = i
        right = i+2
        break
    if S[i+1] == S[i+2]:
        left = i+1
        right = i+2
        break

print(left+1, right+1)
x,y,z = map(int, input().split())
if (z+y)%2==1:
	print(min(max(y,z)-1, max(x-y,x-z))
else:
	print((abs(y-z)+1)//2)


### FIXED CODE ###

x,y,z = map(int, input().split())
if (z+y)%2==1:
        d = min(y + z - 2, 2*x-y-z)+1
        print(d//2)
else:
	print((abs(y-z)+1)//2)
N = int(input())
h = [int(x) for x in input().split()]
dp = []
dp1 = 0
dp2 = 0
for i in range(N):
    if i == 0:
        dp.append(0)
        continue

    if i == 1:
        dp.append(abs(h[0] - h[1]))
        continue

    dp1 = dp[i - 1] + abs(h[i] - h[i - 1])
    dp2 = dp[i - 2] + abs(h[i] - h[i - 2])

    if dp1 < dp2:
        dp.append(dp1)
    else:
        dp.append(dp2)
return dp[-1]


### FIXED CODE ###

N = int(input())
h = [int(x) for x in input().split()]
dp = []
dp1 = 0
dp2 = 0
for i in range(N):
    if i == 0:
        dp.append(0)
        continue

    if i == 1:
        dp.append(abs(h[0] - h[1]))
        continue

    dp1 = dp[i - 1] + abs(h[i] - h[i - 1])
    dp2 = dp[i - 2] + abs(h[i] - h[i - 2])

    if dp1 < dp2:
        dp.append(dp1)
    else:
        dp.append(dp2)
print(dp[-1])
while True:
    a, op, b = input().split()
    a = int(a)
    b = int(b)
    if op = '+':
        print(a + b)
    elif op = '-':
        print(a - b)
    elif op = '*'
        print(a * b)
    elif op = '/':
        print(a // b)
    else
        break

### FIXED CODE ###

while True:
    a, op, b = input().split()
    a = int(a)
    b = int(b)
    if op == '+':
        print(a + b)
    elif op == '-':
        print(a - b)
    elif op == '*':
        print(a * b)
    elif op == '/':
        print(a // b)
    else:
        break
N, M = map( int, input().split())
A = list( map( int, input().split()))
C = [0,2,5,5,4,5,6,3,7,6]
dp = [(0,0)]*(N+1)
for a in A:
    dp[C[a]] = (1,0)
Z = sorted(list( set( C[a] for a in A)))
for i in range(2,N+1):
    for z in Z:
        if i >= z:
            if dp[i-z][0] == 1:
                dp[i] = (1, i-z)
                break
s = N
ANS = [0]*10
while s != 0:
    _, b = dp[s]
    ANS[s-b] += 1
    if s == b:
        break
    s = b
ans = ""
for i in range(9,0,-1):
    if ANS[C[i]] > 0:
        if i in A:
            ans += str(i)*ANS[C[i]]
            ANS[C[i]] = 0
print( ans)


### FIXED CODE ###

N, M = map( int, input().split())
A = list( map( int, input().split()))
Needs = [0,2,5,5,4,5,6,3,7,6]
A.sort(reverse = True)
V = [0]*10
Check = []
for a in A:
    if V[Needs[a]] == 0:
        Check.append(Needs[a])
        V[Needs[a]] = a
Check.sort()
dp = [-100000]*(N+1)
dp[0] = 0

for x in Check:
    if x <= N:
        dp[x] = 1
for i in range(1,N):
    t = dp[i]
    for x in Check:
        if x + i <= N:
            if dp[x+i] < t + 1:
                dp[x+i] = t+1
ans = ""
t = N
W = [0]*10
while t > 0:
    for a in A:
        x = Needs[a]
        if t-x>=0:
            if dp[t-x]+1 == dp[t]:
                W[V[x]] += 1
                t -= x
                break
for i in range(9,0,-1):
    ans += str(i)*W[i]
print(ans)
L=[int(x) for x in input().split()]
sum=0
product=0
mod=1000000007
for i in range(n):
    sum+=L[i]%mod
for i in range(n-1):
    sum-=(L[i]%mod)
    product+=sum*(L[i]%mod)
print(product)

### FIXED CODE ###

n=int(input())
L=[int(x) for x in input().split()]
sum=0
product=0
mod=1000000007
for i in range(n):
    sum+=L[i]%mod
for i in range(n-1):
    sum-=(L[i]%mod)
    product+=sum*(L[i]%mod)
print(product%mod)
n, m = map(int, input().split())
a = list(map(int, input().split()))

a.sort()

for i in range(m):
  a[-1] = int(a[-1] / 2)
  if a[-1] < max(a[0:n-2]):
    a[-1], a[a.index(max(a[0:n-2]))] = a[a.index(max(a[0:n-2]))], a[-1]
    
print(sum(a))

### FIXED CODE ###

import heapq

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

def minus_int(x):
  return -1 * int(x)

a = list(map(minus_int, input().split()))
heapq.heapify(a)

for i in range(m):
  maxp = heapq.heappop(a)
  maxp = -int(-maxp // 2)
  heapq.heappush(a, maxp)
  
print(-sum(a))
A = input()
B = input()
A = int(A)
B = int(B)

if A+B == 3:
    ans = 3
elif A+B == 4:
    ans == 2
elif A+B == 5:
    ans == 1

### FIXED CODE ###

A = input()
B = input()
A = int(A)
B = int(B)

if A+B == 3:
    ans = 3
elif A+B == 4:
    ans = 2
elif A+B == 5:
    ans = 1
print(ans)
N,A,B,C=[int(i) for i in input().split()]
l=[int(input()) for _ in range(n)]
INF=10**18

def dfs(cur, a, b, c):
    if cur==N:
        return abs(a-A)+abs(b-B)+abs(c-C)-30 
    ret0 = dfs(cur+1,a,b,c)
    ret1 = dfs(cur+1,a+l[cur],b,c)+10
    ret2 = dfs(cur+1,a,b+l[cur],c)+10    
    ret3 = dfs(cur+1,a,b,c+l[cur])+10    
    return min(ret0,ret1,ret2,ret3)

print(dfs(0,0,0,0))

### FIXED CODE ###

N,A,B,C=[int(i) for i in input().split()]
l=[int(input()) for _ in range(N)]
INF=10**18

def dfs(cur, a, b, c):
    if cur==N:
        return abs(a-A)+abs(b-B)+abs(c-C)-30 if min(a,b,c)>0 else INF
    ret0 = dfs(cur+1,a,b,c)
    ret1 = dfs(cur+1,a+l[cur],b,c)+10
    ret2 = dfs(cur+1,a,b+l[cur],c)+10
    ret3 = dfs(cur+1,a,b,c+l[cur])+10
    return min(ret0,ret1,ret2,ret3)

print(dfs(0,0,0,0))