Harryxun/stf_run huggingface dataset:
a=list(input())
for i in RANGE(3):
  if a[i]=='1':
    a[i]='9'
  elif a[i]=='9':
    a[i]='1'
print(a[0]+a[1]+a[2])


### FIXED CODE ###

a=list(input())
for i in range(3):
  if a[i]=='1':
    a[i]='9'
  elif a[i]=='9':
    a[i]='1'
print(a[0]+a[1]+a[2])
from collections import Counter

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

c = Counter(a)

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

for z in range(c[3] + 1):
    for y in range(c[2]+1 + c[3] - z):
        for x in range(n+1 - z - y):
            if x + y + z == 0:
                continue
            ret = 0.0
            if x > 0:
                ret += dp[x-1][y][z] * x
            if y > 0:
                ret += dp[x+1][y-1][z] * y
            if z > 0:
                ret += dp[x][y+1][z-1] * z
            dp[x][y][z] = (ret + n) / (x + y + z)

print(dp[c[1]][c[2]][c[3]])


### FIXED CODE ###

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

t = min(a)

dp = [0] * (k+1)

for x in a:
    dp[x] = 1

for i in range(k+1):
    for x in a:
        if i >= x:
            if dp[i] + (dp[i-x] + 1) % 2 > 0:
                dp[i] = 1
            else:
                dp[i] = 0

print("First" if dp[i] == 1 else "Second")
def lcs_size():
  X = input()
  Y = input()
  a = len(X)
  b = len(Y)
  z2 = [0 for i in range(b+1)]

  for i in range(a):
    z1 = z2 + []
    for j in range(b):
      if X[i] == Y[j]:
        z2[j+1] = z1[j] + 1
      else:
        z2[j+1] = z2[j]

  return z2[-1]

q = input()
for k in range(q):
  print lcs_size()

### FIXED CODE ###

def lcs_size():
  X = raw_input()
  Y = raw_input()
  a = len(X)
  b = len(Y)
  z2 = [0 for i in range(b+1)]

  for i in range(a):
    ch = X[i]
    z1 = z2 + []
    for j in range(b):
      if ch == Y[j]:
        z2[j+1] = z1[j] + 1
      elif z2[j+1] < z2[j]:
        z2[j+1] = z2[j]

  return z2[-1]

q = input()
for k in range(q):
  print lcs_size()
from fractions import gcd

N, M = list(map(int, input().split()))
S = input()
T = input()

L = (N * M) // gcd(N, M)

L1 = [1]
L2 = [1]
for i in range(1, N):
    t = i * (L // N) + 1
    L1.append(t)

for i in range(1, M):
    t = i * (L // M) + 1
    L2.append(t)


LS = [None] * L
# for i, li in enumerate(L1):
#     ind = li-1
#     LS[ind] = S[i]

ans = True
# for i, li in enumerate(L2):
#     ind = li-1
#     if LS[ind] is not None:
#         if LS[ind] != T[i]:
#             ans = False
############################

if ans:
    print(L)
else:
    print(-1)


# print(L1)
# print(L2)
# print(LS)

### FIXED CODE ###

from fractions import gcd

N, M = list(map(int, input().split()))
S = input()
T = input()

L = (N * M) // gcd(N, M)

L1 = [0]
L2 = [0]

from collections import Counter
c = Counter()

for i in range(1, N):
    t = i * (L // N) + 1
    L1.append(t-1)

for i in range(1, M):
    t = i * (L // M) + 1
    L2.append(t-1)


d = {}
for i, li in enumerate(L1):
    d[li] = S[i]

# print(d)

ans = True

for i, li in enumerate(L2):
    if not d.get(li):
        continue
    if d[li] != T[i]:
        ans = False

# print(L1)
# print(L2)
# print(common)
# print(dic)

if ans:
    print(L)
else:
    print(-1)
n, k = map(int, input().split())
h = sorted[int(input()) for i in range(n)]
ans = 1e9
for i in range(n - k + 1):
  ans = min(ans, h[i + k - 1] - h[i])
print(ans)


### FIXED CODE ###

n, k = map(int, input().split())
h = sorted([int(input()) for i in range(n)])
ans = 1e9
for i in range(n - k + 1):
  ans = min(ans, h[i + k - 1] - h[i])
print(ans)
# coding: utf-8
# Your code here!

s = input()


a=int(s[0:2])
b=int(s[2:])


aY=0
bY=0
aM=0
bM=0
if 1 <= a <= 12:
    aM=1
if 1 <= b <= 12:
    bM=1

if a==0:
#    print(a,b,"a0")
    if bM==1:
        print("YYMM")
    else:
        print("NA")
elif b==0:
#    print(a,b,"b0")
    if aM==1:
        print("MMYY")
    else:
        print("NA")
else:
    if aM == 1 and bM==1:
       print("AMBIGUOUS")
    elif aM == 1:
       print("MMYY")
    elif bM == 1:
       print("YYMM")
    else:
        assert()


### FIXED CODE ###

# coding: utf-8
# Your code here!

s = input()


a=int(s[0:2])
b=int(s[2:])


aY=0
bY=0
aM=0
bM=0
if 1 <= a <= 12:
    aM=1
if 1 <= b <= 12:
    bM=1

if a==0:
#    print(a,b,"a0")
    if bM==1:
        print("YYMM")
    else:
        print("NA")
elif b==0:
#    print(a,b,"b0")
    if aM==1:
        print("MMYY")
    else:
        print("NA")
else:
    if aM == 1 and bM==1:
       print("AMBIGUOUS")
    elif aM == 1:
       print("MMYY")
    elif bM == 1:
       print("YYMM")
    else:
        print("NA")
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import itertools

S = []
N = []
while True:
    n,s = map(int,input().split(" "))
    if s == 0 and n == 0:
        break
    else:
        N.append(n)
        S.append(s)

for i in range(0,len(S)):
    sumMap = list(map(sum,list(itertools.combinations(range(0,S[i]+1),N[i]))))
    print(sum([1 for j in range(0,len(sumMap)) if sumMap[j] == S[i]]))

### FIXED CODE ###

#!/usr/bin/env python
# -*- coding: utf-8 -*-
import itertools

S = []
N = []
while True:
    n,s = map(int,input().split(" "))
    if s == 0 and n == 0:
        break
    else:
        N.append(n)
        S.append(s)

for i in range(0,len(S)):
    sumMap = list(map(sum,list(itertools.combinations(range(0,10),N[i]))))
    print(sum([1 for j in range(0,len(sumMap)) if sumMap[j] == S[i]]))
n = int(input())

for _ in range(0, n):
    t, x, y = map(int, n.split())
    if x + y > t or (t - x - y) % 2:
        print("No")
        exit()
print("Yes")

### FIXED CODE ###

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

x = y = t = 0
for i in range(n):
    dx, dy, dt = l[i][1], l[i][2], l[i][0]
    dist = abs((dx - x) + (dy - y))

    if abs(dt - t) < dist:
        print("No")
        exit()
    if abs(dt - t) % 2:
        if dist % 2 == 0:
            print("No")
            exit()
    else:
        if dist % 2 == 1:
            print("No")
            exit()
    x, y, t = dx, dy, dt
print("Yes")
b = input()
 
if  "A"==b
    print("T")
elif "C"==b
    print("G")
elif "T"==b
    print("A")
else:
    print("C")

### FIXED CODE ###

b = input()
 
if  b=="A":
    print("T")
elif b=="C":
    print("G")
elif b=="T":
    print("A")
else:
    print("C")
s = []
for _ in range(3):
    x = input().replace('a', '0').replace('b', '1').replace('c', '2')
    s.append(str(x))
    
now = 0
while True:
    if len(s[0])==0:
        print('A')
        break
    elif len(s[1])==0:
        print('B')
        break
    elif len(s[1])==0:
        print('C')
        break
        
    after = int(s[now][0])
    s[now] =  s[now][1:]
    now = after
    

### FIXED CODE ###

s = []
for _ in range(3):
    x = input().replace('a', '0').replace('b', '1').replace('c', '2')
    s.append(str(x))
    
now = 0
while True:
    if len(s[now]) == 0:
        if now == 0:
            print('A')
        if now == 1:
            print('B')   
        if now == 2:
            print('C')
        break
        
    after = int(s[now][0])
    s[now] =  s[now][1:]
    now = after
N, T = map(int, input().split())
X = []
for _ in range(N):
    a, b = map(int, input().split())
    X.append((a,b))

X.sort(key=lambda x:x[0]/(x[1]+1))
X=X[::-1]

dp = [[0]+[T+2]*29 for _ in range(N+1)]
bs = []
for i, (a, b) in enumerate(X):
    if a==0:
        bs.append(b)
        continue
    for j in range(1, 30):
#        if j==1:
#            print(a*(dp[i][j-1]+1)+b)
        dp[i+1][j] = min(min(dp[i][j], a*(dp[i][j-1]+1)+b), T+1)
    fi = i+1

#print(dp)

bs.sort()
bbs = [0]
for i, b in enumerate(bs):
    bbs.append(bbs[-1]+bs[i]+1)
bbs.append(10**18)


#print(dp[fi], bbs)
r=0
for i in range(30):
    if dp[fi][i] > T:
        break
    nt = T-dp[fi][i]
#    print(nt)
    for j, b in enumerate(bbs):
#        print(1, b)
        if b > nt:
            break
    r=max(r, i+j-1)
print(r)


### FIXED CODE ###


N, T = map(int, input().split())
X = []
for _ in range(N):
    a, b = map(int, input().split())
    X.append((a,b))

X.sort(key=lambda x:x[0]/(x[1]+1))
X=X[::-1]

dp = [[0]+[T+2]*29 for _ in range(N+1)]
bs = []
fi=0
for i, (a, b) in enumerate(X):
    if a==0:
        bs.append(b)
        continue
    for j in range(1, 30):
#        if j==1:
#            print(a*(dp[i][j-1]+1)+b)
        dp[i+1][j] = min(min(dp[i][j], (a+1)*(dp[i][j-1]+1)+b), T+1)
    fi = i+1

#print(dp)

bs.sort()
bbs = [0]
for i, b in enumerate(bs):
    bbs.append(bbs[-1]+bs[i]+1)
bbs.append(10**18)


#print(dp[fi], bbs)
r=0
for i in range(30):
    if dp[fi][i] > T:
        break
    nt = T-dp[fi][i]
#    print(nt)
    for j, b in enumerate(bbs):
#        print(1, b)
        if b > nt:
            break
    r=max(r, i+j-1)
print(r)
x = input()
if(x%2 == 0):
  print(x/2)
else:
  print(x/2 +1)
  
  
  

### FIXED CODE ###

x = int(input())
if(x%2 == 0):
  print(x//2)
else:
  print(x//2 +1)
a,b=[int(i) for i in input().split()]a,b=[float(i) for i in input().split()]

print(int(a*b))

### FIXED CODE ###

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

a=int(a)
b=round(float(b)*100)

print(a*b//100)
N = input()
N = int(N)
N,K = (int(i) for i in input().split())
s = [[ i for i in input().split()] for i in range(N)]


N,A,B,C,D = (int(i) for i in input().split())
S = input()
S = list(S)

result = "Yes"
onon = True

if C < D:
    for i in range(len(S)-1):
        if S[i] == "#" and S[i + 1] == "#":
            result =  "No"
else:
    result = "No"
    for i in range(len(S)-1):
        if S[i] == "#" and S[i + 1] == "#":
            onon = False
    if onon:
        for i in range(B,D-2):
            if S[i] == "." and S[i + 1] == "."and S[i + 2] == ".":
                result = "Yes"


print(result)
    

### FIXED CODE ###

N,A,B,C,D = (int(i) for i in input().split())
S = input()
S = list(S)

result = "Yes"
onon = True

if C < D:
    for i in range(A-1,D):
        if S[i] == "#" and S[i + 1] == "#":
            result =  "No"
else:
    result = "No"
    for i in range(A-1,C):
        if S[i] == "#" and S[i + 1] == "#":
            onon = False
    if onon:
        for i in range(B -2,D-1):
            if S[i] == "." and S[i + 1] == "."and S[i + 2] == ".":
                result = "Yes"


print(result)
N = int(input())
A = sorted(list(map(int, input().split())), reverse=True)

res = [0]
tmp = -1
for a in A:
    if a == tmp:
        res.append(a)
        tmp = -1
    else:
        tmp = a
    if len(res) > 2:
        break

res = sorted(res, reverse=True)

result = 1
for i in range(2):
    result *= res[i]

print(result)


### FIXED CODE ###

N = int(input())
A = sorted(list(map(int, input().split())), reverse=True)

res = [0, 0]
tmp = -1
for a in A:
    if a == tmp:
        res.append(a)
        tmp = -1
    else:
        tmp = a
    if len(res) >= 4:
        break

res = sorted(res, reverse=True)

result = 1
for i in range(2):
    result *= res[i]

print(result)
# -*- coding: utf-8 -*-
H, W = map(int, input().split())
h, w = map(int, input().split())
print((H-h)*(W-w)


### FIXED CODE ###

# -*- coding: utf-8 -*-
H, W = map(int, input().split())
h, w = map(int, input().split())
print((H-h)*(W-w))
N = int(input())
S = input()
for i in range(N):
    if S[i]+S[i+1]+S[i+2] == 'ABC':
        a += 1
    if i == N - 3:
        break
print(a)


### FIXED CODE ###

N = int(input())
S = input()
a = 0
for i in range(N):
    if S[i]+S[i+1]+S[i+2] == 'ABC':
        a += 1
    if i == N - 3:
        break
print(a)
for i in range(4):
  a,b,c,d=map(int,input().split())
print(min(a,b)+min(c,d))

### FIXED CODE ###

a,b,c,d=[int(input()) for i in range(4)]
print(min(a,b)+min(c,d))
from collections import deque
H, W = map(int, input().split())
G = [list(input()) for i in range(H)]  # 迷路
D = [[None] * W for i in range(W)]  # 最短距離
D[0][0] = 0

Black = 0  # 最初の盤面の黒の数
for g in G:
    Black += g.count('#')

# BFS
que = deque([[0, 0]])
direction = [(1, 0), (-1, 0), (0, 1), (0, -1)]
while que:
    nh, nw = que.pop()
    for dh, dw in direction:
        if not ((0 <= nh + dh < H) and (0 <= nw + dw < W)):
            continue

        if D[nh + dh][nw + dw] is not None:
            continue

        if G[nh + dh][nw + dw] == '#':
            continue

        D[nh + dh][nw + dw] = D[nh][nw] + 1
        que.appendleft([nh + dh, nw + dw])

if D[H - 1][W - 1]:
    print(H * W - D[H - 1][W - 1] - Black - 1)
else:
    print(-1)


### FIXED CODE ###

from collections import deque
H, W = map(int, input().split())
Field = [list(input()) for i in range(H)]

que = deque()
que.append([0, 0])
Field[0][0] = 0

while que:
    now = que.popleft()
    if now == [H-1, W-1]:
        break

    if now[0]+1 <= H -1:
        if Field[now[0]+1][now[1]] == ".":
            Field[now[0]+1][now[1]] = str(int(Field[now[0]][now[1]])+1)
            que.append([now[0]+1, now[1]])

    if now[0]-1 >= 0:
        if Field[now[0]-1][now[1]] == ".":
            Field[now[0]-1][now[1]] = str(int(Field[now[0]][now[1]])+1)
            que.append([now[0]-1, now[1]])

    if now[1] + 1 <= W -1:
        if Field[now[0]][now[1]+1] == ".":
            Field[now[0]][now[1]+1] = str(int(Field[now[0]][now[1]])+1)
            que.append([now[0], now[1]+1])

    if now[1] -1 >= 0:
        if Field[now[0]][now[1]-1] == ".":
            Field[now[0]][now[1]-1] = str(int(Field[now[0]][now[1]])+1)
            que.append([now[0], now[1]-1])
else:
    print(-1)
    exit()
Z = int(Field[H-1][W-1])

sharp_cnt = 0
for f in Field:
    sharp_cnt += f.count("#")

print(H*W - sharp_cnt - Z - 1)
n = input()
a = list(map(int, input().split()))
 
counter = 0
while sum(list(map(lambda x: x % 2, a))) == 0:
	a = list(map(lambda x: x / 2, a))
	counter += 1
 
prrint(counter)

### FIXED CODE ###

n = input()
a = list(map(int, input().split()))
 
counter = 0
while sum(list(map(lambda x: x % 2, a))) == 0:
    a = list(map(lambda x: x / 2, a))
    counter += 1
 
print(counter)
import sys
def ii(): return int(sys.stdin.readline())
def mi(): return map(int, sys.stdin.readline().split())
def li(): return list(map(int, sys.stdin.readline().split()))
def li2(N): return [list(map(int, sys.stdin.readline().split())) for i in range(N)]
def dp2(ini, i, j): return [[ini]*i for i2 in range(j)]
def dp3(ini, i, j, k): return [[[ini]*i for i2 in range(j)] for i3 in range(k)]
#import bisect #bisect.bisect_left(B, a)
#from collections import defaultdict #d = defaultdict(int) d[key] += value

from collections import deque
N, M = mi()
x = li2(M)

adj = [[] for i in range(N)]
for i in range(M):
    x[i][0] -= 1
    x[i][1] -= 1
    adj[x[i][0]].append(x[i][1])

flag = [0]*N
ans = deque([])

def dfs(x, ans):
    if flag[x]:
        return None
    else:
        flag[x] = 1
        if adj[x]:
            for a in adj[x]:
                dfs(a, ans)
        #global ans
        ans.appendleft(x)

for i in range(N):
    dfs(i, ans)

print(ans)

dp = [0]*N
for a in ans:
    if adj[a]:
        for b in adj[a]:
            dp[b] = max(dp[b], dp[a] + 1)

print(max(dp))


### FIXED CODE ###

import sys
def ii(): return int(sys.stdin.readline())
def mi(): return map(int, sys.stdin.readline().split())
def li(): return list(map(int, sys.stdin.readline().split()))
def li2(N): return [list(map(int, sys.stdin.readline().split())) for i in range(N)]
def dp2(ini, i, j): return [[ini]*i for i2 in range(j)]
def dp3(ini, i, j, k): return [[[ini]*i for i2 in range(j)] for i3 in range(k)]
#import bisect #bisect.bisect_left(B, a)
#from collections import defaultdict #d = defaultdict(int) d[key] += value
'''
N, M = mi()
x = li2(M)

#dp = dp2(0, 2, N)
dp = [[0, []] for i1 in range(N+1)]


for i in range(M):
    dp[x[i][1]][0] = max(dp[x[i][1]][0], dp[x[i][0]][0] + 1)
    dp[x[i][0]][1].append(x[i][1])
    if dp[x[i][1]][1] != []:
        for a in dp[x[i][1]][1]:
            dp[a][0] = max(dp[x[i][1]][0] + 1, dp[a][0])

print(dp)
print(max([row[0] for row in dp])) 
'''
from collections import deque
N, M = mi()
x = li2(M)

h = [0]*N
adj = [[] for i in range(N)]
for i in range(M):
    x[i][0] -= 1
    x[i][1] -= 1
    h[x[i][1]] += 1
    adj[x[i][0]].append(x[i][1])

zeros = deque([])
ans = []
for i in range(N):
    if h[i] == 0:
        zeros.append(i)
        ans.append(i)

while(zeros != deque()):
    a = zeros.popleft()
    if(adj[a]):
        for b in adj[a]:
            h[b] -= 1
            if h[b] == 0:
                zeros.append(b)
                ans.append(b)

#print(ans)

dp = [0]*N
#print(ans)
#print(adj)
for a in ans:
    #print(dp)
    if adj[a]:
        for b in adj[a]:
            dp[b] = max(dp[a] + 1, dp[b])
#print(dp)
print(dp[ans[-1]])
cond=input().split(" ")
n=int(cond[0])
m=int(cond[1])
q=int(cond[2])
train=[[0 for i in range(2)] for j in range(m)]
sect=[[0 for i in range(2)] for j in range(q)]
#print(train)

def judge(arr_m,arr_q):
    a=0
    #print(arr_m)
    #print(arr_q)
    #print("*")
    if arr_q[0]<=arr_m[0] and arr_m[1]<=arr_q[1]:
        a=1
    return a

for i in range(m):
    train[i]=input().split(" ")
    train[i]=list(map(int,train[i]))
    #print(train)
for i in range(q):
    sect[i]=input().split(" ")
    sect[i]=list(map(int,sect[i]))
    #print(sect)
for i in range(q):
    ans=0
    for j in range(m):
        ans+=judge(train[j],sect[i])
    print(ans)

### FIXED CODE ###

nums=input().split(" ")
print((int(nums[0])-1)*(int(nums[1])-1))
def pluss_zero(a, L):
    a = str(a)
    while len(a) < L:
        a = "0" + a
    return a

def make_maxminnum(a):
    a = list(a)
    a.sort()
    maxa = int("".join(a[::-1]))
    mina = int("".join(a))
    return maxa - mina

ans_list = []

while True:
    a, L = map(int, input().split())
    if a == 0 and L == 0:
        break
    a_list = [a]
    for i in range(20):
        a = make_maxminnum(pluss_zero(a, L))
        a_list.append(a)

    ans = 0
    for i in range(20):
        for j in range(20):
            if i < j and a_list[i] == a_list[j]:
                ans = [str(i), str(a_list[i]), str(j - i)]
                break
        if ans:
            break
    ans_list.append(ans)

for i in ans_list:
    print(" ".join(i))


### FIXED CODE ###

def pluss_zero(a, L):
    a = str(a)
    while len(a) < L:
        a = "0" + a
    return a

def make_maxminnum(a):
    a = list(a)
    a.sort()
    maxa = int("".join(a[::-1]))
    mina = int("".join(a))
    return maxa - mina

ans_list = []

while True:
    a, L = map(int, input().split())
    if a == 0 and L == 0:
        break
    a_list = [a]
    for i in range(21):
        a = make_maxminnum(pluss_zero(a, L))
        a_list.append(a)

    ans = 0
    for i in range(21):
        for j in range(21):
            if i < j and a_list[i] == a_list[j]:
                ans = [str(i), str(a_list[i]), str(j - i)]
                break
        if ans:
            break
    ans_list.append(ans)

#print(ans_list)
for i in ans_list:
    #print(i)
    print(" ".join(i))
a, b, c = map(int, input().split(/))

if a == 2017:
    print('{}/{}/{}'.format(2018, b, c))

### FIXED CODE ###

s = input()
print('2018/01/' + s[-2] + s[-1])
import sys

# import re
import math
import collections
# import decimal
import bisect
import itertools
import fractions
# import functools
import copy
import heapq
import decimal
# import statistics
import queue
import numpy as np

sys.setrecursionlimit(10000001)
INF = 10 ** 16
MOD = 10 ** 9 + 7
# MOD = 998244353

ni = lambda: int(sys.stdin.readline())
ns = lambda: map(int, sys.stdin.readline().split())
na = lambda: list(map(int, sys.stdin.readline().split()))


# ===CODE===


def main():
    n, k = ns()
    a = na()

    for _ in range(42):
        imos = [0 for _ in range(n)]

        for i, ai in enumerate(a):
            imos[max(0, i - ai)] += 1
            if i + ai + 1 < n:
                imos[i + ai + 1] -= 1

        val = 0
        for i, im in enumerate(imos):
            val += im
            a[i] = min(val, n)

        if min(a) == n:
            break

    print(*a, sep=" ")


if __name__ == '__main__':
    main()


### FIXED CODE ###

import sys

# import re
import math
import collections
# import decimal
import bisect
import itertools
import fractions
# import functools
import copy
import heapq
import decimal
# import statistics
import queue
# import numpy as np

sys.setrecursionlimit(10000001)
INF = 10 ** 16
MOD = 10 ** 9 + 7
# MOD = 998244353

ni = lambda: int(sys.stdin.readline())
ns = lambda: map(int, sys.stdin.readline().split())
na = lambda: list(map(int, sys.stdin.readline().split()))


# ===CODE===


def main():
    n, k = ns()
    a = na()

    for _ in range(min(k,42)):
        imos = [0 for _ in range(n)]

        for i, ai in enumerate(a):
            imos[max(0, i - ai)] += 1
            if i + ai + 1 < n:
                imos[i + ai + 1] -= 1

        val = 0
        for i, im in enumerate(imos):
            val += im
            a[i] = min(val, n)

        # if min(a) == n:
        #     break

    print(*a, sep=" ")


if __name__ == '__main__':
    main()
N, M = map(int, input().split())
A = list(map(int,input(),split()))
a = sum(A)

if N >= a:
  print(int(N-a))
if N < a:
  print(-1)

### FIXED CODE ###

N, M = map(int, input().split())
A = list(map(int,input().split()))
a = sum(A)
 
if N >= a:
  print(int(N-a))
else:
  print(-1)
N = int(input())
L = int(input())
l=[]
for _ in range(0,N):
    s=input()
    l.append(s)
s=""
l.sort()

for i in l:
    s = s+i
print(s)

### FIXED CODE ###

n,l=map(int,input().split())
a=[]
for i in range(n):
	a.append(str(input()))

a.sort()
ans=''
for i in a:
	ans+=i
print(ans)
c = [input() for i in range(2)]
print("YES" if c[0] == c[1][::-1]) else "NO")

### FIXED CODE ###

c = [input() for i in range(2)]
print("YES" if c[0] == c[1][::-1] else "NO")
input(sum([int(x)-1 for x in input().split()]))

### FIXED CODE ###

i=[int(x)-1 for x in input().split()]
print(i[0]*i[1])
def main():
    import sys
    def input(): return sys.stdin.readline().rstrip()
    n, k = map(int, input().split())
    a = list(map(int, input().split()))
    mod = 10 ** 9+ 7
    ans = 1

    def answer(a):
        ans =1
        for x in a:
            ans *= x
            ans %= mod
        return ans

    if n == k:
        print(answer(a))
        return
    a.sort(reverse=True, key= lambda x:abs(x))
    if sum(x<0 for x in a[:k])%2 == 0:
        print(answer(a[:k])
    else:
        if all(x < 0 for x in a):
            print(answer(a[-k:]))
        else:
            try:
                x1, y1= min([x for x in a[:k] if x > 0]), min([x for x in a[k:] if x < 0])
            except ValueError:
                x1, y1 = 1, 0
            try:
                x2, y2= max([x for x in a[:k] if x < 0]),\
                    max([x for x in a[k:] if x >= 0])
            except ValueError:
                x2, y2 = 1, 0
            if abs(x2*y1) > abs(x1*y2):           
                a[a.index(x1)] = y1
            else:
                a[a.index(x2)] = y2
            print(answer(a[:k]))
            


if __name__ == '__main__':
    main()

### FIXED CODE ###

def main():
    import sys
    def input(): return sys.stdin.readline().rstrip()
    n, k = map(int, input().split())
    a = list(map(int, input().split()))
    mod = 10 ** 9+ 7
    ans = 1

    def answer(a):
        ans =1
        for x in a:
            ans *= x
            ans %= mod
        return ans

    if n == k:
        print(answer(a))
        return
    a.sort(reverse=True, key= lambda x:abs(x))
    if sum(x<0 for x in a[:k])%2 == 0:
        print(answer(a[:k]))
    else:
        if all(x < 0 for x in a):
            print(answer(a[-k:]))
        else:
            try:
                x1, y1= min([x for x in a[:k] if x > 0]), min([x for x in a[k:] if x < 0])
            except ValueError:
                x1, y1 = 1, 0
            try:
                x2, y2= max([x for x in a[:k] if x < 0]),\
                    max([x for x in a[k:] if x >= 0])
            except ValueError:
                x2, y2 = 1, 0
            if abs(x2*y1) > abs(x1*y2):           
                a[a.index(x1)] = y1
            else:
                a[a.index(x2)] = y2
            print(answer(a[:k]))
            


if __name__ == '__main__':
    main()