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

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

int main(void) {
  int array[3];
  for (int i = 0; i < 3; i++)
    scanf("%d", &array[i]);
  for (int i = 2; i > 0; i--) {
    for (int j = 0; j < i; j++) {
      if (array[j] > array[j + 1]) {
        int tmp = array[j];
        array[j] = array[j + 1];
        array[j + 1] = tmp;
      }
    }
  }
  cout << array[0] << " " << array[1] << " " << array[2] << endl;
  return 0;
}


Error: -11

Fixed submission:

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

int main(void) {
  int array[3];
  for (int i = 0; i < 3; i++)
    scanf("%d", array[i]);
  for (int i = 2; i > 0; i--) {
    for (int j = 0; j < i - 1; j++) {
      int tmp = array[j];
      array[j] = array[j + 1];
      array[j + 1] = tmp;
    }
  }
  cout << array[0] << " " << array[1] << " " << array[2] << endl;
  return 0;
}
Problem p02393 (C++) — buggy submission, verdict: Runtime Error

#include <iostream>
using namespace std;
int main() {
  int a, b, c, x, y, z;
  cin >> a >> b >> c;
  if (a < b) {
    if (a < c) {
      x = a;
      if (c < b) {
        y = c;
        z = b;
      } else {
        y = b;
        z = c;
      }
    } else {
      y = a;
      if (b < c) {
        x = b;
        z = c;
      } else {
        x = c;
        z = b;
      }
    }
  } else if (a < c) {
    y = a;
    if (b < c) {
      x = b;
      z = c;
    } else {
      x = c;
      z = b;
    }
  } else {
    z = a;
    if (b < c) {
      x = b;
      y = c;
    } else {
      x = c;
      y = b;
    }
  }
  cout << x << " " << y << " " << z << endl;
}


Error: WA

Fixed submission:

#include <stdio.h>

int main(void) {

  int i, j, tmp;

  /* 数値を格納する配列 */
  int number[100];

  /* 数値の総数を入力 */
  int total;
  printf("入力する数値の総数 = ");
  scanf("%d", &total);

  /* 配列に格納する数値を入力 */
  printf("%d個の数値を入力 \\n", total);
  for (i = 0; i < total; ++i)
    scanf("%d", &number[i]);

  /* 数値を昇順にソート */
  for (i = 0; i < total; ++i) {
    for (j = i + 1; j < total; ++j) {
      if (number[i] > number[j]) {
        tmp = number[i];
        number[i] = number[j];
        number[j] = tmp;
      }
    }
  }

  /* 昇順ソートした数値を出力 */
  printf("昇順ソートした数値\\n");
  for (i = 0; i < total; ++i)
    printf("%d\\n", number[i]);
}
Problem p02393 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>

int main() {
  int a[3];
  int d;
  std::cin >> a[0] >> a[1] >> a[2];
  for (int i = 3; i > 0; i--) {
    for (int j = 0; j < i - 1; j++) {
      if (a[j] > a[j + 1]) {
        d = a[j];
        a[j] = a[j + 1];
        a[j + 1] = d;
      }
    }
  }
  std::cout << a[0] << " " << a[1] << " " << a[2] << "\\n";

  return 0;
}

Error: TLE

Fixed submission:

#include <iostream>

int main() {
  int a[3];
  int d;
  std::cin >> a[0] >> a[1] >> a[2];
  for (int i = 3; i > 0; i--) {
    for (int j = 0; j < i - 1; i++) {
      if (a[j] > a[j + 1])
        d = a[j];
      a[j] = a[j + 1];
      a[j + 1] = d;
    }
  }
  std::cout << a[0] << " " << a[1] << " " << a[2] << "\\n";

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

#include <bits/stdc++.h>
using namespace std;
int main(void) {
  int a, b, c, d;
  cin >> a >> b >> c;
  while (1) {
    if (a <= b && b <= c && a <= c)
      break;
    if (a > b) {
      d = a;
      a = b;
      b = d;
    }
    if (b > c) {
      d = b;
      b = c;
      c = d;
    }
    if (a > c) {
      d = a;
      a = c;
      c = d;
    }
  }
  cout << a << ' ' << b << ' ' << c << endl;

  return 0;
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
int main(void) {
  int a, b, c, d;
  cin >> a >> b >> c;
  while (1) {
    if (a < b && b < c && a < c)
      break;
    if (a > b) {
      d = a;
      a = b;
      b = d;
    }
    if (b > c) {
      d = b;
      b = c;
      c = d;
    }
    if (a > c) {
      d = a;
      a = c;
      c = d;
    }
  }
  cout << a << ' ' << b << ' ' << c << endl;

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

#include <iostream>
using namespace std;

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;
}


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);
    }
    if (b > c) {
      swap(b, c);
    }

    if (a < b && b < c) {
      cout << a << ' ' << b << ' ' << c << endl;
    }
  }
}
Problem p02393 (C++) — buggy submission, verdict: Runtime Error

#include <algorithm>
#include <iostream>

int main() {
  int a, b, c;
  std::cin >> a >> b >> c;
  if (a > b)
    std::swap(a, b);
  if (b > c)
    std::swap(b, c);
  if (a > b)
    std::swap(a, b);
  std::cout << a << ' ' << b << ' ' << c << std::endl;
  return 0;
}

Error: -11

Fixed submission:

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

int main() {
  std::vector<int> x;
  std::cin >> x[0] >> x[1] >> x[2];
  std::sort(x.begin(), x.end());
  std::cout << x[0] << ' ' << x[1] << ' ' << x[2] << std::endl;
}
Problem p02393 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <algorithm>
#include <iostream>

using namespace std;
int main() {
  int x[3], buf;
  for (int i = 0; i < 3; i++) {
    cin >> x[i];
  }
  for (int i = 2; i > 0; i--) {
    for (int j = 0; j < i; j++) {
      if (x[j] > x[j + 1]) {
        swap(x[j], x[j + 1]);
      }
    }
  }

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


Error: TLE

Fixed submission:

#include <iostream>

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

#include <cstdio>
int main(void) {
  int a[3];
  scanf("%d%d%d", &a[0], &a[1], &a[2]);
  for (int i = 0; i < 3; i++) {
    int min = a[i];
    for (int j = i; j < 3; j++) {
      if (min > a[j]) {
        min = a[j];
        a[j] = a[i];
        a[i] = min;
      }
    }
  }
  printf("%d %d %d\\n", a[0], a[1], a[2]);
  return 0;
}


Error: -11

Fixed submission:

#include <cstdio>
int main(void) {
  int a[3];
  scanf("%d%d%d", a[0], a[1], a[2]);
  for (int i = 0; i < 3; i++) {
    int min = a[i];
    for (int j = i; j < 3; j++) {
      if (min > a[j]) {
        min = a[j];
        a[j] = a[i];
        a[i] = min;
      }
    }
  }
  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, temp;

  cin >> a >> b >> c;

  while (1) {
    if ((a < b && b < c) || (a == b && b < c) || (a == b && b == c))
      break;
    else if (b < a) {
      temp = b;
      b = a;
      a = temp;
    } else if (c < b) {
      temp = c;
      c = b;
      b = temp;
    } else if (c < a) {
      temp = c;
      c = a;
      a = temp;
    }
  }
  cout << a << " " << b << " " << c << endl;
  return 0;
}

Error: TLE

Fixed submission:

#include <iostream>
using namespace std;

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

  cin >> a >> b >> c;

  while (1) {
    if (a < b && b < c)
      break;
    else if (b < a) {
      temp = b;
      b = a;
      a = temp;
    } else if (c < b) {
      temp = c;
      c = b;
      b = temp;
    } else if (c < a) {
      temp = c;
      c = a;
      a = temp;
    }
  }
  cout << a << " " << b << " " << c << endl;
  return 0;
}
Problem p02393 (C++) — buggy submission, verdict: Time Limit Exceeded

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

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

  for (size_t i = 0; i < 2; i++) {
    for (size_t j = 0; j < 2 - i; j++) {
      int nTemp = 0;
      if (nInput[j] > nInput[j + 1]) {
        nTemp = nInput[j];
        nInput[j] = nInput[j + 1];
        nInput[j + 1] = nTemp;
      }
    }
  }
  cout << nInput[0] << " " << nInput[1] << " " << nInput[2] << endl;
  // system("pause");
  return 0;
}

Error: TLE

Fixed submission:

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

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

  while (true) {
    for (size_t i = 0; i < 3; i++) {
      cin >> nInput[i];
    }

    for (size_t i = 0; i < 2; i++) {
      for (size_t j = 0; j < 2 - i; j++) {
        int nTemp = 0;
        if (nInput[j] > nInput[j + 1]) {
          nTemp = nInput[j];
          nInput[j] = nInput[j + 1];
          nInput[j + 1] = nTemp;
        }
      }
    }
    for (size_t i = 0; i < 3; i++) {
      cout << nInput[i] << " ";
    }
    cout << endl;
  }

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

#include <cstdio>

int main() {
  int x, y, z;
  scanf("%d %d %d", &x, &y, &z);

  int a[3] = {x, y, z}, buff = 0;

  while (1) {
    for (int i = 0; i < 3; i++) {
      for (int j = i; j < 3; j++) {
        if (a[i] > a[j]) {
          buff = a[j];
          a[j] = a[i];
          a[i] = buff;
        }
      }
    }
    if (a[0] <= a[1] && a[1] <= a[2])
      break;
  }

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

Error: TLE

Fixed submission:

#include <cstdio>

int main() {
  int x, y, z;
  scanf("%d %d %d", &x, &y, &z);

  int a[3] = {x, y, z}, buff = 0;

  while (1) {
    for (int i = 0; i < 3; i++) {
      for (int j = i; j < 3; j++) {
        if (a[i] > a[j]) {
          buff = a[j];
          a[j] = a[i];
          a[i] = buff;
        }
      }
    }
    if (a[0] < a[1] && a[1] < a[2])
      break;
  }

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

#include <algorithm>
#include <iostream>

using namespace std;

int main() {
  int A[3];

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

  sort(A, A + 3);

  cout << A[0] << " " << A[1] << " " << A[2] << endl;
}

Error: WA

Fixed submission:

#include <stdio.h>

int main(void) {

  int i, j, tmp;

  int number[100];

  int total;
  scanf("%d", &total);

  for (i = 0; i < total; ++i)
    scanf("%d", &number[i]);

  for (i = 0; i < total; ++i) {
    for (j = i + 1; j < total; ++j) {
      if (number[i] < number[j]) {
        tmp = number[i];
        number[i] = number[j];
        number[j] = tmp;
      }
    }
  }

  for (i = 0; i < total; ++i)
    printf("%d\\n", number[i]);
  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 >> b >> c;

  while (1) {
    if (a > b) {
      temp = a;
      a = b;
      b = temp;
    }
    if (b > c) {
      temp = b;
      b = c;
      c = temp;
    }
    if (a > b) {
      temp = a;
      a = b;
      b = temp;
    }

    if (a <= b && b <= c) {
      cout << a << " " << b << " " << c << endl;
      return 0;
    }
  }
  return 0;
}

Error: TLE

Fixed submission:

#include <iostream>
using namespace std;

int main() {
  int a, b, c;
  int temp;
  cin >> a >> b >> c;

  while (1) {
    if (a > b) {
      temp = a;
      a = b;
      b = temp;
    }
    if (b > c) {
      temp = b;
      b = c;
      c = temp;
    }
    if (a > b) {
      temp = a;
      a = b;
      b = temp;
    }

    if (a < b && b < c) {
      cout << a << " " << b << " " << c << endl;
      return 0;
    }
  }
  return 0;
}
Problem p02393 (C++) — buggy submission, verdict: Runtime Error

#include <stdio.h>

int main(void) {
  int i, j, a[3];

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

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

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

Error: -11

Fixed submission:

#include <stdio.h>

int main(void) {
  int i, j, a[3];

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

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

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

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

int main(int argc, const char *argv[]) {
  int N, a[N];
  for (N = 0; N < 3; N++) {
    cin >> a[N];
  }
  sort(a, a + 3);
  cout << a[0] << " " << a[1] << " " << a[2] << endl;
  return 0;
}

Error: WA

Fixed submission:

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

int main(int argc, const char *argv[]) {
  int N, n, a[N];
  cin >> n;
  for (N = 0; N < n; N++) {
    cin >> a[N];
  }
  sort(a, a + n);
  for (N = 0; N < n; N++) {
    cout << a[N];
  }
  return 0;
}
Problem p02393 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <stdio.h>

int main() {

  int a, b, c, m;
  scanf("%d%d%d", &a, &b, &c);
  if (a > b) {
    m = b;
    b = a;
    a = m;
  }
  if (b > c) {
    m = c;
    c = b;
    b = m;
  }
  if (a > b) {
    m = b;
    b = a;
    a = m;
  }
  printf("%d %d %d\\n", a, b, c);
  return 0;
}


Error: TLE

Fixed submission:

#include <stdio.h>

int main() {

  int a, b, c, m;
  scanf("%d%d%d", &a, &b, &c);
  while (1) {
    if (a < b && b < c) {
      break;
    }
    if (a > b) {
      m = b;
      b = a;
      a = m;
    }
    if (b > c) {
      m = c;
      c = b;
      b = m;
    }
    if (a > c) {
      m = c;
      c = a;
      a = m;
    }
  }
  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() {
  int a, b, c;
  cin >> a >> b >> c;

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

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

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

  cout << a << ' ' << b << ' ' << c << '\\n';
  return 0;
}

Error: TLE

Fixed submission:

#include <iostream>
using namespace std;

int main() {
  const int num = 3;
  int math[num];

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

  for (int s = 0; s < num; s++) {
    for (int t = s + 1; t < 4; t++) {
      if (math[t] > math[s]) {
        int tmp = math[t];
        math[t] = math[s];
        math[s] = tmp;
      }
    }
  }

  cout << math[2] << ' ' << math[1] << ' ' << math[0] << '\\n';

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

#include <algorithm>
#include <iostream>

using namespace std;
int main() {
  int x[3];
  for (int i; i < 3; i++) {
    cin >> x[i];
  }
  sort(x, x + 3);
  cout << x[0] << " " << x[1] << " " << x[2] << endl;
}


Error: -11

Fixed submission:

#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
int main() {
  vector<int> x;
  for (int i; i < 3; i++) {
    cin >> x[i];
  }
  sort(x.begin(), x.end());
  for (int i; i < 3; i++) {
    cout << x[i] << " ";
  }
  cout << endl;
}
Problem p02393 (C++) — buggy submission, verdict: Runtime Error

// Example program
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;

int main() {
  int a;
  int b;
  int c;
  cin >> a >> b >> c;
  vector<int> v{a, b, c};
  sort(v.begin(), v.end());
  cout << v[0] << " " << v[1] << " " << v[2] << endl;
}

Error: -11

Fixed submission:

// Example program
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;

int main() {
  vector<int> v;
  sort(v.begin(), v.end());
  cout << v[0] << v[1] << v[2] << endl;
}
Problem p02393 (C++) — buggy submission, verdict: Runtime Error

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

Error: -11

Fixed submission:

#include <stdio.h>
int main() {
  int a, b, c;
  scanf("%d %d %d", a, b, c);
  if (a < b) {
    if (b < c && a < c) {
      printf("a b c\\n");
    } else if (b < c && a > c) {
      printf("c a b\\n");
    } else {
      printf("a c b\\n");
    }
  } else if (b < a) {
    if (a < c && b < c) {
      printf("b a c\\n");
    } else if (a > c && b < c) {
      printf("b c a\\n");
    } else {
      printf("c b a\\n");
    }
  }

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

#include <iostream>

using namespace std;

#define INPUT_MIN 0
#define INPUT_MAX 100

void swap(int *num1, int *num2);

int main() {
  int a = 0, b = 0, c = 0;

  cin >> a;
  cin >> b;
  cin >> c;
  /*
          if( (INPUT_MIN > a) || (INPUT_MAX < a) )
          {
                  return 1;
          }

          if( (INPUT_MIN > b) || (INPUT_MAX < b) )
          {
                  return 1;
          }

          if( (INPUT_MIN > c) || (INPUT_MAX < c) )
          {
                  return 1;
          }
  */
  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 *num1, int *num2) {
  int tmp;

  tmp = *num1;
  *num1 = *num2;
  *num2 = tmp;
}


Error: 0

Fixed submission:

#include <iostream>

using namespace std;

#define INPUT_MIN 0
#define INPUT_MAX 100

void swap(int *num1, int *num2);

int main() {
  int a = 0, b = 0, c = 0;

  cin >> a;
  cin >> b;
  cin >> c;

  if ((INPUT_MIN > a) || (INPUT_MAX < a)) {
    return 1;
  }

  if ((INPUT_MIN > b) || (INPUT_MAX < b)) {
    return 1;
  }

  if ((INPUT_MIN > c) || (INPUT_MAX < c)) {
    return 1;
  }

  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 *num1, int *num2) {
  int tmp;

  tmp = *num1;
  *num1 = *num2;
  *num2 = tmp;
}
Problem p02393 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <algorithm>
#include <iostream>

using namespace std;

int main() {
  int A[3];

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

  sort(A, A + 3);

  cout << A[0] << " " << A[1] << " " << A[2] << endl;
}

Error: TLE

Fixed submission:

#include <iostream>

using namespace std;

void swap(int *x, int *y);

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

void swap(int *x, int *y) {
  int z;
  if (x > y) {
    z = *y;
    *y = *x;
    *x = z;
  }
}
Problem p02393 (C++) — buggy submission, verdict: Runtime Error

#include <iostream>

using namespace std;

// int a,b,c;

int main() {
  int x[3];
  cin >> x[0] >> x[1] >> x[2];

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

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

  return 0;
}


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


Fixed submission:

#include <iostream>

using namespace std;

// int a,b,c;

int main() {
  int x[3];
  cin >> x[0] >> x[1] >> x[2];

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

  cout << x[0] << " " << x[1] << " " << x[2] << endl;
}
Problem p02393 (C++) — buggy submission, verdict: Runtime Error

#include <cstdio>

int main() {
  // 入力
  int a, b, c;
  std::scanf("%d %d %d", &a, &b, &c);

  if (a <= b && b <= c) {
    std::printf("%d %d %d", a, b, c);
  }

  else if (a <= c && c <= b) {
    std::printf("%d %d %d", a, c, b);
  } else if (b <= a && a <= c) {
    std::printf("%d %d %d", b, a, c);
  } else if (b <= c && c <= a) {
    std::printf("%d %d %d", b, c, a);
  } else if (c <= b && b <= a) {
    std::printf("%d %d %d", c, b, a);
  } else if (c <= a && a <= b) {
    std::printf("%d %d %d", c, a, b);
  }
  std::printf("\\n");

  return 0;
}


Error: -11

Fixed submission:

#include <cstdio>

int main() {
  // 入力
  int a, b, c;
  std::scanf("%d %d %d\\n", a, b, c);

  if (a < b && b < c) {
    std::printf("a b c");
  }

  else if (a < c && c < b) {
    std::printf("a c b");
  } else if (b < a && a < c) {
    std::printf("b a c");
  } else if (b < c && c < a) {
    std::printf("b c a");
  } else if (c < b && b < a) {
    std::printf("c b a");
  } else if (c < a && a < b) {
    std::printf("c a b");
  }
  std::printf("\\n");

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

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

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

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

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

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

  return 0;
}


Error: -11

Fixed submission:

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

int main() {
  vector<int> a;

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

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

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

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

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

Error: TLE

Fixed submission:

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

#include <iostream>

using namespace std;

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  string as = to_string(a);
  string bs = to_string(b);
  string cs = to_string(c);

  string s;
  if (a <= b && a <= c) // aが最小
  {
    s += (as + " ");
    if (b <= c)
      s += (bs + " " + cs);
    else
      s += (cs + " " + bs);
  } else if (b <= a && b <= c) // bが最小
  {
    s += (bs + " ");
    if (a <= c)
      s += (as + " " + cs);
    else
      s += (cs + " " + as);
  } else if (c <= a && c <= b) // cが最小
  {
    s += (cs + " ");
    if (a <= b)
      s += (as + " " + bs);
    else
      s += (bs + " " + as);
  }
  cout << s << endl;

  return 0;
}

Error: WA

Fixed submission:

#include <iostream>

using namespace std;

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

  string s;
  if (a <= b && a <= c) // aが最小
  {
    s += (a + " ");
    if (b <= c)
      s += (b + " " + c);
    else
      s += (c + " " + b);
  } else if (b <= a && b <= c) // bが最小
  {
    s += (b + " ");
    if (a <= c)
      s += (a + " " + c);
    else
      s += (c + " " + a);
  } else if (c <= a && c <= b) // cが最小
  {
    s += (c + " ");
    if (a <= b)
      s += (a + " " + b);
    else
      s += (b + " " + a);
  }
  cout << s << endl;

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

#include <iostream>
using namespace std;

int main() {
  int num[3], i, j, damy;

  cin >> num[0] >> num[1] >> num[2];
  for (i = 0; i < 3; i++) {
    for (j = 2; j > i; j--) {
      if (num[j - 1] > num[j]) {
        damy = num[j];
        num[j] = num[j - 1];
        num[j - 1] = damy;
      }
    }
  }
  cout << num[0] << " " << num[1] << " " << num[2] << endl;

  return 0;
}

Error: TLE

Fixed submission:

#include <stdio.h>
int main() {
  int a[3], damy, i, j;
  for (i = 0; i < 3; i++) {
    scanf("%d", &a[i]);
  }
  for (i = 0; i < 3; i++) {
    for (j = 2; j > i; i--) {
      if (a[j - 1] > a[j]) {
        damy = a[j];
        a[j] = a[j + 1];
        a[j + 1] = damy;
      }
    }
  }
  for (i = 0; i < 3; i++) {
    printf("%d", a[i]);
  }
  return 0;
}