alexjercan/bugnet huggingface dataset:
Problem p00001 (C++) — buggy submission, verdict: Runtime Error

#include <iostream>
#include <vector>

int main() {
  std::vector<int> vec(10);
  for (int i = 0; i < 10; i++) {
    std::cin >> vec[i];
  }
  while (1) {
    int a = 0;
    for (int i = 0; i < 9; i++) {
      if (vec[i] > vec[i + 1]) {
        int b = 0;
        b = vec[i];
        vec[i] = vec[i + 1];
        vec[i + 1] = b;
        a++;
      }
    }
    if (a == 0)
      break;
  }
  std::cout << vec[9] << std::endl
            << vec[8] << std::endl
            << vec[7] << std::endl;
  return 0;
}

Error: -11

Fixed submission:

#include <iostream>
#include <vector>
int main() {
  std::vector<int> vec(10);
  for (int i = 0; i < 10; i++) {
    std::cin >> vec[i];
  }
  while (1) {
    int a, b = 0;
    for (int j = 0; j < 10; j++) {
      if (vec[j] > vec[j + 1] && j + 1 < 10) {
        a = 0;
        a = vec[j];
        vec[j] = vec[j + 1];
        vec[j + 1] = a;
        b++;
      }
    }
    if (b == 0)
      break;
  }
  for (int i = 9; i >= 7; i++) {
    std::cout << vec[i] << std::endl;
  }
  return 0;
}
Problem p00001 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <algorithm>
#include <bitset>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

typedef long long ll;

using namespace std;

int main(void) {
  int h[10];
  for (int i = 0; i < 10; i++) {
    cin >> h[i];
  }

  sort(h, h + 10, greater<int>());

  cout << h[0] << endl << h[1] << endl << h[2] << endl;

  return 0;
}

Error: TLE

Fixed submission:

#include <algorithm>
#include <bitset>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

typedef long long ll;

using namespace std;

int main(void) {
  int h[10];
  for (int i = 0; i < 10; i++) {
    cin >> h[i];
  }

  sort(h, h + 10, greater<int>());

  cout << h[0] << endl << h[1] << endl << h[2];
  while (1)
    ;

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

#include <stdio.h>
void SimpleSelectionSort(int *array, int n) {
  int temp = 0;
  int i = 0;
  int j = 0;

  for (i = 0; i < n - 1; i++) {
    for (j = i + 1; j < n; j++) {
      if (array[i] < array[j]) {
        temp = array[i];
        array[i] = array[j];
        array[j] = temp;
      }
    }
  }

  return;
}

int main(void) {
  int array[10];
  int i = 0;
  for (i = 0; i < 10; i++) {
    scanf("%d", &array[i]);
  }

  SimpleSelectionSort(array, 10);

  for (i = 0; i < 3; i++) {
    printf("%d\\n", array[i]);
  }

  return 0;
}

Error: TLE

Fixed submission:

#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

int main() {
  vector<int> v;
  int a;

  while (1) {
    for (int i = 0; i < 10; i++) {
      cin >> a;
      v.push_back(a);
    }

    sort(v.begin(), v.end());

    cout << v[0] << endl << v[1] << endl << v[2] << endl;
  }
  return 0;
}
Problem p00001 (C++) — buggy submission, verdict: Runtime Error

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

int main(void) {
  /* 宣言と初期化 */
  int hai[10];
  int id[2];
  int i;
  int temp2nd;
  int temp3rd;
  int tempmax;

  for (i = 0; i < 10; i++) {
    cin >> hai[i];
  }
  /* 代入 */
  temp2nd = hai[0];
  tempmax = hai[0];
  temp3rd = hai[0];
  /* 計算 */
  for (int j = 9; j > 1; j--) {
    for (i = 0; i < j; i++) {
      /* 最大値求める */
      if (hai[j] < hai[i]) {
        tempmax = hai[i];
        hai[i] = hai[j];
        hai[j] = tempmax;
      }
    }
  }

  /* 表示 */
  printf("%d\\n", hai[9]);
  printf("%d\\n", hai[8]);
  printf("%d\\n", hai[7]);

  return 0;
}

Error: -11

Fixed submission:

#include <stdio.h>

int main(void) {

  /* 宣言と初期化 */
  int hai[10];
  int i;
  int temp2nd;
  int temp3rd;
  int tempmax;

  for (i = 0; i < 10; i++) {
    printf("山の高さ　");
    scanf("%d", hai[i]);
  }
  /* 代入 */
  temp2nd = hai[0];
  tempmax = hai[0];
  temp3rd = hai[0];

  /* 計算 */
  for (i = 0; i < 10; i++) {
    /* 最大値求める */
    if (hai[i] > tempmax)
      tempmax = hai[i];
  }

  for (i = 0; i < 10; i++) {
    /*2番目求める */
    if (hai[i] < tempmax && hai[i] > temp2nd)
      temp2nd = hai[i];
  }

  for (i = 0; i < 10; i++) {
    /* 3番目求める */
    if (hai[i] > temp3rd && hai[i] < temp2nd)
      temp3rd = hai[i];
  }

  /* 表示 */
  printf("最も高い山の高さ　%d\\n", tempmax);
  printf("２番目に高い山の高さ　%d\\n", temp2nd);
  printf("３番目に高い山の高さ　%d\\n", temp3rd);

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

#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <iostream>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<vi> vvi;
int H[10];
int main() {
  for (int i = 0; i < 10; i++) {
    cin >> H[i];
  }
  sort(H, H + 10, greater<int>());
  for (int i = 0; i < 3; i++) {
    cout << H[i] << endl;
  }
}

Error: 0

Fixed submission:

#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<vi> vvi;
int H[10];
int main() {
  int n;
  vi H(n);
  for (int i = 0; i < 10; i++) {
    cin >> H[i];
  }
  sort(H.rbegin(), H.rend());
  for (int i = 0; i < 3; i++) {
    cout << H[i] << endl;
  }
}
Problem p00001 (C++) — buggy submission, verdict: Runtime Error

#include <algorithm>
#include <cstdio>

using namespace std;

int main(void) {
  int i, array[10];

  for (i = 0; i < 10; i++)
    scanf("%d", &array[i]);
  sort(array, array + 10);
  for (i = 9; i >= 7; i--)
    printf("%d\\n", array[i]);

  return 0;
}


Error: -11

Fixed submission:

#include <algorithm>
#include <cstdio>

using namespace std;

int main(void) {
  int i, array[10];

  for (i = 0; i < 10; i++)
    scanf("%d", &array[i]);
  sort(array, array + 10);
  for (i = 9; i >= 7; i++)
    printf("%d\\n", array[i]);

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

#include <iostream>
#include <stdio.h>
using namespace std;
int main() {
  int a[10];
  int b = 0;
  for (int i = 0; i < 10; i++) {
    cin >> a[i];
  }
  int mou1, mou2, mou3;
  mou1 = a[0];
  for (int i = 0; i < 10; i++) {

    if (mou1 < a[i]) {
      mou1 = a[i];
      b = i;
    }
  }
  a[b] = 0;
  mou2 = a[0];
  for (int i = 0; i < 10; i++) {

    if (mou2 < a[i]) {
      mou2 = a[i];
      b = i;
    }
  }
  a[b] = 0;
  mou3 = a[0];
  for (int i = 0; i < 10; i++) {

    if (mou3 < a[i]) {
      mou3 = a[i];
      b = i;
    }
  }
  cout << mou1 << "\\n" << mou2 << "\\n" << mou3 << "\\n";

  return 0;
}

Error: 0

Fixed submission:

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

using std::cin;
int main() {
  int a[10];
  int b;
  for (int i = 0; i < 10; i++) {
    cin >> a[i];
  }
  int mou1, mou2, mou3;
  mou1 = a[0];
  for (int i = 0; i < 10; i++) {

    if (mou1 < a[i]) {
      mou1 = a[i];
      b = i;
    }
  }
  a[b] = 0;
  mou2 = a[0];
  for (int i = 0; i < 10; i++) {

    if (mou2 < a[i]) {
      mou2 = a[i];
      b = i;
    }
  }
  a[b] = 0;
  mou3 = a[0];
  for (int i = 0; i < 10; i++) {

    if (mou3 < a[i]) {
      mou3 = a[i];
      b = i;
    }
  }
  cout << mou1 << "\\n" << mou2 << "\\n" << mou3 << "\\n";

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

#include <algorithm>
#include <iostream>
using namespace std;
void q_sort(int array[], int begin, int end);

void q_sort(int array[], int begin, int end) {
  int i = begin;
  int k = end;
  int pivot;
  int temp;
  pivot = array[(begin + end) / 2];
  while (1) {
    while (array[i] < pivot) {
      ++i;
    }
    while (pivot < array[k]) {
      k--;
    }
    if (i >= k) {
      break;
    }
    temp = array[i];
    array[i] = array[k];
    array[k] = temp;
    i++;
    k--; // check
  }
  if (begin < i - 1) {
    q_sort(array, begin, i - 1);
  }
  if (k + 1 < end) {
    q_sort(array, k + 1, end);
  }
}
int main(int argc, const char *argv[]) {
  int mt[10];
  for (int i = 0; i < 10; i++) {
    cin >> mt[i];
  }
  q_sort(mt, 0, 9);
  for (int i = 9; 6 < i; i--) {
    cout << mt[i] << endl;
  }
  return 0;
}

Error: -6
*** stack smashing detected ***: terminated


Fixed submission:

#include <algorithm>
#include <iostream>
using namespace std;
void q_sort(int array[], int begin, int end);

void q_sort(int array[], int begin, int end) {
  int i = begin;
  int k = end;
  int pivot;
  int temp;
  pivot = array[(begin + end) / 2];
  while (1) {
    while (array[i] < pivot) {
      ++i;
    }
    while (pivot < array[k]) {
      k--;
    }
    if (i >= k) {
      break;
    }
    temp = array[i];
    array[i] = array[k];
    array[k] = temp;
    i++;
    k++;
  }
  if (begin < i - 1) {
    q_sort(array, begin, i - 1);
  }
  if (k + 1 < end) {
    q_sort(array, k + 1, end);
  }
}
int main(int argc, const char *argv[]) {
  int mt[10];
  for (int i = 0; i < 10; i++) {
    cin >> mt[i];
  }
  q_sort(mt, 0, 10);
  for (int i = 9; 6 < i; i--) {
    cout << mt[i] << endl;
  }
  return 0;
}
Problem p00001 (C++) — buggy submission, verdict: Runtime Error

#include <algorithm>
#include <iostream>
using namespace std;
int main() {
  int a[10];
  for (int i = 0; i < 10; i++) {
    cin >> a[i];
  }
  sort(a, a + 10);
  for (int i = 9; i > 6; i--) {
    cout << a[i] << endl;
  }
  return 0;
}

Error: -11

Fixed submission:

#include <algorithm>
#include <iostream>
using namespace std;
int main() {
  int a[10];
  for (int i = 0; i < 10; i++) {
    cin >> a[i];
  }
  sort(a, a + 10);
  for (int i = 9; i > 6; i++) {
    cout << a[i] << endl;
  }
  return 0;
}
Problem p00001 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <algorithm>
#include <cstdio>
#include <functional>

#define SIZE 10
#define MAX 10000
#define TOP 3

using namespace std;

int main() {
  int i = 0;
  int buf;
  int height[SIZE];

  while (i < SIZE) {
    scanf("%d", &buf);

    height[i] = buf;

    ++i;
  }

  sort(height, height + SIZE, greater<int>());

  for (i = 0; i < TOP; ++i) {
    printf("%d\\n", height[i]);
  }

  return 0;
}

Error: TLE

Fixed submission:

#include <algorithm>
#include <cstdlib>
#include <functional>
#include <iostream>

#define SIZE 10
#define MAX 10000
#define TOP 3

using namespace std;

int main() {
  int i = 0;
  int height[SIZE];
  char buf[256];

  while (i < SIZE) {
    cin >> buf;

    if (atoi(buf) != 0) {
      if (atoi(buf) <= MAX) {
        height[i] = atoi(buf);
        i++;
      }
    }
  }

  sort(height, height + SIZE, greater<int>());

  for (i = 0; i < TOP; i++) {
    cout << height[i] << endl;
  }

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

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

int main() {
  int i;
  int list[10];
  for (i = 0; i < 10; i++) {
    cin >> list[i];
  }
  sort(list, list + 10);
  for (i = 0; i < 3; i++) {
    cout << list[9 - i] << endl;
  }
  return 0;
}


Error: TLE

Fixed submission:

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

int Size = 10;

int main(void) {
  int height[Size];

  for (int i = 0; i < Size; ++i) {
    while (true) {
      cout << "No." << i + 1 << " : " << flush;
      cin >> height[i];
      if (height[i] > 0) {
        break;
      }
    }
  }
  sort(height, height + Size);

  cout << height[9] << endl << height[8] << endl << height[7] << endl;
}
Problem p00001 (C++) — buggy submission, verdict: Runtime Error

/* AOJ0001 */
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;

int main() {
  int h, most[10];
  for (int i = 0; i < 10; i++) {
    cin >> most[i];
  }
  sort(most, most + 10, greater<int>());
  for (int i = 0; i < 3; i++) {
    cout << most[i] << endl;
  }
}

Error: -6
terminate called after throwing an instance of 'std::bad_alloc'
  what():  std::bad_alloc


Fixed submission:

/* AOJ0001 */
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;

int main() {
  int h;
  vector<int> most;
  while (cin >> h, h) {
    most.push_back(h);
  }
  sort(most.rbegin(), most.rend());
  for (int i = 0; i < 3; i++) {
    cout << most[i] << endl;
  }
}
Problem p00001 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>
using namespace std;
int main() {
  int a, b, c = 0, d;
  int yama[10];
  int hyama[3];
  for (a = 0; a < 10; a++) {
    cin >> yama[a];
  }
  for (a = 0;; a++) {
    if (a == 9) {
      a = 0;
      c = 0;
    }
    if (yama[a] < yama[a + 1]) {
      b = yama[a];
      yama[a] = yama[a + 1];
      yama[a + 1] = b;
    } else {
      c++;
    }
    if (c == 9) {
      break;
    }
  }
  for (a = 0; a < 3; a++) {
    cout << yama[a] << endl;
  }
  return 0;
}

Error: TLE

Fixed submission:

#include <iostream>
using namespace std;
int main() {
  int yama[9];
  int x, y, z, a;
  for (x = 0; x < 10; x++) {
    cin >> yama[x];
  }
  for (y = 0; y < 10000; y++) {
    if (yama[y] > yama[y + 1]) {
      z = yama[y];
      yama[y] = yama[y + 1];
      yama[y + 1] = z;
    } else {
      a++;
    }
    if (y == 8) {
      if (a == 9) {
        break;
      } else {
        y = 0;
        a = 0;
      }
    }
  }
  cout << yama[9] << endl;
  cout << yama[8] << endl;
  cout << yama[7] << endl;
  return 0;
}
Problem p00001 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <algorithm>
#include <iostream>

using namespace std;

int main() {
  int i, m[10];

  for (i = 0; i < 10; i++) {
    cin >> m[i];
  }

  sort(m, m + 10);

  for (i = 9; i > 6; i--) {
    cout << m[i] << endl;
  }
}

Error: TLE

Fixed submission:

#include <algorithm>
#include <iostream>

using namespace std;

int main() {
  int i, m[10];

  for (i = 0; i < 10; i++) {
    while (1) {
      cin >> m[i];
      if (m[i] > 0 && m[i] < 10001)
        break;
    }
  }

  sort(m, m + 10);

  for (i = 9; i > 6; i--) {
    cout << m[i] << endl;
  }
}
Problem p00001 (C++) — buggy submission, verdict: Runtime Error

#include <algorithm>
#include <cstdlib>
#include <iostream>
#include <vector>

using namespace std;

const int numOfMountain = 10;

int main() {
  int mountainBuf;
  vector<int> mountains;

  for (int i = 0; i < numOfMountain; i++) {
    cin >> mountainBuf;
    mountains.push_back(mountainBuf);
  }

  sort(mountains.begin(), mountains.end());

  vector<int>::iterator out = mountains.end();
  for (int i = 0; i < 3; i++) {
    out--;
    cout << *out << endl;
  }

  return 0;
}


Error: -11

Fixed submission:

#include <algorithm>
#include <cstdlib>
#include <iostream>
#include <vector>

using namespace std;

const int numOfMountain = 10;

int main(int argc, char **argv) {
  int mountainBuf;
  vector<int> mountains;

  for (int i = 0; i <= numOfMountain; i++) {
    mountainBuf = atoi(argv[i]);
    mountains.push_back(mountainBuf);
  }

  sort(mountains.begin(), mountains.end());

  vector<int>::iterator out = mountains.end();
  for (int i = 0; i < 3; i++) {
    out--;
    cout << *out << endl;
  }

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

#include <algorithm>
#include <cstdlib>
#include <ctime>
#include <iostream>

#define BOGO 10

using namespace std;

int main() {
  int arr[BOGO];
  bool found;
  int j;
  srand(static_cast<unsigned int>(time(NULL)));

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

  for (;;) {

    /**
    for(int j = 0; j < BOGO; j++){
            cout << arr[j] << flush;
    }
    cout << endl;
    /**/

    found = true;
    for (j = 0; j < BOGO - 1; j++) {
      if (arr[j] > arr[j + 1]) {
        found = false;
        break;
      }
    }

    if (found) {
      break;
    }
    random_shuffle(arr, arr + BOGO);
  }
  cout << arr[9] << "\\n" << arr[8] << "\\n" << arr[7] << endl;
}

Error: TLE

Fixed submission:

#include <algorithm>
#include <cstdlib>
#include <ctime>
#include <iostream>

#define BOGO 10

using namespace std;

int main() {
  int arr[BOGO];
  srand(static_cast<unsigned int>(time(NULL)));

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

  for (;;) {

    /**
    for(int j = 0; j < BOGO; j++){
            cout << arr[j] << flush;
    }
    cout << endl;
    /**/

    bool found = true;
    for (int j = 0; j < BOGO - 1; j++) {
      if (arr[j] > arr[j + 1]) {
        found = false;
        break;
      }
    }

    if (found) {
      break;
    }
    random_shuffle(arr, arr + BOGO);
  }
  cout << arr[9] << "\\n" << arr[8] << "\\n" << arr[7] << endl;
}
Problem p00001 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
#include <cctype>
#include <cstdio>
#include <cstdlib>
#include <cstring>

#include <cmath>
#include <fstream>
#include <iostream>

#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>

using namespace std;

int main() {

  long long int n, i = 0, j, a, b, c, ln, my = 0, ck = 0;
  int arr[10];

  for (i = 0; i < 10; i++) {
    cin >> arr[i];
  }
  sort(arr, arr + 10);

  cout << arr[9] << endl;
  cout << arr[8] << endl;
  cout << arr[7] << endl;
}


Error: TLE

Fixed submission:

#include <iostream>
#include <stdio.h>
using namespace std;
int main() {
  int height[10];
  for (int i = 0; i < 10; i++) {
    scanf("%d", &height[i]);
  }
  int temp;
  for (int i = 0; i < 10; i++) {
    for (int j = i + 1; j <= 10; j++) {
      if (height[i] < height[j]) {
        temp = height[i];
        height[i] = height[j];
        height[j] = temp;
      }
    }
  }

  for (int i = 0; i < 3; i++) {
    printf("%d\\n", height[i]);
  }
  return 0;
}
Problem p00001 (C++) — buggy submission, verdict: Time Limit Exceeded

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

int main() {
  int i, f, s, t, h;
  f = -1;
  s = -1;
  t = -1;
  for (i = 0; i < 10; i++) {
    scanf("%d", &h);
    if (h > f) {
      t = s;
      s = f;
      f = h;
    } else if (h > s) {
      t = s;
      s = h;
    } else if (h > t) {
      t = h;
    }
  }
  printf("%d\\n%d\\n%d\\n", f, s, t);
  return 0;
}


Error: TLE

Fixed submission:

#include <iostream>
#include <stdio.h>
using namespace std;
int main() {
  int i, j, temp, h[10];
  for (i = 0; i < 10; i++) {
    cin >> h[i];
  }
  for (i = 0; i < 3; i++) {
    for (j = 0; j < 10 - i; j++) {
      if (h[j] > h[j + 1]) {
        temp = h[j];
        h[j] = h[j + 1];
        h[j + 1] = temp;
      }
    }
  }
  for (i = 9; i > 6; i--) {
    cout << h[i] << endl;
  }
  return 0;
}
Problem p00001 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
using namespace std;
int main() {
  int a[10], i;
  for (i = 0; i <= 9; i++)
    scanf("%d", &a[i]);
  sort(a, a + 10);
  printf("%d\\n%d\\n%d\\n", a[9], a[8], a[7]);
  return 0;
}

Error: TLE

Fixed submission:

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

int comparefunc(const void *a, const void *b) {
  return (*(int *)b - *(int *)a);
}

int main() {
  int height[10], i;
  while (1 != EOF) {
    for (i = 0; i < 10; i++) {
      scanf("%d", &height[i]);
    }
    qsort(height, 10, sizeof(int), comparefunc);

    for (i = 0; i < 3; i++) {
      printf("%d\\n", height[i]);
    }
  }
  return 0;
}
Problem p00001 (C++) — buggy submission, verdict: Runtime Error

#include <iostream>
#include <math.h>
#include <stdio.h>
#include <string.h>

using namespace std;

int main() {
  int T, i, j, a[11];

  for (i = 1; i < 11; i++) {
    scanf("%d", &a[i]);
  }
  for (i = 1; i < 11; i++) {
    for (j = 1; j < 11; j++) {
      if (a[i] > a[j]) {
        T = a[i];
        a[i] = a[j];
        a[j] = T;
      }
    }
  }
  for (i = 1; i < 4; i++) {
    printf("%d\\n", a[i]);
  }

  return 0;
}

Error: 1

Fixed submission:

#include <iostream>
using namespace std;
void swap(int &x, int &y) {
  int t;
  if (x > y) {
    t = y;
    y = x;
    x = t;
  }
}
int main() {
  int a[10], i, j;
  cin >> a[0] >> a[1] >> a[2] >> a[3] >> a[4] >> a[5] >> a[6] >> a[7] >> a[8] >>
      a[9];
  for (i = 0; i < 10; i++) {
    if (a[i] < 0 || a[i] > 10000)
      return 0;
  }
  for (j = 9; j > 6; j--) {
    for (i = 0; i < j; i++)
      swap(a[i], a[i + 1]);
  }
  cout << a[9] << endl << a[8] << endl << a[7];
  return 1;
}
Problem p00001 (C++) — buggy submission, verdict: Runtime Error

#include <algorithm>
#include <cstdio>
#include <iostream>

using namespace std;

int main() {
  int a[10];
  int k;
  for (int i = 0; i < 10; i++) {
    cin >> a[i];
    // a.push_back(k);
  }
  sort(a, a + 10);
  for (int j = 9; j >= 7; j--)
    cout << a[j] << endl;
  return 0;
}

Error: -11

Fixed submission:

#include <stdio.h>
int main() {
  long long array1[11], array2[11], i, j, n, k = 0, temp, l, p = 0;

  scanf("%lld", &n);

  for (i = 0; i < n; i++) {
    scanf("%lld", &array1[i]);
  }
  for (i = 0; i < n - 1; i++) {
    for (j = i + 1; j < n; j++) {
      if (array1[i] > array1[j]) {
        temp = array1[i];
        array1[i] = array1[j];
        array1[j] = temp;
      }
    }
  }
  l = 0;
  for (k = n - 1; k >= 0; k--) {

    array2[l] = array1[k];
    l++;
  }

  for (p = 0; p < 3; p++) {
    printf("%lld\\n", array2[p]);
  }
  return 0;
}
Problem p00001 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
int main() {

  int height[10];
  for (int i = 0; i < 10; i++) {
    cin >> height[i];
  }
  sort(height, height + 10);
  cout << height[9] << endl;
  cout << height[8] << endl;
  cout << height[7] << endl;
  return 0;
}

Error: TLE

Fixed submission:

#include <stdio.h>
int main() {
  int a[50], i;
  while (scanf("%d\\n", &a[i]) != EOF) {
    int t, j;
    for (i = 0; i < 9; i++) {
      for (j = 1; j < 10; j++) {
        if (a[i] < a[j]) {
          t = a[i];
          a[i] = a[j];
          a[j] = t;
        }
      }
      for (i = 0; i < 4; i++)

        printf("%d\\n", a[i]);
    }
  }
  return 0;
}
Problem p00001 (C++) — buggy submission, verdict: Runtime Error

#include <cstdio>

int main() {
  int i = 0, j = 0, a[10] = {0}, temp;
  for (i = 0; i <= 9; i++)
    scanf("%d", &a[i]);
  for (i = j; i <= 9; i++) {
    for (j = 0; j <= 2; j++)
      if (a[i] > a[j]) {
        temp = a[i];
        a[i] = a[j];
        a[j] = temp;
      }
  }
  printf("%d\\n%d\\n%d\\n", a[0], a[1], a[2]);
  return 0;
}

Error: -6
*** stack smashing detected ***: terminated


Fixed submission:

#include <algorithm>
#include <stdio.h>

using namespace std;
int main() {
  int a[100], i;
  int n = 10;
  scanf("%d", &n);

  for (i = 0; i < n; i++) {
    scanf("%d", &a[i]);
  }
  sort(a, a + n);
  printf("%d\\n%d\\n%d\\n", a[n - 1], a[n - 2], a[n - 3]);
  return 0;
}
Problem p00001 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
using namespace std;
int n, a[50];
int main() {
  n = 10;
  for (int i = 1; i <= n; i++)
    cin >> a[i];
  sort(a + 1, a + 1 + n);
  for (int i = n; i >= n - 2; i--) {
    cout << a[i] << endl;
  }
}

Error: -11

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
int n, a[50];
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++)
    cin >> a[i];
  sort(a + 1, a + 1 + n);
  for (int i = n; i >= n - 2; i--) {
    cout << a[i] << endl;
  }
}