prithivMLmods/Coder-Stat huggingface dataset:
Problem p02705 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
#define rep(i, b) for (i = 0; i < b; ++i)
#define repp(i, a, b) for (i = a; i < b; ++i)
#define endl "\n"
// #define LLONG_MAX 99999999999999
typedef long long int lli;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  lli t, n, i, j, b, a, q, m;
  cin >> n >> m;
  vector<lli> v(m);
  rep(i, m) cin >> v[i];
  lli ans = 0;
  rep(i, m) { ans += v[i]; }
  if (ans > n) {
    cout << -1 << endl;
  } else {
    cout << n - ans << endl;
  }
}


Fixed submission:
#include <bits/stdc++.h>
using namespace std;
#define rep(i, b) for (i = 0; i < b; ++i)
#define repp(i, a, b) for (i = a; i < b; ++i)
#define endl "\n"
// #define LLONG_MAX 99999999999999
typedef long long int lli;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  lli t, n, i, j, b, a, q, m;
  double r;
  cin >> r;
  cout << 2.0 * 3.141 * r << endl;
}
Problem p02705 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define int long long
#define endl '\n'
#define pb push_back
#define fi first
#define se second
#define all(c) (c).begin(), (c).end()
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;

template <typename T>
using ordered_set =
    tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define TRACE
#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1> void __f(const char *name, Arg1 &&arg1) {
  cerr << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char *names, Arg1 &&arg1, Args &&...args) {
  const char *comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << " : " << arg1 << " | ";
  __f(comma + 1, args...);
}
#else
#define trace(...)
#endif

const ll inf = 2e18;
const int mod = 1e9 + 7;
const int N = 2e5 + 10;

signed main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);

  int n, m;
  cin >> n >> m;
  int a[m], sum = 0;
  for (int i = 0; i < m; i++) {
    cin >> a[i];
    sum += a[i];
  }
  if (sum > n) {
    cout << -1;
  } else {
    cout << (n - sum);
  }

  return 0;
}

Fixed submission:
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define int long long
#define endl '\n'
#define pb push_back
#define fi first
#define se second
#define all(c) (c).begin(), (c).end()
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;

template <typename T>
using ordered_set =
    tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define TRACE
#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1> void __f(const char *name, Arg1 &&arg1) {
  cerr << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char *names, Arg1 &&arg1, Args &&...args) {
  const char *comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << " : " << arg1 << " | ";
  __f(comma + 1, args...);
}
#else
#define trace(...)
#endif

const ll inf = 2e18;
const int mod = 1e9 + 7;
const int N = 2e5 + 10;

signed main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);

  ld r;
  cin >> r;
  cout << fixed << setprecision(10) << 2.0 * acos(-1) * r;

  return 0;
}
Problem p02705 (C++)

Buggy submission (status: Runtime Error):
///******* In the name of Allah *******///

#include <bits/stdc++.h>
using namespace std;

void Ok() {
  int a;
  double aa, bb;
  scanf("%ld", &a);
  aa = a;
  bb = 2 * 3.1416 * aa;
  printf("%0.2lf", bb);
}

int main() {
  Ok();

  return 0;
}


Fixed submission:
///******* In the name of Allah *******///

#include <bits/stdc++.h>
using namespace std;

void Ok() {
  int a;
  double aa, bb;
  scanf("%d", &a);
  aa = a;
  bb = 2 * 3.1416 * aa;
  printf("%0.2lf", bb);
}

int main() {
  Ok();

  return 0;
}
Problem p02705 (C++)

Buggy submission (status: Time Limit Exceeded):
// =====================================================================================
//
//       Filename:  at.cpp
//
//    Description:
//
//        Version:  1.0
//        Created:  19/04/20 05:21:38 PM IST
//       Revision:  none
//       Compiler:  g++
//
//         Author:  Kiran Bhanushali (), kiranbhanushali143.kb143@gmail.com
//   Organization:
//
// =====================================================================================

#include <bits/stdc++.h>

using namespace std;

#define int long long
#define pb push_back
// #define _SHOW_TIME

void solve() {
  // your code here;
  int n, m;
  cin >> n >> m;
  int sum = 0;
  for (int i = 0; i < m; i++) {
    int x;
    cin >> x;
    sum += x;
  }

  if (sum <= n)
    cout << n - sum << endl;
  else
    cout << "-1" << endl;
}
int32_t main() {
  /////////////////////////////////////
#ifdef _SHOW_TIME
  int tt = (int)clock();
#endif
  /////////////////////////////////////
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  /////////////////////////////////////
  solve();
/////////////////////////////////////
#ifdef _SHOW_TIME
  cerr << "TIME = " << (double)(clock() - tt) / CLOCKS_PER_SEC << endl;
#endif
  /////////////////////////////////////
  return 0;
}


Fixed submission:
// =====================================================================================
//
//       Filename:  at.cpp
//
//    Description:
//
//        Version:  1.0
//        Created:  19/04/20 05:21:38 PM IST
//       Revision:  none
//       Compiler:  g++
//
//         Author:  Kiran Bhanushali (), kiranbhanushali143.kb143@gmail.com
//   Organization:
//
// =====================================================================================

#include <bits/stdc++.h>

using namespace std;

#define int long long
#define pb push_back
// #define _SHOW_TIME

void solve() {
  // your code here;
  int n, m;
  cin >> n;
  double d = 22 / 7.0;
  d *= 2;
  d *= n;
  cout << d << endl;
}
int32_t main() {
  /////////////////////////////////////
#ifdef _SHOW_TIME
  int tt = (int)clock();
#endif
  /////////////////////////////////////
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  /////////////////////////////////////
  solve();
/////////////////////////////////////
#ifdef _SHOW_TIME
  cerr << "TIME = " << (double)(clock() - tt) / CLOCKS_PER_SEC << endl;
#endif
  /////////////////////////////////////
  return 0;
}
Problem p02705 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
#define boost                                                                  \
  ios_base::sync_with_stdio(false);                                            \
  cin.tie(NULL);
#define ull unsigned long long
#define d1(x) cout << #x << " " << x << endl;
#define d2(x, y) cout << #x << " " << x << " " << #y << " " << y << endl;
#define d2i(x, y, i)                                                           \
  cout << #x << i << " " << x << " " << #y << i << " " << y << endl;

#define fr(i, l, r) for (ll i = l; i < r; i++)
#define mems(a, x) memset(a, x, sizeof(a))
#define mod 1000000007
#define ff first
#define ss second
#define pb(x) push_back(x)
#define vll vector<ll>
#define pbp(x, y) push_back(make_pair(x, y))
#define mat vector<vector<ll>>
#define pi 3.14159265358979323846
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

void solve() {
  ll n, m;
  cin >> n >> m;
  ll sm = 0, x;
  fr(i, 0, m) cin >> x, sm += x;
  n -= sm;
  if (n < 0)
    cout << -1;
  else
    cout << n;
}

int main() {
  ll t = 1;
  // cin>>t;
  while (t--) {
    solve();
    cout << endl;
  }
  return 0;
}


Fixed submission:
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
#define boost                                                                  \
  ios_base::sync_with_stdio(false);                                            \
  cin.tie(NULL);
#define ull unsigned long long
#define d1(x) cout << #x << " " << x << endl;
#define d2(x, y) cout << #x << " " << x << " " << #y << " " << y << endl;
#define d2i(x, y, i)                                                           \
  cout << #x << i << " " << x << " " << #y << i << " " << y << endl;

#define fr(i, l, r) for (ll i = l; i < r; i++)
#define mems(a, x) memset(a, x, sizeof(a))
#define mod 1000000007
#define ff first
#define ss second
#define pb(x) push_back(x)
#define vll vector<ll>
#define pbp(x, y) push_back(make_pair(x, y))
#define mat vector<vector<ll>>
#define pi 3.14159265358979323846
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

void solve() {
  double r;
  cin >> r;
  cout << fixed;
  cout << setprecision(10) << (double)2 * pi * r << endl;
}

int main() {
  ll t = 1;
  // cin>>t;
  while (t--) {
    solve();
    cout << endl;
  }
  return 0;
}
Problem p02705 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
const int INF = 0x3f3f3f3f;
const int maxn = 110000;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << setiosflags(ios::fixed) << setprecision(12);
  ll n, m;
  cin >> n >> m;
  vector<int> a(n + 1);
  ll sum = 0;
  for (int i = 1; i <= m; i++) {
    ll t;
    cin >> t;
    sum += t;
  }
  if (n >= sum)
    cout << n - sum << "\n";
  else
    cout << -1 << "\n";
  return 0;
}

Fixed submission:
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
const int INF = 0x3f3f3f3f;
const int maxn = 110000;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << setiosflags(ios::fixed) << setprecision(12);
  double pi = acos(-1);
  int n;
  cin >> n;
  double ans = 2 * pi * n;
  cout << ans << "\n";
  return 0;
}
Problem p02706 (C++)

Buggy submission (status: Runtime Error):
#include <iostream>
#include <stdlib.h>
#include <string>
using namespace std;

int main() {

  int n, m, A[1000], ans;
  cin >> n >> m;
  ans = n;
  for (int i = 0; i < m; i++) {
    cin >> A[i];
    ans = ans - A[i];
  }
  if (ans < 0)
    ans = -1;
  cout << ans;
  return 0;
}

Fixed submission:
#include <iostream>
#include <stdlib.h>
#include <string>
using namespace std;

int main() {
  int n, m, A[10000], ans;
  cin >> n >> m;
  ans = n;
  for (int i = 0; i < m; i++) {
    cin >> A[i];
    ans = ans - A[i];
  }
  if (ans < 0)
    ans = -1;
  cout << ans;
  return 0;
}
Problem p02706 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>

using namespace std;

int main() {
  int n, m;
  cin >> n >> m;
  int ara[1000];

  for (int i = 1; i <= m; i++) {
    cin >> ara[i];
  }
  int sum = 0;
  for (int i = 1; i <= m; i++) {
    sum = sum + ara[i];
  }
  if (n >= sum)
    cout << n - sum << endl;
  else
    cout << "-1" << endl;

  return 0;
}

Fixed submission:
#include <bits/stdc++.h>

using namespace std;

int main() {
  int n, m;
  cin >> n >> m;
  int ara[10000];

  for (int i = 1; i <= m; i++) {
    cin >> ara[i];
  }
  int sum = 0;
  for (int i = 1; i <= m; i++) {
    sum = sum + ara[i];
  }
  if (n >= sum)
    cout << n - sum << endl;
  else
    cout << "-1" << endl;

  return 0;
}
Problem p02706 (C++)

Buggy submission (status: Runtime Error):
#include <iostream>
using namespace std;

int main() {
  int day, hw, req[1000] = {};
  cin >> day >> hw;
  for (int i = 0; i < hw; ++i) {
    cin >> req[i];
    day -= req[i];
  }
  if (day >= 0) {
    cout << day;
  } else {
    cout << "-1";
  }
  cout << endl;
  return 0;
}

Fixed submission:
#include <iostream>
using namespace std;

int main() {
  int day, hw, req[10000] = {};
  cin >> day >> hw;
  for (int i = 0; i < hw; ++i) {
    cin >> req[i];
    day -= req[i];
  }
  if (day >= 0) {
    cout << day;
  } else {
    cout << "-1";
  }
  cout << endl;
  return 0;
}
Problem p02706 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;

int main() {
  ios::sync_with_stdio(0);

  int n, m;
  cin >> n >> m;
  vector<int> a(1000100, 0);
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
  }

  int s = accumulate(a.begin() + 1, a.end() + n + 1, 0);
  if (n - s >= 0)
    cout << n - s << "\n";
  else
    cout << -1 << "\n";
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;

int main() {
  ios::sync_with_stdio(0);

  int n, m;
  cin >> n >> m;
  vector<int> a(1000100, 0);
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
  }

  long long s = accumulate(a.begin() + 1, a.begin() + n + 1, 0);
  if (n - s >= 0)
    cout << n - s << "\n";
  else
    cout << -1 << "\n";
}
Problem p02706 (C++)

Buggy submission (status: Runtime Error):
#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;
}

Fixed submission:
#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;
}
Problem p02706 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <iostream>
#include <vector>
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rep1(i, n) for (int i = 1; i <= n; ++i)
using namespace std;
template <class T> bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T> bool chmin(T &a, const T &b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
int main() {
  int n, m;
  cin >> n >> m;
  vector<int> a(m);
  rep(i, m) cin >> a[i];

  int sum = 0;
  rep(i, n) sum += a[i];
  int res = n - sum;
  if (res < 0)
    res = -1;
  cout << res << "\n";
  return 0;
}


Fixed submission:
#include <algorithm>
#include <iostream>
#include <vector>
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rep1(i, n) for (int i = 1; i <= n; ++i)
using namespace std;
template <class T> bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T> bool chmin(T &a, const T &b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
int main() {
  int n, m;
  cin >> n >> m;
  vector<int> a(m);
  rep(i, m) cin >> a[i];

  int sum = 0;
  rep(i, m) sum += a[i];
  int res = n - sum;
  if (res < 0)
    res = -1;
  cout << res << "\n";
  return 0;
}
Problem p02706 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;

int main() {
  int N, M;
  cin >> N >> M;
  vector<int> A;
  for (int i = 0; i < M; i++) {
    cin >> A.at(i);
  }
  int sum = 0;
  for (int i = 0; i < M; i++) {
    sum += A.at(i);
  }
  cout << max(N - sum, -1) << endl;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;

int main() {
  int N, M;
  cin >> N >> M;
  vector<int> A(M);
  for (int i = 0; i < M; i++) {
    cin >> A.at(i);
  }
  int sum = 0;
  for (int i = 0; i < M; i++) {
    sum += A.at(i);
  }
  cout << max(N - sum, -1) << endl;
}
Problem p02706 (C++)

Buggy submission (status: Runtime Error):
#include <iostream>
using namespace std;

int main() {
  int N, M;

  cin >> N;
  cin >> M;

  int A[M];
  int T = 0;

  for (int i = 0; i < N; i++) {
    cin >> A[i];
    T += A[i];
  }

  if (N >= T) {
    cout << N - T << endl;
  } else {
    cout << -1 << endl;
  }
}


Fixed submission:
#include <iostream>
using namespace std;

int main() {
  int N, M;

  cin >> N;
  cin >> M;

  int A[M];
  int T = 0;

  for (int i = 0; i < M; i++) {
    cin >> A[i];
    T += A[i];
  }

  if (N >= T) {
    cout << N - T << endl;
  } else {
    cout << -1 << endl;
  }
}
Problem p02706 (C++)

Buggy submission (status: Runtime Error):
#include <iostream>
using namespace std;

int main() {
  int n, m, a[1500] = {0};
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    cin >> a[i];
  }
  int sum = 0, ans;

  for (int i = 0; i < m; i++) {
    sum = sum + a[i];
  }
  ans = n - sum;
  if (ans >= 0) {
    cout << ans << "\n";
  } else {
    cout << -1 << "\n";
  }
  return 0;
}

Fixed submission:
#include <iostream>
using namespace std;

int main() {
  int n, m, a[10000] = {0};
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    cin >> a[i];
  }
  int sum = 0, ans;

  for (int i = 0; i < m; i++) {
    sum = sum + a[i];
  }
  ans = n - sum;
  if (ans >= 0) {
    cout << ans << "\n";
  } else {
    cout << -1 << "\n";
  }
  return 0;
}
Problem p02706 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;

int main() {
  int N, M;
  cin >> N >> M;

  int sum;
  vector<int> syukudai_nissuu;
  for (int i = 0; i < M; i++) {
    cin >> syukudai_nissuu.at(i);
  }
  sum = accumulate(syukudai_nissuu.begin(), syukudai_nissuu.end(), 0);

  if (N - sum >= 0) {
    cout << N - sum << endl;
  } else {
    cout << -1 << endl;
  }
}


Fixed submission:
#include <bits/stdc++.h>
using namespace std;

int main() {
  int N, M;
  cin >> N >> M;

  int sum;
  vector<int> syukudai_nissuu(M);
  for (int i = 0; i < M; i++) {
    cin >> syukudai_nissuu.at(i);
  }
  sum = accumulate(syukudai_nissuu.begin(), syukudai_nissuu.end(), 0);

  if (N - sum >= 0) {
    cout << N - sum << endl;
  } else {
    cout << -1 << endl;
  }
}
Problem p02706 (C++)

Buggy submission (status: Runtime Error):
#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;
}


Fixed submission:
#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;
}
Problem p02706 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>

#define REP(i, n) for (int(i) = 0; (i) < (n); ++(i))
#define REPV(iter, v)                                                          \
  for (auto(iter) = (v).begin(); (iter) != (v).end(); ++(iter))
#define ALL(v) (v).begin(), (v).end()

#define MOD 1000000007

using namespace std;

typedef long long ll;

int main() {
  ll N, M;
  cin >> N >> M;
  vector<ll> A(M);
  REP(i, M) cin >> A[i];
  ll sum = 0;
  REP(i, N) sum += A[i];
  ll ans;
  if (sum <= N)
    ans = N - sum;
  else
    ans = -1;

  cout << ans << endl;
}


Fixed submission:
#include <bits/stdc++.h>

#define REP(i, n) for (int(i) = 0; (i) < (n); ++(i))
#define REPV(iter, v)                                                          \
  for (auto(iter) = (v).begin(); (iter) != (v).end(); ++(iter))
#define ALL(v) (v).begin(), (v).end()

#define MOD 1000000007

using namespace std;

typedef long long ll;

int main() {
  ll N, M;
  cin >> N >> M;
  vector<ll> A(M);
  REP(i, M) cin >> A[i];
  ll sum = 0;
  REP(i, M) sum += A[i];
  ll ans;
  if (sum <= N)
    ans = N - sum;
  else
    ans = -1;

  cout << ans << endl;
}
Problem p02706 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
using namespace std;
using p = pair<int, int>;

int main() {
  int n, m, sum = 0;
  vector<int> a(1000);

  cin >> n >> m;
  rep(i, m) {
    cin >> a.at(i);
    sum += a.at(i);
  }

  if (sum > n)
    cout << -1;
  else
    cout << n - sum;

  return 0;
}

Fixed submission:
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
using namespace std;
using p = pair<int, int>;

int main() {
  int n, m, sum = 0;
  vector<int> a(10000);

  cin >> n >> m;
  rep(i, m) {
    cin >> a.at(i);
    sum += a.at(i);
  }

  if (sum > n)
    cout << -1;
  else
    cout << n - sum;

  return 0;
}
Problem p02706 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, M;
  cin >> N >> M;
  vector<int> vec(100, 0);
  for (int i = 0; i < M; i++) {
    cin >> vec.at(i);
  }
  int a = 0;
  for (int i = 0; i < M; i++) {
    a += vec.at(i);
  }
  if (N < a) {
    cout << "-1" << endl;
  } else {
    cout << N - a << endl;
  }
}


Fixed submission:
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, M;
  cin >> N >> M;
  vector<int> vec(M);
  for (int i = 0; i < M; i++) {
    cin >> vec.at(i);
  }
  int a = 0;
  for (int i = 0; i < M; i++) {
    a += vec.at(i);
  }
  if (N < a) {
    cout << "-1" << endl;
  } else {
    cout << N - a << endl;
  }
}
Problem p02706 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;

int main() {
  int N, M;
  cin >> N >> M;
  int sum = 0;
  vector<int> a(M);
  for (int i = 0; i < N; i++) {
    cin >> a.at(i);
    sum += a.at(i);
  }

  if (sum <= N) {
    cout << N - sum << endl;
  } else {
    cout << -1 << endl;
  }
  // ここにプログラムを追記
}


Fixed submission:
#include <bits/stdc++.h>
using namespace std;

int main() {
  int N, M;
  cin >> N >> M;
  int sum = 0;
  vector<int> a(M);
  for (int i = 0; i < M; i++) {
    cin >> a.at(i);
    sum += a.at(i);
  }

  if (sum <= N) {
    cout << N - sum << endl;
  } else {
    cout << -1 << endl;
  }
  // ここにプログラムを追記
}
Problem p02706 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;

const int N = 200005;
const long double EPS = 1e-9;
const long double PI = acos(-1.);

int main() {
  //    #ifdef LOCAL
  //    freopen("input.txt", "r", stdin);
  //    freopen("output.txt", "w", stdout);
  //    #endif

  ll n, m, sum = 0, a[N];
  scanf("%I64d%I64d", &n, &m);
  for (int i = 0; i < m; i++) {
    scanf("%I64d", &a[i]);
    sum += a[i];
  }
  if (sum > n)
    return printf("%d\n", -1);
  printf("%I64d\n", n - sum);

  return 0;
}


Fixed submission:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;

const int N = 200005;
const long double EPS = 1e-9;
const long double PI = acos(-1.);

int main() {
  //    #ifdef LOCAL
  //    freopen("input.txt", "r", stdin);
  //    freopen("output.txt", "w", stdout);
  //    #endif

  ll n, m, sum = 0, a[N];
  scanf("%I64d%I64d", &n, &m);
  for (int i = 0; i < m; i++) {
    scanf("%I64d", &a[i]);
    sum += a[i];
  }
  if (sum > n)
    return printf("%d\n", -1), 0;
  printf("%I64d\n", n - sum);

  return 0;
}
Problem p02706 (C++)

Buggy submission (status: Runtime Error):
#include <array>
#include <iostream>
using namespace std;

int main() {
  int n, m, sum = 0;
  array<int, 1000> working_day;
  cin >> n >> m;
  for (int i = 1; i <= m; i++) {
    cin >> working_day[i];
    sum += working_day[i];
  }
  if (n >= sum) {
    cout << n - sum;
  } else {
    cout << -1;
  }
  return 0;
}

Fixed submission:
#include <array>
#include <iostream>
using namespace std;

int main() {
  int n, m, sum = 0;
  array<int, 10000> working_day;
  cin >> n >> m;
  for (int i = 1; i <= m; i++) {
    cin >> working_day[i];
    sum += working_day[i];
  }
  if (n >= sum) {
    cout << n - sum;
  } else {
    cout << -1;
  }
  return 0;
}
Problem p02706 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <queue>
#include <vector>
using namespace std;

int main() {
  int n, m, ans = 0, sum = 0;
  cin >> n >> m;
  vector<int> a(1000000000);
  for (int i = 0; i < m; i++) {
    cin >> a[i];
    sum += a[i];
  }
  if (n < sum) {
    ans = -1;
  } else {
    ans = n - sum;
  }
  cout << ans << endl;
  return 0;
}

Fixed submission:
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <queue>
#include <vector>
using namespace std;

int main() {
  int n, m, ans = 0, sum = 0;
  cin >> n >> m;
  vector<int> a(10000000);
  for (int i = 0; i < m; i++) {
    cin >> a[i];
    sum += a[i];
  }
  if (n < sum) {
    ans = -1;
  } else {
    ans = n - sum;
  }
  cout << ans << endl;
  return 0;
}
Problem p02706 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
  ll n, m, sum;
  ll a[1000];
  cin >> n >> m;
  sum = 0;
  for (int i = 1; i <= m; i++) {
    cin >> a[i];
    sum += a[i];
  }
  if (n > sum) {
    cout << n - sum << endl;
  } else if (n == sum) {
    cout << "0" << endl;
  } else if (sum > n) {
    cout << "-1" << endl;
  }
  return 0;
}


Fixed submission:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
  ll n, m, sum;
  ll a[10000];
  cin >> n >> m;
  sum = 0;
  for (int i = 1; i <= m; i++) {
    cin >> a[i];
    sum += a[i];
  }
  if (n > sum) {
    cout << n - sum << endl;
  } else if (n == sum) {
    cout << "0" << endl;
  } else if (sum > n) {
    cout << "-1" << endl;
  }
  return 0;
}
Problem p02706 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;

int main() {

  int n, m;
  cin >> n >> m;
  vector<int> v;
  for (int i = 0; i < m; i++) {
    cin >> v.at(i);
  }
  int k;
  k = 0;
  for (int i = 0; i < m; i++) {
    k += v.at(i);
  }
  if (n < k) {
    cout << -1 << endl;
  } else {
    cout << n - k << endl;
  }
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;

int main() {

  int n, m;
  cin >> n >> m;
  vector<int> v(m);
  for (int i = 0; i < m; i++) {
    cin >> v.at(i);
  }
  int k;
  k = 0;
  for (int i = 0; i < m; i++) {
    k += v.at(i);
  }
  if (n < k) {
    cout << -1 << endl;
  } else {
    cout << n - k << endl;
  }
}
Problem p02706 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  int M;
  cin >> N >> M;
  int sum = 0;
  vector<int> a(M, 0);
  for (int i = 0; i < M; i++) {
    cin >> a[i];
    sum = sum + a[i];
  }
  if (N - sum < 0) {
    cout << -1 << endl;
    return 9;
  }
  cout << N - sum << endl;
  // cout<<N<<" "<<sum<<endl;
}


Fixed submission:
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  int M;
  cin >> N >> M;
  int sum = 0;
  vector<int> a(M, 0);
  for (int i = 0; i < M; i++) {
    cin >> a[i];
    sum = sum + a[i];
  }
  if (N - sum < 0) {
    cout << -1 << endl;
    return 0;
  }
  cout << N - sum << endl;
  // cout<<N<<" "<<sum<<endl;
}
Problem p02706 (C++)

Buggy submission (status: Runtime Error):
// Bismillahir Rahmanir Rahim
#include <bits/stdc++.h>
using namespace std;

int main() {
  // freopen("a.txt","r",stdin);
  int n, ar[1001], x = 0, i, j, m, sum;
  cin >> n >> m;
  for (i = 0; i < m; i++) {
    cin >> ar[i];
    x += ar[i];
  }
  sum = n - x;
  if (sum >= 0)
    cout << sum << endl;
  else
    cout << "-1\n";
}


Fixed submission:
// Bismillahir Rahmanir Rahim
#include <bits/stdc++.h>
using namespace std;

int main() {
  // freopen("a.txt","r",stdin);
  int n, ar[10001], x = 0, i, j, m, sum;
  cin >> n >> m;
  for (i = 0; i < m; i++) {
    cin >> ar[i];
    x += ar[i];
  }
  sum = n - x;
  if (sum >= 0)
    cout << sum << endl;
  else
    cout << "-1\n";
}
Problem p02706 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <cstdlib>
#include <iostream>
#include <string>
#include <vector>
#define _USE_MATH_DEFINES
#include <math.h>
using namespace std;

int main() {
  int N, M;
  int A[1000];
  cin >> N >> M;
  for (int i = 0; i < M; i++) {
    cin >> A[i];
  }

  int sum = 0;
  for (int i = 0; i < M; i++) {
    sum += A[i];
  }
  if (N - sum >= 0)
    cout << N - sum << endl;
  else
    cout << -1 << endl;

  return 0;
}

Fixed submission:
#include <algorithm>
#include <cstdlib>
#include <iostream>
#include <string>
#include <vector>
#define _USE_MATH_DEFINES
#include <math.h>
using namespace std;

int main() {
  int N, M;
  int A[10000];
  cin >> N >> M;
  for (int i = 0; i < M; i++) {
    cin >> A[i];
  }

  int sum = 0;
  for (int i = 0; i < M; i++) {
    sum += A[i];
  }
  if (N - sum >= 0)
    cout << N - sum << endl;
  else
    cout << -1 << endl;

  return 0;
}
Problem p02706 (C++)

Buggy submission (status: Runtime Error):
#include <iostream>
using namespace std;

int main() {
  int i, n, m, sum = 0, a[100];
  cin >> n >> m;
  for (i = 0; i < m; i++) {
    cin >> a[i];
    sum += a[i];
  }
  if (sum > n)
    cout << -1;
  else
    cout << n - sum;
  return 0;
}


Fixed submission:
#include <iostream>
using namespace std;

int main() {
  int i, n, m, sum = 0, a[100000];
  cin >> n >> m;
  for (i = 0; i < m; i++) {
    cin >> a[i];
    sum += a[i];
  }
  if (sum > n)
    cout << -1;
  else
    cout << n - sum;
  return 0;
}
Problem p02706 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;

int main() {
  int N, M, sum = 0;
  cin >> N >> M;
  vector<int> A(M);
  for (int i = 0; i < N; i++) {
    cin >> A.at(i);
    sum += A.at(i);
  }
  if (sum > N) {
    cout << -1 << endl;
  } else {
    cout << N - sum << endl;
  }
}


Fixed submission:
#include <bits/stdc++.h>
using namespace std;

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 (sum > N) {
    cout << -1 << endl;
  } else {
    cout << N - sum << endl;
  }
}
Problem p02706 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
// define #Asukaminato is cute
#define ll long long
#define rep(i, m) for (int i = 0; i < (int)(m); i++)
const int inf = 1000000000; // 10^9 Ten to the power of nine.

int main() {
  int N, M;
  cin >> N >> M;
  int sum = 0;
  int A[100];

  for (int i = 0; i < M; i++) {
    cin >> A[i];
    sum += A[i];
  }

  if (N >= sum) {
    cout << N - sum;
  } else {
    cout << -1;
  }
}


Fixed submission:
#include <bits/stdc++.h>
using namespace std;
// define #Asukaminato is cute
#define ll long long
#define rep(i, m) for (int i = 0; i < (int)(m); i++)
const int inf = 1000000000; // 10^9 Ten to the power of nine.

int main() {
  int N, M;
  cin >> N >> M;
  int sum = 0;
  int A[10000];

  for (int i = 0; i < M; i++) {
    cin >> A[i];
    sum += A[i];
  }

  if (N >= sum) {
    cout << N - sum;
  } else {
    cout << -1;
  }
}
Problem p02706 (C++)

Buggy submission (status: Runtime Error):
#include <cstdio>
#include <iostream>
using namespace std;
int n, m, a[1008], i = 0;
int tot = 0;
int main() {
  cin >> n;
  cin >> m;
  for (i = 1; i <= m; i++) {
    cin >> a[i];
  }
  for (i = 1; i <= m; i++) {
    tot += a[i];
  }
  if (tot <= n) {
    cout << n - tot;
  } else {
    cout << -1;
  }
  return 0;
}


Fixed submission:
#include <cstdio>
#include <iostream>
using namespace std;
int n, m, a[10008], i = 0;
int tot = 0;
int main() {
  cin >> n;
  cin >> m;
  for (i = 1; i <= m; i++) {
    cin >> a[i];
  }
  for (i = 1; i <= m; i++) {
    tot += a[i];
  }
  if (tot <= n) {
    cout << n - tot;
  } else {
    cout << -1;
  }
  return 0;
}
Problem p02706 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <iostream>

using namespace std;

int main() {
  int N;
  int M;
  int A;
  int b;
  cin >> N >> M;
  while (M > 0) {
    cin >> A;
    b = b + A;
  }
  if (N - b >= 0)
    cout << N - b;
  else
    cout << "-1";
}

Fixed submission:
#include <iostream>

using namespace std;

int main() {
  int N;
  int M;
  int A;
  int b;
  cin >> N >> M;
  while (M > 0) {
    cin >> A;
    b = b + A;
    M--;
  }
  if (N - b >= 0)
    cout << N - b;
  else
    cout << "-1";
}
Problem p02706 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>

using namespace std;

typedef long long int ll;
typedef long double ld;
typedef unsigned long long int ull;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;

#define N 100010
#define M 200010
#define A 110
#define endl "\n"
#define mod 1000000007

int main() {

  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);

  int n, m;
  int arr[1010];
  ll tot = 0;

  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    cin >> arr[i];
    tot += arr[i];
  }

  if (tot > n) {
    cout << -1 << endl;
  } else {
    cout << n - tot << endl;
  }

  return 0;
}

Fixed submission:
#include <bits/stdc++.h>

using namespace std;

typedef long long int ll;
typedef long double ld;
typedef unsigned long long int ull;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;

#define N 100010
#define M 200010
#define A 110
#define endl "\n"
#define mod 1000000007

int main() {

  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);

  int n, m;
  int arr[10010];
  ll tot = 0;

  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    cin >> arr[i];
    tot += arr[i];
  }

  if (tot > n) {
    cout << -1 << endl;
  } else {
    cout << n - tot << endl;
  }

  return 0;
}
Problem p02706 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m, a[n];
  cin >> n >> m;
  for (int i = 0; i < m; i++)
    cin >> a[i];
  int s = 0;
  for (int i = 0; i < m; i++)
    s += a[i];
  if (s > n) {
    cout << "-1" << endl;
  } else {
    cout << n - s << endl;
  }
}


Fixed submission:
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m, a[10000];
  cin >> n >> m;
  for (int i = 0; i < m; i++)
    cin >> a[i];
  int s = 0;
  for (int i = 0; i < m; i++)
    s += a[i];
  if (s > n) {
    cout << "-1" << endl;
  } else {
    cout << n - s << endl;
  }
}
Problem p02706 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
void solving() {
  int n, m;
  cin >> n >> m;
  int a[m];
  int sum = 0;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    sum += a[i];
  }
  n = n - sum;
  if (n < 0)
    cout << "-1";
  else
    cout << n << "\n";
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  solving();
  return 0;
}


Fixed submission:
#include <bits/stdc++.h>
using namespace std;
void solving() {
  int n, m;
  cin >> n >> m;
  int a[m];
  int sum = 0;
  for (int i = 0; i < m; i++) {
    cin >> a[i];
    sum += a[i];
  }
  n = n - sum;
  if (n < 0)
    cout << "-1";
  else
    cout << n << "\n";
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  solving();
  return 0;
}
Problem p02706 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>

using namespace std;

int A[10005];

int main() {

  // freopen("input.txt", "r", stdin);
  // freopen("output.txt", "w", stdout);

  long long n, m;
  cin >> n >> m;
  long long total = 0;
  for (int i = 0; i < n; ++i) {
    cin >> A[i];
    total += A[i];
  }
  total = n - total;
  if (total >= 0)
    cout << total << '\n';
  else
    cout << -1 << '\n';
  return 0;
}

Fixed submission:
#include <bits/stdc++.h>

using namespace std;

int A[10005];

int main() {

  // freopen("input.txt", "r", stdin);
  // freopen("output.txt", "w", stdout);

  long long n, m;
  cin >> n >> m;
  long long total = 0;
  for (int i = 0; i < m; ++i) {
    cin >> A[i];
    total += A[i];
  }
  total = n - total;
  if (total >= 0)
    cout << total << '\n';
  else
    cout << -1 << '\n';
  return 0;
}
Problem p02706 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <bitset>
#include <ciso646>
#include <cmath>
#include <complex>
#include <cstdio>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <utility>
#include <vector>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop                                                                   \
  char nyaa;                                                                   \
  cin >> nyaa;
#define rep(i, n) for (int i = 0; i < n; i++)
#define per(i, n) for (int i = n - 1; i >= 0; i--)
#define Rep(i, sta, n) for (int i = sta; i < n; i++)
#define Per(i, sta, n) for (int i = n - 1; i >= sta; i--)
#define rep1(i, n) for (int i = 1; i <= n; i++)
#define per1(i, n) for (int i = n; i >= 1; i--)
#define Rep1(i, sta, n) for (int i = sta; i <= n; i++)
typedef long double ld;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;
int dx[4] = {1, -1, 0, 0};
int dy[4] = {0, 0, 1, -1};

int n, m;
int a[5010];

void solve() {
  cin >> n >> m;
  int S = 0;
  rep(i, m) {
    cin >> a[i];
    S += a[i];
  }
  if (n >= S)
    cout << n - S << endl;
  else
    cout << -1 << endl;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << fixed << setprecision(50);
  solve();
}

Fixed submission:
#include <algorithm>
#include <bitset>
#include <ciso646>
#include <cmath>
#include <complex>
#include <cstdio>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <utility>
#include <vector>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop                                                                   \
  char nyaa;                                                                   \
  cin >> nyaa;
#define rep(i, n) for (int i = 0; i < n; i++)
#define per(i, n) for (int i = n - 1; i >= 0; i--)
#define Rep(i, sta, n) for (int i = sta; i < n; i++)
#define Per(i, sta, n) for (int i = n - 1; i >= sta; i--)
#define rep1(i, n) for (int i = 1; i <= n; i++)
#define per1(i, n) for (int i = n; i >= 1; i--)
#define Rep1(i, sta, n) for (int i = sta; i <= n; i++)
typedef long double ld;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;
int dx[4] = {1, -1, 0, 0};
int dy[4] = {0, 0, 1, -1};

int n, m;
int a[50010];

void solve() {
  cin >> n >> m;
  int S = 0;
  rep(i, m) {
    cin >> a[i];
    S += a[i];
  }
  if (n >= S)
    cout << n - S << endl;
  else
    cout << -1 << endl;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << fixed << setprecision(50);
  solve();
}
Problem p02706 (C++)

Buggy submission (status: Runtime Error):
#include <iostream>
using namespace std;

#define M_PI 3.14159265358979323846
int main() {
  int N, M, sum = 0;
  int A[100];
  cin >> N >> M;

  for (int i = 0; i < M; i++) {
    cin >> A[i];
    sum += A[i];
  }

  if ((N - sum) >= 0)
    cout << N - sum;
  else
    cout << "-1";
  return 0;
}

Fixed submission:
#include <iostream>
using namespace std;

#define M_PI 3.14159265358979323846
int main() {
  int N, M, sum = 0;
  int A[10000];
  cin >> N >> M;

  for (int i = 0; i < M; i++) {
    cin >> A[i];
    sum += A[i];
  }

  if ((N - sum) >= 0)
    cout << N - sum;
  else
    cout << "-1";
  return 0;
}
Problem p02706 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>

using namespace std;
int a[1010];

int main() {
  int n, m, sum = 0;
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    cin >> a[i];
    sum += a[i];
  }
  if (sum <= n)
    printf("%d\n", n - sum);
  else
    printf("-1\n");
  return 0;
}

Fixed submission:
#include <bits/stdc++.h>

using namespace std;
int a[10010];

int main() {
  int n, m, sum = 0;
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    cin >> a[i];
    sum += a[i];
  }
  if (sum <= n)
    printf("%d\n", n - sum);
  else
    printf("-1\n");
  return 0;
}
Problem p02706 (Python)

Buggy submission (status: Runtime Error):
n, m = map(int, input().split)
a = list(map(int, input().split()))
ct = 0
for i in range(m):
    ct += a[i]

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


Fixed submission:
n, m = map(int, input().split())
a = list(map(int, input().split()))
ct = 0
for i in range(m):
    ct += a[i]

if n - ct >= 0:
    print(n - ct)
else:
    print(-1)
Problem p02706 (Python)

Buggy submission (status: Runtime Error):
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 submission:
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)
Problem p02706 (Python)

Buggy submission (status: Runtime Error):
n, m = map(int, input().split())
print(max(n - sum(list(map(int, input().split())))), -1)


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

if n >= sum(A):
    print(n - sum(A))
else:
    print("-1")
Problem p02706 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;

int main() {
  int M, N, l, i = 0, a[1000], j = 0;
  cin >> M >> N;
  while (cin >> l) {
    a[i] = l;
    i++;
  }
  while (j < N) {
    M = M - a[j];
    j++;
  }
  if (M >= 0) {
    cout << M;
  } else {
    cout << -1;
  }
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;

int main() {
  int M, N, l, i = 0, a[10000], j = 0;
  cin >> M >> N;
  while (cin >> l) {
    a[i] = l;
    i++;
  }
  while (j < N) {
    M = M - a[j];
    j++;
  }
  if (M >= 0) {
    cout << M;
  } else {
    cout << -1;
  }
}
Problem p02706 (C++)

Buggy submission (status: Runtime Error):
#include <iostream>
using namespace std;
int a[1000];
int main() {
  int n, m;
  cin >> n >> m;
  int ans = 0;
  for (int i = 0; i < m; i++) {
    cin >> a[i];
    ans += a[i];
  }
  if (ans > n) {
    cout << -1;
  } else {
    cout << n - ans;
  }
  return 0;
}


Fixed submission:
#include <iostream>
using namespace std;
int a[100000];
int main() {
  int n, m;
  cin >> n >> m;
  int ans = 0;
  for (int i = 0; i < m; i++) {
    cin >> a[i];
    ans += a[i];
  }
  if (ans > n) {
    cout << -1;
  } else {
    cout << n - ans;
  }
  return 0;
}
Problem p02706 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <cmath>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>

#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define per(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define pb push_back
#define mp make_pair
#define bg begin()
#define en end()
#define all(v) (v).begin(), (v).end()
#define sz(v) (int)(v).size()

using namespace std;

typedef long long ll;

static const long long MOD = 1000000007;

int ans;
int a[10005];

int main(void) {
  int n, m, sum = 0;
  cin >> n >> m;
  rep(i, 0, m) scanf("%d", &a[i]);
  rep(i, 0, n) sum += a[i];

  ans = n - sum;
  printf("%d\n", ans >= 0 ? ans : -1);

  return 0;
}


Fixed submission:
#include <algorithm>
#include <cmath>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>

#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define per(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define pb push_back
#define mp make_pair
#define bg begin()
#define en end()
#define all(v) (v).begin(), (v).end()
#define sz(v) (int)(v).size()

using namespace std;

typedef long long ll;

static const long long MOD = 1000000007;

int ans;
int a[10005];

int main(void) {
  int n, m, sum = 0;
  cin >> n >> m;
  rep(i, 0, m) scanf("%d", &a[i]);
  rep(i, 0, m) sum += a[i];

  ans = n - sum;
  printf("%d\n", ans >= 0 ? ans : -1);

  return 0;
}
Problem p02706 (C++)

Buggy submission (status: Runtime Error):
#include <iostream>
using namespace std;
int main() {
  int N, M;
  int A = 0;
  int day[1000];
  cin >> N >> M;
  for (int i = 0; i < M; i++) {
    cin >> day[i];
    A += day[i];
  };

  if ((N - A) >= 0) {
    cout << N - A << endl;
  } else {
    cout << -1 << endl;
  }
  return 0;
}

Fixed submission:
#include <iostream>
using namespace std;
int main() {
  int N, M;
  int A = 0;
  int day[10000];
  cin >> N >> M;
  for (int i = 0; i < M; i++) {
    cin >> day[i];
    A += day[i];
  };

  if ((N - A) >= 0) {
    cout << N - A << endl;
  } else {
    cout << -1 << endl;
  }
  return 0;
}
Problem p02706 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
#include <math.h>
#define _GLIBCXX_DEBUG
using namespace std;
int main() {

  int N, M;
  cin >> N >> M;
  vector<int> vec(M);
  for (int i = 0; i < M; i++) {
    cin >> vec[i];
  }

  int sum = 0;
  for (int i = 0; i < N; i++) {
    sum += vec[i];
  }

  if (sum <= N) {
    cout << N - sum << endl;
  } else {
    cout << "-1" << endl;
  }
}


Fixed submission:
#include <bits/stdc++.h>
#include <math.h>
#define _GLIBCXX_DEBUG
using namespace std;
int main() {

  int N, M;
  cin >> N >> M;
  vector<int> vec(M);
  for (int i = 0; i < M; i++) {
    cin >> vec[i];
  }

  int sum = 0;
  for (int i = 0; i < M; i++) {
    sum += vec[i];
  }

  if (sum <= N) {
    cout << N - sum << endl;
  } else {
    cout << "-1" << endl;
  }
}
Problem p02706 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;

typedef long long int ll;

#define fast                                                                   \
  ios_base::sync_with_stdio(false);                                            \
  cin.tie(NULL);                                                               \
  cout.tie(NULL);
#define endl "\n"

int main() {
  fast;
  ll n, m, i, a[10000], sum = 0;
  cin >> n >> m;
  for (i = 0; i < n; i++) {
    cin >> a[i];
    sum += a[i];
  }

  if (sum <= n)
    cout << abs(sum - n) << endl;
  else
    cout << "-1" << endl;

  return 0;
}


Fixed submission:
#include <bits/stdc++.h>
using namespace std;

typedef long long int ll;

#define fast                                                                   \
  ios_base::sync_with_stdio(false);                                            \
  cin.tie(NULL);                                                               \
  cout.tie(NULL);
#define endl "\n"

int main() {
  fast;
  ll n, m, i, a[10000], sum = 0;
  cin >> n >> m;
  for (i = 0; i < m; i++) {
    cin >> a[i];
    sum += a[i];
  }

  if (sum <= n)
    cout << abs(sum - n) << endl;
  else
    cout << "-1" << endl;

  return 0;
}
Problem p02706 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;

int main() {
  int N, M;
  cin >> N >> M;
  vector<int> V;
  for (int i = 0; i < M; i++) {
    cin >> V.at(i);
  }
  int P = 0;
  for (int i = 0; i < M; i++) {
    P += V.at(i);
  }
  if (N - P >= 0)
    cout << N - P;
  else
    cout << "-1";
}


Fixed submission:
#include <bits/stdc++.h>
using namespace std;

int main() {
  int N, M;
  cin >> N >> M;
  vector<int> V(M);
  for (int i = 0; i < M; i++) {
    cin >> V.at(i);
  }
  int P = 0;
  for (int i = 0; i < M; i++) {
    P += V.at(i);
  }
  if (N - P >= 0)
    cout << N - P;
  else
    cout << "-1";
}
Problem p02706 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <numeric>
#include <vector>
using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()

int main() {
  int n, m;
  cin >> n >> m;
  vector<int> A(m);
  rep(i, n) cin >> A.at(i);

  int sum = accumulate(A.begin(), A.end(), 0);
  if (sum > n) {
    cout << -1 << endl;
  } else {
    cout << n - sum << endl;
  }
}

Fixed submission:
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <numeric>
#include <vector>
using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()

int main() {
  int n, m;
  cin >> n >> m;
  vector<int> A(m);
  rep(i, m) cin >> A.at(i);

  int sum = accumulate(A.begin(), A.end(), 0);
  if (sum > n) {
    cout << -1 << endl;
  } else {
    cout << n - sum << endl;
  }
}