qyliang/CodeNanoFix huggingface dataset:
Buggy code:
N,M = map(int,input().split())
A = list(map(int,input().split()))
ans = N-sum(A)
if ans <= 0:
  print(-1)
else:
  print(ans)

Fixed code:
N,M = map(int,input().split())
A = list(map(int,input().split()))
ans = N-sum(A)
if ans < 0:
  print(-1)
else:
  print(ans)
Buggy code:
import math
from sys import *
inp=stdin.readline

zip=zip 
def linp(x):
    return list(map(int,x.split()))
def minp(x):
    return map(int,x.split())

n,m=minp(inp())
a=linp(inp())
an=sum(a)-n
if an>=0:
    print(an)
else:
    print("-1")
    




    

Fixed code:
import math
from sys import *
inp=stdin.readline

zip=zip 
def linp(x):
    return list(map(int,x.split()))
def minp(x):
    return map(int,x.split())

n,m=minp(inp())
a=linp(inp())
an=n-sum(a)
if an>=0:
    print(an)
else:
    print("-1")
Buggy code:
a = input().split(" ")
b = input().split(" ")
c = 0
for i in b:
    c += int(i)
if a >= c:
    print(a - c)
else:
    print(-1)

Fixed code:
a = input().split(" ")
b = input().split(" ")
c = 0
for i in b:
    c += int(i)
if int(a[0]) >= c:
    print(int(a[0]) - c)
else:
    print(-1)
Buggy code:
N,M = map(int,input().split(sep=" "))
A = list(map(int,input().split(sep=" ")))
a_Sum = sum(A)
if N-a_Sum > 0:
    print(N-a_Sum)
else:
    print(-1)

Fixed code:
N,M = map(int,input().split(sep=" "))
A = list(map(int,input().split(sep=" ")))
a_Sum = sum(A)
if N-a_Sum >= 0:
    print(N-a_Sum)
else:
    print(-1)
Buggy code:
n, m = map(int, input().split())
a_list = list(map(int, input().split()))

all_done_days = sum(a_list)

if all_done_days < n:
    print(n - all_done_days)
else:
    print(-1)

Fixed code:
n, m = map(int, input().split())
a_list = list(map(int, input().split()))

all_done_days = sum(a_list)

if all_done_days <= n:
    print(n - all_done_days)
else:
    print(-1)
Buggy code:
n, m = map(int, input().split())

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

if n > sum(a):
    print(-1)
else:
    print(n - sum(a))


Fixed code:
n, m = list(map(int, input().split()))
a = list(map(int, input().split()))
res = n - sum(a)
if res >= 0:
  print(res)
else:
  print(-1)
Buggy code:
n,m = map(int,input().split())
a = map(int,input().split())

date = sum(a)
if n-date <= 0:
    print(-1)
else:
    print(n-date)


Fixed code:
n,m = map(int,input().split())
a = map(int,input().split())

date = sum(a)
if n-date < 0:
    print(-1)
else:
    print(n-date)
Buggy code:
n,m=map(int,input().split())
for num	in input().split():
  n-=num
print(n if n>=0 else -1)

Fixed code:
n,m=map(int,input().split())
for num	in input().split():
  n-=int(num)
print(n if n>=0 else -1)
Buggy code:
def main():
    N, M = map(int, input().split())
    A = list(map(int, input().split(' ')))
    homework_day = 0
    for i in range(2):
        homework_day = homework_day + A[i]
    if homework_day > N:
        print(-1)
    else:
        print(N - homework_day)
main()

Fixed code:
def main():
    N, M = map(int, input().split())
    A = list(map(int, input().split(' ')))
    homework_day = 0
    for i in range(len(A)):
        homework_day = homework_day + A[i]
    if homework_day > N:
        print(-1)
    else:
        print(N - homework_day)
main()
Buggy code:
N, M = map(int, input().split())
A = [int(a) for a in input().split()]
asum = sum(A)
if N > asum:
    print(N - asum)
else:
    print(-1)


Fixed code:
N, M = map(int, input().split())
A = [int(a) for a in input().split()]
asum = sum(A)
if N >= asum:
    print(N - asum)
else:
    print(-1)
Buggy code:
n,m = map(int,input().split())
a = list(map(int,input().split()))

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

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

if n >= sum(A):
    print(n - sum(A))
else:
    print(-1)
Buggy code:
N, M = map(int,input().sprit())
A = list(map(int,input().sprit()))

enjoy = N - sum(A)

if N >= sum(A):
    print(enjoy)

else:
    print('-1')

Fixed code:
N, M = map(int, input().split())
A = list(map(int, input().split()))

enjoy = N - sum(A)

if N >= sum(A):
    print(enjoy)

else:
    print('-1')
Buggy code:
N, M = [int(s) for s in input().split()]
A = [int(s) for s in input().split()]
days = N - sum(A)
days = -1 if days < 0 else -1
print(days)

Fixed code:
N, M = [int(s) for s in input().split()]
A = [int(s) for s in input().split()]
days = N - sum(A)
days = '-1' if days < 0 else days
print(days)
Buggy code:
N, M = map(int, input().split())
A = list(map(int, input().split()))

if N - sum(set(A)) >= 0:
  print(N - sum(set(A)))
else:
  print(-1)

Fixed code:
N, M = map(int, input().split())
A = list(map(int, input().split()))

if N - sum(A) >= 0:
  print(N - sum(A))
else:
  print(-1)
Buggy code:
n, m = map(int, input().split())
A = list(map(int, input().split()))

homework = A.sum()
print(n - m if n - m >= 0 else -1)

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

homework = sum(A) 
print(n - homework if n - homework >= 0 else -1)
Buggy code:
n,m=map(int,input().split())
a=list(map(int,input().split()))
s=0
for i in a:
    s+=i
if s>a:
    print(-1)
else:
    print(a-s)

Fixed code:
n,m=map(int,input().split())
a=list(map(int,input().split()))
s=0
for i in a:
    s+=i
if s>n:
    print(-1)
else:
    print(n-s)
Buggy code:
n = int(input())
m = int(input())
a = list(map(int,input().split()))

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




Fixed code:
n,m = map(int,input().split())
a = list(map(int,input().split()))

if n >= sum(a):
    print(n-sum(a))
else:
    print(-1)
Buggy code:
A,B=map(int,input().split())
Lis=list(map(int,input().split()))

if A>sum(Lis):
    print(A-sum(Lis))

else:
    print(-1)

Fixed code:
A,B=map(int,input().split())
Lis=list(map(int,input().split()))

if A>=sum(Lis):
    print(A-sum(Lis))

else:
    print(-1)
Buggy code:
n,m = map(int,input().split())
l = [int(i) for i in input().split()]
if(n > sum(l)):
  print(n-sum(l))
else:
  print(-1)

Fixed code:
n,m = map(int,input().split())
l = [int(i) for i in input().split()]
if(n >= sum(l)):
  print(n-sum(l))
else:
  print(-1)
Buggy code:
def q2():
    N, M = (int(i) for i in input().split())
    A = [int(i) for i in input().split()]
    sum_A = sum(A)
    if N > sum_A:
        ans = N - sum_A
    else:
        ans = 0
    print(ans)


if __name__ == '__main__':
    q2()


Fixed code:
def q2():
    N, M = (int(i) for i in input().split())
    A = [int(i) for i in input().split()]
    sum_A = sum(A)
    if N >= sum_A:
        ans = N - sum_A
    else:
        ans = -1
    print(ans)


if __name__ == '__main__':
    q2()
Buggy code:
s = input().split(" ")
N = int(s[0])
M = s[1]
s = input().split(" ")
A = []
sum = 0
for w in s:
    A.append(int(w))
    sum += int(w)

if sum >= N:
    print(N - sum)
else:
    print(-1)

Fixed code:
s = input().split(" ")
N = int(s[0])
M = s[1]
s = input().split(" ")
A = []
sum = 0
for w in s:
    A.append(int(w))
    sum += int(w)

if sum <= N:
    print(N - sum)
else:
    print(-1)
Buggy code:
N,M = map(int,input().split())
A = list(map(int, input().split()))
S=0
for a in A:
   S+=a
   
if N-S>0:
    print(N-S)   
else:
    print(-1)

Fixed code:
N,M = map(int,input().split())
A = list(map(int, input().split()))
S=0
for a in A:
   S+=a
   
if N-S>=0:
    print(N-S)   
else:
    print(-1)
Buggy code:
import math
def ii(): return int(input())
def mi(): return map(int, input().split())
def li(): return list(mi())
n,m = mi()
a = li()
if (sum(a) - n < 0):
    print("-1")
else:
    print(n - sum(a))

Fixed code:
import math
def ii(): return int(input())
def mi(): return map(int, input().split())
def li(): return list(mi())
n,m = mi()
a = li()
if (n - sum(a) < 0):
    print("-1")
else:
    print(n - sum(a))
Buggy code:
n,m=[int(i)for i in input()]
list=[int(i) for i in input().split()]
a=n-sum(list)
if a>=0:
  print(a)
else:
  print('-1')

Fixed code:
n,m=[int(i)for i in input().split()]
list=[int(i) for i in input().split()]
a=n-sum(list)
if a>=0:
  print(a)
else:
  print('-1')
Buggy code:
n, m = map(int, input().split())

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

if n > sum(l):
  print(n-sum(l))
else:
  print(-1)

Fixed code:
n, m = map(int, input().split())
 
l = list(map(int, input().split()))
 
if n >= sum(l):
  print(n-sum(l))
else:
  print(-1)
Buggy code:
N,b=map(int,input().split())
a_list=list(map(int,input().split()))

s=0

for a in a_list:
    s+=a


if N-s <0:
    ans=0
else:
    ans=N-s

print(ans)

Fixed code:
N,b=map(int,input().split())
a_list=list(map(int,input().split()))

s=0

for a in a_list:
    s+=a


if N-s <0:
    ans=-1
else:
    ans=N-s

print(ans)
Buggy code:
import math
a=input().split()
n,m=int(a[0]),int(a[1])
f=list(map(int,input().split()))
s=0
fl=0
s=sum(a)
if(s>=n):
  print(s-n)
else:
  print("-1")

Fixed code:
import math
a=input().split()
n,m=int(a[0]),int(a[1])
f=list(map(int,input().split()))
s=0
fl=0
s=sum(f)
if(n>=s):
  print(n-s)
else:
  print("-1")
Buggy code:
from math import gcd
from functools import reduce
from itertools import product

def resolve():
  K, M = map(int, input().split(" "))
  A = [int(x) for x in input().split(" ")]
  print(K-sum(A) if K-sum(A) > 0 else -1)

if __name__ == "__main__":
  resolve()

Fixed code:
from math import gcd
from functools import reduce
from itertools import product

def resolve():
  K, M = map(int, input().split(" "))
  A = [int(x) for x in input().split(" ")]
  print(K-sum(A) if K-sum(A) >= 0 else -1)

if __name__ == "__main__":
    resolve()
Buggy code:
n,m = map(int,input())
ai = list(map(int,input().split()))
sumday = sum(ai)
if n-sumday<0:
  print(-1)
else:
  print(n-sumday)

Fixed code:
n,m = map(int,input().split())
ai = list(map(int,input().split()))
sumday = sum(ai)
if n-sumday<0:
  print(-1)
else:
  print(n-sumday)
Buggy code:
m,n = int(input())
li = list(map(int,input().split()))
if sum(li)>m:
  print(-1)
else:
  print(m - sum(li))

Fixed code:
n,m=map(int,input().split())
a=list(map(int,input().split()))
if n>=sum(a):
  print(n-sum(a))
else:
  print(-1)
Buggy code:
yasumi = 0
syukudai = 1
nissu = list(map(int,input().split()))
syukudaiNissu = list(map(int,input().split()))
if sum(syukudaiNissu) > nissu[yasumi]:
  print()-1
print(nissu[yasumi] - sum(syukudaiNissu))

Fixed code:
yasumi = 0
syukudai = 1
nissu = list(map(int,input().split()))
syukudaiNissu = list(map(int,input().split()))
if sum(syukudaiNissu) > nissu[yasumi]:
  print(-1)
  exit()
print(nissu[yasumi] - sum(syukudaiNissu))
Buggy code:
n = input().split(" ")
a = input().split(" ")
n[0] = int(n[0])
sum_HomeworkDays = 0

for i in a:
	sum_HomeworkDays += int(i)
    
if n[0]-sum_HomeworkDays > 0:
  print(n[0]-sum_HomeworkDays)
else:
  print("-1")

Fixed code:
n = input().split(" ")
a = input().split(" ")
n[0] = int(n[0])
sum_HomeworkDays = 0

for i in a:
	sum_HomeworkDays += int(i)
    
if n[0]-sum_HomeworkDays >= 0:
  print(n[0]-sum_HomeworkDays)
else:
  print("-1")
Buggy code:
a=[int(x) for x in input().split()]
b=[int(x) for x in input().split()]
c=sum(b)

if(c > a[0]):
    print(-1)
else:
    print(c - a[0])

Fixed code:
a=[int(x) for x in input().split()]
b=[int(x) for x in input().split()]
c=sum(b)

if(c > a[0]):
    print(-1)
else:
    print(a[0] - c)
Buggy code:
NM = [int(i) for i in input().split(" ")]
A = [int(i) fot i in input().split(" ")]

N = NM[0]
M = NM[1]

if NM => sum(A):
  print(NM-sum(A))
else:
  print(-1)

Fixed code:
NM = [int(i) for i in input().split()]
A = [int(i) for i in input().split()]

N = NM[0]
M = NM[1]

if N >= sum(A):
  print(N-sum(A))
else:
  print(-1)
Buggy code:
N,M=map(int,input().split())
A=list(map(int,input().split()))
Ans=0
for i in A:
    Ans=Ans+i
if N<=Ans:
    print(-1)
else:
    print(N-Ans)

Fixed code:
N,M=map(int,input().split())
A=list(map(int,input().split()))
Ans=0
for i in A:
    Ans=Ans+i
if N<Ans:
    print(-1)
else:
    print(N-Ans)
Buggy code:
#import numpy as np
#import math
#from decimal import *
#from numba import njit

#@njit
def main():
    N,M = map(int, input().split())
    A = list(map(int, input().split()))
    s = sum(A)
    if s >= N:
        print(-1)
    else:
        print(N-s)

main()


Fixed code:
#import numpy as np
#import math
#from decimal import *
#from numba import njit

#@njit
def main():
    N,M = map(int, input().split())
    A = list(map(int, input().split()))
    s = sum(A)
    if s > N:
        print(-1)
    else:
        print(N-s)

main()
Buggy code:

N, M = map(int, input().split())
task = []
for i in range(1, M + 1):
    task.append("A_" + str(i))

task = map(int, input().split())
task_total = sum(task)

if task_total <= N:
    print(N - task_total)


Fixed code:
N, M = map(int, input().split())
task = []
for i in range(1, M + 1):
    task.append("A_" + str(i))

task = map(int, input().split())
task_total = sum(task)

if task_total <= N:
    print(N - task_total)

else:
    print(-1)
Buggy code:
N,M = [int(i) for i in input().split(" ")]
A = [int(i) for i in input().split(" ")]

print ((N - sum(A)) if sum(A)<N else -1 ) 


Fixed code:
N,M = [int(i) for i in input().split(" ")]
A = [int(i) for i in input().split(" ")]

print ((N - sum(A)) if sum(A)<=N else -1 )
Buggy code:
n,m = map(int,input().split())
li=list(map(int,input().split()))
g=n-sum(li)
if g>=0:
  return g
else:
  return -1

Fixed code:
n,m = map(int,input().split())
li=list(map(int,input().split()))
g=n-sum(li)
if g>=0:
    print(g)
else:
    print(-1)
Buggy code:
N,M = map(int,input().split())
day_list = input().split()

t = 0

for A in day_list:
    t += A

if N - t < 0: print(-1)
else: print(N - t)

Fixed code:
N,M = map(int,input().split())
day_list = input().split()

t = 0

for A in day_list:
    t += int(A)

if N - t < 0: print(-1)
else: print(N - t)
Buggy code:
n,m=map(int(input().split())
a=list(map(int,input().split()))
if n>=sum(a):
  print(n-sum(a))
else:
  print(-1)

Fixed code:
n, m = map(int, input().split())
a = list(map(int, input().split()))

A = sum(a)

if n >= A:
    print(n-A)
else:
    print(-1)
Buggy code:
import numpy as np
N,M=map(int,input().split())
p=list(map(int,input().split()))
if np.sum(p)>M:
  print(-1)
else:
  print(N-np.sum(p))

Fixed code:
import numpy as np
N,M=map(int,input().split())
p=list(map(int,input().split()))
if np.sum(p)>N:
  print(-1)
else:
  print(N-np.sum(p))
Buggy code:
N,M=map(int,input().split())
A=list(map(int,input().split()))
print(N-sum(A) if N-sum(A) >0 else -1)


Fixed code:
N,M=map(int,input().split())
A=list(map(int,input().split()))
print(N-sum(A) if N-sum(A) >=0 else -1)
Buggy code:
n, m = map(int,input().split())
li = list(map(int, input().split()))

res = n - li.sum()
if res >= 0:
	print(res)
else:
    print(-1)

Fixed code:
n, m = map(int,input().split())
li = list(map(int, input().split()))
 
res = n - sum(li)
if res >= 0:
	print(res)
else:
    print(-1)
Buggy code:
def readinput():
    n,m=map(int,input().split())
    a=list(map(int,input().split()))
    return n,m,a

def main(n,m,a):
    days=sum(a)
    if days<n:
        return -1
    else:
        return n-days

if __name__=='__main__':
    n,m,a=readinput()
    ans=main(n,m,a)
    print(ans)


Fixed code:
def readinput():
    n,m=map(int,input().split())
    a=list(map(int,input().split()))
    return n,m,a

def main(n,m,a):
    days=sum(a)
    if days>n:
        return -1
    else:
        return n-days

if __name__=='__main__':
    n,m,a=readinput()
    ans=main(n,m,a)
    print(ans)
Buggy code:
n,m=map(int,input().split())
l=list(map(int,input()))
k=sum(l)
if k>n:
    print(-1)
else:
    print(n-k)

Fixed code:
n,m=map(int,input().split())
l=list(map(int,input().split()))
k=sum(l)
if k>n:
    print(-1)
else:
    print(n-k)
Buggy code:
m,n,*aa = open(0).read().split()
ans = m-sum(aa)
if ans<0:
  print(-1)
else:
  print(ans)

Fixed code:
m,n,*aa = map(int, open(0).read().split())
ans = m-sum(aa)
if ans<0:
  print(-1)
else:
  print(ans)
Buggy code:
x, y = map(int,input().split())
arr = list(map(int, input().split()[:y]))
s = 0
for i in arr:
    s += i
re = x - s
if re > 0:
    print(re)
else:
    print(-1)

Fixed code:
x, y = map(int,input().split())
arr = list(map(int, input().split()[:y]))
s = 0
for i in arr:
    s += i
re = x - s
if s > x:
    print(-1)
elif s == x:
    print(0)
else:
    print(re)
Buggy code:
n, m = list(map(int, input().split()))
a = list(map(int, input().split()))
total = 0
for i in a:
  total += a
if n < total:
  print(-1)
else:
  print(n - total)


Fixed code:
n, m = list(map(int, input().split()))
a = list(map(int, input().split()))
total = 0
for i in a:
  total += i
if n < total:
  print(-1)
else:
  print(n - total)
Buggy code:
tot , n = list( map ( int ,input().split()))
a = list( map( int , input().split()))
if tot >= a.sum():
	print(tot -a.sum())
else:
	print(-1)

Fixed code:
tot , n = list( map ( int ,input().split()))
a = list( map( int , input().split()))
if tot >= sum(a):
	print(tot -sum(a))
else:
	print(-1)
Buggy code:
n,m = list(map(int,input().split()))
A = list(map(int,input().split()))
for a in A:
  n -= a

print(max(0,n))

Fixed code:
n,m = list(map(int,input().split()))
A = list(map(int,input().split()))
for a in A:
  n -= a

print(max(-1,n))
Buggy code:
nm = list(map(int, input().split()))
am = list(map(int, input().split()))
x = 0
for i in range(len(am)):
    x += am[i]
if x > nm[0]:
    print('-1')
else:
    print(x)

Fixed code:
nm = list(map(int, input().split()))
am = list(map(int, input().split()))
x = 0
for i in range(len(am)):
    x += am[i]
if x > nm[0]:
    print('-1')
else:
    ans = nm[0] - x
    print(ans)
Buggy code:
n,m = map(int,input().split())
a = list(map(int,input().split()))
for v in a:
    n = n - v
    if n <= 0:
        n = -1
        break
print(n)

Fixed code:
n,m = map(int,input().split())
a = list(map(int,input().split()))
for v in a:
    n = n - v
    if n < 0:
        n = -1
        break
print(n)
Buggy code:
N, M = map(int, input().split())
l = list(map(int, input().split()))

res = N - sum(l)
print(res if res>0 else -1)


Fixed code:
N, M = map(int, input().split())
l = list(map(int, input().split()))


free = N - sum(l)
print(free if free>=0 else -1)
Buggy code:
a,b = map(int,input().split())
c  =[int(i) for  i in input().split()]
su=sum(c)
n = a-su
if n>0:
  print(n)
else:
  print(-1)

Fixed code:
a,b = map(int,input().split())
c  =[int(i) for  i in input().split()]
su=sum(c)
n = a-su
if n>=0:
  print(n)
else:
  print(-1)
Buggy code:
n,m = map(int,input().split())
A = list(map(int,input().split()))
free = n - sum(A)
if free < 0:
  print(0)
else:
  print(free)

Fixed code:
n,m = map(int,input().split())
A = list(map(int,input().split()))
free = n - sum(A)
if free < 0:
  print(-1)
else:
  print(free)
Buggy code:
N, M = map(int, input().split())
A = list(map(int, input().split()))
if N - sum(A) > 0:
  days = N- sum(A)
else:
  days = 0
print(days)

Fixed code:
N, M = map(int, input().split())
A = list(map(int, input().split()))
if N - sum(A) >= 0:
  days = N - sum(A)
else:
  days = -1
print(days)
Buggy code:
N,M = map(int(input().split()))
A = list(map(int(input().split())))
sumA = sum(A)
if N-sumA < 0:
  print(-1)
else:
  print(N-sumA)

Fixed code:
N,M=map(int,input().split())
A=list(map(int,input().split()))
if N-sum(A) >= 0:
    print(int(N-sum(A)))
else:
    print(-1)
Buggy code:
# py abc163b.py
n,m = map(int,input().split())
val = sum(list(map(int,input().split())))
if val>m:
	print(-1)
else
	print(m-val)

Fixed code:
# py abc163b.py
n,m = map(int,input().split())
val = sum(list(map(int,input().split())))
if val>n:
	print(-1)
else:
	print(n-val)
Buggy code:
N,M = map(int,input().split())
A = list(map(int,input().split()))
a = sum(A)
if N > a:
    print(N-a)
else:
    print(-1)

Fixed code:
N,M = map(int,input().split())
A = list(map(int,input().split()))
a = sum(A)
if N >= a:
    print(N-a)
else:
    print(-1)
Buggy code:
a, b = map(int, input().split())
l = list(map(int, input().split()))
if sum(l) < a:
	print('-1')
else:
	print(a-sum(l))


Fixed code:
a, b = map(int, input().split())
l = list(map(int, input().split()))
if sum(l) > a:
	print('-1')
else:
	print(a-sum(l))
Buggy code:
a = list(map(int,input().split()))
b = list(map(int,input().split()))
c = a[0]-sum(b)
if c>0:
  print(c)
else:
  print("-1")

Fixed code:
a = list(map(int,input().split()))
b = list(map(int,input().split()))
c = a[0]-sum(b)
if c>=0:
  print(c)
else:
  print("-1")
Buggy code:
N, M = map(int, input().split())
a_data = input()
a = a_data.split(' ')

sum = 0
# sum = sum(a)
for item as a:
  sum += int(item)

if sum > N:
  print(-1)
else:
  print(N-sum)


Fixed code:
N, M = map(int, input().split())
a_data = input()
a = a_data.split(' ')

sum = 0
# sum = sum(a)
for item in a:
  sum += int(item)

if sum > N:
  print(-1)
else:
  print(N-sum)
Buggy code:
LI = lambda: list(map(int,input().split()))
MI = lambda: map(int,input().split())
yes = lambda: print("YES")
no = lambda: print("NO")
I = lambda: list(input())
J = lambda x: "".join(x)
II = lambda: int(input())
SI = lambda: input()
#---khan17---template
n,m = MI()
a = LI()
c = n-sum(a)
print(c if c>0 else -1)

Fixed code:
LI = lambda: list(map(int,input().split()))
MI = lambda: map(int,input().split())
yes = lambda: print("YES")
no = lambda: print("NO")
I = lambda: list(input())
J = lambda x: "".join(x)
II = lambda: int(input())
SI = lambda: input()
#---khan17---template
n,m = MI()
a = LI()
c = n-sum(a)
print(c if c>=0 else -1)
Buggy code:
N, M = map(int, input().split())
A = sum(map(int, input().split()))

print(N - A) if N - A >= 0 else print(0)

Fixed code:
N, M = map(int, input().split())
A = sum(map(int, input().split()))

print(N - A) if N - A >= 0 else print(-1)
Buggy code:
n,m = (int(x) for x in input().split())
take = list(map(int, input().split()))
for per in take:
    n -= per

if n > 0:
    print(n)
else:
    print('-1')

Fixed code:
n,m = (int(x) for x in input().split())
take = list(map(int, input().split()))
for per in take:
    n -= per

if n >= 0:
    print(n)
else:
    print('-1')
Buggy code:
n,m=map(int,input().split())
a=sum(list(map(int,input().split())))
if n-a<=0:
    print(n-a)
else:
    print(-1)

Fixed code:
n,m=map(int,input().split())
a=sum(list(map(int,input().split())))
if n-a>=0:
    print(n-a)
else:
    print(-1)
Buggy code:
n,m=(int(x) for x in input().split())
a=[int(x) for x in input().split()]
s=sum(a)
if (s<n):
     ans=n-s
else:
    ans=-1
    
print(ans)

Fixed code:
n,m=(int(x) for x in input().split())
a=[int(x) for x in input().split()]
s=sum(a)
if (s<=n):
     ans=n-s
else:
    ans=-1
    
print(ans)
Buggy code:
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
import numpy as np

def main():
    N, M, *A = map(int, read().split())
    ans = sum(A)
    if ans > N:
        ans == -1
    print(ans)
    return

if __name__ == '__main__':
    main()



Fixed code:
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
import numpy as np

def main():
    N, M, *A = map(int, read().split())
    ans = sum(A)
    if ans > N:
        ans = -1
    else:
        ans = N - ans
    print(ans)
    return

if __name__ == '__main__':
    main()
Buggy code:
N, M = map(int, input().split())
A = input().split()
A_int = [int(n) for n in A]

rest = sum(A_int)
if rest >= 0:
  print(rest)
else:
  print(-1)

Fixed code:
N, M = map(int, input().split())
A = input().split()
A_int = [int(n) for n in A]

rest = N - sum(A_int)
if rest >= 0:
  print(rest)
else:
  print(-1)
Buggy code:
a, b = map(int, input().split())
c = sum(map(int, input().split()))

print(max(c - a, -1))

Fixed code:
a, b = map(int, input().split())
c = sum(map(int, input().split()))

print(max(a - c, -1))
Buggy code:
n, m = input().split()
a = input().split()

a = [int(i) for i in a]
if int(n) >= sum(a):
    print(int(n)-sum(a))
else:
    print(0)

Fixed code:
n, m = input().split()
a = input().split()

a = [int(i) for i in a]
if int(n) >= sum(a):
    print(int(n)-sum(a))
else:
    print(-1)
Buggy code:
summer_vacation, amount_of_homework = map(int, input().split())
a = map(int, input().split())
homework_list = list[a]

total_days = 0

for i in homework_list:
    total_days += i

if summer_vacation >= total_days:
    print(summer_vacation - total_days)
else:
    print(-1)


Fixed code:
summer_vacation, amount_of_homework = map(int, input().split())
a = map(int, input().split())
homework_list = list(a)

total_days = 0

for i in homework_list:
    total_days += i

if summer_vacation >= total_days:
    print(summer_vacation - total_days)
else:
    print(-1)