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

#include <iostream>
using namespace std;

int main() {
  bool flag;
  int result[3], buf, temp[10];
  for (int i = 0; i < 10; i++) {
    cin >> temp[i];
  }
  for (int l = 0; l < 3; l++) {
    while (1) {
      for (int j = l; j < 9; j++) {
        if (temp[j] < temp[j + 1]) {
          buf = temp[j + 1];
          temp[j + 1] = temp[j];
          temp[j] = buf;
        }
      }
      flag = false;
      for (int k = l; k < 9; k++) {
        if (temp[l] < temp[k])
          flag = true;
      }
      if (flag != true) {
        result[l] = temp[l];
        break;
      }
    }
  }
  cout << result[0] << endl;
  cout << result[1] << endl;
  cout << result[2] << endl;
  return 0;
}

Error: TLE

Fixed submission:

#include <iostream>
using namespace std;

int main() {
  bool flag;
  int result[3], buf, temp[10];
  for (int i = 0; i < 10; i++) {
    cin >> temp[i];
  }
  for (int l = 0; l < 3; l++) {
    while (1) {
      for (int j = l; j < 9; j++) {
        if (temp[j] < temp[j + 1]) {
          buf = temp[j + 1];
          temp[j + 1] = temp[j];
          temp[j] = buf;
        }
      }
      flag = false;
      for (int k = 0; k < 9; k++) {
        if (temp[l] < temp[k])
          flag = true;
      }
      if (flag != true) {
        result[l] = temp[l];
        break;
      }
    }
  }
  cout << result[0] << endl;
  cout << result[1] << endl;
  cout << result[2] << endl;
  return 0;
}
Problem p00001 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <stdio.h>
int main(void) {
  int a = 0, b = 0, c = 0, n, t;
  while (scanf("%d", &n) > 0) {
    if (n > a)
      t = n, n = a, a = t;
    if (n > b)
      t = n, n = b, b = t;
    if (n > c)
      c = n;
  }
  printf("%d\\n%d\\n%d\\n", a, b, c);
  return 0;
}

Error: TLE

Fixed submission:

#include <stdio.h>
int main(void) {
  int a = 0, b = 0, c = 0, n, t;
  while (scanf("%d", &n)) {
    if (n > a)
      t = n, n = a, a = t;
    if (n > b)
      t = n, n = b, b = t;
    if (n > c)
      c = n;
  }
  printf("%d\\n%d\\n%d\\n", a, b, c);
  return 0;
}
Problem p00001 (C++) — buggy submission, verdict: Runtime Error

#include <cstdio>
#include <iostream>

using namespace std;

int main() {
  int hM[10], I, K, temp;

  for (I = 0; I < 10; I = I + 1)
    scanf("%d", &hM[I]);

  for (I = 0; I < 9; I = I + 1)
    for (K = 0; K < 9 - I; K = K + 1)
      if (hM[K] < hM[K + 1]) {
        temp = hM[K];
        hM[K] = hM[K + 1];
        hM[K + 1] = temp;
      }

  for (I = 0; I < 3; I = I + 1)
    printf("%d\\n", hM[I]);

  return 0;
}


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


Fixed submission:

#include <stdio.h>
int main() {
  int number[30];
  int i, j, a, n;
  scanf("%d", &n);
  for (i = 0; i < n; i++)
    scanf("%d", &number[i]);
  for (i = 0; i < n; i++) {
    for (j = i + 1; j < n; j++) {
      if (number[i] < number[j]) {
        a = number[i];
        number[i] = number[j];
        number[j] = a;
      }
    }
  }
  for (i = 0; i < 3; i++)
    printf("%d\\n", number[i]);
}
Problem p00001 (C++) — buggy submission, verdict: Runtime Error

#include <stdio.h>

int main() {
  int i;
  int c = 0, a[3] = {0, 0, 0};
  for (i = 0; i < 10; i++) {
    scanf("%d", &c);
    if (c > a[0]) {
      a[2] = a[1];
      a[1] = a[0];
      a[0] = c;
    } else if (c > a[1]) {
      a[2] = a[1];
      a[1] = c;
    } else if (c > a[2]) {
      a[2] = c;
    }
  }

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

Error: -11

Fixed submission:

#include <stdio.h>

int main() {
  int i;
  int c, a[3];
  c = 0;
  for (i = 0; i < 10; i++) {
    scanf("%d", c);
    if (c > a[0]) {
      a[2] = a[1];
      a[1] = a[0];
      a[0] = c;
    } else if (c > a[1]) {
      a[2] = a[1];
      a[1] = c;
    } else if (c > a[2]) {
      a[2] = c;
    }
  }

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

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

using namespace std;

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

Error: -11

Fixed submission:

#include <stdio.h>

int a, b, c, d, e, f, g, h, i, j, X;

int main() {
  scanf("%d %d %d %d %d %d %d %d %d %d", a, b, c, d, e, f, g, h, i, j);
  if (a > b) {
    X = a;
    a = b;
    b = X;
  }
  if (b > c) {
    X = b;
    b = c;
    c = X;
  }
  if (c > d) {
    X = c;
    c = d;
    d = X;
  }
  if (d > e) {
    X = d;
    d = e;
    e = X;
  }
  if (e > f) {
    X = e;
    e = f;
    f = X;
  }
  if (f > g) {
    X = f;
    f = g;
    g = X;
  }
  if (g > h) {
    X = g;
    g = h;
    h = X;
  }
  if (h > i) {
    X = h;
    h = i;
    i = X;
  }
  if (i > j) {
    X = i;
    i = j;
    j = X;
  }
  if (a > b) {
    X = a;
    a = b;
    b = X;
  }
  if (b > c) {
    X = b;
    b = c;
    c = X;
  }
  if (c > d) {
    X = c;
    c = d;
    d = X;
  }
  if (d > e) {
    X = d;
    d = e;
    e = X;
  }
  if (e > f) {
    X = e;
    e = f;
    f = X;
  }
  if (f > g) {
    X = f;
    f = g;
    g = X;
  }
  if (g > h) {
    X = g;
    g = h;
    h = X;
  }
  if (h > i) {
    X = h;
    h = i;
    i = X;
  }
  if (a > b) {
    X = a;
    a = b;
    b = X;
  }
  if (b > c) {
    X = b;
    b = c;
    c = X;
  }
  if (c > d) {
    X = c;
    c = d;
    d = X;
  }
  if (d > e) {
    X = d;
    d = e;
    e = X;
  }
  if (e > f) {
    X = e;
    e = f;
    f = X;
  }
  if (f > g) {
    X = f;
    f = g;
    g = X;
  }
  if (g > h) {
    X = g;
    g = h;
    h = X;
  }
  if (a > b) {
    X = a;
    a = b;
    b = X;
  }
  if (b > c) {
    X = b;
    b = c;
    c = X;
  }
  if (c > d) {
    X = c;
    c = d;
    d = X;
  }
  if (d > e) {
    X = d;
    d = e;
    e = X;
  }
  if (e > f) {
    X = e;
    e = f;
    f = X;
  }
  if (f > g) {
    X = f;
    f = g;
    g = X;
  }
  if (a > b) {
    X = a;
    a = b;
    b = X;
  }
  if (b > c) {
    X = b;
    b = c;
    c = X;
  }
  if (c > d) {
    X = c;
    c = d;
    d = X;
  }
  if (d > e) {
    X = d;
    d = e;
    e = X;
  }
  if (e > f) {
    X = e;
    e = f;
    f = X;
  }
  if (a > b) {
    X = a;
    a = b;
    b = X;
  }
  if (b > c) {
    X = b;
    b = c;
    c = X;
  }
  if (c > d) {
    X = c;
    c = d;
    d = X;
  }
  if (d > e) {
    X = d;
    d = e;
    e = X;
  }
  if (a > b) {
    X = a;
    a = b;
    b = X;
  }
  if (b > c) {
    X = b;
    b = c;
    c = X;
  }
  if (c > d) {
    X = c;
    c = d;
    d = X;
  }
  if (a > b) {
    X = a;
    a = b;
    b = X;
  }
  if (b > c) {
    X = b;
    b = c;
    c = X;
  }
  if (a > b) {
    X = a;
    a = b;
    b = X;
  }
  printf("%d\\n%d\\n%d", j, i, h);

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

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

int main() {
  int h[10], tmp;
  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;
  return 0;
}

Error: TLE

Fixed submission:

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

int main() {
  int f = 0, s = 0, t = 0, tmp;
  while (cin >> tmp, tmp != EOF) {
    if (f < tmp) {
      f = tmp;
    } else if (s < tmp) {
      s = tmp;
    } else if (t < tmp) {
      t = tmp;
    }
  }
  cout << f << endl;
  cout << s << endl;
  cout << t << endl;
  return 0;
}
Problem p00001 (C++) — buggy submission, verdict: Runtime Error

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

int main() {
  int m[10];
  for (int i = 0; i < 10; i++)
    cin >> m[i];
  sort(m, m + 10);
  for (int i = 9; i > 6; i--)
    cout << m[i] << endl;

  return 0;
}

Error: -11

Fixed submission:

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

int main() {
  int m[10];
  for (int i = 0; i < 9; i++)
    cin >> m[i];
  sort(m, m + 10);
  for (int i = 9; i > 6; i++)
    cout << m[i] << endl;

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

#include <iostream>
using namespace std;

int main() {
  int nya[10];
  int hoge;
  for (int j = 0; j < 10; j++) {
    cin >> nya[j];
  }
  for (int i = 0; i < 20; i++) {
    for (int k = 1; k < 10; k++) {
      if (nya[k] > nya[k - 1]) {
        hoge = nya[k - 1];
        nya[k - 1] = nya[k];
        nya[k] = hoge;
      }
    }
  }
  //	for(int i=0;i<10;++i)	cout << nya[i] <<endl;
  cout << nya[0] << endl << nya[1] << endl << nya[2] << endl;
  return 0;
}

Error: 0

Fixed submission:

#include <iostream>
using namespace std;

int main() {
  int nya[9];
  int hoge;
  for (int j = 0; j < 10; j++) {
    cin >> nya[j];
  }
  for (int i = 0; i < 20; i++) {
    for (int k = 1; k < 10; k++) {
      if (nya[k] > nya[k - 1]) {
        hoge = nya[k - 1];
        nya[k - 1] = nya[k];
        nya[k] = hoge;
      }
    }
  }
  cout << nya[0] << endl << nya[1] << endl << nya[2] << endl;
  return 0;
}
Problem p00001 (C++) — buggy submission, verdict: Runtime Error

#include <algorithm>
#include <stdio.h>
using namespace std;
int main() {
  const int N = 10;
  int height[N];
  for (int i = 0; i < 10; i++) {
    scanf("%d", &height[i]);
  }
  sort(height, height + N);
  reverse(height, height + N);
  for (int j = 0; j < 3; j++) {
    printf("%d\\n", height[j]);
  }
  return 0;
}

Error: -11

Fixed submission:

#include <algorithm>
#include <stdio.h>
using namespace std;
int main() {
  const int N = 10;
  int height[N];
  for (int i = 0; i < 10; i++) {
    scanf("%d", height[i]);
  }
  sort(height, height + N);
  reverse(height, height + N);
  for (int j = 0; j < 3; j++) {
    printf("%d", height[j]);
  }
  return 0;
}
Problem p00001 (C++) — buggy submission, verdict: Runtime Error

#include <algorithm>
#include <iostream>

using namespace ::std;

int main() {
  int array[10];

  for (int i = 0; i < 10; i++)
    cin >> array[i];

  sort(array, array + 10);

  for (int i = 9; i > 6; i--)
    cout << array[i] << endl;
  return 0;
}

Error: -11

Fixed submission:

#include <algorithm>
#include <iostream>

using namespace ::std;

int main() {
  int array[10];

  for (int i = 0; i < 10; i++)
    cin >> array[i];

  sort(array, array + 10);

  for (int i = 9; i > 6; i++)
    cout << array[i] << endl;
  return 0;
}
Problem p00001 (C++) — buggy submission, verdict: Time Limit Exceeded

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

Error: TLE

Fixed submission:

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

#include <algorithm>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <map>
#include <sstream>
#include <string>
#include <vector>
using namespace std;

const int MAX = 10000100;

#define loop(i, a, b) for (int i = a; i < b; i++)
#define rep(i, a) loop(i, 0, a)
#define all(a) (a).begin(), (a).end()
#define ll long long int
#define gcd(a, b) __gcd(a, b)
#define pb(a) push_back(a)
int GCD(int a, int b) {
  if (!b)
    return a;
  return gcd(b, a % b);
}
int lcm(int a, int b) { return a * b / gcd(a, b); }

int main(void) {
  int a[10];
  rep(i, 10) cin >> a[i];
  sort(a, a + 10, greater<int>());
  rep(i, 3) cout << a[i] << endl;
}

Error: TLE

Fixed submission:

//	created : 16/03/15
// 	author   : Rp7rf
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <set>
#include <vector>
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
#define rep(i, a) for (int i = 0; i < a; i++)
#define loop(i, a, b) for (int i = a; i < b; i++)
#define vi vector<int>
#define mp make_pair
#define pb push_back
#define MOD 1000000007
#define INF 1e9

int main(void) {
  int q;
  string a, b;
  cin >> q;
  while (q--) {
    cin >> a >> b;
    int dp[1010][1010] = {0};
    for (int j = 0; j < a.size(); j++) {
      for (int i = 0; i < b.size(); i++) {
        if (a[j] == b[i]) {
          dp[j + 1][i + 1] = dp[j][i] + 1;
        } else {
          dp[j + 1][i + 1] = max(dp[j][i + 1], dp[j + 1][i]);
        }
      }
    }
    cout << dp[a.size()][b.size()] << endl;
  }
}
Problem p00001 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <stdio.h>

int main() {
  int a1 = 0, a2 = 0, a3 = 0;
  int x;
  for (int i = 0; i < 10; i++) {
    scanf("%d", &x);
    if (x > a1) {
      a3 = a2;
      a2 = a1;
      a1 = x;
    } else if (x > a2) {
      a3 = a2;
      a2 = x;
    } else if (x > a3) {
      a3 = x;
    }
  }

  printf("%d\\n%d\\n%d\\n", a1, a2, a3);

  return 0;
}

Error: TLE

Fixed submission:

#include <stdio.h>

int main() {
  int a1 = 0, a2 = 0, a3 = 0;

  int x;
  while (scanf("%d", &x)) {
    if (x > a3) {
      a3 = x;
    }
    if (x > a2) {
      a3 = a2;
      a2 = x;
    }
    if (x > a1) {
      a3 = a2;
      a2 = a1;
      a1 = x;
    }
  }

  printf("%d\\n%d\\n%d\\n", a1, a2, a3);

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

#include <algorithm>
#include <cstdio>

using namespace std;

const int N = 10;
int a[N];

int main() {
  for (int i = 0; i < N; i++) {
    scanf("%d", &a[i]);
  }
  sort(a, a + N);
  for (int i = 1; i < 4; i++)
    printf("%d\\n", a[N - i]);
}

Error: -11

Fixed submission:

#include <algorithm>
#include <cstdio>

using namespace std;

const int N = 10;
int a[N];

int main() {
  for (int i = 0; i < N; i++) {
    scanf("%d", &a[i]);
  }
  sort(a, a + N);
  for (int i = N - 1; i > N - 4; i++)
    printf("%d/n", a[i]);
}
Problem p00001 (C++) — buggy submission, verdict: Runtime Error

#include <algorithm>
#include <functional>
#include <iostream>
int main() {
  int h[10];
  for (int n = 0; n < 10; n++) {
    using std::cin;
    cin >> h[n];
  }
  using std::greater;
  using std::sort;
  sort(h, h + 10, greater<int>());
  for (int n = 0; n < 3; n++) {
    using std::cout;
    using std::endl;
    cout << h[n] << endl;
  }
  return 0;
}

Error: -11

Fixed submission:

#include <algorithm>
#include <iostream>

int main() {
  int h[10];
  for (int n = 0; n < 10; n++) {
    using std::cin;
    cin >> h[n];
  }
  using std::sort;
  sort(h + 10, h);
  for (int n = 0; n < 3; n++) {
    using std::cout;
    using std::endl;
    cout << h[n] << endl;
  }
  return 0;
}
Problem p00001 (C++) — buggy submission, verdict: Time Limit Exceeded

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

int main(void) {
  vector<int> a;
  int b;

  for (int i = 0; i < 10; i++) {
    scanf("%d", &b);
    a.push_back(b);
  }
  sort(a.begin(), a.end());
  printf("%d\\n%d\\n%d\\n", a[9], a[8], a[7]);

  return 0;
}

Error: TLE

Fixed submission:

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

int main(void) {
  vector<int> a;
  int b;

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

  while (1)
    ;

  sort(a.begin(), a.end());
  cout << a[9] << endl << a[8] << endl << a[7] << endl;

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


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

int main() {
  int i;
  int input;
  std::vector<int> height;
  for (i = 0; i < 10; i++) {
    scanf("%d", &input);
    height.push_back(input);
  }

  std::sort(height.begin(), height.end());

  printf("%d\\n", height[9]);
  printf("%d\\n", height[8]);
  printf("%d\\n", height[7]);

  return 0;
}

Error: -11

Fixed submission:

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

int main() {
  int i;
  int input;
  std::vector<int> height;
  for (i = 0; i < 10; i++) {
    scanf("%d", &input);
    height[i] = input;
  }

  std::sort(height.begin(), height.end());

  printf("%d\\n", height[0]);
  printf("%d\\n", height[1]);
  printf("%d\\n", height[2]);

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

#include <stdio.h>

int main() {
  int height[10], rank[3] = {0};
  int i;

  for (i = 0; i < 10; i++) {
    scanf("%d\\n", &height[i]);

    if (rank[0] < height[i]) {
      rank[2] = rank[1];
      rank[1] = rank[0];
      rank[0] = height[i];
    } else if (rank[1] < height[i]) {
      rank[2] = rank[1];
      rank[1] = height[i];
    } else if (rank[2] < height[i]) {
      rank[2] = height[i];
    }
  }

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

  return 0;
}

Error: -11

Fixed submission:

#include <stdio.h>

int main() {
  int height[10], rank[3] = {0};
  int i;

  for (i = 0; i < 10; i++) {
    scanf("%d\\n", height[i]);

    if (rank[0] < height[i]) {
      rank[2] = rank[1];
      rank[1] = rank[0];
      rank[0] = height[i];
    } else if (rank[1] < height[i]) {
      rank[2] = rank[1];
      rank[1] = height[i];
    } else if (rank[2] < height[i]) {
      rank[2] = height[i];
    }
  }

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

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

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

Error: TLE

Fixed submission:

#include <stdio.h>
int main() {
  int n, m[10000], i, sum;
  while (1) {
    sum = 0;
    scanf("%d", &n);
    if (n == 0)
      break;
    for (i = 0; i < n / 4; i++) {
      scanf("%d", &m[i]);
      sum += m[i];
    }
    printf("%d\\n", sum);
  }
  return 0;
}
Problem p00001 (C++) — buggy submission, verdict: Runtime Error

#include <iostream>
using namespace std;
int main() {
  int takasa[10];
  for (int i = 0; i < 10; i++) {
    cin >> takasa[i];
  }
  for (int i = 0; i < 9; i++) {
    for (int j = i + 1; j < 10; j++) {
      if (takasa[i] < takasa[j]) {
        swap(takasa[i], takasa[j]);
      }
    }
  }
  for (int i = 0; i < 3; i++) {
    cout << takasa[i] << endl;
  }
  return 0;
}

Error: -11

Fixed submission:

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

#include <iostream>
using namespace std;
int main() {
  int high[11], i, j;
  for (i = 1; i <= 10; i++) {
    cin >> high[i];
  }
  for (i = 1; i <= 10; i++) {
    for (j = 1; j <= 10; j++) {
      if (high[i] > high[j])
        swap(high[i], high[j]);
    }
  }
  for (i = 1; i <= 3; i++)
    cout << high[i] << endl;
}

Error: TLE

Fixed submission:

#include <iostream>
using namespace std;

int main() {
  int x, i, n;
  i = 1;
  cin >> n;
  3 <= n <= 10000;
  while (i <= n) {
    x = i;
    if (x % 3 == 0) {
      cout << " " << i;
    } else if (x % 10 != 0) {
      while (x % 10 > 0) {
        if (x % 10 == 3)
          cout << " " << i;
      }
      x /= 10;
    }
    i++;
  }
  cout << endl;
}
Problem p00001 (C++) — buggy submission, verdict: Runtime Error

#include <algorithm>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using namespace std;
inline int toInt(string s) {
  int v;
  istringstream sin(s);
  sin >> v;
  return v;
}
template <class T> inline string toString(T x) {
  ostringstream sout;
  sout << x;
  return sout.str();
}
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define EXIST(s, e) ((s).find(e) != (s).end())
#define EXIST2(s, e) (find(ALL(s), (e)) != (s).end())
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define EACH(t, i, c) for (t::iterator i = (c).begin(); i != (c).end(); ++i)
const double EPS = 1e-10;
const double PI = acos(-1.0);

int main() {
  vi a(10);
  REP(i, 10) { cin >> a[i]; }
  sort(RALL(a));
  cout << a[0] << endl;
  cout << a[1] << endl;
  cout << a[2] << endl;
}

Error: -11

Fixed submission:

#include <algorithm>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using namespace std;
inline int toInt(string s) {
  int v;
  istringstream sin(s);
  sin >> v;
  return v;
}
template <class T> inline string toString(T x) {
  ostringstream sout;
  sout << x;
  return sout.str();
}
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define EXIST(s, e) ((s).find(e) != (s).end())
#define EXIST2(s, e) (find(ALL(s), (e)) != (s).end())
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define EACH(t, i, c) for (t::iterator i = (c).begin(); i != (c).end(); ++i)
const double EPS = 1e-10;
const double PI = acos(-1.0);

int main() {
  vi a;
  REP(i, 10) { cin >> a[i]; }
  sort(RALL(a));
  cout << a[0] << endl;
  cout << a[1] << endl;
  cout << a[2] << endl;
}
Problem p00001 (C++) — buggy submission, verdict: Runtime Error

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

int main() {
  vector<int> v;
  int num;
  for (int i = 0; i < 10; i++) {
    cin >> num;
    v.push_back(num);
  }

  sort(v.begin(), v.end(), greater<int>());

  for (int i = 0; i < 3; i++)
    cout << v.at(i) << endl;
  return 0;
}

Error: -11

Fixed submission:

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

int main() {
  vector<int> v;
  int num;
  for (int i = 0; i < 10; i++) {
    cin >> num;
    v.push_back(num);
  }

  sort(v.end(), v.begin(), greater<int>());

  for (int i = 0; i < 3; i++)
    cout << v.at(i);
  return 0;
}
Problem p00001 (C++) — buggy submission, verdict: Runtime Error

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

int main() {
  vector<int> mountain(10);
  for (int i = 0; i < 10; i++) {
    cin >> mountain.at(i);
  }
  sort(mountain.begin(), mountain.end());
  reverse(mountain.begin(), mountain.end());

  for (int i = 0; i < 3; i++) {
    cout << mountain.at(i) << endl;
  }
}


Error: -6
terminate called after throwing an instance of 'std::out_of_range'
  what():  vector::_M_range_check: __n (which is 0) >= this->size() (which is 0)


Fixed submission:

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

int main() {
  vector<int> mountain;
  for (int i = 0; i < 10; i++) {
    cin >> mountain.at(i);
  }
  sort(mountain.begin(), mountain.end());
  reverse(mountain.begin(), mountain.end());

  for (int i = 0; i < 3; i++) {
    cout << mountain.at(i) << endl;
  }
}