alexjercan/bugnet huggingface dataset:
Problem p02401 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <cstdio>
int main() {
  int a, b;
  char op;
  while (scanf("%d %c %d", &a, &op, &b)) {
    if (op == '?')
      break;

    if (op == '+')
      printf("%d\\n", a + b);

    if (op == '-')
      printf("%d\\n", a - b);

    if (op == '*')
      printf("%d\\n", a * b);

    if (op == '/')
      printf("%d\\n", a / b);
  }
  return 0;
}

Error: TLE

Fixed submission:

#include <cstdio>
int main() {
  int a, b;
  char op;
  while (scanf("%d %c %d", &a, &op, &b)) {
    if (a == 0 && op == '?' && b == 0)
      break;

    if (op == '+')
      printf("%d\\n", a + b);

    if (op == '-')
      printf("%d\\n", a - b);

    if (op == '*')
      printf("%d\\n", a * b);

    if (op == '/')
      printf("%d\\n", a / b);
  }
  return 0;
}
Problem p02402 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>
using namespace std;

int main() {

  long int n;
  cin >> n;
  int *a = new int[n];
  long int min, max, sum;
  min = 1000000;
  max = -1000000;
  sum = 0;

  for (int i = 0; i < n; i++) {
    cin >> a[i];
    if (min > a[i])
      min = a[i];
    if (max < a[i])
      max = a[i];

    sum = sum + a[i];
  }
  cout << min << " " << max << " " << sum << "\\n";
}

Error: TLE

Fixed submission:

#include <iostream>
using namespace std;

int main() {

  int n;
  cin >> n;
  int *a = new int[n];
  cin >> n;
  int min, max, sum;
  min = 1000000;
  max = -1000000;
  sum = 0;

  for (int i = 0; i = n; i++) {
    cin >> a[i];
    if (max < a[i])
      max = a[i];
    if (min > a[i])
      min = a[i];
    sum = sum + a[i];
  }
  cout << min << " " << max << " " << sum << " "
       << "\\n";
}
Problem p02402 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>
using namespace std;

int main() {
  int n, max, min, x;
  long long sum;

  cin >> n;

  cin >> x;
  max = min = sum = x;

  for (int i = 0; i < n - 1; i++) {
    cin >> x;
    if (x > max)
      max = x;
    if (x < min)
      min = x;
    sum += x;
  }
  cout << min << " " << max << " " << sum << endl;

  return 0;
}

Error: TLE

Fixed submission:

#include <iostream>
using namespace std;

int main() {
  int n, max, min, sum;
  cin >> n;

  for (int i = 0; i < n; i++) {
    int x;
    cin >> x;
    if (i = 0)
      max = min = sum = x;
    else {
      if (x > max)
        max = x;
      if (x < min)
        min = x;
      sum += x;
    }
  }
  cout << min << " " << max << " " << sum << endl;

  return 0;
}
Problem p02402 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, min, max, i, s;
  long long sum = 0;
  cin >> n;
  cin >> s;
  min = s;
  max = s;
  sum = s;
  for (i = 0; i < n - 1; i++) {
    cin >> s;
    if (s > max)
      max = s;
    if (min > s)
      min = s;
    sum = sum + s;
  }
  cout << min << " " << max << " " << sum << endl;
  return 0;
}


Error: -11

Fixed submission:

#include <stdio.h>

int main() {
  int n, min, max, sum, i, ai[10000];
  sum = 0;
  scanf("%d", &n);
  for (i = 0; i < n; i++) {
    scanf("%d", ai[i]);
    if (i == 0) {
      max = ai[i];
      min = ai[i];
    }
    if (min > ai[i])
      min = ai[i];
    if (max < ai[i])
      max = ai[i];

    sum += ai[i];
  }
  printf("%d %d %d\\n", min, max, sum);
}
Problem p02402 (C++) — buggy submission, verdict: Runtime Error

#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <string>
using namespace std;
int main() {
  long long a, n, max;
  long long goukei = 0;
  long long min = 999999999;
  long long array[1000000];
  cin >> n;
  for (;;) {
    for (a = 0; a < n; a++)
      cin >> array[a];
    int max = array[0];
    for (a = 0; a < n; a++)
      if (array[a] > max)
        max = array[a];
    for (a = 0; a < n; a++)
      if (array[a] < min)
        min = array[a];
    for (a = 0; a < n; a++)
      goukei += array[a];

    cout << min << " " << max << " " << goukei << endl;
    break;
  }

  return 0;
}

Error: -11

Fixed submission:

#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <string>
using namespace std;
int main() {
  long long a, n, max;
  long long goukei = 0;
  long long min = 999999999;
  long long array[9999999];
  cin >> n;
  for (;;) {
    for (a = 0; a < n; a++)
      cin >> array[a];
    int max = array[0];
    for (a = 0; a < n; a++)
      if (array[a] > max)
        max = array[a];
    for (a = 0; a < n; a++)
      if (array[a] < min)
        min = array[a];
    for (a = 0; a < n; a++)
      goukei += array[a];

    cout << min << " " << max << " " << goukei << endl;
    break;
  }

  return 0;
}
Problem p02402 (C++) — buggy submission, verdict: Runtime Error

#include <algorithm>
#include <iostream>
using namespace std;
int main() {
  int n;
  long a[10000], x, max = -1000000, min = 1000000, gou = 0;
  ;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    gou += a[i];
  }
  for (int i = 0; i < n; ++i) {
    if (a[i] != 0) {
      if (min > a[i]) {
        swap(a[i], min);
      } else if (max < a[i]) {
        swap(a[i], max);
      }
    }
  }
  if (min > max) {
    min = 0;
    max = 0;
  }
  cout << min << " " << max << " " << gou << endl;
  return 0;
}


Error: 0

Fixed submission:

#include <algorithm>
#include <iostream>
using namespace std;
int main() {
  int n, a[10], x, max = -1000000, min = 1000000, gou = 0;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    gou += a[i];
  }
  for (int i = 0; i < n; ++i) {
    if (min > a[i]) {
      swap(a[i], min);
    } else if (max < a[i]) {
      swap(a[i], max);
    }
  }
  cout << min << " " << max << " " << gou << endl;
  return 0;
}
Problem p02402 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>

using namespace std;

int main() {
  int num = 0;
  int a[10000] = {};
  long int max = -1000000, min = 1000000, sum = 0;

  cin >> num;

  for (int i = 0; i < num; i++) {
    cin >> a[i];

    if (max < a[i])
      max = a[i];
    if (min > a[i])
      min = a[i];

    sum += a[i];
  }

  cout << min << " " << max << " " << sum << endl;

  return 0;
}

Error: TLE

Fixed submission:

#include <cstdio>

int main(void) {
  int a, b;
  char op;

  while (1) {
    scanf("%d %c %d", &a, &op, &b);
    if (op == '+')
      printf("%d\\n", a + b);
    else if (op == '-')
      printf("%d\\n", a - b);
    else if (op == '*')
      printf("%d\\n", a * b);
    else if (op == '/')
      printf("%d\\n", a / b);
    else if (op == '?')
      break;
  }

  return 0;
}
Problem p02402 (C++) — buggy submission, verdict: Runtime Error

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

int main() {
  int n;
  long long sum = 0;
  scanf("%d", &n);
  vector<int> a(n);
  for (int i = 0; i < n; i++)
    scanf("%d", &a[i]);
  sort(a.begin(), a.end());
  for (int i = 0; i < n; i++)
    sum += a[i];
  printf("%d %d %lld\\n", a[0], a[n - 1], sum);
  return 0;
}


Error: -11

Fixed submission:

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

int main() {
  int n, sum;
  scanf("%d", &n);
  vector<int> a(n);
  for (int i = 0; i < n; i++)
    scanf("%d", a[i]);
  sort(a.begin(), a.end());
  sum = accumulate(a.begin(), a.end(), 0);
  printf("%d %d %d\\n", a[0], a[n - 1], sum);
  return 0;
}
Problem p02402 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>

using namespace std;

int main() {
  int n, a;
  int max = -10000000, min = 10000000;
  long sum = 0;
  cin >> n;
  for (int i = 0; i < n; ++i) {
    cin >> a;
    if (max < a) {
      max = a;
    }
    if (min > a) {
      min = a;
    }
    sum += a;
  }
  cout << min << " " << max << " " << sum << endl;
  return 0;
}


Error: TLE

Fixed submission:

#include <iostream>

using namespace std;

int main() {
  int n, a;
  int max, min;
  long sum = 0;
  cin >> n;
  for (int i = 0; i < n; ++i) {
    cin >> a;
    if (i = 0) {
      max = min = a;
    }
    if (max < a) {
      max = a;
    }
    if (min > a) {
      min = a;
    }
    sum += a;
  }
  cout << min << " " << max << " " << sum << endl;
  return 0;
}
Problem p02402 (C++) — buggy submission, verdict: Runtime Error

#include <stdio.h>

int main() {
  int n, A[10001];
  scanf("%d", &n);
  int i;
  for (i = 0; i <= n - 1; i++) {
    scanf("%d ", &A[i]);
  }
  long int min = 1000001, max = -1000001, total = 0;
  for (i = 0; i <= n - 1; i++) {
    if (min > A[i])
      min = A[i];
    if (max < A[i])
      max = A[i];
    total = total + A[i];
  }
  printf("%ld %ld %ld\\n", min, max, total);
  return 0;
}

Error: -11

Fixed submission:

#include <stdio.h>

int main() {
  int n, A[10001];
  scanf("%d", &n);
  int i;
  for (i = 0; i <= n - 1; i++) {
    scanf("%d ", A[i]);
  }
  int min = -1000001, max = 1000000, total = 0;
  for (i = 0; i <= n - 1; i++) {
    if (min > A[i])
      min = A[i];
    if (max < A[i])
      max = A[i];
    total = total + A[i];
  }
  printf("%d %d %d\\n", min, max, total);
  return 0;
}
Problem p02402 (C++) — buggy submission, verdict: Runtime Error

#include <iostream>

using namespace std;

int main() {

  int a;
  int data[10000];
  long long int max = -1000000, min = 1000000, sum = 0;
  cin >> a;
  for (int i = 0; i < a; i++) {
    cin >> data[i];
    if (data[i] > max) {
      max = data[i];
    }
    if (data[i] < min) {
      min = data[i];
    }
    sum += data[i];
  }
  cout << min << ' ' << max << ' ' << sum << endl;
}


Error: -11

Fixed submission:

#include <iostream>
#include <vector>

using namespace std;

int main() {

  int a;
  vector<int> data;
  long long int max = -1000000, min = 1000000, sum = 0;
  cin >> a;

  for (int i = 0; i < a; i++) {
    cin >> data[i];
    if (data[i] > max) {
      max = data[i];
    }
    if (data[i] > min) {
      min = data[i];
    }
    sum += data[i];
  }
  cout << min << ' ' << max << ' ' << sum;
}
Problem p02402 (C++) — buggy submission, verdict: Runtime Error

#include <algorithm>
#include <cstdlib>
#include <iostream>
#include <string>

#include <ctype.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

using namespace std;

int main() {

  long long min = 1000000, max = -1000000, sum = 0;
  int n = 0, m = 0, i = 0;

  cin >> n;

  for (i = 0; i < n; i++) {
    cin >> m;
    if (min > m)
      min = m;
    if (max < m)
      max = m;
    sum = sum + m;
  }

  cout << min << " " << max << " " << sum << endl;

  return 0;
}

Error: 0

Fixed submission:

#include <algorithm>
#include <iostream>
#include <math.h>
#include <stdio.h>
using namespace std;

int main() {

  int m[256];
  int i, n;
  int sum = 0, max = -1000000, min = 1000000;

  cin >> n;
  for (i = 0; i < n; i++)
    cin >> m[i];

  for (i = 0; i < n; i++) {
    if (m[i] > max)
      max = m[i];
    if (m[i] < min)
      min = m[i];
    sum += m[i];
  }
  cout << min << " " << max << " " << sum << endl;

  return 0;
}
Problem p02402 (C++) — buggy submission, verdict: Runtime Error

#include <cstdio>
#include <cstdlib>
#include <iostream>
using namespace std;

int main(int argc, char *argv[]) {
  long long min = 1000000, max = -1000000, sum = 0, nline, i;
  cin >> nline;
  const int n = nline;
  int arr[n];
  //  int *arr = new int(nline);
  for (i = 0; i < n; i++) {
    cin >> arr[i];
  }
  for (i = 0; i < n; i++) {
    if (arr[i] < min)
      min = arr[i];
    if (arr[i] > max)
      max = arr[i];
  }
  for (i = 0; i < n; i++) {
    sum += arr[i];
  }
  cout << min << " " << max << " " << sum << endl;
  //  delete[] arr;
  return 0;
}

Error: 0

Fixed submission:

#include <cstdio>
#include <cstdlib>
#include <iostream>
using namespace std;

int main(int argc, char *argv[]) {
  int min = 1000000, max = -1000000, sum = 0, nline, i;
  cin >> nline;
  int *arr = new int(nline);
  for (i = 0; i < nline; i++) {
    cin >> arr[i];
  }
  for (i = 0; i < nline; i++) {
    if (arr[i] <= min)
      min = arr[i];
    if (arr[i] >= max)
      max = arr[i];
  }
  for (i = 0; i < nline; i++) {
    sum += arr[i];
  }
  cout << min << " " << max << " " << sum << endl;
  delete[] arr;
  return 0;
}
Problem p02402 (C++) — buggy submission, verdict: Runtime Error

#include <algorithm>
#include <iostream>
#include <numeric>
using namespace std;

int main() {
  long long n, a[10000];
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  cout << *min_element(a, a + n) << " " << *max_element(a, a + n) << " "
       << accumulate(a, a + n, 0LL) << endl;
}


Error: -11

Fixed submission:

#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
int main() {
  vector<int> x;
  int num;
  cin >> num;
  for (int i = 0; i < num; i++) {
    cin >> x[i];
  }
}
Problem p02402 (C++) — buggy submission, verdict: Runtime Error

#include <iostream>
using namespace std;
int main() {
  int n, a[10000], i, x;
  long long sum = 0, max = -1000000, min = 1000000;
  cin >> n;
  for (i = 0; i < n; i++) {
    cin >> a[i];
    sum += a[i];
    if (a[i] > max) {
      max = a[i];
    }
    if (a[i] < min) {
      min = a[i];
    }
  }
  cout << min << " " << max << " " << sum << endl;
  // What Japanese people!?

  return 0;
}

Error: 0

Fixed submission:

#include <iostream>
using namespace std;
int main() {
  int n, a[100], i, x, sum = 0, max = 0, min = 10000;
  cin >> n;
  for (i = 0; i < n; i++) {
    cin >> a[i];
    sum += a[i];
    if (a[i] > max) {
      max = a[i];
    }
    if (a[i] < min) {
      min = a[i];
    }
  }
  cout << min << " " << max << " " << sum << endl;
  // What Japanese people!?

  return 0;
}
Problem p02402 (C++) — buggy submission, verdict: Time Limit Exceeded


#include <iomanip>
#include <iostream>

using namespace std;

long long a, n, smallest, biggest, sum;
char op;

int main() {

  cin >> n;

  smallest = 0;
  biggest = 0;
  sum = 0;

  for (int i = 0; i + 1 <= n; i++) {

    cin >> a;

    if (i == 0 || a < smallest) {
      smallest = a;
    }
    if (i == 0 || a > biggest) {
      biggest = a;
    }

    sum += a;
  }

  cout << smallest << " " << biggest << " " << sum << endl;

  return 0;
}


Error: TLE

Fixed submission:


#include <iomanip>
#include <iostream>

using namespace std;

long long a, n, smallest, biggest, sum;
char op;

int main() {

  cin >> n;

  smallest = 0;
  biggest = 0;
  sum = 0;

  for (int i = 0; i + 1 <= n; i++) {

    cin >> a;

    if (i == 0 || a < smallest) {
      smallest = a;
    }
    if (i = 0 || a > biggest) {
      biggest = a;
    }

    sum += a;
  }

  cout << smallest << " " << biggest << " " << sum << endl;

  return 0;
}
Problem p02402 (C++) — buggy submission, verdict: Time Limit Exceeded

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

int main() {

  int n;
  cin >> n;

  int a[10000];
  for (int i = 0; i < n; i++)
    cin >> a[i];

  int mn = a[0], mx = a[0];
  long long sum = 0;
  for (int i = 0; i < n; i++) {
    mn = min(mn, a[i]);
    mx = max(mx, a[i]);
    sum += a[i];
  }

  cout << mn << " " << mx << " " << sum << endl;

  return 0;
}


Error: TLE

Fixed submission:

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

int main() {

  int n;
  cin >> n;

  int a[10000];
  for (int i = 0; 1 < n; i++)
    cin >> a[i];

  int mn = a[0], mx = a[0];
  long long sum = 0;
  for (int i = 0; i < n; i++) {
    mn = min(mn, a[i]);
    mx = max(mx, a[i]);
    sum += a[i];
  }

  cout << mn << " " << mx << " " << sum << endl;

  return 0;
}
Problem p02402 (C++) — buggy submission, verdict: Runtime Error

#include <algorithm>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

#define INF (1 << 30)
#define INFL (1LL << 62)
#define MOD7 1000000007
#define MOD9 1000000009
#define EPS 1e-10

#define ll long long
#define ull unsigned long long
#define all(a) (a).begin(), (a).end()

int main() {
  int n;
  cin >> n;
  vector<ll> v(n);
  for (int i = 0; i < n; ++i)
    cin >> v[i];
  cout << *min_element(all(v)) << " ";
  cout << *max_element(all(v)) << " ";
  cout << accumulate(all(v), 0LL) << endl;

  return 0;
}


Error: WA

Fixed submission:

#include <algorithm>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

#define INF (1 << 30)
#define INFL (1LL << 62)
#define MOD7 1000000007
#define MOD9 1000000009
#define EPS 1e-10

#define ll long long
#define ull unsigned long long
#define all(a) (a).begin(), (a).end()

int main() {
  int n;
  vector<int> v(n);
  for (int i = 0; i < n; ++i)
    cin >> v[i];
  cout << *min_element(all(v)) << " ";
  cout << *max_element(all(v)) << " ";
  cout << accumulate(all(v), 0) << endl;

  return 0;
}
Problem p02402 (C++) — buggy submission, verdict: Runtime Error

#include <limits.h>
#include <stdio.h>

int main() {
  int n, a;
  long long sum = 0;
  int min = INT_MAX;
  int max = INT_MIN;

  scanf("%d", &n);

  for (; n > 0; n--) {
    scanf("%d ", &a);
    sum += a;
    if (a < min) {
      min = a;
    }
    if (a > max) {
      max = a;
    }
  }

  printf("%d %d %lld\\n", min, max, sum);
}

Error: -11

Fixed submission:

#include <stdio.h>

int main() {
  int n, a;
  long long sum = 0;
  int min = 10000;
  int max = 0;

  scanf("%d", &n);

  for (; n > 0; n--) {
    scanf("%d ", a);
    sum += a;
    if (a < min) {
      min = a;
    }
    if (a > max) {
      max = a;
    }
  }

  printf("%d %d %lld\\n", min, max, sum);
}
Problem p02402 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <algorithm>
#include <iostream>
using namespace std;

int main() {
  long sum = 0;
  long fra[10000];
  int n;

  // 上限'n'の入力
  cin >> n;

  // 配列fra[]に値を代入、合計値sumに加算
  for (int i = 0; i < n; i++) {
    cin >> fra[i];
    sum = sum + fra[i];
  }

  while (1) {
    int flag = 0;
    // ソート本体
    for (int i = 0; i < n; i++) {
      if (fra[i - 1] > fra[i] && i > 0 && i < n) {
        swap(fra[i - 1], fra[i]);
      }
    }
    // ソート判定
    int count = 0;
    for (int i = 0; i < n; i++) {
      if (fra[i - 1] <= fra[i] && i > 0) {
        count++;
      }
      if (count == n - 1) {
        flag = 1;
      }
    }

    if (flag == 1)
      break;
  }

  cout << fra[0] << " " << fra[n - 1] << " " << sum << endl;

  return 0;
}

Error: TLE

Fixed submission:

#include <algorithm>
#include <iostream>
using namespace std;

int main() {
  long sum = 0;
  long fra[10000];
  int n;

  // 上限'n'の入力
  cin >> n;

  // 配列fra[]に値を代入、合計値sumに加算
  for (int i = 0; i < n; i++) {
    cin >> fra[i];
    sum = sum + fra[i];
  }

  while (1) {
    int flag = 0;
    // ソート本体
    for (int i = 0; i < n; i++) {
      if (fra[i - 1] > fra[i] && i > 0 && i < n) {
        swap(fra[i - 1], fra[i]);
      }
    }
    // ソート判定
    int count = 0;
    for (int i = 0; i < n; i++) {
      if (fra[i - 1] < fra[i] && i > 0) {
        count++;
      }
      if (count == n - 1) {
        flag = 1;
      }
    }

    if (flag == 1)
      break;
  }

  cout << fra[0] << " " << fra[n - 1] << " " << sum << endl;

  return 0;
}
Problem p02402 (C++) — buggy submission, verdict: Runtime Error

#include <ctype.h>
#include <stdio.h>
#include <stdlib.h>

int main() {
  int n;
  int d, min, max;
  long long sum;

  scanf("%d%d", &n, &d);
  sum = min = max = d;
  while (--n > 0) {
    scanf("%d", &d);
    if (d < min)
      min = d;
    if (d > max)
      max = d;
    sum += d;
  }
  printf("%d %d %lld\\n", min, max, sum);
  return 0;
}


Error: -11

Fixed submission:

#include <stdio.h>
int main(void) {
  int n, i, x, y;
  long int z;
  scanf("%d", n);
  int a;
  x = -1000000;
  y = 1000000;
  z = 0;
  for (i = 0; i <= n; i++) {
    if (x > a) {
      x = a;
    }
    if (y < a) {
      y = a;
    }
    z = z + a;
  }
  printf("%d %d %d", x, y, z);
  return 0;
}
Problem p02402 (C++) — buggy submission, verdict: Runtime Error

#include <stdio.h>
int main(void) {
  int An, i, max, min, n;
  long amount;
  max = -1000000;
  min = 1000000;
  amount = 0;
  scanf("%d", &n);
  for (i = 0; i < n; i++) {
    scanf("%d", &An);
    if (max < An) {
      max = An;
    }
    if (min > An) {
      min = An;
    }
    amount += An;
  }
  printf("%d %d %ld\\n", min, max, amount);
  return 0;
}

Error: -11

Fixed submission:


#include <stdio.h>

int main(void) {
  long n[10000], i, x, max, min, amount;
  max = -1000000;
  min = 1000000;
  amount = 0;
  scanf("%d\\n", &i);
  for (x = 0; x < i; x++) {
    scanf("%d ", n[x]);
  }
  for (x = 0; x < i; x++) {
    if (min > n[x]) {
      min = n[x];
    }
    if (max < n[x]) {
      max = n[x];
    }
    amount = amount + n[x];
  }
  printf("%d %d %d\\n", min, max, amount);
  return 0;
}
Problem p02402 (C++) — buggy submission, verdict: Runtime Error

#include <iostream>
using namespace std;

int main() {
  long long a[10000], Min, Max, Sum;
  int n;
  cin >> n;
  Min = 1000000;
  Max = -1000000;
  Sum = 0;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    if (a[i] < Min) {
      Min = a[i];
    }
    if (a[i] > Max) {
      Max = a[i];
    }
    Sum = Sum + a[i];
  }

  cout << Min << " " << Max << " " << Sum << endl;

  return 0;
}

Error: 0

Fixed submission:

#include <iostream>
using namespace std;

int main() {
  long long a[100], Min, Max, Sum;
  int n;
  cin >> n;
  Min = 10000000;
  Max = -10000000;
  Sum = 0;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    if (a[i] < Min) {
      Min = a[i];
    }
    if (a[i] > Max) {
      Max = a[i];
    }
    Sum = Sum + a[i];
  }

  cout << Min << " " << Max << " " << Sum << endl;

  return 0;
}
Problem p02402 (C++) — buggy submission, verdict: Runtime Error

#include <cstdio>
#include <iostream>
#include <stdio.h>
using namespace std;

int main() {
  int a, b[10001];
  long long int max, min, sum = 0;

  cin >> a;

  for (int i = 0; i < a; i++) {
    cin >> b[i];
    if (i == 0) {
      min = b[i];
      max = b[i];
    }

    if (b[i] < min) {
      min = b[i];
    } else if (max < b[i]) {
      max = b[i];
    }

    sum += b[i];
  }
  cout << min << " " << max << " " << sum << endl;

  return 0;
}


Error: -11

Fixed submission:

#include <cstdio>
#include <iostream>
#include <stdio.h>
using namespace std;

int main() {
  long a, b[100000000];
  long max, min, sum = 0;

  cin >> a;

  for (int i = 0; i < a; i++) {
    cin >> b[i];
    if (i == 0) {
      min = b[i];
      max = b[i];
    }

    if (b[i] < min) {
      min = b[i];
    } else if (max < b[i]) {
      max = b[i];
    }

    sum += b[i];
  }
  cout << min << " " << max << " " << sum << endl;

  return 0;
}
Problem p02402 (C++) — buggy submission, verdict: Runtime Error

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

int main() {
  int n;
  cin >> n;
  int a[10000];
  for (int i = 0; i < n; i++)
    cin >> a[i];
  int mn = a[0];
  int mx = a[0];
  long long sum = 0;
  for (int i = 0; i < n; i++) {
    mn = min(mn, a[i]);
    mx = max(mx, a[i]);
    sum += a[i];
  }
  cout << mn << " " << mx << " " << sum << endl;
  return 0;
}


Error: 0

Fixed submission:

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

int main() {
  int n;
  cin >> n;
  int a[1000];
  for (int i = 0; i < n; i++)
    cin >> a[i];
  int mn = a[0];
  int mx = a[0];
  long long sum = 0;
  for (int i = 0; i < n; i++) {
    mn = min(mn, a[i]);
    mx = max(mx, a[i]);
    sum += a[i];
  }
  cout << mn << " " << mx << " " << sum << endl;
  return 0;
}