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

#include <algorithm>
#include <cctype>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
int main() {
  int a, b, c, t;
  scanf("%d %d %d", &a, &b, &c);
  for (;;) {
    if (a <= b && b <= c) {
      break;
    }
    if (a > b) {
      t = a;
      a = b;
      b = t;
    }
    if (b > c) {
      t = b;
      b = c;
      c = t;
    }
  }
  printf("%d %d %d\\n", a, b, c);
  return 0;
}

Error: TLE

Fixed submission:

#include <algorithm>
#include <cctype>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
int main() {
  int a, b, c, t;
  scanf("%d %d %d", &a, &b, &c);
  for (;;) {
    if (a < b && b < c) {
      break;
    }
    if (a > b) {
      t = a;
      a = b;
      b = t;
    }
    if (b > c) {
      t = b;
      b = c;
      c = t;
    }
  }
  printf("%d %d %d\\n", a, b, c);
  return 0;
}
Problem p02393 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>

using namespace std;

int main(void) {
  int data[3], temp;

  cin >> data[0] >> data[1] >> data[2];

  for (int i = 0; i < 2; ++i) {
    if (data[i] > data[i + 1]) {
      temp = data[i];
      data[i] = data[i + 1];
      data[i + 1] = temp;
    }
  }
  if (data[0] > data[1]) {
    temp = data[0];
    data[0] = data[1];
    data[1] = temp;
  }
  cout << data[0] << " " << data[1] << " " << data[2] << endl;

  return 0;
}


Error: TLE

Fixed submission:

#include <iostream>

using namespace std;

int main(void) {
  int data[3], temp;

  cin >> data[0] >> data[1] >> data[2];

  while (!(data[0] < data[1] && data[1] < data[2])) {
    for (int i = 0; i < 2; ++i) {
      if (data[i] > data[i + 1]) {
        temp = data[i];
        data[i] = data[i + 1];
        data[i + 1] = temp;
      }
    }
  }
  cout << data[0] << " " << data[1] << " " << data[2] << endl;

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

#include <stdio.h>

int main() {

  int a[3] = {0};
  int b[3] = {0};

  scanf("%d %d %d", &a[0], &a[1], &a[2]);

  if (a[0] < a[1]) {
    b[0] = 0;
    b[1] = 1;
  } else {
    b[0] = 1;
    b[1] = 0;
  }

  if (a[2] < a[b[0]]) {
    b[2] = b[1];
    b[1] = b[0];
    b[0] = 2;
  } else if (a[2] < a[b[1]]) {
    b[2] = b[1];
    b[1] = 2;
  } else {
    b[2] = 2;
  }

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

  return 0;
}

Error: -11

Fixed submission:

#include <stdio.h>

int main() {

  int a[3] = {0};
  int b[3] = {0};

  scanf("%d %d %d", a[0], a[1], a[2]);

  if (a[0] < a[1]) {
    b[0] = 0;
    b[1] = 1;
  } else {
    b[0] = 1;
    b[1] = 0;
  }

  if (a[2] < b[0]) {
    b[1] = b[0];
    b[2] = b[1];
    b[0] = a[2];
  } else if (a[2] < b[1]) {
    b[1] = a[2];
    b[2] = b[1];
  } else {
    b[2] = a[2];
  }

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

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

#include <iostream>
using std::cin;
using std::cout;
using std::endl;

int main() {
  int num[3] = {0, 0, 0};

  cin >> num[0] >> num[1] >> num[2];

  for (int i = 0; i < 2; i++) {
    for (int j = 1; j < 3; j++) {
      if (num[i] >= num[j]) {
        int swap = num[i];
        num[i] = num[j];
        num[j] = swap;
      }
    }
  }
  cout << num[0] << " " << num[1] << " " << num[2] << endl;
  return 0;
}

Error: TLE

Fixed submission:

#include <iostream>
using std::cin;
using std::cout;
using std::endl;

bool swap(int &s, int &b);

int main() {
  int num[3] = {0, 0, 0};

  cin >> num[0] >> num[1] >> num[2];

  if (num[0] <= num[1])
    swap(num[1], num[0]);

  for (int i = 0, j = 0; j < 2;) {
    while (swap(num[j], num[i + 1])) {
      i++;
      if (i >= 2)
        i = 1;
    }
    j++;
    i = j;
  }
  cout << num[0] << " " << num[1] << " " << num[2] << endl;
  return 0;
}
bool swap(int &s, int &b) {
  if (s >= b) {
    int swap = 0;
    swap = s;
    s = b;
    b = swap;

    return true;
  }
  return false;
}
Problem p02393 (C++) — buggy submission, verdict: Time Limit Exceeded

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

using namespace std;

vector<int> num;

int main() {

  int A[3] = {};

  while (cin >> A[0] >> A[1] >> A[2]) {
    num.clear();

    for (int i = 0; i < 3; i++)
      num.push_back(A[i]);

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

    for (int i = 0; i < 2; i++)
      cout << num[i] << " ";

    cout << num[2] << "\\n";
  }

  return 0;
}


Error: TLE

Fixed submission:

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

using namespace std;

vector<int> num;

int main() {

  while (1) {

    int a;

    num.clear();

    for (int i = 0; i < 3; i++) {
      cin >> a;
      num.push_back(a);
    }
    sort(num.begin(), num.end());

    for (int i = 0; i < 3; i++)
      cout << num[i] << " ";

    cout << "\\n";
  }

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

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

  int x[3] = {0};

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

  int k = 0;
  for (i = 0; i < 2; i++) {
    for (k = 2; k > i; k--) {
      if (x[k - 1] > x[k]) {
        int j;
        j = x[k];
        x[k] = x[k - 1];
        x[k - 1] = j;
      }
    }
  }

  cout << x[0] << " " << x[1] << " " << x[2] << endl;

  return 0;
}

Error: 0

Fixed submission:

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

  int x[3] = {0};

  int i = 0;
  for (i = 0; i < 3; i++) {
    cin >> x[i];

    if (0 >= x[i] || x[i] > 1000) {
      return 1;
    }
  }

  int k = 0;
  for (i = 0; i < 2; i++) {
    for (k = 2; k > i; k--) {
      if (x[k - 1] > x[k]) {
        int j;
        j = x[k - 1];
        x[k - 1] = x[k];
        x[k] = j;
      }
    }
  }

  cout << x[0] << " " << x[1] << " " << x[2] << endl;

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

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

  int x[3] = {0};

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

  int k = 0;
  for (i = 0; i < 2; i++) {
    for (k = 2; k > i; k--) {
      if (x[k - 1] > x[k]) {
        int j;
        j = x[k - 1];
        x[k - 1] = x[k];
        x[k] = j;
      }
    }
  }

  cout << x[0] << " " << x[1] << " " << x[2] << endl;

  return 0;
}

Error: 0

Fixed submission:

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

  int x[3] = {0};

  int i = 0;
  for (i = 0; i < 3; i++) {
    cin >> x[i];

    if (0 >= x[i] || x[i] > 1000) {
      return 1;
    }
  }

  int k = 0;
  for (i = 0; i < 2; i++) {
    for (k = 2; k > i; k--) {
      if (x[k - 1] > x[k]) {
        int j;
        j = x[k];
        x[k] = x[k - 1];
        x[k - 1] = j;
      }
    }
  }

  cout << x[0] << " " << x[1] << " " << x[2] << endl;

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

#include <iostream>
using namespace std;

int main() {
  int a, b, c, d;
  cin >> a >> b >> c;
  while (true) {
    if (a > b) {
      d = a;
      a = b;
      b = d;
    } else if (b > c) {
      d = b;
      b = c;
      c = d;
    } else if (a > b) {
      d = a;
      a = b;
      b = d;
    } else {
      break;
    }
  }
  cout << a << " " << b << " " << c << endl;
  return 0;
}

Error: TLE

Fixed submission:

#include <iostream>
using namespace std;

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  while (true) {
    if (a > b) {
      int d = a;
      int a = b;
      int b = a;
    } else if (b > c) {
      int d = b;
      int b = c;
      int c = d;
    } else if (a > b) {
      int d = a;
      int a = b;
      int b = a;
    } else {
      break;
    }
  }
  cout << a << " " << b << " " << c << endl;
  return 0;
}
Problem p02393 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <stdio.h>

int main() {
  int a, b, c;
  int num[] = {0, 0, 0};
  int tmp = 0;

  scanf("%d%d%d", &a, &b, &c);

  num[0] = a;
  num[1] = b;
  num[2] = c;

  while (num[0] > num[1] || num[1] > num[2]) {
    for (int i = 0; i < 2; i++) {
      if (num[i] > num[i + 1]) {
        tmp = num[i + 1];
        num[i + 1] = num[i];
        num[i] = tmp;
      }
    }
  }

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

  return 0;
}

Error: TLE

Fixed submission:


#include <stdio.h>

int main() {
  int a, b, c;
  int num[] = {0, 0, 0};
  int tmp = 0;

  scanf("%d%d%d", &a, &b, &c);

  num[0] = a;
  num[1] = b;
  num[2] = c;

  while (num[0] >= num[1] || num[1] > num[2]) {
    for (int i = 0; i < 2; i++) {
      if (num[i] > num[i + 1]) {
        tmp = num[i + 1];
        num[i + 1] = num[i];
        num[i] = tmp;
      }
    }
  }

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

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

#define len(arr) sizeof(arr) / sizeof(arr[0])
#include <algorithm>
#include <iostream>
#include <string>
using namespace std;
int main() {
  int in[3];
  cin >> in[0] >> in[1] >> in[2];
  sort(in, in + len(in));
  string out =
      to_string(in[0]) + " " + to_string(in[1]) + " " + to_string(in[2]);
  cout << out << endl;
  return 0;
}


Error: TLE

Fixed submission:

#define len(arr) sizeof(arr) / sizeof(int)
#include <algorithm>
#include <iostream>
using namespace std;
int main() {
  int n[3];
  cin >> n[0] >> n[1] >> n[2];
  sort(n, n + len(n));
  for (int x : n)
    cout << x << ((x == n[2]) ? "" : " ");
  return 0;
}
Problem p02393 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <stdio.h>

int main() {
  int i;
  int j;
  int k;
  int tmp;
  int x[2];
  scanf("%d %d %d", &x[0], &x[1], &x[2]);
  for (i = 0; i <= 2; i++) {
    for (j = 0; j < 2; j++) {
      if (x[j] > x[j + 1]) {

        tmp = x[j];
        x[j] = x[j + 1];
        x[j + 1] = tmp;
      }
    }
  }

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

  return 0;
}

Error: TLE

Fixed submission:

#include <stdio.h>

int main() {
  int i;
  int j;
  int k;
  int tmp;
  int x[2];
  scanf("%d %d %d", &x[0], &x[1], &x[2]);
  for (i; i = 2; i++) {
    for (j; j = 1; j++) {
      if (x[j] > x[j + 1]) {

        x[j] = tmp;
        x[j] = x[j + 1];
        x[j + 1] = tmp;
      }
    }
  }
  for (k; k = 2; k++) {
    printf("%d\\n", x[k]);
  }

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

#include <iostream>
using namespace std;

int main() {
  int a, b, c, x, y;
  cin >> a >> b >> c;
  while (!(a <= b && b <= c)) {
    if (a > b) {
      x = a;
      y = b;
      a = y;
      b = x;
    }
    if (b > c) {
      x = b;
      y = c;
      b = y;
      c = x;
    }
  }
  cout << a << " " << b << " " << c << endl;
  return 0;
}

Error: TLE

Fixed submission:

#include <iostream>
using namespace std;

int main() {
  int a, b, c, x, y;
  cin >> a >> b >> c;
  while (!(a < b && b < c)) {
    if (a > b) {
      x = a;
      y = b;
      a = y;
      b = x;
    }
    if (b > c) {
      x = b;
      y = c;
      b = y;
      c = x;
    }
  }
  cout << a << " " << b << " " << c << endl;
  return 0;
}
Problem p02393 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <algorithm>
#include <array>
#include <iostream>
int main(void) {
  std::array<int, 3> num;
  std::cin >> num[0] >> num[1] >> num[2];

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

  std::cout << num[0] << " " << num[1] << " " << num[2] << std::endl;
  return 0;
}

Error: TLE

Fixed submission:

#include <iostream>
int main(void) {
  int a, b, c, temp;
  std::cin >> a >> b >> c;
  while (1) {
    if (a < b && b < c) {
      std::cout << a << " " << b << " " << c << std::endl;
      break;
    }

    if (b > c) {
      temp = b;
      b = c;
      c = temp;
    }

    if (a > b) {
      temp = a;
      a = b;
      b = temp;
    }
  }
  return 0;
}
Problem p02393 (C++) — buggy submission, verdict: Runtime Error

#include <algorithm>
#include <iostream>

using namespace std;
int main() {
  ios::sync_with_stdio(false);
  int v[3];
  cin >> v[0] >> v[1] >> v[2];
  sort(v, v + 3);
  cout << v[0] << " " << v[1] << " " << v[2] << endl;
  return 0;
}

Error: -11

Fixed submission:

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

using namespace std;
int main() {
  ios::sync_with_stdio(false);
  vector<int> v;
  cin >> v[0] >> v[1] >> v[2];
  sort(v.begin(), v.end());
  cout << v[0] << " " << v[1] << " " << v[2] << endl;
  return 0;
}
Problem p02393 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <algorithm>
#include <iostream>
#include <string>
using namespace std;
int main() {
  int a, b, c;
  cin >> a >> b >> c;
  int t = 0;
loop:;
  t = 0;
  if (a > b) {
    t = t + 1;
    swap(a, b);
  }
  if (b > c) {
    t = t + 1;
    swap(b, c);
  }
  if (t != 0) {
    goto loop;
  }
  cout << a << " " << b << " " << c << endl;
  return 0;
}


Error: TLE

Fixed submission:

#include <algorithm>
#include <iostream>
#include <string>
using namespace std;
int main() {
  int a, b, c;
  cin >> a >> b >> c;
  int t = 0;
loop:;
  t = 0;
  if (a > b) {
    t = t + 1;
    swap(a, b);
  }
  if (b > c) {
    t = t + 1;
    swap(a, b);
  }
  if (t != 0) {
    goto loop;
  }
  cout << a << " " << b << " " << c << endl;
  return 0;
}
Problem p02393 (C++) — buggy submission, verdict: Runtime Error

#include <iostream>
using namespace std;

void swap(int *a, int *b) {
  int tmp = *a;
  *a = *b;
  *b = tmp;
}

int main(void) {
  int a;
  int b;
  int c;
  cin >> a >> b >> c;

  if (a > b)
    swap(&a, &b);
  if (b > c)
    swap(&b, &c);
  if (a > b)
    swap(&a, &b);

  cout << a << " " << b << " " << c << endl;
  return 0;
}


Error: -11

Fixed submission:

#include <iostream>
using namespace std;

void swap(int *a, int *b) {
  int tmp = *a;
  *a = *b;
  *b = tmp;
}

int main(void) {
  int *a;
  int *b;
  int *c;
  cin >> *a >> *b >> *c;

  if (*a > *b)
    swap(a, b);
  if (*b > *c)
    swap(b, c);
  if (*a > *b)
    swap(a, b);

  cout << *a << " " << *b << " " << *c << endl;
  return 0;
}
Problem p02393 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>
using namespace std;

// ポインタ渡しによる解法

void swap(int *a, int *b);

int main() {

  int a, b, c;

  cin >> a >> b >> c;

  if (a > b)
    swap(&a, &b);
  if (b > c)
    swap(&b, &c);

  if (a > b)
    swap(&a, &b);

  cout << a << " " << b << " " << c << endl;

  return 0;
}

void swap(int *a, int *b) {

  int temp = *a;
  *a = *b;
  *b = temp;
}


Error: TLE

Fixed submission:

#include <iostream>
using namespace std;

// ポインタ渡しによる解法

void swap(int *a, int *b);

int main() {

  int a, b, c;

  cin >> a >> b >> c;

  if (a > b)
    swap(&a, &b);
  if (b > c)
    swap(&b, &c);

  if (a > b)
    swap(&a, &b);

  cout << a << " " << b << " " << c << endl;

  while (1) {
  }

  return 0;
}

void swap(int *a, int *b) {

  int temp = *a;
  *a = *b;
  *b = temp;
}
Problem p02393 (C++) — buggy submission, verdict: Runtime Error

#include <stdio.h>

int main(void) {

  int i, j;
  int a[3];
  int temp;

  scanf("%d %d %d", &a[0], &a[1], &a[2]);

  for (i = 0; i < 3; i++) {
    for (j = 2; j > i; j--) {
      if (a[j] < a[j - 1]) {
        temp = a[j];
        a[j] = a[j - 1];
        a[j - 1] = temp;
      }
    }
  }

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

  return 0;
}

Error: 0

Fixed submission:

#include <stdio.h>

int main(void) {

  int i, j;
  int a[3];
  int temp;

  scanf("%d %d %d", &a[0], &a[1], &a[2]);

  for (i = 0; i < 3; i++) {
    for (j = 2; j >= i; j--) {
      if (a[j] < a[j - 1]) {
        temp = a[j];
        a[j] = a[j - 1];
        a[j - 1] = temp;
      }
    }
  }

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

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

#include <iostream>

using namespace std;

int main() {
  int a, b, c;
  int temp;
  cin >> a;
  cin >> b;
  cin >> c;
  while (!(a <= b && b <= c)) {
    if (a > b) {
      temp = a;
      a = b;
      b = temp;
    }
    if (b > c) {
      temp = b;
      b = c;
      c = temp;
    }
  }
  cout << a << " " << b << " " << c << endl;
  return 0;
}

Error: TLE

Fixed submission:

#include <iostream>

using namespace std;

int main() {
  int a, b, c;
  int temp;
  cin >> a;
  cin >> b;
  cin >> c;
  while (!(a < b && b < c)) {
    if (a > b) {
      temp = a;
      a = b;
      b = temp;
    }
    if (b > c) {
      temp = b;
      b = c;
      c = temp;
    }
  }
  cout << a << " " << b << " " << c << endl;
  return 0;
}
Problem p02393 (C++) — buggy submission, verdict: Runtime Error

#include <cstdio>
using namespace std;

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

  printf("%d %d %d\\n", a[0], a[1], a[2]);
  return 0;
}

Error: -11

Fixed submission:

#include <cstdio>
using namespace std;

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

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

#include <iostream>

int main(void) {
  int a, b, c, x;
  scanf("%d%d%d", &a, &b, &c);
  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 %d %d\\n", a, b, c);
  return 0;
}

Error: -11

Fixed submission:

#include <iostream>

int main(void) {
  int a, b, c, x;
  scanf("%d%d%d", a, b, c);
  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 %d %d\\n", a, b, c);
  return 0;
}
Problem p02393 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <cstdio>

int main() {
  int a, b, c, t;
  scanf("%d %d %d", &a, &b, &c);

  if (a > b) {
    t = a;
    a = b;
    b = t;
  }
  if (b > c) {
    t = b;
    b = c;
    c = t;
  }
  if (a > b) {
    t = a;
    a = b;
    b = t;
  }

  printf("%d %d %d\\n", a, b, c);
  return 0;
}

Error: TLE

Fixed submission:

#include <cstdio>

int main() {
  int a, b, c, t;
  scanf("%d %d %d", &a, &b, &c);

  while (!(a < b && b < c)) {
    if (a > b) {
      t = a;
      a = b;
      b = t;
    }
    if (b > c) {
      t = b;
      b = c;
      c = t;
    }
  }

  printf("%d %d %d\\n", a, b, c);
  return 0;
}
Problem p02393 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>
using namespace std;

void tmp(int &x, int &y) {
  int tmp;
  tmp = x;
  x = y;
  y = tmp;
}

int main(void) {
  int a, b, c;

  cin >> a >> b >> c;

  while (!(a <= b && b <= c)) {
    if (a > b) {
      tmp(a, b);
    }
    if (b > c) {
      tmp(b, c);
    }
  }

  cout << a << " " << b << " " << c << "\\n";

  return 0;
}

Error: TLE

Fixed submission:

#include <iostream>
using namespace std;

void tmp(int &x, int &y) {
  int tmp;
  tmp = x;
  x = y;
  y = tmp;
}

int main(void) {
  int a, b, c;

  cin >> a >> b >> c;

  while (!(a < b && b < c)) {
    if (a > b) {
      tmp(a, b);

    } else if (b > c) {
      tmp(b, c);
    }
  }

  cout << a << " " << b << " " << c << "\\n";

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

#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
int main() {
  vector<int> a(3);
  cin >> a[0] >> a[1] >> a[2];
  sort(a.begin(), a.begin() + 3);
  cout << a[0] << ' ' << a[1] << ' ' << a[2] << endl;
  return 0;
}

Error: -11

Fixed submission:

#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
int main() {
  vector<int> a;
  cin >> a[0] >> a[1] >> a[2];
  sort(a.begin(), a.begin() + 2);
  cout << a[0] << ' ' << a[1] << ' ' << a[2] << endl;
  return 0;
}
Problem p02393 (C++) — buggy submission, verdict: Runtime Error

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

using namespace std;

int main(int argc, char *argv[]) {
  vector<int> input(3);
  cin >> input[0] >> input[1] >> input[2];

  sort(input.begin(), input.end());
  cout << input[0] << ' ' << input[1] << ' ' << input[2] << endl;
  return 0;
}

Error: -11

Fixed submission:

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

using namespace std;

int main(int argc, char *argv[]) {
  vector<int> input;
  cin >> input[0] >> input[1] >> input[2];

  sort(input.begin(), input.end());
  cout << input[0] << ' ' << input[1] << ' ' << input[2] << endl;

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

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

using namespace std;

int main() {

  int a[3];

  cin >> a[0] >> a[1] >> a[2];

  int temp;

  for (int c = 0; c < sizeof(a) / 4; ++c) {
    for (int b = 0; b < sizeof(a) / 4; ++b) {
      if (a[c] < a[b]) {
        temp = a[c];
        a[c] = a[b];
        a[b] = temp;
      }
    }
  }

  cout << a[0] << " " << a[1] << " " << a[2] << endl;

  return 0;
}

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


Fixed submission:

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

using namespace std;

int main() {

  int a[3];

  for (int count = 0; count < 3; ++count) {
    cin >> a[count];
  }

  int temp;

  for (int c = 0; c < sizeof(a); ++c) {
    for (int b = 0; b < sizeof(a); ++b) {
      if (a[c] < a[b]) {
        temp = a[c];
        a[c] = a[b];
        a[b] = temp;
      }
    }
  }

  cout << a[0] << " " << a[1] << " " << a[2] << endl;
}
Problem p02393 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>
using namespace std;

int main() {

  int a, b, c, t;

  cin >> a >> b >> c;

  while (1) {
    if (c <= b && b <= a)
      break;
    if (a > b) {
      t = a;
      a = b;
      b = t;
    } else if (b > c) {
      t = b;
      b = c;
      c = t;
    } else if (c > a) {
      t = c;
      c = a;
      a = t;
    }
  }
  cout << c << " " << b << " " << a << endl;
}

Error: TLE

Fixed submission:

#include <iostream>
using namespace std;

int main() {

  int a, b, c, t;

  cin >> a >> b >> c;

  while (1) {
    if (a < b && b < c)
      break;
    if (a > b) {
      t = a;
      a = b;
      b = t;
    } else if (b > c) {
      t = b;
      b = c;
      c = t;
    } else if (c > a) {
      t = c;
      c = a;
      a = t;
    }
  }
  cout << a << " " << b << " " << c << endl;
}
Problem p02393 (C++) — buggy submission, verdict: Runtime Error

#include <iostream>
using namespace std;

int main() {
  int a[3] = {}; // 配列の定義

  for (int i = 0; i < 3; i++) {
    cin >> a[i]; // 配列に文字を入力
  }

  for (int i = 0; i < 3; ++i) {
    if (a[1] < a[0])
      swap(a[0], a[1]);
    if (a[2] < a[1])
      swap(a[1], a[2]);
  }

  cout << a[0] << " " << a[1] << " " << a[2] << endl;
  ;
  return 0;
}


Error: 1

Fixed submission:

#include <iostream>
using namespace std;

int main() {
  int a[3] = {}; // 配列の定義
  // int min=0;

  for (int i = 0; i < 3; i++) {
    cin >> a[i]; // 配列に文字を入力
  }

  for (int i = 0; i < 3; i++) {
    cout << a[i] << " "; // 配列に入っている文字の確認
  }
  cout << endl; // 改行

  for (int i = 0; i < 3; i++) {
    if (a[i + 1] < a[i]) {
      swap(a[i], a[i + 1]);
    } else {
      return 1;
    }
    for (int k = 0; k < 3; k++) {
      cout << a[k] << " ";
    }
    cout << endl;
  }

  for (int i = 0; i < 3; i++) { // ソートした配列の表示
    cout << a[i] << " ";
  }
  cout << endl;
  return 0;
}
Problem p02393 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>
using namespace std;

int main() {
  int a, b, c, d, e, f;
  cin >> a >> b >> c;

  if (a > b) {
    swap(a, b);
  }

  if (b > c) {
    swap(b, c);
  }

  if (a > b) {
    swap(a, b);
  }

  cout << a << ' ' << b << ' ' << c << endl;
}


Error: TLE

Fixed submission:

#include <iostream>
using namespace std;

int main() {

  int a, b, c;

  cin >> a >> b >> c;

  while (1) {

    if (a < b) {

      swap(a, b);

    } else if (b < c) {

      swap(b, c);

    } else {

      cout << a << " " << b << " " << c << endl;
    }
  }
}