Harryxun/stf_run huggingface dataset:
import sys

sys.setrecursionlimit(1000000)


def judge(now, edges, searched):
    pattern = 0

    if searched[now] == "searched":
        return 0

    searched[now] = "searched"

    if searched.count("searched") == len(searched) - 1:
        return 1

    for next in edges[now]:
        pattern += judge(next, edges, list(searched))
    return pattern


def main():
    n, m = map(int, input().split())
    edges = [[int(x) for x in input().split()] for x in range(m)]
    adjacent_edges = [[] for x in range(m + 1)]
    for edge in edges:
        adjacent_edges[edge[0]].append(edge[1])
        adjacent_edges[edge[1]].append(edge[0])
    searched = ["yet" for x in range(n + 1)]

    print(judge(1, adjacent_edges, searched))


if __name__ == '__main__':
    main()


### FIXED CODE ###

import sys

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

array = [[int(x) for x in input().split()] for x in range(m)]

if m == 0:
    print(0)
    sys.exit()

adj_array = [[] for x in range(n + 1)]
res_array = [True] + [False for x in range(n)]
for item in array:
    adj_array[item[0]].append(item[1])
    adj_array[item[1]].append(item[0])


def dfs(n, res_array, res):
    res_array[n] = True
    if False not in res_array:
        return res+1
    else:
        for next in adj_array[n]:
            if not res_array[next]:
                res = dfs(next, list(res_array), res)
    return res


res = 0
res_array[1] = True
print(dfs(1, res_array, res))
import collections
import numpy as np
import sys
sys.setrecursionlimit(10**8)
A,B,C,K=map(int,input().split())
if K<=A:
    print(K)
elif A<K<=A+B:
    print(A)
else: print(A-(K-(A+B)))


#N=int(input())

# h=np.array(list(map(int,input().split())))
# ans=0
# def sol(l,m,k):
#     global ans
#     if m==0:
#         return ans
#     elif m>0:
#         for i in range(N-m+1):
#             if not 0 in l[i:i+m]:
#                 ans+=np.amin(l[i:i+m])
#                 l[i:i+m]=l[i:i+m]-min(l[i:i+m])
#                 print(l)
#         sol(l,m-1,ans)
#     # else:
#     #     ans+=np.count_nonzero(h)
#     #     sol(l, m - 1, ans)
# n=0
# sol(h,N,ans)
# print(ans)

### FIXED CODE ###


A,B,C,K=map(int,input().split())
if K<=A:
    print(K)
elif A<K<=A+B:
    print(A)
else: print(A-(K-(A+B)))
import numpy as np
N, M=list(map(int(input().split()))
AC=[0]*(a+1)
WA=[0]*(a+1)
ac=0
wa=0
t=0
for i in range(M):
    x,y=list(map(str(input().split()))
    if y=="WA":
        WA[int(x)]+=1   
    elif x=="AC" and AC[int(x)]==0:
        wa+=WA[int(x)]
        ac+=1     
        AC[int(x)]=1
print(ac, wa)             

### FIXED CODE ###

a,b = map(int,input().split())
AC = [0]*(a+1)
WA = [0]*(a+1)
ac = 0
wa = 0
wat = 0

for i in range(b):
  x,y = map(str,input().split())
  if y == "WA":
    WA[int(x)] += 1
  elif AC[int(x)] == 0 and y == "AC":
    wa += WA[int(x)]
    ac += 1
    AC[int(x)] = 1

print(ac,wa)
while True:
	n, x = map(int, raw_input().split())
	if n == 0 and x == 0:
		break

	a = 0
	for i in range(1, n+1):
		for j in range(i + 1, n + 1):
			b = x - (i + j)
			if b > j and b <= n:
				a += 1
	print(a)

### FIXED CODE ###

while True:
	n, x = map(int, input().split())
	if n == 0 and x == 0:
		break

	ans = 0
	for i in range(1, n + 1):
		for j in range(i + 1, n + 1):
			a = x - (i + j)
			if j < a <= n:
				ans += 1
	print(ans)
n,d=map(int,input().split())
cnt = 0
for _ in range(n):
    x,y = map(int,input().split())
    if(sqrt((x**2) + (y**2))<=d):
        cnt +=1 
print(cnt)

### FIXED CODE ###

import math as m
n,d=map(int,input().split())
cnt = 0
for _ in range(n):
    x,y = map(int,input().split())
    if(m.sqrt((x**2) + (y**2))<=d):
        cnt +=1 
print(cnt)
def s(n):
  x = 0
  for i in range(len(n)):
    x += int(n[i])
  return x
n = input()
print("Yes" if n % s(n) == 0 else "No")

### FIXED CODE ###

def s(n):
  x = 0
  for i in range(len(n)):
    x += int(n[i])
  return x
n = input()
print("Yes") if int(n) % s(n) == 0 else print("No")
h,w,d = map(int, input().split())

dp= [0]*(h*w+1)

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

for i in range(w):
    for j in range(h):
        s = ab[i][j]
        dp[s] =[i,j]
        
dpp= [0]*(h*w+1)

for k in range(d+1,h*w+1):
#    print(k)
    dpp[k] = dpp[k-d] + abs(dp[k][0]-dp[k-d][0]) +abs(dp[k][1]-dp[k-d][1])
    
q = int(input())

for x in range(q):
    a,b = map(int, input().split())
    print(dpp[b]-dpp[a])

### FIXED CODE ###

h,w,d = map(int, input().split())

dp= [0]*(h*w+1)

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

for i in range(h):
    for j in range(w):
        s = ab[i][j]
        dp[s] =[i,j]
        
dpp= [0]*(h*w+1)

for k in range(d+1,h*w+1):
#    print(k)
    dpp[k] = dpp[k-d] + abs(dp[k][0]-dp[k-d][0]) +abs(dp[k][1]-dp[k-d][1])
    
q = int(input())

for x in range(q):
    a,b = map(int, input().split())
    print(dpp[b]-dpp[a])
N = int(input())
S = input()
ans = 0
if N == 1:
    print(0)
    exit()
elif N == 2 and (S[0] == '.' and S[1] == '#'):
    print(0)
    exit()
else:
    S = S[0] + S + S[N - 1]
    S = list(S)
    for n in range(N):
        if S[n] == '.' and S[n + 2] == '.' and S[n + 1] == '#':
            ans += 1
            S[n + 1] = '.'
        elif S[n] == '#' and S[n + 2] == '#' and S[n + 1] == '.':
            ans += 1
            S[S + 1] = '#'
print(ans)


### FIXED CODE ###

N = int(input())
S = input()
ans = N
sumB = [0] * (N + 1)
tmp = 0
for i in range(N):
    if S[i] == '#':
        tmp += 1
    sumB[i+1] = tmp
for i in range(N+1):
    ans = min(sumB[i] + (N - i) - (sumB[N] - sumB[i]), ans)
    # print(sumB[i] , (N - i), (sumB[N] - sumB[i]), ans)
print(ans)
N, M = map(int, input.split())
heights = list(map(int, input.split()))

good = [True] * N
for m in range(0, M):
  A, B = map(int, input.split())
  if A > B:
    good[B] = False
  elif A < B:
    good[A] = False
    
count = 0
for obs in good:
  if obs: count++
    
print(count)

### FIXED CODE ###

N, M = map(int, input().split())
heights = list(map(int, input().split()))
 
greatest = [0] * N
for m in range(0, M):
  A, B = [int(s)-1 for s in input().split()]
  greatest[A] = max(greatest[A], heights[B])
  greatest[B] = max(greatest[B], heights[A])
    
count = 0
for i in range(0, N):
    count += heights[i] > greatest[i]
    
print(count)
x,n=map(int,input().split())
try:
    p=list(map(int,input().split()))
    p.sort()
    min=abs(p[n-1])
    for i in range(p[0],p[n-1]):
        if i not in p:
            if min>abs(i-x):
                min=abs(i-x)
                ans=i
                if ans>x and x-min not in p:
                    ans-=min
except:
    ans=x

print(ans)

### FIXED CODE ###

x, n = map(int, input().split())
a = [int(x) for x in input().split()]
b = [i for i in range(0,102) if i not in a] 
b_tmp = list(map(lambda s:abs(s-x), b)) 
address = b_tmp.index(min(b_tmp))
print(b[address])
s=input()
n=len(s)
def T(i):
    if i==n-1:
        return int(s[n-1])
    return T(i+1)+10**(n-1-i)*int(s[i])
dict={}
def modi(i,dict):
    if i in dict.keys():
        return dict[i]
    else:
        if i==n-1:
            dict[i]=int(s[i])
            return int(s[i])
        else:
            c=modi(i+1,dict)+(10**(n-1-i)*int(s[i]))
            c=c%2019
            dict[i]=c
            return c

modnum={}
for i in range(n):
    #print(T(i))
    x=modi(i,dict)
    #print(T(i),x)
    if x not in modnum.keys():
        modnum[x]=1
    else:
        modnum[x]+=1
sum=0
for md in modnum.keys():
    a=modnum[md]
    if md==0:
        sum+=a
   # print(a*(a-1)//2)
    sum+=a*(a-1)//2
print(sum)


### FIXED CODE ###

import sys
import collections as coun
sys.setrecursionlimit(10000000)
s=input()
n=len(s)
def mod10(x):
    return (10**(x%224))%2019
dp=[-1]*n
tmp=0
for i in reversed(range(n)):
    if i==n-1:
        dp[i]=int(s[i])
    else:
        dp[i]=(dp[i+1]+int(s[i])*pow(10,n-1-i,2019))%2019

#print(dp)
p=-1
for i in range(len(dp)-1):
    if dp[i]==dp[i+1]:
        dp[i]=p
        p=p-1

#print(dp)

c=coun.Counter(dp)
sum=0
for v in c.values():
    sum+=v*(v-1)//2
#print(sum)
for i in dp:
    if i==0:
        sum+=1
#print(sum)
if dp[-1]==0:
    sum=sum-1
print(sum)
import sys
sys.setrecursionlimit(10**9)
N,M = map(int,input().split())
note = [[0]*M for i in range(N)]
visited = [False]*N
ans = 0
for i in range(M):
    a,b = map(int,input().split())
    a -= 1
    b -= 1
    note[a][b] = 1
    note[b][a] = 1

def dfs(p=0, depth=0):
    if depth == N-2:
        global ans
        ans += 1
        return
    visited[p] = True
    for i in range(N):
        if note[p][i] == 1 and visited[i] is False:
            dfs(i,depth+1)

dfs()
print(ans)

### FIXED CODE ###

import sys
sys.setrecursionlimit(10**9)
N,M = map(int,input().split())
note = [[0]*N for i in range(N)]
visited = [False]*N
visited[0] = True
ans = 0
for i in range(M):
    a,b = map(int,input().split())
    a -= 1
    b -= 1
    note[a][b] = 1
    note[b][a] = 1

def dfs(p=0, depth=0):
    if depth == N-1:
        global ans
        ans += 1
        return
    for i in range(N):
        if note[p][i] == 1 and visited[i] is False:
            visited[i] = True
            dfs(i,depth+1)
            visited[i] = False

dfs()
print(ans)
S = include()
a = "Sunny"
b = 'Cloudy'
c = 'Rainy'
if S == a:
    print(b)
elif S == b:
        print(c)
elif S == b:
        print(a)



### FIXED CODE ###

import sys
S = input()
a = "Sunny"
b = 'Cloudy'
c = 'Rainy'
if S == a:
    print(b)
elif S == b:
        print(c)
elif S == c:
        print(a)
else:
    sys.exit()
sys.exit()
import math;

n, m = map(int, input().split(" "));
ab = [];
for i in range(0, n):
    ab.append(input().split(" "));

cd = [];
for i in range(0, m):
    cd.append(input().split(" "));

for i in range(0, n):
    dist=9999999999999
    nearm=0;
    for j in range(0, m):
         dist2 = math.fabs(int(ab[i][0]) - int(cd[j][0])) + math.fabs(int(ab[i][1]) - int(cd[j][1]));
         if dist2 < dist:
            dist = dist2;
            nearm=j;
    print(nearm + 1);




### FIXED CODE ###

a, b = map(int, input().split(" "));
print( (a+b) % 24);
import numpy as np

N = int(input())
A = list(map(int, input().split()))
Q = int(input())

num_A = [A.count(i) for i in range(10**5)]

for i in range(Q):
    b, c = map(int, input().split())
    num_A[c] += num_A[b]
    num_A[b] = 0
    print(sum(np.array(num_A)*np.array([j for j in range(10**5)])))
    

### FIXED CODE ###

N = int(input())
A = list(map(int, input().split()))
Q = int(input())

num_A = [0 for i in range(10**5+1)]
first = 0

for a in A:
    num_A[a] += 1
    first += a

for i in range(Q):
    b, c = map(int, input().split())
    first += c*num_A[b]
    first -= b*num_A[b]
    num_A[c] += num_A[b]
    num_A[b] = 0
    print(first)
A, B = map(int, input().split())
if A > B:
    result = A + (A - 1)
elif A < B:
    reuslt = B + (B - 1)
else:
    result = A + B
print(result)

### FIXED CODE ###

A, B = map(int, input().split())
if A > B:
    result = A + (A - 1)
elif A < B:
    result = B + (B - 1)
else:
    result = A + B
print(result)
N, A, B = list(map(int.input().split()))
if abs(A-B) % 2 == 0:
  print(abs(A-B)//2)
else:
  print(max(A-1,B-1))

### FIXED CODE ###

N,A,B = map(int,input().split())
if (B-A) % 2 == 0:
  print((B-A)//2)
else:
  print(min(A-1,N-B)+1+(B-A-1)//2)
n = int(input())

a = list(map(int, input()))

import collections
b = collections.deque()

for i in range(n):
  if i %% 2 == n %% 2:
    b.appendleft(a[i])
  else:
    b.append(a[i])

print(*b)
  

### FIXED CODE ###

n = int(input())

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

import collections

b = collections.deque()

for i in range(n):
    if i % 2 == n % 2:
        b.append(a[i])
    else:
        b.appendleft(a[i])

print(*b)
N = int(input())
A = list(map(int,input().split()))
Acount = {}
q = []
 
for a in A:
  if a not in Acount:
    Acount[a] = 0
  else:
    Acount[a] += 1
    
for key, val in Acount.items():
  if val >= 2:
    q.append(key)
    
  if val >= 4:
    q.append(key)
 
q.sort(reverse=True)
 
if len(q) < 2:
  print(0)
else:
  print(q[0]*q[1])
N = int(input())


### FIXED CODE ###

import sys
import math
import collections
import itertools
import array
import inspect

# Set max recursion limit
sys.setrecursionlimit(10000)


# Debug output
def chkprint(*args):
    names = {
        id(v): k
        for k, v in inspect.currentframe().f_back.f_locals.items()
    }
    print(', '.join(
        names.get(id(arg), '???') + ' = ' + repr(arg) for arg in args))


# Binary converter
def to_bin(x):
    return bin(x)[2:]


def li_input():
    return [int(_) for _ in input().split()]


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

dp = None


def main():
    N = int(input())
    A = li_input()
    D = collections.defaultdict(lambda: 0)
    C = [0, 0]

    for a in A:
        D[a] += 1

    for k, v in D.items():
        if 2 <= v:
            C.append(k)
        if 4 <= v:
            C.append(k)

    C.sort(reverse=True)

    print(C[0] * C[1])


main()
from math import gcd
n,x=map(int, input().split())
town=list(map(int, input().split()))+[x]
town.sort()
if n == 1:
    town.remove(x)
    print(abs(town[0]-x))
    exit()

d1 = abs(town[0]-town[1])
d2 = abs(town[1]-town[2])
ans = gcd(d1,d2)

for i in range(2,n):
    d = abs(town[i]-town[i+1])
    ans = gcd(d,ans)
print(ans)






### FIXED CODE ###

from fractions import gcd
n,x=map(int, input().split())
town=list(map(int, input().split()))+[x]
town.sort()
if n == 1:
    town.remove(x)
    print(abs(town[0]-x))
    exit()

d1 = abs(town[0]-town[1])
d2 = abs(town[1]-town[2])
ans = gcd(d1,d2)

for i in range(2,n):
    d = abs(town[i]-town[i+1])
    ans = gcd(d,ans)
print(ans)
n, x, t = map(int, input().split()))

print(-(-n // x) * t) 


### FIXED CODE ###

# ABC176A

n, x, t = map(int, input().split())

print(-(-n // x) * t)
s = input()
k = int(input())

if len(set(s)) == 1:
    ans = len(s) * k //2
else:
    if s[0] != s[-1]:
        i = 0
        cnt = 0
        while i < len(s) - 1:
            if s[i] == s[i+1]:
                cnt += 1
                i += 2
            else:
                i += 1
        ans = cnt * k
    else:
        cnt = 0
        for i in range(len(s) - 1):
            if s[i] == s[i+1]:
                cnt += 1
        tmp = cnt * k

        # # s_head == s_tail
        # s_head = s[0]
        # s_tail = s[-1]
        # a, b = 0, 0
        # for val in s:
        #     if val == s_head:
        #         a += 1
        #     else:
        #         break
        # for val in s[::-1]:
        #     if val == s_tail:
        #         b += 1
        #     else:
        #         break
        
        cnt_s = 0
        i = 0
        while i < len(s) - 1:
            if s[i] == s[i+1]:
                cnt_2 += 1
                i += 2
            else:
                i += 1
        
        s_2 = s * 2
        cnt_s_2 = 0
        i = 0
        while i < 2 * len(s) - 1:
            if s[i] == s[i+1]:
                cnt_s_2 += 1
                i += 2
            else:
                i += 1

        diff = cnt_s_2 - cnt_s
        ans = tmp - diff * (k-1)

print(ans)

### FIXED CODE ###

s = input()
k = int(input())

if len(set(s)) == 1:
    ans = len(s) * k //2
else:
    if s[0] != s[-1]:
        i = 0
        cnt = 0
        while i < len(s) - 1:
            if s[i] == s[i+1]:
                cnt += 1
                i += 2
            else:
                i += 1
        ans = cnt * k
    else:
        i = 0
        cnt = 0
        while i < len(s) - 1:
            if s[i] == s[i+1]:
                cnt += 1
                i += 2
            else:
                i += 1
        tmp = cnt * k

        cnt_s = 0
        i = 0
        while i < len(s) - 1:
            if s[i] == s[i+1]:
                cnt_s += 1
                i += 2
            else:
                i += 1
        
        s_2 = s * 2
        cnt_s_2 = 0
        i = 0
        while i < len(s_2) - 1:
            if s_2[i] == s_2[i+1]:
                cnt_s_2 += 1
                i += 2
            else:
                i += 1

        diff = cnt_s_2 - 2 * cnt_s
        ans = tmp + diff * (k-1)



print(ans)
K = int(input())
S = input()
 
if len(S) =< len(K):
    print(S)
    
else:
    print(S[1:len(S)]+'...')

### FIXED CODE ###

K = int(input())
S = input()
 
if len(S) <= K:
    print(S)
    
else:
    print(S[0:K]+'...')
S,T=map(str(input().split()))
M=str(T)+str(S)
print(M)


### FIXED CODE ###

S,T=map(str,input().split())
print(T+S)
import sys
sys.setrecursionlimit(10000000)
input = sys.stdin.readline
n, k = map(int, input().split())
a = []
mod = 998244353
for i in range(k):
    l, r = map(int, input().split())
    for j in range(l, r + 1):
        a.append(j)
dp = [0] * (n + 20)
dp[0] = 1
for i in range(n):
    for j in a:
        dp[i + j] += dp[i]
        dp[i + j] %= mod

print(dp[n - 1])


### FIXED CODE ###

class Binary_Indexed_Tree:
    def __init__(self, n):
        """
        :param n: 最大の要素数
        """
        self.n = n
        self.tree = [0] * (n + 1)
        self.depth = n.bit_length() - 1

    def sum(self, i):
        """ 区間[0,i) の総和を求める """
        s = 0
        i -= 1
        while i >= 0:
            s += self.tree[i]
            i = (i & (i + 1)) - 1
        return s

    def built(self, array):
        """ array を初期値とするBITを構築 """
        for i, a in enumerate(array):
            self.add(i, a)

    def add(self, i, x):
        """ i 番目の要素に x を足す """
        while i < self.n:
            self.tree[i] += x
            i |= i + 1

    def get(self, i, j):
        """ 部分区間和 [i, j) """
        if i == 0:
            return self.sum(j)
        return self.sum(j) - self.sum(i)

    def lower_bound(self, x, equal=False):
        """ (a0+a1+...+ai < x となる最大の i, その時の a0+a1+...+ai )
             a0+a1+...+ai <= x としたい場合は equal = True
             二分探索であるため、ai>=0 を満たす必要がある"""
        sum_ = 0
        pos = -1  # 1-indexed の時は pos = 0
        if equal:
            for i in range(self.depth, -1, -1):
                k = pos + (1 << i)
                if k < self.n and sum_ + self.tree[k] <= x:  # 1-indexed の時は k <= self.n
                    sum_ += self.tree[k]
                    pos += 1 << i
        else:
            for i in range(self.depth, -1, -1):
                k = pos + (1 << i)
                if k < self.n and sum_ + self.tree[k] < x:  # 1-indexed の時は k <= self.n
                    sum_ += self.tree[k]
                    pos += 1 << i

        return pos, sum_

    def __getitem__(self, i):
        """ [a0, a1, a2, ...] """
        return self.get(i, i + 1)

    def __iter__(self):
        """ [a0, a1, a2, ...] """
        for i in range(self.n):
            yield self.get(i, i + 1)

    def __str__(self):
        text1 = " ".join(["element:            "] + list(map(str, self)))
        text2 = " ".join(["cumsum(1-indexed):  "] + list(str(self.sum(i)) for i in range(1, self.n + 1)))
        return "\n".join((text1, text2))


mod = 998244353
n, k = map(int, input().split())
a = [list(map(int, input().split())) for _ in range(k)]
for i in range(k):
    a[i][0] -= 1
b = Binary_Indexed_Tree(n)
dp = [0] * n
dp[0] = 1
b.add(0, 1)
for i in range(1, n):
    for l, r in a:
        dp[i] += b.get(max(0, i - r), max(0, i - l))
    dp[i] %= mod
    b.add(i, dp[i])
print(dp[-1])
N, M = list(map(int, input().split()))
A = [0] * M
C = [0] * M
for i in range(M):
    a, b = list(map(int, input().split()))
    A[i] = a
    c = list(map(int, input().split()))
    n = ['0'] * N
    for j in range(b):
        n[N-c[j]-2] = '1'
    C[i] = int(''.join(n), 2)

INF = float('inf')

dp = [[INF for i in range(2**N)] for j in range(M+1)]
dp[0][0] = 0

for i in range(1, M+1):
    for j in range(2**N):
        dp[i][j] = dp[i-1][j]

    for j in range(2**N):
        dp[i][j | C[i-1]] = min(dp[i][j | C[i-1]], dp[i-1][j | C[i-1]], dp[i-1][j]+A[i-1])

ans = dp[M][-1]
if ans == INF: ans = -1
print(ans)

### FIXED CODE ###

def main():
    N, M = map(int, input().split())
    INF = float('inf')
    
    L = 2 ** N
    dp = [INF] * L
    dp_next = [INF] * L
    
    nums = [2 ** i for i in range(N)]
    
    for i in range(M):
        a, b = map(int, input().split())
        b = sum([nums[c-1] for c in list(map(int, input().split()))])            
    
        dp[b] = min(dp[b], a)
        for j in range(L):
            n = j | b
            dp_next[n] = min(dp[n], dp_next[n], dp[j]+a)
        
        for j in range(L):
            dp[j] = dp_next[j]
            
    if dp[-1] == INF: print(-1)
    else: print(dp[-1])

if __name__ == '__main__':
    main()
n = int(input())
if n = 105:
  print(1)
else:
  print(0)

### FIXED CODE ###

def make_divisors(n):
    a,b =[],[]
    i = 1
    while i*i<=n:
        if n%i == 0:
            a.append(i)
            if i != n//i:
                b.append(n//i)
        i+= 1
    return a+b[::-1]

n = int(input())
c = 0
for i in range(1,n+1):
    if len(make_divisors(i))== 8 and i%2==1:
        c+=1
print(c)
N = int(inout())
L = int(input().split())
flag = 0

for i in range(N):
  total += L[i]

for i in range(N):
  if L[i]*2 >= total:
    print("No")
    flag = 1
    break

if flag == 0:
  print("Yes")


### FIXED CODE ###

N = int(input())
L = input().split()
max = 0
count = 0

for i in range(N):
  count += int(L[i])
  if max < int(L[i]):
    max = int(L[i])
    
if count > 2*max:
  print("Yes")
else:
  print("No")
n, m = map(int, input().split())
A = list(map(int, input().split()))

sum = 0
for i in m:
  sum += A[i]

ans = n - sum
if ans >= 0:
  print(ans)
else:
  print(-1)

### FIXED CODE ###

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

sum = 0
for i in range(m):
  sum += A[i]

ans = n - sum
if ans >= 0:
  print(ans)
else:
  print(-1)
a = int(input())
b = list(map(int,input().split()))
c = list(map(int,input().split()))
x = []

for i in range(a):
  l = abs(b[0] - c[i]*0.006 - b[1])
  x.append(l)
  
print(x.index(min(x)) + 1)

### FIXED CODE ###

a = list(map(int,input().split()))
print(a[0] + int(a[1]/2))
def resolve():
    n, s = map(int, input().split())
    a = list(map(int, input().split()))
    mod = 998244353
    dp = [0] * (s + 1)
    dp[0] = 1
    for i in a:
        for j in range(s - i, -1, -1):
            dp[j + i] = dp[j + i] * 2 + dp[j]
            dp[j + i] %= mod
        for j in range(i):
            dp[j] *= 2
            dp[j] %= mod
    print(dp[-1])


if __name__ == '__main__':
    resolve()


### FIXED CODE ###

def resolve():
    n, s = map(int, input().split())
    a = list(map(int, input().split()))
    mod = 998244353
    modinv = pow(2, mod - 2, mod)
    dp = [0] * (s + 1)
    dp[0] = pow(2, n, mod)
    for i in a:
        for j in range(s - i, -1, -1):
            dp[j + i] += dp[j] * modinv
            dp[j + i] %= mod
    print(dp[-1])


if __name__ == '__main__':
    resolve()
n = int(input())
s = [input() for i in range(n)]

ans = 0
A = 0
B = 0
BA = 0
for i in s:
    ans += i.count("AB")
    if i[0:1] != "B" and i[-1:] == "A":
        A += 1
    elif i[0:1] == "B" and i[-1:] != "A":
        B += 1
    elif i[0:1] == "B" and i[-1:] == "A":
        BA += 1

#print(ans)
#print(A,B,BA)

while 1:
    if BA == 0 or A == B:
        break
    if A >= B:
        B += 1
    else:
        A += 1
    BA -= 1
#print(A,B,BA)
if A == 0 and B == 0:
    BA -= 1
print(ans + min(A,B) + BA)

### FIXED CODE ###

R,G,B,N = map(int,input().split())
ans = 0
for r in range(int(N/R)+1):
    for g in range(int((N-r*R)/G)+1):
        if N-(r*R+g*G) >= 0 and (N-(r*R+g*G))%B == 0:
        #    print(r,g,(N-(r*R+g*G))%B)
            ans += 1
print(ans)
a, b = map(int, input().split())

if a * b % 2 = 0
    print("Even")
else:
    print("Odd")


### FIXED CODE ###

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

if (a * b) % 2 == 0:
    print("Even")
else:
    print("Odd")