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

#include <iostream>
using namespace std;

int main() {
  int x;
  cin >> x;
  int y;
  cin >> y;
  while (x != 0 || y != 0) {
    if (x >= y) {
      cout << y << " " << x << endl;

    } else {
      cout << x << " " << y << endl;
    }
    cin >> x;
    cin >> y;
  }
  return 0;
}


Error: TLE

Fixed submission:

#include <iostream>
using namespace std;

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

#include <algorithm>
#include <iostream>
#include <math.h>
#include <sstream>
using namespace std;
int main() {
  while (1) {
    int i, j;
    cin >> i >> j;
    if (i == 0 && j == 0) {
      break;
    } else if (i <= j) {
      cout << i << " " << j << endl;
    } else {
      cout << j << " " << i << endl;
    }
  }
  return 0;
}


Error: TLE

Fixed submission:

#include <algorithm>
#include <iostream>
#include <math.h>
#include <sstream>
using namespace std;
int main() {
  while (1) {
    int i, j;
    cin >> i >> j;
    if (i <= j) {
      cout << i << " " << j << endl;
    } else {
      cout << j << " " << i << endl;
    }
  }
  return 0;
}
Problem p02397 (C++) — buggy submission, verdict: Time Limit Exceeded

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

int main() {
  int n = 1;
  while (n <= 10000) {
    int a, b;
    scanf("%d %d", &a, &b); ///////////////
    if (a == 0) {
      if (b == 0) {
        n = 100001;
      }
    }
    if (n <= 10000) {
      if (a < b) {
        printf("%d %d\\n", a, b);
      } else {
        printf("%d %d\\n", b, a);
      }
      n++;
    }
  }
}

Error: TLE

Fixed submission:

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

int main() {
  int n = 1;
  while (n <= 10000) {
    int a, b;
    scanf("%d %d", &a, &b); ///////////////
    if (a != 0) {
      if (b != 0) {
        if (a < b) {
          printf("%d %d\\n", a, b);
        } else {
          printf("%d %d\\n", b, a);
        }
        n++;
      } else {
        n = 10000;
      }
    }
    n = 10000;
  }
}
Problem p02397 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>
using namespace std;

int main() {
  int x, y, p;

  for (;;) {
    cin >> x >> y;

    if (x > y) {
      p = x;
      x = y;
      y = p;
    }
    if (x == 0 && y == 0)
      break;
    cout << x << " " << y << endl;
  }

  return 0;
}

Error: TLE

Fixed submission:

#include <iostream>
using namespace std;

int main() {
  int x, y, p;

  for (;;) {
    cin >> x >> y;

    if (x > y) {
      p = x;
      x = y;
      y = p;
    }
    if (x && y == 0)
      break;
    cout << x << " " << y << endl;
  }

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

#include <iostream>
using namespace std;
int main() {
  int a, b;
  while (true) {
    cin >> a >> b;
    if (a == 0 && b == 0)
      break;
    else {
      if (a > b)
        cout << b << " " << a << endl;
      else
        cout << a << " " << b << endl;
    }
  }
  return 0;
}

Error: TLE

Fixed submission:

#include <iostream>
using namespace std;
int main() {
  int a, b;
  for (int i = 0;; i++) {
    cin >> a >> b;
    int temp = a;
    a = b;
    b = temp;
    cout << a << " " << b << endl;
  }
  return 0;
}
Problem p02397 (C++) — buggy submission, verdict: Runtime Error

#include <algorithm>
#include <iostream>
using namespace std;
int main() {
  int x, y;
  while (true) {
    cin >> x >> y;
    if (x == 0 && y == 0)
      break;
    else {
      if (x > y)
        swap(x, y);
      cout << x << " " << y << endl;
    }
  }
}


Error: WA

Fixed submission:

#include <iostream>
using namespace std;
int main() {
  int x, y;
  while (true) {
    cin >> x >> y;
    if (x == 0 && y == 0)
      break;
    else {
      cout << ((x > y) ? (x + " " + y) : (y + " " + x)) << endl;
    }
  }
}
Problem p02397 (C++) — buggy submission, verdict: Runtime Error

#include <algorithm>
#include <iostream>
#include <utility>

using namespace std;

int main() {
  const int VALUES = 10000;

  int A[VALUES], B[VALUES], C = 0;

  while (true) {
    cin >> A[C] >> B[C];

    if (A[C] == 0 && B[C] == 0) {
      goto Exit;
    }

    if (A[C] > B[C]) {
      swap(A[C], B[C]);
    }

    C++;
  }

Exit:;

  for (int i = 0; i < C; i++) {
    cout << A[i] << ' ' << B[i] << endl;
  }

  return 0;
}

Error: 0

Fixed submission:

#include <algorithm>
#include <iostream>
#include <utility>

using namespace std;

int main() {
  const int VALUES = 1000;

  int A[VALUES], B[VALUES], C = 0;

  while (true) {
    cin >> A[C] >> B[C];

    if (A[C] == 0 && B[C] == 0) {
      goto Exit;
    }

    swap(A[C], B[C]);

    C++;
  }

Exit:;

  for (int i = 0; i < C; i++) {
    cout << A[i] << ' ' << B[i] << endl;
  }

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

#include <iostream>
using namespace std;

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


Error: TLE

Fixed submission:

#include <iostream>
using namespace std;

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

#include <iostream>
using namespace std;

int main() {
  int x, y, i = 0;
  while (1) {
    cin >> x >> y;
    if (x == 0 && y == 0)
      break;
    if (x > y) {
      int t = x;
      x = y;
      y = t;
    }
    cout << x << " " << y << endl;
  }
  return 0;
}

Error: 0

Fixed submission:

#include <iostream>
using namespace std;

int main() {
  int x[300], y[300], i = 0;
  while (1) {
    cin >> x[i] >> y[i];
    if (x[i] == 0 && y[i] == 0)
      break;
    if (x[i] > y[i]) {
      int t = x[i];
      x[i] = y[i];
      y[i] = t;
    }
    cout << x[i] << " " << y[i] << endl;
    i++;
  }
  return 0;
}
Problem p02397 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>
using namespace std;
int main() {
  int x, y;
  while (true) {
    cin >> x >> y;
    if (x == 0 && y == 0) {
      break;
    } else if (x <= y) {
      cout << x << " " << y << endl;
    } else if (x > y) {
      cout << y << " " << x << endl;
    }
  }
  return 0;
}


Error: TLE

Fixed submission:

#include <iostream>
using namespace std;
int main() {
  int x, y;
  cin >> x >> y;
  while (true) {
    if (x <= y) {
      cout << x << " " << y << endl;
    } else if (x > y) {
      cout << y << " " << x << endl;
    } else {
      break;
    }
  }
  return 0;
}
Problem p02397 (C++) — buggy submission, verdict: Runtime Error

#include <cstdio>

int main() {
  int x, y;
  while (1) {
    scanf("%d %d", &x, &y);
    if (x == 0 && y == 0)
      break;
    if (x > y) {
      printf("%d %d\\n", y, x);
    } else {
      printf("%d %d\\n", x, y);
    }
  }

  return 0;
}

Error: -11

Fixed submission:

#include <cstdio>

int main() {
  int x, y;
  while (1) {
    scanf("%d %d", x, y);
    if (x == 0 && y == 0)
      break;
    if (x > y) {
      printf("%d %d\\n", y, x);
    } else {
      printf("%d %d\\n", x, y);
    }
  }

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

#include <iostream>
using namespace std;
int main() {
  int x, y;
  while (1) {
    cin >> x >> y;
    if (x == 0 && y == 0)
      break;

    if (x < y)
      cout << x << " " << y << endl;
    else
      cout << y << " " << x << endl;
  }
  return 0;
}


Error: TLE

Fixed submission:

#include <iostream>
using namespace std;
int main() {
  int x, y;
  cin >> x >> y;
  while (1) {
    if (x == 0 && y == 0)
      break;
  }
  if (x < y)
    cout << x << " " << y << endl;
  else
    cout << y << " " << x << endl;
  return 0;
}
Problem p02397 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>
using namespace std;
int main() {
  int a, b;
  while (1) {
    cin >> a >> b;
    if (a == b && a == 0)
      break;
    else if (a <= b)
      cout << a << " " << b << endl;
    else if (a >= b)
      cout << b << " " << a << endl;
  }
  return 0;
}

Error: TLE

Fixed submission:

#include <iostream>
using namespace std;
int main() {
  int a, b;
  while (1) {
    cin >> a >> b;
    if (a <= b)
      cout << a << " " << b;
    else if (a >= b)
      cout << b << " " << a;
    else if (a == b == 0)
      break;
  }
  cout << endl;
  return 0;
}
Problem p02397 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <stdio.h>
int main(void) {
  int x, y;
  while (1) {
    scanf("%d%d", &x, &y);
    if (x == 0 && y == 0)
      break;
    else if (x > y)
      printf("%d %d\\n", y, x);
    else if (x == y || x < y)
      printf("%d %d\\n", x, y);
  }
  return 0;
}

Error: TLE

Fixed submission:

#include <stdio.h>
int main(void) {
  int x, y, cin;
  scanf("%d%d", &x, &y);
  while (1) {
    cin >> x >> y;
    if (x > y)
      printf("%d %d\\n", y, x);
    if (x == y)
      printf("%d %d\\n", x, y);
    if (x < y)
      printf("%d %d\\n", x, y);
    if (x == 0 && y == 0)
      break;
  }
  return 0;
}
Problem p02397 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>
using namespace std;

int main() {
  int x, y;
  while (true) {
    cin >> x >> y;
    if ((x | y) != 0) {
      if (x < y) {
        cout << x << " " << y << endl;
      } else {
        cout << y << " " << x << endl;
      }
    } else {
      break;
    }
  }
  return 0;
}

Error: TLE

Fixed submission:

#include <iostream>
using namespace std;

int main() {
  int x, y;
  while (true) {
    cin >> x >> y;
    if ((x | y) != 0) {
      if (x < y) {
        cout << x << " " << y << endl;
      } else {
        cout << y << " " << x << endl;
      }
    }
  }
  return 0;
}
Problem p02397 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <stdio.h>
int main() {
  int x, y;
  for (;;) {
    scanf("%d %d", &x, &y);
    if (x < y) {
      printf("%d %d\\n", x, y);
    } else if (y < x) {
      printf("%d %d\\n", y, x);
    } else if (x == y && x != 0 && y != 0) {
      printf("%d %d\\n", x, y);
    } else if (x == 0 && y == 0) {
      break;
    }
  }
  return 0;
}

Error: TLE

Fixed submission:

#include <stdio.h>
int main() {
  int x, y;
  for (;;) {
    scanf("%d %d", &x, &y);
    if (x < y) {
      printf("%d %d\\n", x, y);
    } else if (y < x) {
      printf("%d %d\\n", y, x);
    } else if (x == y) {
      printf("%d %d\\n", x, y);
    } else if (x == 0 && y == 0) {
      break;
    }
  }
  return 0;
}
Problem p02397 (C++) — buggy submission, verdict: Runtime Error

#include <iostream>
using namespace std;

int main() {
  int a[100000][4];
  int b = 0;
  for (int i = 1; i < 100000; i++) {
    cin >> a[i][0] >> a[i][1];
    b++;
    if (a[i][0] > a[i][1]) {
      a[i][3] = a[i][0];
      a[i][2] = a[i][1];
    } else {
      a[i][2] = a[i][0];
      a[i][3] = a[i][1];
    }
    if (a[i][0] == 0 && a[i][1] == 0) {
      goto aa;
    }
  }
aa:;
  for (int i = 1; i < b; i++) {
    cout << a[i][2] << " " << a[i][3] << endl;
  }
  return 0;
}

Error: -11

Fixed submission:

#include <iostream>
using namespace std;

int main() {
  int a[1000000][4];
  int b = 0;
  for (int i = 1; i < 1000000; i++) {
    cin >> a[i][0] >> a[i][1];
    b++;
    if (a[i][0] > a[i][1]) {
      a[i][3] = a[i][0];
      a[i][2] = a[i][1];
    } else {
      a[i][2] = a[i][0];
      a[i][3] = a[i][1];
    }
    if (a[i][0] == 0 && a[i][1] == 0) {
      goto aa;
    }
  }
aa:;
  for (int i = 1; i < b; i++) {
    cout << a[i][2] << a[i][3] << endl;
  }
  return 0;
}
Problem p02397 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>
using namespace std;

int main(void) {
  int x, y, t;
  while (1) {
    cin >> x >> y;
    if (x == 0 && y == 0) {
      break;
    } else if (x > y) {
      t = x;
      x = y;
      y = t;
    }
    cout << x << " " << y << endl;
  }
  return 0;
}

Error: TLE

Fixed submission:

#include <iostream>
using namespace std;

int main(void) {
  int x, y, t;
  while (1) {
    cin >> x >> y;
    if (x > y) {
      t = x;
      x = y;
      y = t;
    }
    cout << x << " " << y << endl;
  }
  return 0;
}
Problem p02397 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>
using namespace std;
int main() {
  int a, b;
  while (true) {
    cin >> a >> b;
    if (a == 0 && b == 0)
      break;
    if (a > b)
      cout << b << " " << a << endl;
    else
      cout << a << " " << b << endl;
  }
  return 0;
}

Error: TLE

Fixed submission:

#include <iostream>
using namespace std;

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

#include <iostream>
using namespace std;
int main() {
  int x, y;
  while (true) {
    cin >> x >> y;
    if (x == 0 && y == 0) {
      break;

    } else if (x <= y) {
      cout << x << " " << y << endl;
    } else {
      cout << y << " " << x << endl;
    }
  }
  return 0;
}


Error: TLE

Fixed submission:

#include <iostream>
using namespace std;
int main() {
  int x, y;
  cin >> x >> y;
  while (true) {
    if (x == 0 && y == 0) {
      break;
    } else if (x <= y) {
      cout << x << " " << y << endl;
    } else {
      cout << y << " " << x << endl;
    }
  }
  return 0;
}
Problem p02397 (C++) — buggy submission, verdict: Runtime Error

/*
 * SwappingTwoNumbers.cpp
 *
 *  Created on: 2014/07/21
 *      Author: WanWan1985
 */
#include <iostream>
#include <vector>
using namespace std;

typedef struct {
  int x, y;
} DataSet;

void swap(int &a_x, int &a_y) {
  if (a_x > a_y) {
    int tmp = a_x;
    a_x = a_y;
    a_y = tmp;
  }
}

int main(void) {

  vector<DataSet> vecDataSet;
  while (1) {
    int x, y = 0;
    cin >> x >> y;
    if ((0 == x) && (0 == y)) {
      break;
    }
    DataSet data;
    data.x = x;
    data.y = y;
    vecDataSet.push_back(data);
  }

  for (unsigned int i = 0; i < vecDataSet.size(); i++) {
    DataSet data = vecDataSet.at(i);
    swap(data.x, data.y);
    cout << data.x << " " << data.y << endl;
  }

  return 0;
}

Error: WA

Fixed submission:

/*
 * Distance2.cpp
 *
 *  Created on: 2014/07/21
 *      Author: WanWan1985
 */
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <math.h>
#include <vector>
using namespace std;

int main(void) {

  int n = 0;
  cin >> n;

  vector<int> vecX, vecY;
  for (unsigned int i = 0; i < n; i++) {
    int iX = 0;
    cin >> iX;
    vecX.push_back(iX);
  }

  for (unsigned int i = 0; i < n; i++) {
    int iY = 0;
    cin >> iY;
    vecY.push_back(iY);
  }

  double dDistance1 = 0.0;   // p = 1
  double dDistance2 = 0.0;   // p = 2
  double dDistance3 = 0.0;   // p = 3
  double dDistanceInf = 0.0; // p = infinity
  vector<double> vecInf;
  for (unsigned int j = 0; j < vecX.size(); j++) {
    dDistance1 += fabs(vecX.at(j) - vecY.at(j));
    dDistance2 += pow(fabs(vecX.at(j) - vecY.at(j)), 2.0);
    dDistance3 += pow(fabs(vecX.at(j) - vecY.at(j)), 3.0);
    vecInf.push_back(fabs(vecX.at(j) - vecY.at(j)));
  }
  dDistance2 = sqrt(dDistance2);
  dDistance3 = cbrt(dDistance3);
  dDistanceInf = *max_element(vecInf.begin(), vecInf.end());

  cout << fixed << setprecision(6) << dDistance1 << endl;
  cout << fixed << setprecision(6) << dDistance2 << endl;
  cout << fixed << setprecision(6) << dDistance3 << endl;
  cout << fixed << setprecision(6) << dDistanceInf << endl;

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

#include <iostream>
using namespace std;
int main() {
  int x, y;
  while (1) {
    cin >> x >> y;
    if (x == 0 && y == 0) {
      break;
    } else if (x <= y) {
      cout << x << " " << y << endl;
    } else if (x > y) {
      cout << y << " " << x << endl;
    }
  }
  return 0;
}


Error: TLE

Fixed submission:

#include <iostream>
using namespace std;
int main() {
  int x, y;
  while (1) {
    cin >> x >> y;
    if (x = 0, y = 0) {
      break;
    } else if (x <= y) {
      cout << x << " " << y << endl;
    } else if (x > y) {
      cout << y << " " << x << endl;
    }
  }
  return 0;
}
Problem p02397 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>
int main() {
  int x, y;
  while (1) {
    std::cin >> x >> y;
    if (x == 0 && y == 0)
      break;
    if (x > y) {
      std::cout << y << " " << x << std::endl;
    } else {
      std::cout << x << " " << y << std::endl;
    }
  }

  return 0;
}


Error: TLE

Fixed submission:

#include <iostream>
int main() {
  int x, y;
  std::cin >> x >> y;
  while (1) {
    if (x == 0 && y == 0)
      break;
    if (x > y) {
      std::cout << y << x << std::endl;
    } else {
      std::cout << x << y << std::endl;
    }
  }

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

#include <iostream>
using namespace std;
int main() {
  int x, y;
  for (;;) {
    cin >> x >> y;
    if (x == 0 && y == 0)
      break;
    if (x > y) {
      cout << y << " " << x;
    } else {
      cout << x << " " << y;
    }
    cout << endl;
  }
  return 0;
}


Error: TLE

Fixed submission:

#include <iostream>
using namespace std;
int main() {
  int x, y;
  cin >> x >> y;
  for (x = 0; x >= 0; x++) {
    for (y = 0; y <= 10000; y++) {
      if (x < y) {
        cout << x << " " << y << endl;
      } else if (x > y) {
        cout << y << " " << x << endl;
      }
    }
  }
  return 0;
}
Problem p02397 (C++) — buggy submission, verdict: Runtime Error

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

int main() {
  for (;;) {
    int x, y;

    cin >> x >> y;
    if (x == 0 && y == 0)
      break;
    cout << min(x, y) << " " << max(x, y) << endl;
  }
}

Error: -11

Fixed submission:

#include <stdio.h>

int main(void) {
  int i, x, y;

  scanf("%d", "%d", &x, &y);
  for (i = 1; x != 0 || y != 0; i++) {
    printf("%d %d\\n", x, y);
    scanf("%d", "%d", &x, &y);
  }
  return 0;
}
Problem p02397 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <cstdio>
using namespace std;

int main() {
  int x;
  int y;
  while (1) {
    scanf("%d %d", &x, &y);
    if (x == 0 && y == 0)
      break;
    else if (x > y)
      printf("%d %d\\n", y, x);
    else if (x < y)
      printf("%d %d\\n", x, y);
    else if (x == y)
      printf("%d %d\\n", x, y);
  }
  return 0;
}

Error: TLE

Fixed submission:

#include <cstdio>
using namespace std;

int main() {
  int x;
  int y;
  while (1) {
    scanf("%d %d", &x, &y);
    if (x = 0, y = 0)
      break;
    else if (x > y)
      printf("%d %d\\n", y, x);
    else if (x < y)
      printf("%d %d\\n", x, y);
    else if (x = y)
      printf("%d %d\\n", x, y);
  }
  return 0;
}
Problem p02397 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>
using namespace std;
int main() {
  int x;
  int y;
  int i = 0;

  while (i >= 0) {
    cin >> x >> y;
    if ((x == 0) && (y == 0))
      break;
    if (x <= y) {
      cout << x << " " << y << endl;
    } else {
      cout << y << " " << x << endl;
    }

    i++;
  }
}


Error: TLE

Fixed submission:

#include <iostream>
using namespace std;
int main() {
  int x;
  int y;
  int i = 0;

  while (i >= 0) {
    cin >> x >> y;
    if (x <= y) {
      cout << x << " " << y << endl;
    } else {
      cout << y << " " << x << endl;
    }

    i++;
  }
}
Problem p02397 (C++) — buggy submission, verdict: Time Limit Exceeded

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

int main() {
  int n, m;
  while (true) {
    cin >> n >> m;
    if (n == 0 && m == 0) {
      break;
    } else if (n <= m) {
      cout << n << " " << m << endl;
    } else {
      cout << m << " " << n << endl;
    }
  }
}


Error: TLE

Fixed submission:

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

int main() {
  int n, m;
  while (true) {
    cin >> n >> m;
    if (n <= m) {
      cout << m << " " << n;
    } else if (m < n) {
      cout << n << " " << m;
    } else if (n == 0 && m == 0) {
      break;
    }
  }
}
Problem p02397 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
using namespace std;
int main() {
  while (1) {
    int x, y;
    cin >> x >> y;
    if (x == 0 && y == 0)
      break;
    if (x > y)
      swap(x, y);
    cout << x << " " << y << endl;
  }
  return 0;
}


Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
int main() {
  while (1) {
    int x, y;
    cin >> x, y;
    if (x == 0 && y == 0)
      break;
    if (x > y)
      swap(x, y);
    cout << x << " " << y << endl;
  }
  return 0;
}
Problem p02397 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>
using namespace std;

int main() {
  // your code goes here
  int x, y;
  while (1) {
    cin >> x;
    cin >> y;
    if (x == 0 && y == 0) {
      break;
    }
    if (x > y) {
      cout << y << " " << x << endl;
    }
    if (x <= y) {
      cout << x << " " << y << endl;
    }
  }
  return 0;
}

Error: TLE

Fixed submission:

#include <iostream>
using namespace std;

int main() {
  // your code goes here
  int x, y;
  while (1) {
    cin >> x;
    cin >> y;
    if (x > y) {
      cout << x << " " << y << endl;
    }
    if (x < y) {
      cout << y << " " << x << endl;
    }
    if (x = 0, y = 0) {
      break;
    }
  }
  return 0;
}
Problem p02397 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>
using namespace std;

int main() {
  int x, y;

  while (1) {
    cin >> x >> y;

    if (x == 0 && y == 0) {
      return 0;
    }
    if (x <= y) {
      cout << x << " " << y << "\\n";
    } else {
      cout << y << " " << x << "\\n";
    }
  }
  return 0;
}

Error: TLE

Fixed submission:

#include <iostream>
using namespace std;

int main() {
  int x, y;
  int n = 1;
  int dx[10000];
  int dy[10000];
  cin >> x >> y;

  while (1) {
    if (x != 0) {
      cin >> x >> y;
      n++;
    }
    if (x == 0 && y == 0) {
      return 0;
      break;
    }
    if (x <= y) {
      cout << dx[n] << " " << dy[n] << "\\n";
    }
    if (y < x) {
      cout << dy[n] << " " << dx[n] << "\\n";
    }
  }
  return 0;
}
Problem p02397 (C++) — buggy submission, verdict: Time Limit Exceeded

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

  while (1) {
    cin >> x >> y;

    if ((x == 0) && (y == 0))
      break;

    if (x < y) {
      cout << x << " " << y << endl;
    }
    if (x > y) {
      cout << y << " " << x << endl;
    }
    if (x == y) {
      cout << x << " " << y << endl;
    }
  }

  return 0;
}

Error: TLE

Fixed submission:

#include <iostream>
using namespace std;
int main() {
  int x, y;
  cin >> x >> y;
  for (; x == 0;) {
    if (x < y) {
      cout << x << " " << y;
    } else
      cout << y << " " << x;
  }

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

#include <stdio.h>
int main() {
  int x, y, i;
  for (i = 0; i < 10000; i++) {
    scanf("%d %d", &x, &y);
    if (x == 0 && y == 0)
      break;
    if (x > y)
      printf("%d %d\\n", y, x);
    else
      printf("%d %d\\n", x, y);
  }
  return 0;
}

Error: -11

Fixed submission:

#include <stdio.h>
int main() {
  int x, y, i;
  for (i = 0; i < 10000; i++) {
    scanf("%d %d", x, y);
    if (x == 0 && y == 0)
      break;
    if (x > y)
      printf("%d %d", y, x);
    else
      printf("%d %d", x, y);
  }
  return 0;
}
Problem p02397 (C++) — buggy submission, verdict: Runtime Error

#include <stdio.h>
int main() {
  int i, x, y;
  for (i = 1;; i++) {
    scanf("%d %d", &x, &y);
    if (x == 0 && y == 0) {
      break;
    } else if (x <= y) {
      printf("%d %d\\n", x, y);
    } else {
      printf("%d %d\\n", y, x);
    }
  }

  return 0;
}

Error: WA

Fixed submission:

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