Harryxun/stf_run huggingface dataset:
N = int(input())

import math

def sieve_of_eratosthenes(n):
    candidate = [i for i in range(2, n+1)]
    prime = []
    limit = math.sqrt(n) + 1

    while True:
        p = min(candidate)
        if limit <= p:
            prime.extend(candidate)
            break
        prime.append(p)

        candidate = [i for i in candidate if i % p != 0]

    return prime


if N == 1:
    print(0)
    exit()

rn = math.ceil(math.sqrt(N))
L = sieve_of_eratosthenes(rn)

n = N
c = 0
used = []

for l in L:
    if n % l == 0:
        i = 1
        l2 = l
        while n % l2 == 0:
            c += 1
            i += 1
            used.append(l2)
            n = n // l2
            l2 = l ** i

if c == 0:
    print(1)
else:
    if n != 1:
        x = sieve_of_eratosthenes(n)
        if n in x and not n in used:
            c += 1
    print(c)


### FIXED CODE ###

N = int(input())

# import math
#
# def sieve_of_eratosthenes(n):
#     candidate = [i for i in range(2, n+1)]
#     prime = []
#     limit = math.sqrt(n) + 1
#
#     while True:
#         p = min(candidate)
#         if limit <= p:
#             prime.extend(candidate)
#             break
#         prime.append(p)
#
#         candidate = [i for i in candidate if i % p != 0]
#
#     return prime
#
#
# if N == 1:
#     print(0)
#     exit()
#
# rn = math.ceil(math.sqrt(N))
# L = sieve_of_eratosthenes(rn)
# print('hoge')
#
# n = N
# c = 0
# used = {}
#
# for l in L:
#     if n % l == 0:
#         i = 1
#         l2 = l
#         while n % l2 == 0:
#             c += 1
#             i += 1
#             used[l2] = True
#             n = n // l2
#             l2 = l ** i
#
# if c == 0:
#     print(1)
# else:
#     if n != 1:
#         # x = sieve_of_eratosthenes(n)
#         if n not in used:
#             c += 1
#     print(c)

# if N == 1:
#     print(0)
#     exit()
#
# ans = 0
# used = {}
#
# n = N
# i = 1
# p = 2
# while n % p == 0:
#     ans += 1
#     n = n // p
#     used[p] = True
#     i += 1
#     p = 2**i
#
#
# i = 1
# p = 3
# k = p
# while p * p <= N:
#     while n % k == 0:
#         if k in used:
#             i += 1
#             k = k ** i
#         else:
#             ans += 1
#             i += 1
#             n = n // k
#             used[k] = True
#             k = k ** i
#     i = 1
#     p += 2
#     k = p
#
# if n not in used and n != 1:
#     ans += 1
# print(ans)

def factorize(n):
    a = []
    # 2で割り切れるまでnを割り続ける
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    # 3からはじめて各奇数で割り切れるまでnを割り続ける
    # nの最大約数は√nなので、f*fで計算
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

fs = factorize(N)

from collections import Counter
c = Counter(fs)

ans = 0
i = 1
for k, v in c.items():
    k2, v2 = k,v
    while v2 >= i:
        ans += 1
        v2 -= i
        i += 1
    i = 1

print(ans)
# _*_ coding:utf-8 _*_

import sys

input = sys.stdin.readline()
ans  = 1000

for c in input:
	s = input.split(f'{c}')
	max = 0
	for i in range(len(s)):
		if max < len(s[i]):
			max = len(s[i])
	
	if ans > max:
		ans = max
		
print(ans) 

### FIXED CODE ###

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

import sys

input = sys.stdin.readline().replace('\n','')
ans  = 1000

for c in input:
	s = input.split(c)
	ma = 0
	for i in range(len(s)):
		if ma < len(s[i]):
			ma = len(s[i])
	
	if ans > ma:
		ans = ma
		
print(ans,end='')
k=int(input())
print(k**"ACL")

### FIXED CODE ###

k=int(input())
s="ACL"
for i in range(k):
  print(s,end="")
N = int(input())
edges = [[] for _ in range(N)]
for i in range(N-1):
    a,b = map(int,input().split())
    a -= 1
    b -= 1
    edges[a].append((b,i))
    edges[b].append((a,i))

color = [None]*(N-1)
SIZE = 1
def dfs(i, prev):
    global SIZE
    colors = list(range(1, SIZE+1))
    if prev:
        colors.remove(prev)
    for j, n in edges[i]:
        if not color[n]:
            if not colors:
                SIZE += 1
                color[n] = SIZE
            else:
                color[n] = colors.pop()
            dfs(j, color[n])
dfs(0, None)
print(SIZE)
for n in range(N-1):
    print(color[n])

### FIXED CODE ###

if __name__ == "__main__":
    import sys
    from collections import deque
    input = sys.stdin.readline
    N = int(input())
    edges = [[] for _ in range(N)]
    for i in range(N-1):
        a,b = map(int,input().split())
        a -= 1
        b -= 1
        edges[a].append((b,i))
        edges[b].append((a,i))

    color = [None]*(N-1)
    SIZE = 1
    q = deque([(0,None)])
    while q:
        v, prev_color = q.popleft()
        c = 1
        for w, i in edges[v]:
            if not color[i]:
                if c == prev_color:
                    c += 1
                color[i] = c
                c += 1
                q.append((w,color[i]))
        SIZE = max(SIZE, c-1)
    print(SIZE)
    for n in range(N-1):
        print(color[n])
import sys
stdin = sys.stdin
 
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nn = lambda: list(stdin.readline().split())
ns = lambda: stdin.readline().rstrip()
 
import bisect
 
n,q = na()
s = ns()
x = []
 
for r in range(len(s)):
  if s[r] == 'A':
    if s[r+1] == 'C':
      x.append(r)
 
for i in range(q):
  l,r = na()
  k = [j for j in x if j >= l-1 and j <= r-2]
  print(len(k))

### FIXED CODE ###

import sys
stdin = sys.stdin
 
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nn = lambda: list(stdin.readline().split())
ns = lambda: stdin.readline().rstrip()
 
import bisect
 
n,q = na()
s = ns()
x = []
 
for r in range(len(s)-1):
  if s[r] == 'A':
    if s[r+1] == 'C':
      x.append(r)
 
for i in range(q):
  l,r = na()
  b = bisect.bisect_left(x,l-1)
  a = bisect.bisect_right(x,r-2)
  c = a-b if a-b>0 else 0
  print(c)
dp = [[0]*3 for i in range(n)]
dp[0] = abc[0]

for i in range(1,n):
    dp[i][0] = max(dp[i][1:3]) + abc[i][0]
    dp[i][1] = max(dp[i][0], dp[i][2]) + abc[i][1]
    dp[i][2] = max(dp[i][0:2]) + abc[i][2]
max(dp[n-1])

### FIXED CODE ###

n = int(input())
abc = [list(map(int, input().split())) for i in range(n)]

dp = [[0]*3 for i in range(n)]
dp[0] = abc[0]

for i in range(1,n):
    dp[i][0] = max(dp[i-1][1:3]) + abc[i][0]
    dp[i][1] = max(dp[i-1][0], dp[i-1][2]) + abc[i][1]
    dp[i][2] = max(dp[i-1][0:2]) + abc[i][2]
print(max(dp[n-1]))
a = int(input())
b = int(input())
h = int(input())

print((a + b) * h / / 2)

### FIXED CODE ###

a = int(input())
b = int(input())
h = int(input())

print((a + b) * h // 2)
#56 ABC136E
n,k=map(int,input().split())
a=list(map(int,input().split()))
s=sum(a)

res=[]
for d in range(1,int(s**0.5)+1):
	if s%d==0:
		res.append(d)
		res.append(s//d)
ans=[]
for d in res:
	r1=[t%d for t in a]
	r1.sort()
	r2=[d-t for t in r1]
	r2=r2[::-1]
	x=[r1[0]]
	_=[x.append(x[-1]+r1[i]) for i in range(1,n)]
	y=[r2[0]]
	_=[y.append(y[-1]+r2[i]) for i in range(1,n)]
	#print(r1,r2,d,x,y)
	for i in range(n-1):
		#print(x[i],y[-i-2])
		if x[i]==y[-i-2] and x[i]<k:
			ans.append(d)
print(max(ans))

### FIXED CODE ###

#56 ABC136E
n,k=map(int,input().split())
a=list(map(int,input().split()))
s=sum(a)

res=[]
for d in range(1,int(s**0.5)+1):
	if s%d==0:
		res.append(d)
		res.append(s//d)
ans=[]
for d in res:
	r1=[t%d for t in a]
	r1.sort()
	r2=[(d-t)%d for t in r1]
	r2=r2[::-1]
	x=[r1[0]]
	_=[x.append(x[-1]+r1[i]) for i in range(1,n)]
	y=[r2[0]]
	_=[y.append(y[-1]+r2[i]) for i in range(1,n)]
	#print(r1,r2,d,x,y)
	for i in range(n-1):
		#print(x[i],y[-i-2])
		if x[i]==y[-i-2] and x[i]<=k:
			ans.append(d)
			break
print(max(ans))
from collections import deque    
H,W = map(int, input().split())
maze = []
ans = 0
dist =[]
q = deque([])

for i in range(H):
    maze.append(input())

for i in range(H):
    for j in range(W):
        dist = [[-1]*W for i in range(H)] # 配列の初期化
        q.append([i,j]) #初期値挿入
        dist[i][j] = 0
        while(q):
            a,b = q.popleft()
            if a + 1 < H:
                if maze[a+1][b] == '.' and dist[a+1][b] == -1:
                    q.append([a+1, b])
                    dist[a+1][b] = dist[a][b] + 1
                    tmp = dist[a+1][b] 
            if a > 0:
                if maze[a-1][b] == '.' and dist[a-1][b] == -1:
                    q.append([a-1, b])
                    dist[a-1][b] = dist[a][b] + 1
                    tmp = dist[a-1][b]
            if b + 1 < W:
                if maze[a][b+1] == '.' and dist[a][b+1] == -1:
                    q.append([a, b+1])
                    dist[a][b+1] = dist[a][b] + 1
                    tmp = dist[a][b+1]
            if b > 0:
                if maze[a][b-1] == '.' and dist[a][b-1] == -1:
                    q.append([a, b-1])
                    dist[a][b-1] = dist[a][b] + 1
                    tmp = dist[a][b-1]
        ans = max(ans,tmp)


print(ans)

### FIXED CODE ###

from collections import deque    
H,W = map(int, input().split())
maze = []
ans = 0
dist =[]
q = deque([])
tmp = 0

for i in range(H):
    maze.append(input())

for i in range(H):
    for j in range(W):
        if maze[i][j] == '#':
            continue
        dist = [[-1]*W for i in range(H)] # 配列の初期化
        q.append([i,j]) #初期値挿入
        dist[i][j] = 0
        while(q):
            a,b = q.popleft()
            if a + 1 < H:
                if maze[a+1][b] == '.' and dist[a+1][b] == -1:
                    q.append([a+1, b])
                    dist[a+1][b] = dist[a][b] + 1
                    tmp = dist[a+1][b] 
            if a > 0:
                if maze[a-1][b] == '.' and dist[a-1][b] == -1:
                    q.append([a-1, b])
                    dist[a-1][b] = dist[a][b] + 1
                    tmp = dist[a-1][b]
            if b + 1 < W:
                if maze[a][b+1] == '.' and dist[a][b+1] == -1:
                    q.append([a, b+1])
                    dist[a][b+1] = dist[a][b] + 1
                    tmp = dist[a][b+1]
            if b > 0:
                if maze[a][b-1] == '.' and dist[a][b-1] == -1:
                    q.append([a, b-1])
                    dist[a][b-1] = dist[a][b] + 1
                    tmp = dist[a][b-1]
        ans = max(ans,tmp)


print(ans)
import math

n = int(input())
a = list(map(int,input().split()))
ans = a[0]

for i,item in enumerate(a):
    if i != 0:
        ans = math.gcd(ans,item)

print(ans,end='')

### FIXED CODE ###

from fractions import gcd

n = int(input())
a = list(map(int,input().split()))
ans = a[0]

for i,item in enumerate(a):
    if i != 0:
        ans = gcd(ans,item)

print(ans,end='')
n = int(input())
a = list(map(int,input().split()))

new = 1
for i in a:
	
	new *= a
	if new > (10**18):
		new = -1
		break
print(new)		
	


### FIXED CODE ###

n = int(input())
a = list(map(int,input().split()))
new = 1
if 0 in a:
	print(0)
	exit()
for i in a:
	new *= i
	if new > (10**18):
		new = -1
		break
print(new)
N,K=map(int,input().split())
P=list(map(int,input().split()))
kouho=[]
def saikorokitaiti(A):
    return ((P[A]*(1+P[A])/2)/P[A])
kari=[]
hako=[]
for i in range(N-K+1):
    if i == 0:
        for j in range(K):
            hako.append(saikorokitaiti(i+j))
        if K==1:
            print(sum(hako))
            exit()
    else:
        hako.append(saikorokitaiti(i+K-1))
        hako.pop(0)
        kouho.append(sum(hako))

print(max(kouho))

### FIXED CODE ###

import sys
input = sys.stdin.readline
N,K=map(int,input().split())
P=list(map(int,input().split()))
kouho=0
def saikorokitaiti(A):
    return ((P[A]*(1+P[A])/2)/P[A])
kari=[]
hako=[]
kitaiti=0
if K==1:
    print(saikorokitaiti(P.index(max(P))))
    exit()
for i in range(K):
    hako.append(saikorokitaiti(i))
    kitaiti+=saikorokitaiti(i)
    kouho=kitaiti
b=0
for j in range(N-K+1):
    if j==0:
        continue
    elif j+K-1<N:
        hako.append(saikorokitaiti(j+K-1))
        kitaiti+=saikorokitaiti(j+K-1)
        kitaiti-=hako[b]
        b+=1
        kouho=max(kouho,kitaiti)
#print(kouho)
print(kouho)
X, N = [int(i) for i in input().split()]
if N == 0:
# if False:
    print(X)
else:
    Ps = set([int(i) for i in input().split()])
    if X not in Ps:
        print(X)

    # print(f'{X} {sorted(Ps)}')
    diff = 0
    while True:
        a = X - diff
        if a not in Ps:
            print(a)
            break
        a = X + diff
        if a not in Ps:
            print(a)
            break
        diff += 1

### FIXED CODE ###

#!python
given = [int(i) for i in input().split()]
ans = [1,2,3,4,5]

for i in range(len(ans)):
    if ans[i] != given[i]:
        print(ans[i])
        break
N = int(input())
res = 'No'
for i in range(int(100/7)+1):
	for j in range(int(100/4)+1):
		a = i*7 + j*4
		if int(N) == a:
			res='Yes'
print(res)


### FIXED CODE ###

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

a = [0] * K

for i in range(N):
  a[i%K] +=1

print(max(a) - min(a))
n=int(input())

def dfs(s):
  if int(s)>n:
    return 0
  cnt=1 if all(s.count(i)>0 for i in '753') else 0
  for j in '753':
    cnt+=dfs(s+j)
  retunr cnt
  
print(dfs('0')

### FIXED CODE ###

n=int(input())

def dfs(s):
  if int(s)>n:
    return 0
  cnt=1 if all(s.count(i)>0 for i in '753') else 0
  for j in '753':
    cnt+=dfs(s+j)
  return cnt
  
print(dfs('0'))
import bisect
from itertools import accumulate
# python template for atcoder1
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline


def brute():
    N, K = map(int, input().split())
    L = [int(input()) for _ in range(N)]
    ans = 0
    for i in range(N):
        for j in range(i, N):
            if sum(L[i:j+1])/(j+1-i) >= K:
                ans += 1

    print(ans)


def solve():
    N, K = map(int, input().split())
    L = [int(input()) for _ in range(N)]

    L_acc = [0]+list(accumulate(L))
    for i in range(N+1):
        L_acc[i] -= (i)*K

    L_sort = list(set(sorted(L_acc)))
    L_comp = [-1]*(N+1)
    for i in range(N+1):
        key = L_acc[i]
        ind = bisect.bisect_left(L_sort, key)
        L_comp[i] = ind
    # BIT
    bit = [0]*(N+1)

    def sum_bit(i):
        s = 0
        while i > 0:
            s += bit[i]
            i -= i & (-i)
        return s

    def add(i, x):
        while i <= N:
            bit[i] += x
            i += i & (-i)

    ans = 0
    for i, l in enumerate(L_comp):
        if l == 0:
            ans += N-i
            continue
        ans += sum_bit(l)
        add(l, 1)
    print(ans)


solve()


### FIXED CODE ###

import bisect
from itertools import accumulate
# python template for atcoder1
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline


def solve():
    N, K = map(int, input().split())
    L = [int(input()) for _ in range(N)]

    L_acc = [0]+list(accumulate(L))
    for i in range(N+1):
        L_acc[i] -= (i)*K

    L_sort = list(sorted(set(L_acc)))
    L_comp = [-1]*(N+1)
    for i in range(N+1):
        key = L_acc[i]
        ind = bisect.bisect_left(L_sort, key)
        L_comp[i] = ind
    # BIT
    bit = [0]*(N+1)

    def sum_bit(i):
        s = 0
        while i > 0:
            s += bit[i]
            i -= i & (-i)
        return s

    def add(i, x):
        while i <= N:
            bit[i] += x
            i += i & (-i)

    ans = 0
    for i, l in enumerate(L_comp):
        if l == 0:
            ans += N-i
            continue
        ans += sum_bit(l)
        add(l, 1)
    print(ans)


solve()
a, b, c, d = map(int, input().split())
ans = 0
if abs(a-c) <= d: 
    ans = 1
if abs(a-b) <= d && abs(b-c) <= d: 
    ans = 1
if ans == 1:
    print("Yes")
else
	print("No")

### FIXED CODE ###

a, b, c, d = map(int, input().split())
ans = 0
if abs(a-c) <= d: 
    ans = 1
if abs(a-b) <= d and abs(b-c) <= d: 
    ans = 1
if ans == 1:
    print("Yes")
else:
	print("No")
n = int(input())
graph = [[] for _ in range(n)]
factorial = [1]*(n+1)
for i in range(1,n+1):
    factorial[i] = factorial[i-1]*i
mod = 10**9 + 7
for _ in range(n-1):
    a,b=map(int,input().split())
    graph[a-1].append(b-1)
    graph[b-1].append(a-1)

for i in range(n):
    ch = [[] for _ in range(n)]
    pa = [[] for _ in range(n)]
    dp = [[1,1] for _ in range(n)]
    checked = []
    stack = [i]
    stack2 = []
    while stack:
        a = stack.pop()
        checked.append(a)
        if a != i and len(graph[a]) == 1:
            stack2.append(a)
        else:
            for j in graph[a]:
                if j in checked:
                    continue
                else:
                    checked.append(j)
                    stack.append(j)
                    pa[j].append(a)
                    ch[a].append(j)
    checked = []
    while stack2:
        a = stack2.pop()
        if a == i:
            print(dp[i][0])
            break
        else:
            p = pa[a][0]
            dp[p][0] *= dp[a][0]*pow(factorial[dp[a][1]],mod-2,mod)
            dp[p][0] %= mod
            dp[p][1] += dp[a][1]
            ch[p].remove(a)
            if len(ch[pa[a][0]]) == 0:
                dp[p][0] *= factorial[dp[p][1]-1]
                dp[p][0] %= mod
                stack2.append(p)
            checked.append(a)

### FIXED CODE ###

n = int(input())
graph = [[] for _ in range(n+1)]
for _ in range(n-1):
    a,b=map(int,input().split())
    graph[a].append(b)
    graph[b].append(a)
mod = 10**9 + 7
factorial = [1]*(n+1)
factorial_inv = [1]*(n+1)
for i in range(1,n+1):
    factorial[i] = factorial[i-1]*i%mod
factorial_inv[n] = pow(factorial[n],mod-2,mod)
for i in range(n,0,-1):
    factorial_inv[i-1] = factorial_inv[i]*i%mod

pa = [0]*(n+1)
dp = [1]*(n+1)
size = [1]*(n+1)
checked = []
stack = [i]
while stack:
    a = stack.pop()
    checked.append(a)
    for j in graph[a]:
        if pa[a] == j:   
            continue
        else:
            stack.append(j)
            pa[j] = a

for i in checked[::-1]:
    p = pa[i]
    s = size[i]
    dp[i] *= factorial[s-1]
    dp[i] %= mod
    dp[p] *= dp[i]*factorial_inv[s]
    dp[p] %= mod
    size[p] += s

size_ = [n-i+1 for i in size]
dp_ = [1]*(n+1)
for i in checked[1:]:
    p = pa[i]
    dp_[i] *= dp[p]
    dp_[i] *= factorial_inv[size[p]-1]
    dp_[i] *= pow(dp[i],mod-2,mod)
    dp_[i] *= factorial[size[i]]
    dp_[i] *= dp_[p]
    dp_[i] *= factorial_inv[size_[p]-1]
    dp_[i] *= factorial[size_[i]-2]
    dp_[i] %= mod
    
for i in range(1,n+1):
    ans = factorial[n-1]*dp[i]*dp_[i]*factorial_inv[size[i]-1]*factorial_inv[size_[i]-1]
    ans %= mod
    print(ans)
n, m = [int(x) for x in input().split()]

answers = []
for x in range(m):
    answers.append(input().split())

correct_answers = [answer[0] for answer in answers if answer[1] == "AC"]

temp = {k[0]: [] for k in answers}
for x in answers:
    temp[x[0]].append(x[1])

penalties = 0
for x in temp:
    G = temp[x][:temp[x].index("AC")]
    penalties += len(G)


print(len(set(correct_answers)), penalties)


### FIXED CODE ###

n, m = [int(x) for x in input().split()]

answers = []
for x in range(m):
    answers.append(input().split())

correct_answers = set([answer[0] for answer in answers if answer[1] == "AC"])

temp = {k[0]: [] for k in answers}
for x in answers:
    temp[x[0]].append(x[1])

penalties = 0
for x in temp:
    if (temp[x].count("AC") > 0):
        G = temp[x][:temp[x].index("AC")]
        penalties += len(G)


print(len(correct_answers), penalties)
n = int(input())
v = list(map(int,input().split()))
v_odd = []
v_even = []
for i in range(n//2):
    v_odd.append()
    v_even.append()
p1 = 0
p2 = 0
q1 = 0
q2 = 0
o_max = -1
e_max = -1
for i in range(n//2):
    a = v_odd[i]
    b = v_even[i]
    x = v_odd.count(a)
    y = v_even.count(b)
    if p1 <= x:
        if o_max != a:
            o_max = a
            p2 = p1
            p1 = x
    else:
        if x > p2:
            p2 = x
    if q1 <= y:
        if e_max != b:
            e_max = b
            q2 = q1
            q1 = y
    else:
        if y > q2:
            q2 = y
s = p1 + q1
if p1 == q1:
    if o_max == e_max:
        s = max(p2,q2) + p1
elif p1 > q2:
    if o_max == e_max:
        s = p1 + q2
else: 
    if o_max == e_max:
        s = p2 + q1
ans = n - s
print(ans)
  
        


### FIXED CODE ###

n = int(input())
v = list(map(int,input().split()))
v_odd = []
v_even = []
d_odd = {}
d_even = {}
o = []
e = []
for i in range(n//2):
    a = v[2*i]
    b = v[2*i+1]
    if a in d_odd:
        d_odd[a] += 1
    else:
        d_odd[a] = 1
        o.append(a)
    if b in d_even:
        d_even[b] += 1
    else:
        d_even[b] = 1
        e.append(b)
O = 0
E = 0
o_max = 0
o_second = 0
e_max = 0
e_second = 0
for i in o:
    x = d_odd[i]
    if x >= o_max:
        O = i
        o_max = x
d_odd.pop(O)
o.remove(O)
for i in o:
    x = d_odd[i]
    if x >= o_second:
        o_second = x
for i in e:
    y = d_even[i]
    if y >= e_max:
        E = i
        e_max = y
d_even.pop(E)
e.remove(E)
for i in e:
    y = d_even[i]
    if y >= e_second:
        e_second = y
if O == E:
    m = max(o_max+e_second,e_max+o_second)
else:
    m = o_max + e_max
print(n-m)
N, M = [int(x) for x in input().split()]
a = sorted([int(x) for x in input().split()])
INF = 10**9

num = [0, 2, 5, 5, 4, 5, 6, 3, 7, 6]

keta = [-INF for _ in range(N+1)]
keta[0] = 0
for i in range(1, N+1):
    cand = [keta[i-num[aa]] for aa in a if i-num[aa] >= 0]
    if len(cand) > 0:
        keta[i] = max(cand) + 1

n = N
ans = ""
while n > 0:
    cand = [aa for aa in a if keta[n]-1 == keta[n-num[aa]]]
    if len(cand) > 0:
        ans += str(max(cand))
        n = n - num[max(cand)]
print(ans)


### FIXED CODE ###

N, M = [int(i) for i in input().split()]
a = [int(i) for i in input().split()]
a.sort()                        # 破壊的。返り値はNone

# print(N, M)
# print(a)

num = [0, 2, 5, 5, 4, 5, 6, 3, 7, 6]


dp = [-999 for _ in range(N+1)]
dp[0] = 0
for i in range(N+1):
    n = [dp[i-num[a[j]]] for j in range(M) if i-num[a[j]] >= 0]
    if len(n) > 0:
        dp[i] = max(n) + 1

# print(dp)

i = N
ans = ""
for _ in range(dp[N]):
    # print("i", i)
    # c = [(a[j], dp[i-num[a[j]]], dp[i]) for j in range(M)]
    # print("c", c)
    if dp[i] > 1:
        b = max([a[j] for j in range(M)
                 if i - num[a[j]] >= 0 and dp[i-num[a[j]]] + 1 == dp[i]])
        ans += str(b)
    else:
        b = max([a[j] for j in range(M)
                 if i - num[a[j]] == 0 and dp[i-num[a[j]]] + 1 == dp[i]])
        ans += str(b)
        break
    # print("ans", ans)
    i = i-num[b]
    # print(i)
print(ans)
N,M=map(int,input().split())
P=[[] for i in range(N+1)]
Y=[]
id=[[] for i in range(N+1)]
for i in range(M):
    a,b=map(int,input().split())
    P[a].append(b)
    Y.append(b)
for i in range(N+1):
    P[i].sort()
for i in range(1,N+1):
    j=1
    for p in P[i]:
        id[Y.index(p)]=str(i*1000000+j)
        j+=1
for i in range(M):
    print(id[i].zfill(12))


### FIXED CODE ###

N,M=map(int,input().split())
P=[[] for i in range(M)]
Y=[1 for i in range(N+1)]
for i in range(M):
    a,b=map(int,input().split())
    P[i].append(i)
    P[i].append(a)
    P[i].append(b)
P.sort(key=lambda x:x[2])
for i in range(M):
    P[i].append(str(P[i][1]*1000000+Y[P[i][1]]))
    Y[P[i][1]]+=1
P.sort(key=lambda x:x[0])
for i in range(M):
    print(P[i][3].zfill(12))
n,m=map(int,input().split())
for num	in input().split():
  n-=num
print(n if n>=0 else -1)

### FIXED CODE ###

n,m=[int(x) for x in input().split()]
a=[int(x) for x in input().split()]
rem = n-sum(a)
print(rem if rem>=0 else -1)
#include <bits/stdc++.h>
using namespace std;
string s;
int main() {
    ios::sync_with_stdio(false);
    cin >> s;
    cout << unique(s.begin(), s.end()) - s.begin() - 1 << endl;
    return 0;
}

### FIXED CODE ###

ls=input().strip()
a=ls[0]
b=0
for i in ls[1:]:
     if i!=a:
          b+=1
          a=i
print(b)
a, b = map(int, input().split())
d = a // b
r = a % b
f = float(a / b)
print('{0} {1} [2:0.5f}'.format(d, r, f))

### FIXED CODE ###

a, b = map(int, input().split())
d = a // b
r = a % b
f = float(a / b)
print('{0} {1} {2:0.5f}'.format(d, r, f))
inp=list(map(int,input().split()))
if 2*inp[2]==inp[0] and 2*inp[3]==inp[1]:
  ans=1;
else:
  ans=0;
print('%d %d'%(inp[0]*inp[1]*0.5,ans))
inp=list(map(int,input().split()))
if 2*inp[2]==inp[0] and 2*inp[3]==inp[1]:
  ans=1;
else:
  ans=0;
print('%.6f %d'%(inp[0]*inp[1]*0.5,ans))
提出情報

### FIXED CODE ###

inp=list(map(int,input().split()))
if 2*inp[2]==inp[0] and 2*inp[3]==inp[1]:
  ans=1;
else:
  ans=0;
print('%.6f %d'%(inp[0]*inp[1]*0.5,ans))