buggy_code
stringlengths
11
625k
fixed_code
stringlengths
17
625k
bug_type
stringlengths
2
4.45k
language
int64
0
8
token_count
int64
5
200k
n = int(input().split()[0]) print(max(0, n - sum(map(int, input().split()))))
n = int(input().split()[0]) print(max(-1, n - sum(map(int, input().split()))))
[["-", 0, 652, 3, 4, 0, 652, 3, 4, 0, 612], ["+", 3, 4, 0, 652, 3, 4, 0, 664, 17, 33], ["+", 3, 4, 0, 652, 3, 4, 0, 664, 28, 612]]
5
40
#include <bits/stdc++.h> #define ll long long #define ull unsigned long long #define mod 1000000007 using namespace std; ll binpow(ll x, ll y) /* (x^y)%p in O(log y) */ { ll res = 1; while (y > 0) { if (y & 1) res = (res * x); y = y >> 1; x = (x * x); } return res; } ull binpowmod(ull x, ull y...
#include <bits/stdc++.h> #define ll long long #define ull unsigned long long #define mod 1000000007 using namespace std; ll binpow(ll x, ll y) /* (x^y)%p in O(log y) */ { ll res = 1; while (y > 0) { if (y & 1) res = (res * x); y = y >> 1; x = (x * x); } return res; } ull binpowmod(ull x, ull y...
[["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 20], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 47]]
1
529
n,m=map(int,input().split()) a=list(map(int,input().split())) if(sum(a)>m): print(-1) else: val=n-sum(a) print(val)
n,m=map(int,input().split()) a=list(map(int,input().split())) if(sum(a)>n): print(-1) else: val=n-sum(a) print(val)
[["-", 0, 656, 0, 57, 15, 23, 0, 666, 0, 22], ["+", 0, 656, 0, 57, 15, 23, 0, 666, 0, 22]]
5
62
#include <algorithm> #include <ctime> #include <iomanip> #include <iostream> #include <math.h> #include <queue> #include <set> #include <stdio.h> #include <string> #include <vector> using namespace std; typedef long long ll; #define PI 3.14159265358979323846264338327950L int res = -1; int main() { cin.tie(nullptr)...
#include <algorithm> #include <ctime> #include <iomanip> #include <iostream> #include <math.h> #include <queue> #include <set> #include <stdio.h> #include <string> #include <vector> using namespace std; typedef long long ll; #define PI 3.14159265358979323846264338327950L int res = -1; int main() { cin.tie(nullptr)...
[["-", 64, 9, 0, 1, 0, 11, 12, 16, 31, 22], ["-", 64, 9, 0, 1, 0, 11, 12, 16, 17, 33], ["+", 64, 9, 0, 1, 0, 11, 12, 16, 17, 33], ["+", 64, 9, 0, 1, 0, 11, 12, 16, 12, 22]]
1
135
#include <algorithm> #include <bits/stdc++.h> #include <bitset> #include <cassert> #include <cstring> #include <functional> #include <iomanip> #include <iostream> #include <map> #include <math.h> #include <queue> #include <stack> #include <stdio.h> #include <tuple> #include <vector> using namespace std; #define rep(i,...
#include <algorithm> #include <bits/stdc++.h> #include <bitset> #include <cassert> #include <cstring> #include <functional> #include <iomanip> #include <iostream> #include <map> #include <math.h> #include <queue> #include <stack> #include <stdio.h> #include <tuple> #include <vector> using namespace std; #define rep(i,...
[["-", 8, 9, 0, 57, 15, 339, 51, 16, 31, 22], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 31, 22]]
1
144
n,m=map(int,input().split()) a=list(map(int,input().split())) cnt=0 for i in a: cnt+=i if cnt<0: print(-1) else: print(n-cnt)
n,m=map(int,input().split()) a=list(map(int,input().split())) cnt=0 for i in a: cnt+=i if n-cnt<0: print(-1) else: print(n-cnt)
[["+", 0, 656, 0, 57, 15, 666, 0, 657, 31, 22], ["+", 0, 656, 0, 57, 15, 666, 0, 657, 17, 33]]
5
62
#include <bits/stdc++.h> using namespace std; int main() { int n, m; cin >> n >> m; vector<int> hw(m); for (int &i : hw) cin >> i; for (int i = 0; i < m; i++) n -= hw[i]; if (n > 0) cout << n << endl; else cout << -1 << endl; }
#include <bits/stdc++.h> using namespace std; int main() { int n, m; cin >> n >> m; vector<int> hw(m); for (int &i : hw) cin >> i; for (int i = 0; i < m; i++) n -= hw[i]; if (n >= 0) cout << n << endl; else cout << -1 << endl; }
[["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 47], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 20]]
1
84
#include <iostream> using namespace std; int main() { int n, m; cin >> n >> m; int sum = 0, tmp; for (int i = 0; i < m; i++) { cin >> tmp; sum += tmp; } int val = n - val; if (val < 0) { cout << -1 << endl; } else { cout << val << endl; } return 0; }
#include <iostream> using namespace std; int main() { int n, m; cin >> n >> m; int sum = 0, tmp; for (int i = 0; i < m; i++) { cin >> tmp; sum += tmp; } int val = n - sum; if (val < 0) { cout << -1 << endl; } else { cout << val << endl; } return 0; }
[["-", 8, 9, 0, 43, 49, 50, 51, 16, 12, 22], ["+", 8, 9, 0, 43, 49, 50, 51, 16, 12, 22]]
1
87
x,y=gets.split.map!(&:to_i) s=gets.splot.map!(&:to_i) day=x-s.sum if day>=0 puts day else puts -1 end
x,y=gets.split.map!(&:to_i) s=gets.split.map!(&:to_i) day=x-s.sum if day>=0 puts day else puts -1 end
[["-", 0, 493, 0, 662, 12, 652, 486, 652, 735, 22], ["+", 0, 493, 0, 662, 12, 652, 486, 652, 735, 22]]
4
42
#include <stdio.h> int main() { int n, m, a[1000], temp = 0; scanf("%d %d", &n, &m); for (int i = 0; i < m; i++) { scanf("%d", &a[i]); } for (int p = 0; p < m; p++) { temp = temp + a[p]; } if (n >= temp) { printf("%d\n", n - temp); } else { printf("-1"); } return 0; }
#include <stdio.h> int main() { int n, m, a[10000], temp = 0; scanf("%d %d", &n, &m); for (int i = 0; i < m; i++) { scanf("%d", &a[i]); } for (int p = 0; p < m; p++) { temp = temp + a[p]; } if (n >= temp) { printf("%d\n", n - temp); } else { printf("-1"); } return 0; }
[["-", 0, 14, 8, 9, 0, 43, 49, 80, 81, 13], ["+", 0, 14, 8, 9, 0, 43, 49, 80, 81, 13]]
0
122
input_nm = gets.split(" ").map(&:to_i) n = input_nm[0] array = gets.split(" ").map(&:to_i) sum = array.sum free = n-sum if free >= 1 puts free else puts "-1" end
input_nm = gets.split(" ").map(&:to_i) n = input_nm[0] array = gets.split(" ").map(&:to_i) sum = array.sum free = n-sum if free >= 0 puts free else puts "-1" end
[["-", 36, 36, 0, 493, 0, 121, 15, 738, 12, 612], ["+", 36, 36, 0, 493, 0, 121, 15, 738, 12, 612]]
4
60
#include <stdio.h> int main() { int N, M; int A[1000]; int i; int count = 0; scanf("%d %d", &N, &M); for (i = 0; i < M; i++) { scanf("%d", &A[i]); count += A[i]; } if (count > N) { printf("-1"); } else { printf("%d", N - count); } return 0; }
#include <stdio.h> int main() { int N, M; int A[10000]; int i; int count = 0; scanf("%d %d", &N, &M); for (i = 0; i < M; i++) { scanf("%d", &A[i]); count += A[i]; } if (count > N) { printf("-1"); } else { printf("%d", N - count); } return 0; }
[["-", 0, 14, 8, 9, 0, 43, 49, 80, 81, 13], ["+", 0, 14, 8, 9, 0, 43, 49, 80, 81, 13]]
0
107
#include <stdio.h> int main() { int a[1000]; int n, m; int x = 0; scanf("%d %d", &n, &m); for (int i = 0; i < m; i++) { scanf("%d", &a[i]); } for (int i = 0; i < m; i++) { x += a[i]; } if (x > n) { printf("-1\n"); } else { printf("%d\n", n - x); } return 0; }
#include <stdio.h> int main() { int a[10010]; int n, m; int x = 0; scanf("%d %d", &n, &m); for (int i = 0; i < m; i++) { scanf("%d", &a[i]); } for (int i = 0; i < m; i++) { x += a[i]; } if (x > n) { printf("-1\n"); } else { printf("%d\n", n - x); } return 0; }
[["-", 0, 14, 8, 9, 0, 43, 49, 80, 81, 13], ["+", 0, 14, 8, 9, 0, 43, 49, 80, 81, 13]]
0
123
#include <stdio.h> int main() { int N, M, A[1000]; scanf("%d%d", &N, &M); for (int i = 0; i < M; i++) { scanf("%d", &A[i]); N = N - A[i]; } if (N < 0) { printf("%d", -1); } else { printf("%d", N); } return 0; }
#include <stdio.h> int main() { int N, M, A[10000]; scanf("%d%d", &N, &M); for (int i = 0; i < M; i++) { scanf("%d", &A[i]); N = N - A[i]; } if (N < 0) { printf("%d", -1); } else { printf("%d", N); } return 0; }
[["-", 0, 14, 8, 9, 0, 43, 49, 80, 81, 13], ["+", 0, 14, 8, 9, 0, 43, 49, 80, 81, 13]]
0
101
#include <iostream> using namespace std; int main() { int N, M, A; cin >> N >> M; int sum = 0; for (int i = 0; i < M; i++) { cin >> A; sum += A; } if (sum >= N) cout << -1 << endl; else cout << N - sum << endl; }
#include <iostream> using namespace std; int main() { int N, M, A; cin >> N >> M; int sum = 0; for (int i = 0; i < M; i++) { cin >> A; sum += A; } if (sum > N) cout << -1 << endl; else cout << N - sum << endl; }
[["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 20], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 47]]
1
75
a=list(map(int,input().split())) b=list(map(int,input().split())) if sum(b)>a[0]: print(-1) elif sum(b)==a[0]: print(1) else: print(a[0]-sum(b))
a=list(map(int,input().split())) b=list(map(int,input().split())) if sum(b)>a[0]: print(-1) elif sum(b)==a[0]: print(0) else: print(a[0]-sum(b))
[["-", 64, 196, 0, 1, 0, 652, 3, 4, 0, 612], ["+", 64, 196, 0, 1, 0, 652, 3, 4, 0, 612]]
5
79
#include <stdio.h> int main(void) { int n, m; int i, a = 0; scanf("%d", &n); //休みの日数 scanf("%d", &m); //宿題の数 for (i = 0; i < m; i++) { scanf("%d", &a); //終わらせるまでの日数 a += a; } if (n - a >= 0) printf("%d", n - a); else printf("-1"); return 0; }
#include <stdio.h> int main(void) { int n, m; int i, a, sum = 0; scanf("%d", &n); //休みの日数 scanf("%d", &m); //宿題の数 for (i = 0; i < m; i++) { scanf("%d", &a); //終わらせるまでの日数 sum += a; } if (n - sum >= 0) printf("%d", n - sum); else printf("-1"); return 0; }
[["+", 0, 30, 0, 14, 8, 9, 0, 43, 0, 21], ["+", 0, 14, 8, 9, 0, 43, 49, 50, 49, 22], ["-", 0, 7, 8, 9, 0, 1, 0, 11, 31, 22], ["+", 0, 7, 8, 9, 0, 1, 0, 11, 31, 22], ["-", 0, 57, 15, 23, 0, 16, 31, 16, 12, 22], ["+", 0, 57, 15, 23, 0, 16, 31, 16, 12, 22], ["-", 64, 1, 0, 2, 3, 4, 0, 16, 12, 22], ["+", 64, 1, 0, 2, 3, 4,...
0
103
#include <stdio.h> #include <stdlib.h> void main(void) { int sum = 0, a, b, c[1000]; scanf("%d", &a); scanf("%d", &b); for (int i = 0; i < b; i++) { scanf("%d", c + i); sum += c[i]; } if (sum > a) { printf("-1"); } else { printf("%d", a - sum); } }
#include <stdio.h> #include <stdlib.h> void main(void) { int sum = 0, a, b, c[10000]; scanf("%d", &a); scanf("%d", &b); for (int i = 0; i < b; i++) { scanf("%d", c + i); sum += c[i]; } if (sum > a) { printf("-1"); } else { printf("%d", a - sum); } }
[["-", 0, 14, 8, 9, 0, 43, 49, 80, 81, 13], ["+", 0, 14, 8, 9, 0, 43, 49, 80, 81, 13]]
0
108
#include <bits/stdc++.h> using namespace std; int main() { int n, m, k; cin >> n >> m; int sum = 0; for (int i = 0; i < n; i++) { cin >> k; sum += k; } if (sum > n) { cout << -1; } else { cout << n - sum; } }
#include <bits/stdc++.h> using namespace std; int main() { int n, m, k; cin >> n >> m; int sum = 0; for (int i = 0; i < m; i++) { cin >> k; sum += k; } if (sum > n) { cout << -1; } else { cout << n - sum; } }
[["-", 0, 14, 8, 9, 0, 7, 15, 16, 12, 22], ["+", 0, 14, 8, 9, 0, 7, 15, 16, 12, 22]]
1
75
m,n,*aa = open(0).read().split() ans = m-sum(aa) if ans<0: print(-1) else: print(ans)
m,n,*aa = map(int, open(0).read().split()) ans = m-sum(aa) if ans<0: print(-1) else: print(ans)
[["+", 0, 656, 0, 1, 0, 662, 12, 652, 63, 22], ["+", 0, 1, 0, 662, 12, 652, 3, 4, 0, 24], ["+", 0, 1, 0, 662, 12, 652, 3, 4, 0, 22], ["+", 0, 1, 0, 662, 12, 652, 3, 4, 0, 21], ["+", 12, 652, 3, 4, 0, 652, 3, 4, 0, 25]]
5
43
import math import sys import collections import bisect readline = sys.stdin.readline def main(): n, m = map(int, readline().rstrip().split()) a = list(map(int, readline().rstrip().split())) print(n - sum(a) if n - sum(a) > 0 else -1) if __name__ == '__main__': main()
import math import sys import collections import bisect readline = sys.stdin.readline def main(): n, m = map(int, readline().rstrip().split()) a = list(map(int, readline().rstrip().split())) print(n - sum(a) if n - sum(a) >= 0 else -1) if __name__ == '__main__': main()
[["-", 0, 652, 3, 4, 0, 41, 0, 666, 667, 47], ["+", 0, 652, 3, 4, 0, 41, 0, 666, 667, 20]]
5
92
N, M = map(int, input().split()) A = list(map(int, input().split())) t = sum(A) if N < t: print(-1) exit(0) else: print(N-A)
N, M = map(int, input().split()) A = list(map(int, input().split())) t = sum(A) if N < t: print(-1) exit(0) else: print(N-t)
[["-", 0, 1, 0, 652, 3, 4, 0, 657, 12, 22], ["+", 0, 1, 0, 652, 3, 4, 0, 657, 12, 22]]
5
61
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int, int> ii; typedef vector<ii> vii; typedef vector<int> vi; typedef vector<ll> vll; #define rep(i, a, n) for (int i = a; i < n; i++) #define per(i, a, n) for (int i = n - 1; i >= a; i--) #define pb push_back #define eb emplace_back #defi...
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int, int> ii; typedef vector<ii> vii; typedef vector<int> vi; typedef vector<ll> vll; #define rep(i, a, n) for (int i = a; i < n; i++) #define per(i, a, n) for (int i = n - 1; i >= a; i--) #define pb push_back #define eb emplace_back #defi...
[["-", 8, 9, 0, 1, 0, 2, 3, 4, 0, 22], ["+", 8, 9, 0, 1, 0, 2, 3, 4, 0, 22]]
1
202
#include <bits/stdc++.h> using namespace std; long long N, M; int main() { cin >> N >> M; for (long long i = 0; i < M; i++) { long long tmp; cin >> tmp; N -= tmp; } if (N > 0) { cout << N << endl; } else { cout << -1 << endl; } }
#include <bits/stdc++.h> using namespace std; long long N, M; int main() { cin >> N >> M; for (long long i = 0; i < M; i++) { long long tmp; cin >> tmp; N -= tmp; } if (N >= 0) { cout << N << endl; } else { cout << -1 << endl; } }
[["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 47], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 20]]
1
76
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (n); ++i) using namespace std; using ll = long long; // using P = pair<int,int>; int main() { int n, m, b = 0, a = 0; cin >> n >> m; rep(i, m) { cin >> a; b += a; } if (n > b) cout << n - b << endl; else cout << -1 << endl; }
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (n); ++i) using namespace std; using ll = long long; // using P = pair<int,int>; int main() { int n, m, b = 0, a = 0; cin >> n >> m; rep(i, m) { cin >> a; b += a; } if (n >= b) cout << n - b << endl; else cout << -1 << endl; }
[["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 47], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 20]]
1
83
N,M = map(int, input().split()) A = list(map(int, input().split())) ans = max(N - sum(A)) print(ans)
N,M = map(int, input().split()) A = list(map(int, input().split())) ans = max(N - sum(A), -1) print(ans)
[["+", 0, 1, 0, 662, 12, 652, 3, 4, 0, 21], ["+", 0, 662, 12, 652, 3, 4, 0, 664, 17, 33], ["+", 0, 662, 12, 652, 3, 4, 0, 664, 28, 612]]
5
48
#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()
#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()
[["-", 0, 14, 8, 196, 0, 57, 15, 666, 667, 20], ["+", 0, 14, 8, 196, 0, 57, 15, 666, 667, 47]]
5
70
def main(): n, m = map(int,input().split()) a = list(map(int,input().split())) sum = sum(a) if sum <= n: print(n - sum) else: print(-1) main()
def main(): n, m = map(int,input().split()) a = list(map(int,input().split())) Sum = sum(a) if Sum <= n: print(n - Sum) else: print(-1) main()
[["-", 0, 14, 8, 196, 0, 1, 0, 662, 31, 22], ["+", 0, 14, 8, 196, 0, 1, 0, 662, 31, 22], ["-", 0, 14, 8, 196, 0, 57, 15, 666, 0, 22], ["+", 0, 14, 8, 196, 0, 57, 15, 666, 0, 22], ["-", 0, 1, 0, 652, 3, 4, 0, 657, 12, 22], ["+", 0, 1, 0, 652, 3, 4, 0, 657, 12, 22]]
5
65
// #pragma GCC target("avx2") // #pragma GCC optimize("O3") // #pragma GCC optimize("unroll-loops") // #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native") #include <bits/stdc++.h> using namespace std; // for loop関係 #define rep(i, a, n) for (int i = (a); i < (n); ++i) #define repe(i, a, n) fo...
// #pragma GCC target("avx2") // #pragma GCC optimize("O3") // #pragma GCC optimize("unroll-loops") // #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native") #include <bits/stdc++.h> using namespace std; // for loop関係 #define rep(i, a, n) for (int i = (a); i < (n); ++i) #define repe(i, a, n) fo...
[["+", 8, 9, 0, 9, 0, 43, 49, 50, 0, 32], ["+", 8, 9, 0, 9, 0, 43, 49, 50, 51, 13], ["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 19], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 18]]
1
346
#include <bits/stdc++.h> using namespace std; int main() { int N, M; cin >> N >> M; int A; int S = 0; for (int i = 0; i < M; i++) { cin >> A; S += A; } if (N - S < 0) cout << -1 << endl; else if (N - S >= 0) cout << N - A << endl; }
#include <bits/stdc++.h> using namespace std; int main() { int N, M; cin >> N >> M; int A; int S = 0; for (int i = 0; i < M; i++) { cin >> A; S += A; } if (N - S < 0) cout << -1 << endl; else if (N - S >= 0) cout << N - S << endl; }
[["-", 64, 1, 0, 16, 31, 16, 12, 16, 12, 22], ["+", 64, 1, 0, 16, 31, 16, 12, 16, 12, 22]]
1
86
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)
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)
[["-", 0, 7, 8, 196, 0, 57, 15, 666, 667, 19], ["+", 0, 7, 8, 196, 0, 57, 15, 666, 667, 18]]
5
57
#include <bits/stdc++.h> using namespace std; int main() { int N, M; cin >> N >> M; for (int i = 0; i < M && N > 0; i++) { int A; cin >> A; N -= A; } if (N < 0) N = -1; cout << N << endl; }
#include <bits/stdc++.h> using namespace std; int main() { int N, M; cin >> N >> M; for (int i = 0; i < M && N >= 0; i++) { int A; cin >> A; N -= A; } if (N < 0) N = -1; cout << N << endl; }
[["-", 8, 9, 0, 7, 15, 16, 12, 16, 17, 47], ["+", 8, 9, 0, 7, 15, 16, 12, 16, 17, 20]]
1
70
n,m = map(int,input().split()) a = list(map(int,input().split())) sum_a = sum(a) print(n-sum_a if n-sum_a >0 else -1)
n,m = map(int,input().split()) a = list(map(int,input().split())) sum_a = sum(a) print(n-sum_a if n-sum_a >=0 else -1)
[["-", 0, 652, 3, 4, 0, 41, 0, 666, 667, 47], ["+", 0, 652, 3, 4, 0, 41, 0, 666, 667, 20]]
5
54
N,_ = map(int, input().split()) z = N - eval(input().replace(*' +')) print(z if 0<=0 else -1 )
N,_ = map(int, input().split()) z = N - eval(input().replace(*' +')) print(z if 0 <= z else -1 )
[["-", 0, 652, 3, 4, 0, 41, 0, 666, 0, 612], ["+", 0, 652, 3, 4, 0, 41, 0, 666, 0, 22]]
5
45
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)
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)
[["-", 0, 14, 8, 196, 0, 57, 15, 666, 667, 18], ["+", 0, 14, 8, 196, 0, 57, 15, 666, 667, 47]]
5
104
#include <math.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <time.h> #define FOR(i, n) for (int i = 0; i < n; i++) #define PRN(n) printf("%d\n", n) #define PRF(n) printf("%lf\n", n) #define PRL(n) printf("%lld\n", n) #define PRS(s) printf("%s\n", s) #define PRC(c) printf("%c", c) #define INI(n...
#include <math.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <time.h> #define FOR(i, n) for (int i = 0; i < n; i++) #define PRN(n) printf("%d\n", n) #define PRF(n) printf("%lf\n", n) #define PRL(n) printf("%lld\n", n) #define PRS(s) printf("%s\n", s) #define PRC(c) printf("%c", c) #define INI(n...
[["-", 8, 9, 0, 1, 0, 2, 3, 4, 0, 22], ["+", 8, 9, 0, 1, 0, 2, 3, 4, 0, 22], ["-", 8, 9, 0, 9, 0, 1, 0, 11, 31, 22], ["+", 8, 9, 0, 9, 0, 1, 0, 11, 31, 22], ["-", 8, 9, 0, 57, 15, 23, 0, 16, 31, 22], ["+", 8, 9, 0, 57, 15, 23, 0, 16, 31, 22], ["-", 0, 9, 0, 1, 0, 2, 3, 4, 0, 22], ["+", 0, 9, 0, 1, 0, 2, 3, 4, 0, 22]]
0
726
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < n; i++) using namespace std; using ll = long long; int main() { int N, M; cin >> N, M; int A; int ans = N; rep(i, M) { cin >> A; ans -= A; if (ans < 0) { cout << -1 << endl; return 0; } } cout << ans << endl; re...
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < n; i++) using namespace std; using ll = long long; int main() { int N, M; cin >> N >> M; int A; int ans = N; rep(i, M) { cin >> A; ans -= A; if (ans < 0) { cout << -1 << endl; return 0; } } cout << ans << endl; ...
[["-", 0, 14, 8, 9, 0, 1, 0, 34, 0, 21], ["+", 0, 14, 8, 9, 0, 1, 0, 16, 17, 152]]
1
87
#ABC163B n,m = map(int,input().split()) a = list(map(int,input().split())) print(-1 if sum(a) >= n else n-sum(a))
#ABC163B n,m = map(int,input().split()) a = list(map(int,input().split())) print(-1 if sum(a) > n else n-sum(a))
[["-", 0, 652, 3, 4, 0, 41, 0, 666, 667, 20], ["+", 0, 652, 3, 4, 0, 41, 0, 666, 667, 47]]
5
53
N,M = map(int,input().split()) A = sum(list(map(int,input().split()))) if N - A <= 0: print(-1) else: print(N - A)
N,M = map(int,input().split()) A = sum(list(map(int,input().split()))) if N - A < 0: print("-1") else: print(N - A)
[["-", 36, 36, 0, 656, 0, 57, 15, 666, 667, 19], ["+", 36, 36, 0, 656, 0, 57, 15, 666, 667, 18], ["-", 0, 1, 0, 652, 3, 4, 0, 664, 17, 33], ["-", 0, 1, 0, 652, 3, 4, 0, 664, 28, 612], ["+", 0, 1, 0, 652, 3, 4, 0, 557, 0, 654], ["+", 0, 1, 0, 652, 3, 4, 0, 557, 0, 6], ["+", 0, 1, 0, 652, 3, 4, 0, 557, 0, 655]]
5
56
# 高橋君の夏休みはN日間です。夏休みの宿題がM個出されており,i番目の宿題をやるにはAi日間かかります。 # 複数の宿題を同じ日にやることはできず、また、宿題をやる日には遊ぶことができません。 # 夏休み中に全ての宿題を終わらせるとき、最大何日間遊ぶことができますか? # ただし、夏休み中に全ての宿題を終わらせることができないときは、かわりに -1 を出力してください。 N, M = map(int, input().split()) study_days = map(int, input().split()) # リストにM個の数字を、入力したい # study_days_list = [] # study_days_l...
# 高橋君の夏休みはN日間です。夏休みの宿題がM個出されており,i番目の宿題をやるにはAi日間かかります。 # 複数の宿題を同じ日にやることはできず、また、宿題をやる日には遊ぶことができません。 # 夏休み中に全ての宿題を終わらせるとき、最大何日間遊ぶことができますか? # ただし、夏休み中に全ての宿題を終わらせることができないときは、かわりに -1 を出力してください。 N, M = map(int, input().split()) study_days = map(int, input().split()) # リストにM個の数字を、入力したい # study_days_list = [] # study_days_l...
[["-", 36, 36, 0, 656, 0, 57, 15, 666, 667, 19], ["+", 36, 36, 0, 656, 0, 57, 15, 666, 667, 18]]
5
67
n,m = map(int,input()>split()) homework = list(map(int,input().split())) if n >= sum(homework): print(n-sum(homework)) else: print(-1)
n,m = map(int,input().split()) homework = list(map(int,input().split())) if n >= sum(homework): print(n-sum(homework)) else: print(-1)
[["-", 0, 662, 12, 652, 3, 4, 0, 666, 667, 47], ["+", 12, 652, 3, 4, 0, 652, 63, 319, 0, 131]]
5
57
N, M = map(int, input().split()) A = list(map(int, input().split())) for Ai in A: N -= Ai if N < 0: print(-1) if N >= 0: print(N)
N, M = map(int, input().split()) A = list(map(int, input().split())) for Ai in A: N -= Ai if N < 0: print(-1) break if N >= 0: print(N)
[["+", 8, 196, 0, 57, 64, 196, 0, 93, 0, 94]]
5
60
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')
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')
[["-", 12, 652, 3, 4, 0, 652, 63, 319, 319, 22], ["+", 12, 652, 3, 4, 0, 652, 63, 319, 319, 22], ["-", 0, 652, 3, 4, 0, 652, 63, 319, 319, 22], ["+", 0, 652, 3, 4, 0, 652, 63, 319, 319, 22]]
5
61
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)
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)
[["-", 0, 656, 0, 1, 0, 662, 12, 206, 0, 70], ["+", 0, 1, 0, 662, 12, 652, 3, 4, 0, 24], ["-", 0, 656, 0, 1, 0, 662, 12, 206, 0, 73], ["+", 0, 1, 0, 662, 12, 652, 3, 4, 0, 25]]
5
65
#include <bits/stdc++.h> using namespace std; #define fastIO ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0) typedef long long ll; int main() { fastIO; int n, m; cin >> n >> m; int sum = 0; for (int i = 0; i < m; i++) { int x; cin >> x; sum += x; } if (n > sum) { cout << n - sum...
#include <bits/stdc++.h> using namespace std; #define fastIO ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0) typedef long long ll; int main() { fastIO; int n, m; cin >> n >> m; int sum = 0; for (int i = 0; i < m; i++) { int x; cin >> x; sum += x; } if (n >= sum) { cout << n - su...
[["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 47], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 20]]
1
86
#include <iostream> using namespace std; int main(void) { int N, M; int A[1000]; cin >> N >> M; int sum = 0; for (int i = 0; i < M; i++) { cin >> A[i]; sum += A[i]; } if (N >= sum) { cout << N - sum << endl; } else { cout << "-1" << endl; } return 0; }
#include <iostream> using namespace std; int main(void) { int N, M; int A[10000]; cin >> N >> M; int sum = 0; for (int i = 0; i < M; i++) { cin >> A[i]; sum += A[i]; } if (N >= sum) { cout << N - sum << endl; } else { cout << "-1" << endl; } return 0; }
[["-", 0, 14, 8, 9, 0, 43, 49, 80, 81, 13], ["+", 0, 14, 8, 9, 0, 43, 49, 80, 81, 13]]
1
95
#include <bits/stdc++.h> #include <iostream> int main() { int n, m; std::cin >> n >> m; int sum = 0; for (int i = 0; i < m; ++i) { int a; std::cin >> a; sum += a; } std::cout << std::max(n - m, -1) << std::endl; return 0; }
#include <bits/stdc++.h> #include <iostream> int main() { int n, m; std::cin >> n >> m; int sum = 0; for (int i = 0; i < m; ++i) { int a; std::cin >> a; sum += a; } std::cout << std::max(n - sum, -1) << std::endl; return 0; }
[["-", 31, 16, 12, 2, 3, 4, 0, 16, 12, 22], ["+", 31, 16, 12, 2, 3, 4, 0, 16, 12, 22]]
1
79
#include <bits/stdc++.h> #define fi first #define se second #define rep(i, n) for (ll i = 0; i < (n); i++) #define rrep(i, n) for (ll i = 1; i <= (n); ++i) #define drep(i, n) for (ll i = (n)-1; i >= 0; --i) #define all(v) v.begin(), v.end() #define len(x) (ll)(x).length() #define maxs(x, y) x = max(x, y) #define mins(x...
#include <bits/stdc++.h> #define fi first #define se second #define rep(i, n) for (ll i = 0; i < (n); i++) #define rrep(i, n) for (ll i = 1; i <= (n); ++i) #define drep(i, n) for (ll i = (n)-1; i >= 0; --i) #define all(v) v.begin(), v.end() #define len(x) (ll)(x).length() #define maxs(x, y) x = max(x, y) #define mins(x...
[["-", 8, 9, 0, 57, 15, 339, 51, 16, 12, 22], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 12, 22]]
1
325
n, m = map(int, input().split()) lst = [ int(i) for i in input().split() ] if n - lst.sum() >= 0: print(n-lst.sum()) else: print(-1)
n, m = map(int, input().split()) lst = [ int(i) for i in input().split() ] if n - sum(lst) >= 0: print(n-sum(lst)) else: print(-1)
[["-", 15, 666, 0, 657, 12, 652, 63, 319, 500, 22], ["-", 15, 666, 0, 657, 12, 652, 63, 319, 0, 131], ["+", 15, 666, 0, 657, 12, 652, 3, 4, 0, 22], ["-", 3, 4, 0, 657, 12, 652, 63, 319, 500, 22], ["-", 3, 4, 0, 657, 12, 652, 63, 319, 0, 131], ["+", 3, 4, 0, 657, 12, 652, 3, 4, 0, 22]]
5
62
#include <bits/stdc++.h> using namespace std; #define LL long long int main() { LL N, M, A, B = 0; cin >> N >> M; for (int i = 0; i < M; i++) { cin >> A; B = B + A; if (N < B) { cout << -1 << endl; } } if (N >= B) { cout << N - B << endl; } }
#include <bits/stdc++.h> using namespace std; #define LL long long int main() { LL N, M, A, B = 0; cin >> N >> M; for (int i = 0; i < M; i++) { cin >> A; B = B + A; if (N < B) { cout << -1 << endl; break; } } if (N >= B) { cout << N - B << endl; } }
[["+", 8, 9, 0, 57, 64, 9, 0, 93, 0, 94], ["+", 8, 9, 0, 57, 64, 9, 0, 93, 0, 35]]
1
88
# -*- coding: utf-8 -*- n, m = map(int, input().split()) a = list(map(int, input().split())) ans = n - sum(a) if ans < 0: return -1 else: return ans
# -*- coding: utf-8 -*- n, m = map(int, input().split()) a = list(map(int, input().split())) ans = n - sum(a) if ans < 0: print(-1) else: print(ans)
[["-", 0, 656, 0, 57, 64, 196, 0, 37, 0, 38], ["+", 0, 57, 64, 196, 0, 1, 0, 652, 63, 22], ["+", 64, 196, 0, 1, 0, 652, 3, 4, 0, 24], ["+", 64, 196, 0, 1, 0, 652, 3, 4, 0, 25], ["-", 0, 57, 75, 76, 8, 196, 0, 37, 0, 38], ["+", 75, 76, 8, 196, 0, 1, 0, 652, 63, 22], ["+", 8, 196, 0, 1, 0, 652, 3, 4, 0, 24], ["+", 8, 196...
5
54
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)
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)
[["-", 12, 652, 3, 4, 0, 652, 3, 4, 0, 21], ["+", 0, 652, 3, 4, 0, 652, 63, 319, 0, 131], ["-", 36, 36, 36, 36, 0, 656, 0, 57, 0, 121], ["-", 36, 36, 0, 656, 0, 57, 15, 666, 0, 22], ["-", 36, 36, 0, 656, 0, 57, 15, 666, 667, 18], ["+", 36, 36, 0, 656, 0, 57, 75, 76, 0, 95]]
5
63
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (n); ++i) #define PI 3.14159265359 using namespace std; int main() { int n, m, total = 0, a; cin >> n >> m; rep(i, n) { cin >> a; total += a; } if (n >= total) cout << n - total << endl; else cout << -1 << endl; return 0; }
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (n); ++i) #define PI 3.14159265359 using namespace std; int main() { int n, m, total = 0, a; cin >> n >> m; rep(i, m) { cin >> a; total += a; } if (n >= total) cout << n - total << endl; else cout << -1 << endl; return 0; }
[["-", 0, 14, 49, 53, 54, 55, 0, 56, 39, 78], ["+", 0, 14, 49, 53, 54, 55, 0, 56, 39, 78]]
1
80
#include <bits/stdc++.h> #include <string.h> using namespace std; unsigned euclidean_gcd(unsigned, unsigned); int main() { int N, M, sum = 0; cin >> N >> M; vector<int> A(M); for (int i = 0; i < M; i++) { cin >> A.at(i); sum += A.at(i); } if (N - sum) { cout << N - sum << endl; } else { c...
#include <bits/stdc++.h> #include <string.h> using namespace std; unsigned euclidean_gcd(unsigned, unsigned); int main() { int N, M, sum = 0; cin >> N >> M; vector<int> A(M); for (int i = 0; i < M; i++) { cin >> A.at(i); sum += A.at(i); } if (N - sum >= 0) { cout << N - sum << endl; } else { ...
[["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 20], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 12, 13]]
1
105
#include <bits/stdc++.h> using namespace std; int main() { int N; // Number of days in vac int M; // Number of Assignments cin >> N >> M; int a{0}; int result{0}; while (M--) { cin >> a; result += a; } int fin = N - result; if (fin > 0) { cout << fin << "\n"; } else { cout << "...
#include <bits/stdc++.h> using namespace std; int main() { int N; // Number of days in vac int M; // Number of Assignments cin >> N >> M; int a{0}; int result{0}; while (M--) { cin >> a; result += a; } int fin = N - result; if (fin >= 0) { cout << fin << "\n"; } else { cout << ...
[["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 47], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 20]]
1
92
#include <bits/stdc++.h> using namespace std; int main() { int sum = 0, m, n, a[1001], i; cin >> n >> m; for (i = 0; i < m; i++) { cin >> a[i]; sum += a[i]; } if (sum <= n) cout << n - sum; else cout << "-1"; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int sum = 0, m, n, a[10001], i; cin >> n >> m; for (i = 0; i < m; i++) { cin >> a[i]; sum += a[i]; } if (sum <= n) cout << n - sum; else cout << "-1"; return 0; }
[["-", 0, 14, 8, 9, 0, 43, 49, 80, 81, 13], ["+", 0, 14, 8, 9, 0, 43, 49, 80, 81, 13]]
1
85
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound #include <bitset> // bitset #include <cctype> // isupper, islower, isdigit, toupper, tolower #include <cmath> #include <cstdint> // int64_t, int*_t #include <cstdio> // printf #include <deque> // deque #include <iostream> // cou...
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound #include <bitset> // bitset #include <cctype> // isupper, islower, isdigit, toupper, tolower #include <cmath> #include <cstdint> // int64_t, int*_t #include <cstdio> // printf #include <deque> // deque #include <iostream> // cou...
[["-", 0, 1, 0, 16, 31, 16, 12, 16, 31, 22], ["-", 0, 1, 0, 16, 31, 16, 12, 16, 17, 33], ["+", 0, 1, 0, 16, 31, 16, 12, 16, 17, 33], ["+", 0, 1, 0, 16, 31, 16, 12, 16, 12, 22], ["+", 0, 30, 0, 14, 8, 9, 0, 1, 0, 22], ["+", 0, 30, 0, 14, 8, 9, 0, 1, 0, 35]]
1
187
#include <stdio.h> int main() { int N, M, i, a; scanf("%d", &N); scanf("%d", &M); for (i = 0; i < M; i++) { scanf("%d", &a); N -= a; } if (N > 0) printf("%d", N); else printf("-1"); return 0; }
#include <stdio.h> int main() { int N, M, i, a; scanf("%d", &N); scanf("%d", &M); for (i = 0; i < M; i++) { scanf("%d", &a); N -= a; } if (N >= 0) printf("%d", N); else printf("-1"); return 0; }
[["-", 8, 9, 0, 57, 15, 23, 0, 16, 17, 47], ["+", 8, 9, 0, 57, 15, 23, 0, 16, 17, 20]]
0
92
#include <stdio.h> int main(void) { int N, M, i, num = 0; scanf("%d %d", &N, &M); int A[M]; for (i = 0; i < M; i++) { scanf("%d", A[i]); num = num + A[i]; } if (num > N) printf("-1"); else printf("%d", N - num); }
#include <stdio.h> int main(void) { int N, M, i, num = 0; scanf("%d %d", &N, &M); int A[M]; for (i = 0; i < M; i++) { scanf("%d", &A[i]); num = num + A[i]; } if (num > N) printf("-1"); else printf("%d", N - num); }
[["+", 0, 1, 0, 2, 3, 4, 0, 66, 17, 67]]
0
100
#include <stdio.h> int main(void) { int n; int m; int a[10000]; int i; int va; int sum = 0; scanf("%d %d", &n, &m); for (i = 0; i < m; i++) { scanf("%d ", &a[i]); sum = sum + a[i]; } va = n - sum; if (sum >= 0) printf("%d", va); else printf("%d", -1); return 0; }
#include <stdio.h> int main(void) { int n; int m; int a[10000]; int i; int va; int sum = 0; scanf("%d %d", &n, &m); for (i = 0; i < m; i++) { scanf("%d ", &a[i]); sum = sum + a[i]; } va = n - sum; if (va >= 0) printf("%d", va); else printf("%d", -1); return 0; }
[["-", 8, 9, 0, 57, 15, 23, 0, 16, 31, 22], ["+", 8, 9, 0, 57, 15, 23, 0, 16, 31, 22]]
0
116
#include <stdio.h> int main(void) { int n, m, i, sum = 0; int a[1000]; scanf("%d %d", &n, &m); for (i = 0; i < m; i++) { scanf("%d", &a[i]); sum += a[i]; } if (sum > n) { printf("-1"); } else { printf("%d", n - sum); } return 0; }
#include <stdio.h> int main(void) { int n, m, i, sum = 0; int a[10000]; scanf("%d %d", &n, &m); for (i = 0; i < m; i++) { scanf("%d", &a[i]); sum += a[i]; } if (sum > n) { printf("-1"); } else { printf("%d", n - sum); } return 0; }
[["-", 0, 14, 8, 9, 0, 43, 49, 80, 81, 13], ["+", 0, 14, 8, 9, 0, 43, 49, 80, 81, 13]]
0
106
#include <stdio.h> int main(void) { int n, m, i, sum = 0, judge; int a[10000]; scanf("%d %d", &n, &m); for (i = 0; i < m; i++) { scanf("%d", &a[i]); sum += a[i]; } judge = sum - n; if (judge < 0) printf("-1"); else printf("%d", judge); return 0; }
#include <stdio.h> int main(void) { int n, m, i, sum = 0, judge; int a[10000]; scanf("%d %d", &n, &m); for (i = 0; i < m; i++) { scanf("%d", &a[i]); sum += a[i]; } judge = n - sum; if (judge < 0) printf("-1"); else printf("%d", judge); return 0; }
[["-", 8, 9, 0, 1, 0, 11, 12, 16, 31, 22], ["-", 8, 9, 0, 1, 0, 11, 12, 16, 17, 33], ["+", 8, 9, 0, 1, 0, 11, 12, 16, 17, 33], ["+", 8, 9, 0, 1, 0, 11, 12, 16, 12, 22]]
0
108
x, y = map(int, input().spilit()) array = list(map(int, input().spilit())) su = sum(array) a = x - su if a > -1: print(a) else: print(-1)
x, y = map(int, input().split()) array = list(map(int, input().split())) su = sum(array) a = x - su if a > -1: print(a) else: print(-1)
[["-", 12, 652, 3, 4, 0, 652, 63, 319, 319, 22], ["+", 12, 652, 3, 4, 0, 652, 63, 319, 319, 22], ["-", 0, 652, 3, 4, 0, 652, 63, 319, 319, 22], ["+", 0, 652, 3, 4, 0, 652, 63, 319, 319, 22]]
5
61
n, m = map(int, input().split()) a = list(map(int, input().split())) ans = n for i in a: ans -= i if ans < 0: print(-1) print(ans)
n, m = map(int, input().split()) a = list(map(int, input().split())) ans = n for i in a: ans -= i if ans < 0: print(-1) else: print(ans)
[["+", 36, 36, 0, 656, 0, 57, 75, 76, 0, 95], ["+", 36, 36, 0, 656, 0, 57, 75, 76, 0, 102]]
5
58
a = list(map(int, input().split())) b = list(map(int, input().split())) if a[0] == sum(b): print(-1) else: print(a[0] - sum(b))
a = list(map(int, input().split())) b = list(map(int, input().split())) if a[0] < sum(b): print(-1) else: print(a[0] - sum(b))
[["-", 36, 36, 0, 656, 0, 57, 15, 666, 667, 60], ["+", 36, 36, 0, 656, 0, 57, 15, 666, 667, 18]]
5
64
#include <bits/stdc++.h> using namespace std; int main() { int n, m; cin >> n >> m; int count = 0; for (int i = 0; i < m; i++) { int data; cin >> data; count += data; } if (count) cout << -1 << endl; else cout << n - count << endl; }
#include <bits/stdc++.h> using namespace std; int main() { int n, m; cin >> n >> m; int count = 0; for (int i = 0; i < m; i++) { int data; cin >> data; count += data; } if (count > n) cout << -1 << endl; else cout << n - count << endl; }
[["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 47], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 12, 22]]
1
74
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))
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))
[["-", 36, 36, 0, 656, 0, 57, 15, 666, 0, 22], ["+", 36, 36, 0, 656, 0, 57, 15, 666, 0, 22]]
5
65
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (n); ++i) using namespace std; int main() { int n, m; cin >> n >> m; vector<int> a(m); rep(i, m) { cin >> a.at(i); } int sum = 0; rep(i, m) { sum += i; } if (sum > n) { cout << -1; } else { cout << n - sum; } }
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (n); ++i) using namespace std; int main() { int n, m; cin >> n >> m; vector<int> a(m); rep(i, m) { cin >> a.at(i); } int sum = 0; rep(i, m) { sum += a.at(i); } if (sum > n) { cout << -1; } else { cout << n - sum; } }
[["+", 0, 1, 0, 11, 12, 2, 63, 118, 28, 22], ["+", 0, 1, 0, 11, 12, 2, 63, 118, 17, 131], ["+", 0, 1, 0, 11, 12, 2, 63, 118, 119, 120], ["+", 0, 1, 0, 11, 12, 2, 3, 4, 0, 24], ["+", 0, 1, 0, 11, 12, 2, 3, 4, 0, 25]]
1
95
a, b = map(int, input().split()) c = sum(map(int, input().split())) print(max(c - a, -1))
a, b = map(int, input().split()) c = sum(map(int, input().split())) print(max(a - c, -1))
[["-", 3, 4, 0, 652, 3, 4, 0, 657, 31, 22], ["-", 3, 4, 0, 652, 3, 4, 0, 657, 17, 33], ["+", 3, 4, 0, 652, 3, 4, 0, 657, 17, 33], ["+", 3, 4, 0, 652, 3, 4, 0, 657, 12, 22]]
5
45
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 )
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 )
[["-", 0, 652, 3, 4, 0, 41, 0, 666, 667, 18], ["+", 0, 652, 3, 4, 0, 41, 0, 666, 667, 19]]
5
65
#include <iostream> using namespace std; int main() { int n; cin >> n; int m; cin >> m; int sumofassignments = 0; for (int i = 0; i < m; ++i) { int a; cin >> a; sumofassignments += a; } int remainingdays = n - sumofassignments; if (remainingdays <= 0) { cout << -1 << endl; } els...
#include <iostream> using namespace std; int main() { int n; cin >> n; int m; cin >> m; int sumofassignments = 0; for (int i = 0; i < m; ++i) { int a; cin >> a; sumofassignments += a; } int remainingdays = n - sumofassignments; if (remainingdays < 0) { cout << -1 << endl; } else...
[["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 19], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 18]]
1
91
n,m = map(int,input().split()) A = list(int(input()).split()) tmp = n-sum(A) if tmp >= 0: print(tmp) else: print(-1)
n,m = map(int,input().split()) A = list(map(int,input().split())) tmp = n-sum(A) if tmp >= 0: print(tmp) else: print(-1)
[["-", 3, 4, 0, 652, 63, 319, 500, 652, 63, 22], ["+", 0, 662, 12, 652, 3, 4, 0, 652, 63, 22], ["+", 12, 652, 3, 4, 0, 652, 3, 4, 0, 22], ["+", 12, 652, 3, 4, 0, 652, 3, 4, 0, 21], ["-", 500, 652, 3, 4, 0, 652, 3, 4, 0, 25], ["+", 0, 652, 3, 4, 0, 652, 3, 4, 0, 25]]
5
55
n,m = map(int,input().split()) grid = [] a = list(map(int, input().strip().split())) res = n - sum(a) if(res <= 0): res = -1 print(res)
n,m = map(int,input().split()) a = list(map(int, input().strip().split())) res = n - sum(a) if(res < 0): res = -1 print(res)
[["-", 36, 36, 0, 656, 0, 1, 0, 662, 31, 22], ["-", 36, 36, 0, 656, 0, 1, 0, 662, 0, 32], ["-", 0, 656, 0, 1, 0, 662, 12, 634, 0, 70], ["-", 0, 656, 0, 1, 0, 662, 12, 634, 0, 73], ["-", 0, 656, 0, 57, 15, 23, 0, 666, 667, 19], ["+", 0, 656, 0, 57, 15, 23, 0, 666, 667, 18]]
5
64
n,m=map(int, input().split()) a=list(map(int, input().split())) if sum(a)>=0: print(n-sum(a)) else: print(-1)
n,m=map(int, input().split()) a=list(map(int, input().split())) if n-sum(a)>=0: print(n-sum(a)) else: print(-1)
[["+", 0, 656, 0, 57, 15, 666, 0, 657, 31, 22], ["+", 0, 656, 0, 57, 15, 666, 0, 657, 17, 33]]
5
57
n,m = map(int,input().split()) a = list(map(int, input().split())) if n-sum(a)>n: print(-1) else: print(n-sum(a))
n,m = map(int,input().split()) a = list(map(int, input().split())) if sum(a)>n: print(-1) else: print(n-sum(a))
[["-", 0, 656, 0, 57, 15, 666, 0, 657, 31, 22], ["-", 0, 656, 0, 57, 15, 666, 0, 657, 17, 33]]
5
59
#include <iostream> using namespace std; int main() { int N, M, ans; cin >> N >> M; ans = N; for (int i = 1; i <= M; i++) { int A; cin >> A; ans = ans - N; } if (ans >= 0) cout << ans; else cout << -1; }
#include <iostream> using namespace std; int main() { int N, M, ans; cin >> N >> M; ans = N; for (int i = 1; i <= M; i++) { int A; cin >> A; ans = ans - A; } if (ans >= 0) cout << ans; else cout << -1; }
[["-", 8, 9, 0, 1, 0, 11, 12, 16, 12, 22], ["+", 8, 9, 0, 1, 0, 11, 12, 16, 12, 22]]
1
73
n,m=map(int, input().split()) a=list(map(int, input().split())) for x in range(len(a)): n-=a[x] if n<0: k=-1 print(n)
n,m=map(int, input().split()) a=list(map(int, input().split())) for x in range(len(a)): n-=a[x] if n<0: n=-1 print(n)
[["-", 0, 57, 64, 196, 0, 1, 0, 662, 31, 22], ["+", 0, 57, 64, 196, 0, 1, 0, 662, 31, 22]]
5
63
#include <bits/stdc++.h> using namespace std; int main() { // freopen("number.in", "r", stdin); // freopen("number.out", "w", stdout); int sum = 0; int n, m; cin >> n >> m; for (int i = 1; i <= n; i++) { int x; cin >> x; sum += x; } cout << max(m - sum, -1) << endl; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { // freopen("number.in", "r", stdin); // freopen("number.out", "w", stdout); int sum = 0; int n, m; cin >> n >> m; for (int i = 1; i <= m; i++) { int x; cin >> x; sum += x; } cout << max(n - sum, -1) << endl; return 0; }
[["-", 0, 14, 8, 9, 0, 7, 15, 16, 12, 22], ["+", 0, 14, 8, 9, 0, 7, 15, 16, 12, 22], ["-", 31, 16, 12, 2, 3, 4, 0, 16, 31, 22], ["+", 31, 16, 12, 2, 3, 4, 0, 16, 31, 22]]
1
73
#include <bits/stdc++.h> using namespace std; int main() { int n, a; cin >> n, a; int count = 0; for (int i = 0; i < a; i++) { int b; cin >> b; count += b; } if (count > n) { cout << -1 << endl; } else { cout << n - count << endl; } }
#include <bits/stdc++.h> using namespace std; int main() { int n, a; cin >> n >> a; int count = 0; for (int i = 0; i < a; i++) { int b; cin >> b; count += b; } if (count > n) { cout << -1 << endl; } else { cout << n - count << endl; } }
[["-", 0, 14, 8, 9, 0, 1, 0, 34, 0, 21], ["+", 0, 14, 8, 9, 0, 1, 0, 16, 17, 152]]
1
80
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])
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)
[["-", 0, 1, 0, 652, 3, 4, 0, 657, 31, 22], ["-", 0, 1, 0, 652, 3, 4, 0, 657, 17, 33], ["+", 0, 1, 0, 652, 3, 4, 0, 657, 17, 33], ["+", 0, 1, 0, 652, 3, 4, 0, 657, 12, 22]]
5
68
n, m = gets.split.map(&:to_i) a = gets.split.map(&:to_i) sum_day = 0 a.times do |i| sum_day += a end puts n >= sum_day ? (n - sum_day) : -1
n, m = gets.split.map(&:to_i) a = gets.split.map(&:to_i) sum_day = 0 a.each do |i| sum_day += i end puts n >= sum_day ? (n - sum_day) : -1
[["-", 36, 36, 36, 36, 0, 493, 0, 652, 735, 22], ["+", 36, 36, 36, 36, 0, 493, 0, 652, 735, 22], ["-", 0, 652, 196, 737, 8, 736, 0, 755, 12, 22], ["+", 0, 652, 196, 737, 8, 736, 0, 755, 12, 22]]
4
51
n,m=map(int,input().split(" ")) a=list(map(int,input().split(" "))) print(min(-1, n-sum(a)))
n,m=map(int,input().split(" ")) a=list(map(int,input().split(" "))) print(max(-1, n-sum(a)))
[["-", 0, 1, 0, 652, 3, 4, 0, 652, 63, 22], ["+", 0, 1, 0, 652, 3, 4, 0, 652, 63, 22]]
5
54
#include <bits/stdc++.h> using namespace std; int main() { int a, b, c = 0; cin >> a >> b; for (int i = 0; i < b; i++) { int j; cin >> j; c += j; } if (c > a) { cout << "-1"; return 0; } cout << c - a; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int a, b, c = 0; cin >> a >> b; for (int i = 0; i < b; i++) { int j; cin >> j; c += j; } if (c > a) { cout << "-1"; return 0; } cout << a - c; return 0; }
[["-", 8, 9, 0, 1, 0, 16, 12, 16, 31, 22], ["-", 8, 9, 0, 1, 0, 16, 12, 16, 17, 33], ["+", 8, 9, 0, 1, 0, 16, 12, 16, 17, 33], ["+", 8, 9, 0, 1, 0, 16, 12, 16, 12, 22]]
1
80
n,m = map(int, input().split()) a = list(map(int, input().split())) print(n-sum(a) if n-sum(a) > 0 else "-1")
n,m = map(int, input().split()) a = list(map(int, input().split())) print(n-sum(a) if n-sum(a) >= 0 else "-1")
[["-", 0, 652, 3, 4, 0, 41, 0, 666, 667, 47], ["+", 0, 652, 3, 4, 0, 41, 0, 666, 667, 20]]
5
55
N, M = map(int, input().split()) A = list(map(int, input().split())) ASOBU = sum(A) - N if ASOBU >= 0: print(ASOBU) else: print('-1')
N, M = map(int, input().split()) A = list(map(int, input().split())) ASOBU = N - sum(A) if ASOBU >= 0: print(ASOBU) else: print('-1')
[["+", 0, 656, 0, 1, 0, 662, 12, 657, 31, 22], ["+", 0, 656, 0, 1, 0, 662, 12, 657, 17, 33], ["-", 0, 656, 0, 1, 0, 662, 12, 657, 17, 33], ["-", 0, 656, 0, 1, 0, 662, 12, 657, 12, 22]]
5
58
n,m=map(int,input().split()) a=list(map,int().input()) x=sum(a) if n<x: print('-1') else: print(n-x)
n,m=map(int,input().split()) a=list(map(int,input().split())) x=sum(a) if n<x: print('-1') else: print(n-x)
[["-", 0, 1, 0, 662, 12, 652, 3, 4, 0, 21], ["+", 12, 652, 3, 4, 0, 652, 3, 4, 0, 24], ["+", 12, 652, 3, 4, 0, 652, 3, 4, 0, 21], ["+", 3, 4, 0, 652, 63, 319, 500, 652, 63, 22], ["-", 12, 652, 3, 4, 0, 652, 63, 319, 319, 22], ["+", 0, 652, 3, 4, 0, 652, 63, 319, 319, 22], ["+", 0, 652, 3, 4, 0, 652, 3, 4, 0, 25]]
5
55
#include <bits/stdc++.h> #include <math.h> #define PI 3.14159265358979323846264338327950L #define ll long long using namespace std; int main() { ios::sync_with_stdio(0); cin.tie(0); int n, m; cin >> n >> m; int sum = 0; for (int i = 1; i <= m; i++) { int temp; cin >> temp; sum += temp; } ...
#include <bits/stdc++.h> #include <math.h> #define PI 3.14159265358979323846264338327950L #define ll long long using namespace std; int main() { ios::sync_with_stdio(0); cin.tie(0); int n, m; cin >> n >> m; int sum = 0; for (int i = 1; i <= m; i++) { int temp; cin >> temp; sum += temp; } ...
[["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 47], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 20]]
1
106
n,m = (int(x) for x in input().split()) a = (int(x) for x in input().split()) for node in a: n = n - node print(n if n > 0 else -1)
n,m = (int(x) for x in input().split()) a = (int(x) for x in input().split()) for node in a: n = n - node print(n if n >= 0 else -1)
[["-", 0, 652, 3, 4, 0, 41, 0, 666, 667, 47], ["+", 0, 652, 3, 4, 0, 41, 0, 666, 667, 20]]
5
59
#include <bits/stdc++.h> using namespace std; const int MAXN = 1e5 + 5; typedef long long ll; int main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); ll n, m; cin >> n >> m; ll sum = 0; for (int i = 0; i < m; i++) { ll x; cin >> x; sum += x; } cout << max(-1 * 1LL, n); }
#include <bits/stdc++.h> using namespace std; const int MAXN = 1e5 + 5; typedef long long ll; int main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); ll n, m; cin >> n >> m; ll sum = 0; for (int i = 0; i < m; i++) { ll x; cin >> x; sum += x; } cout << max(-1 * 1LL, n - sum); }
[["+", 0, 16, 12, 2, 3, 4, 0, 16, 17, 33], ["+", 0, 16, 12, 2, 3, 4, 0, 16, 12, 22]]
1
100
import math ex = [] N, M = map(int, input().split()) ex = [exi for exi in map(int, input().split())] rem = N - sum(ex) print(rem) if rem > 0 else print('-1')
import math ex = [] N, M = map(int, input().split()) ex = [exi for exi in map(int, input().split())] rem = N - sum(ex) print(rem) if rem >= 0 else print('-1')
[["-", 0, 656, 0, 1, 0, 41, 0, 666, 667, 47], ["+", 0, 656, 0, 1, 0, 41, 0, 666, 667, 20]]
5
65
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < (int)(n); i++) typedef long long ll; int main() { ll n; cin >> n; ll m; cin >> m; ll s = 0; rep(i, m) { ll a; cin >> a; s += a; } if (s > n) cout << -1; else cout << m - s; }
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < (int)(n); i++) typedef long long ll; int main() { ll n; cin >> n; ll m; cin >> m; ll s = 0; rep(i, m) { ll a; cin >> a; s += a; } if (s > n) cout << -1; else cout << n - s; }
[["-", 75, 76, 0, 1, 0, 16, 12, 16, 31, 22], ["+", 75, 76, 0, 1, 0, 16, 12, 16, 31, 22]]
1
80
#include <bits/stdc++.h> using namespace std; int main() { int n, m; cin >> n >> m; int sum = n; for (int i = 0; i < m; i++) { int a; cin >> a; sum -= a; } if (sum > 0) cout << sum << endl; else cout << "-1" << endl; }
#include <bits/stdc++.h> using namespace std; int main() { int n, m; cin >> n >> m; int sum = n; for (int i = 0; i < m; i++) { int a; cin >> a; sum -= a; } if (sum >= 0) cout << sum << endl; else cout << "-1" << endl; }
[["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 47], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 20]]
1
76
#include <algorithm> #include <cmath> #include <iostream> #include <numeric> #include <regex> #include <set> #include <string> #include <vector> using namespace std; int main() { int n, m; std::vector<int> days; std::cin >> n; std::cin >> m; for (int i = 0; i < m; i++) { int a; std::cin >> a; da...
#include <algorithm> #include <cmath> #include <iostream> #include <numeric> #include <regex> #include <set> #include <string> #include <vector> using namespace std; int main() { int n, m; std::vector<int> days; std::cin >> n; std::cin >> m; for (int i = 0; i < m; i++) { int a; std::cin >> a; da...
[["-", 0, 43, 49, 50, 51, 41, 15, 16, 17, 47], ["+", 0, 43, 49, 50, 51, 41, 15, 16, 17, 20]]
1
129
n,m=map(int,input().split()) a=list(map(int,input().split())) p=0 for i in a: p+=i if(n>=p): print("{}",n-p) else: print("-1")
n,m=map(int,input().split()) a=list(map(int,input().split())) p=0 for i in a: p+=i if(n>=p): print("{}".format(n-p)) else: print("-1")
[["-", 64, 196, 0, 1, 0, 652, 3, 4, 0, 21], ["+", 0, 652, 3, 4, 0, 652, 63, 319, 0, 131], ["+", 0, 652, 3, 4, 0, 652, 63, 319, 319, 22], ["+", 0, 652, 3, 4, 0, 652, 3, 4, 0, 24], ["+", 0, 652, 3, 4, 0, 652, 3, 4, 0, 25]]
5
69
n, m = map(int, input().split()) a = list(map(int, input().split())) d = n-sum(a) if(a<0): d = -1 pritn(d)
n, m = map(int, input().split()) a = list(map(int, input().split())) d = n-sum(a) if(d<0): d = -1 print(d)
[["-", 0, 656, 0, 57, 15, 23, 0, 666, 0, 22], ["+", 0, 656, 0, 57, 15, 23, 0, 666, 0, 22], ["-", 36, 36, 0, 656, 0, 1, 0, 652, 63, 22], ["+", 36, 36, 0, 656, 0, 1, 0, 652, 63, 22]]
5
56
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (n); i++) using namespace std; using ll = long long; using pii = pair<int, int>; int main() { ll n, m, sum = 0; cin >> n >> m; vector<ll> a(m); rep(i, m) { cin >> a[i]; sum += a[i]; } if (n >= sum) cout << n - sum << endl; else ...
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (n); i++) using namespace std; using ll = long long; using pii = pair<int, int>; int main() { ll n, m, sum = 0; cin >> n >> m; vector<ll> a(m); rep(i, m) { cin >> a[i]; sum += a[i]; } if (n >= sum) cout << n - sum << endl; else ...
[["-", 75, 76, 0, 1, 0, 16, 31, 16, 12, 13], ["+", 75, 76, 0, 1, 0, 16, 31, 16, 12, 13]]
1
103
N, M = map(int, input().split()) A = sum([int(x) for x in input().split()]) if N - M < 0: print(-1) else: print(N-M)
N, M = map(int, input().split()) A = sum([int(x) for x in input().split()]) if N - A < 0: print(-1) else: print(N-A)
[["-", 0, 656, 0, 57, 15, 666, 0, 657, 12, 22], ["+", 0, 656, 0, 57, 15, 666, 0, 657, 12, 22], ["-", 0, 1, 0, 652, 3, 4, 0, 657, 12, 22], ["+", 0, 1, 0, 652, 3, 4, 0, 657, 12, 22]]
5
57
#include <stdio.h> int main(void) { int n, m, x = 0, i, a[10000]; scanf("%d%d, &n, &m"); for (i = 0; i < m; i++) { scanf("%d, &a[i"); x = x + a[i]; } if (x > n) printf("-1\n"); else printf("%d\n", n - x); return 0; }
#include <stdio.h> int main(void) { int n, m, x = 0, i, a[10000]; scanf("%d%d", &n, &m); for (i = 0; i < m; i++) { scanf("%d", &a[i]); x = x + a[i]; } if (x > n) printf("-1\n"); else printf("%d\n", n - x); return 0; }
[["-", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["+", 8, 9, 0, 1, 0, 2, 3, 4, 0, 21], ["+", 0, 1, 0, 2, 3, 4, 0, 66, 17, 67], ["+", 0, 1, 0, 2, 3, 4, 0, 66, 28, 22], ["+", 0, 2, 3, 4, 0, 66, 28, 69, 28, 22], ["+", 0, 2, 3, 4, 0, 66, 28, 69, 0, 70], ["+", 0, 2, 3, 4, 0, 66, 28, 69, 71, 22], ["...
0
93
N, M = map(int, input().split()) A = map(int, input().split()) if sum(A) > N: print(-1) else: print(N - sum(A))
N, M = map(int, input().split()) A = list(map(int, input().split())) if sum(A) > N: print(-1) else: print(N - sum(A))
[["+", 0, 656, 0, 1, 0, 662, 12, 652, 63, 22], ["+", 0, 1, 0, 662, 12, 652, 3, 4, 0, 24], ["+", 0, 652, 3, 4, 0, 652, 3, 4, 0, 25]]
5
54
#include <bits/stdc++.h> using namespace std; #define ll long long #define ar array int main() { int n, m, a[1000]; cin >> n >> m; int sum = 0; for (int i = 0; i < m; i++) { cin >> a[i]; sum += a[i]; } if (sum <= n) { cout << n - sum; } else { cout << -1; } }
#include <bits/stdc++.h> using namespace std; #define ll long long #define ar array int main() { int n, m, a[10000]; cin >> n >> m; int sum = 0; for (int i = 0; i < m; i++) { cin >> a[i]; sum += a[i]; } if (sum <= n) { cout << n - sum; } else { cout << -1; } }
[["-", 0, 14, 8, 9, 0, 43, 49, 80, 81, 13], ["+", 0, 14, 8, 9, 0, 43, 49, 80, 81, 13]]
1
90