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

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

int main() {
  long long int n, f = 1, i;
  scanf("%lld", &n);
  for (i = 1; i <= n; i++)
    f = f * i;
  if (n == 0)
    printf("0\\n");
  else
    printf("%lld\\n", f);
  return 0;
}

Error: TLE

Fixed submission:

#include <iostream>
using namespace std;
int main() {
  int i, j;
  long long mul;
  bool stop = false;
  do {
    cin >> i;
    if (i > 0 && i <= 20) {
      mul = 1;
      for (j = i; j > 1; j--) {
        mul *= j;
      }
      cout << mul << endl;
    } else if (i == 0)
      cout << "1" << endl;
    else if (i < 0)
      cout << "Error." << endl;
  } while (stop == false);

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

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

int main() {

  string str;

  getline(cin, str);

  for (int i = 0; i < str.size(); i++) {
    if ('a' <= str[i] && str[i] <= 'z') {
      str[i] -= 32;
    }
  }

  cout << str << endl;

  return (0);
}

Error: TLE

Fixed submission:

#include <cstdio>
using namespace std;

int main() {
  char c;

  while (scanf("%c", &c), c != EOF) {
    if (c >= 'a' && c <= 'z') {
      c -= 32;
    }
    printf("%c", c);
  }
  printf("\\n");
  return (0);
}
Problem p00020 (C++) — buggy submission, verdict: Runtime Error

#include <algorithm>
#include <cstdio>
#include <cstring>
#include <functional>
using namespace std;

int main() {
  static char str[100000];
  scanf("%[a-z .]", str);
  for (int i = 0; str[i]; i++) {
    if ('a' <= str[i] && str[i] <= 'z')
      str[i] += 'A' - 'a';
  }
  printf("%s\\n", str);
  return 0;
}

Error: 0

Fixed submission:

#include <algorithm>
#include <cstdio>
#include <cstring>
#include <functional>
using namespace std;

int main() {
  char str[100];
  scanf("%[a-z .]", str);
  for (int i = 0; str[i]; i++) {
    if ('a' <= str[i] && str[i] <= 'z')
      str[i] += 'A' - 'a';
  }
  printf("%s\\n", str);
  return 0;
}
Problem p00020 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>
using namespace std;
int main() {
  int c;
  while ((c = getc(stdin)) != '\\n') {
    putc((c >= 'a' and c <= 'z') ? c + 'A' - 'a' : c, stdout);
  }
  cout << endl;
  return 0;
}

Error: TLE

Fixed submission:

#include <iostream>
using namespace std;
int main() {
  int c;
  while (c = getc(stdin)) {
    putc((c >= 'a' and c <= 'z') ? c + 'A' - 'a' : c, stdout);
  }
  return 0;
}
Problem p00020 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>

std::string str;

int main() {
  getline(std::cin, str);

  int len = str.length();
  for (int i = 0; i < len; ++i) {
    char c = str[i];
    if (c >= 'a' && c <= 'z') {
      char upper = (c - 'a') + 'A';
      std::cout << upper;
    } else {
      std::cout << c;
    }
  }
  std::cout << std::endl;
}


Error: TLE

Fixed submission:

#include <iostream>

std::string str;

int main() {
  getline(std::cin, str);

  for (char c : str) {
    if (c == '\\n')
      break;
    if (c >= 'a' && c <= 'z') {
      char upper = (c - 'a') + 'A';
      std::cout << upper;
    } else {
      std::cout << c;
    }
  }
}
Problem p00020 (C++) — buggy submission, verdict: Runtime Error

#include <cstdio>
#include <cstring>
#include <iostream>
using namespace std;
int main() {
  char cent[10000];
  for (int i = 0;; i++) {
    if (scanf("%c", &cent[i]) == EOF) {
      break;
    }
    if (cent[i] >= 97 && cent[i] <= 122) {
      cent[i] -= 32;
    }
  }
  cout << cent;
  return 0;
}

Error: WA

Fixed submission:

#include <cstdio>
#include <cstring>
#include <iostream>
using namespace std;
int main() {
  char cent[100];
  for (int i = 0;; i++) {
    if (scanf("%c", &cent[i]) == EOF) {
      break;
    }
    if (cent[i] >= 97 && cent[i] <= 122) {
      cent[i] -= 32;
    }
  }
  cout << cent;
  return 0;
}
Problem p00020 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <stdio.h>
int main() {
  for (char c; scanf("%c", &c) != -1;)
    putchar((c > 96) ? (c - 32) : c);
}

Error: TLE

Fixed submission:

#include <stdio.h>
int main() {
  char c;
  while (scanf("%c", &c)) {
    if (c == ' ')
      printf(" ");
    else if (c == '.')
      printf(".");
    else if (c == '\\n')
      printf("\\n");
    else
      printf("%c", c - 32);
  }
}
Problem p00020 (C++) — buggy submission, verdict: Time Limit Exceeded

/*****include*****/
#include <fstream>
#include <iostream>
#include <string>

/*****デバッグ定義*****/
// #define DEBUG
/*****マクロ定義*****/

/*****名前空間*****/
using namespace std;

/*****グローバル変数置き場*****/

/*****その他関数置き場*****/

/*****main関数*****/
int main() {
  /*****ファイルオープン*****/
#ifdef DEBUG
  ofstream fout("output.txt");
  ifstream fin("input.txt");
  if (!fout || !fin) {
    cout << "Can't open the file.\\n";
    return;
  }
#endif
  /*****変数置き場*****/
  // string words;
  /*****処理部*****/
  // gets(words.c_str());
  /*int i=0;
  for(int i=0;i<words.length();i++){
          if(islower((int)words[i])){
                  words[i] = toupper(words[i]);
          }
  }
  for(int j=0;j<i;j++){
          cout << words[j];
  }*/
  char letter;
  while (1) {
    scanf("%c", &letter);
    if (letter == '\\n')
      break;
    if (islower((int)letter)) {
      letter = toupper(letter);
    }
    cout << letter;
  }
  cout << endl;
  /*****処理終了後*****/
#ifdef DEBUG
  fout.close();
  fin.close();
#endif
  return 0;
}

Error: TLE

Fixed submission:

/*****include*****/
#include <fstream>
#include <iostream>
#include <string>

/*****デバッグ定義*****/
// #define DEBUG
/*****マクロ定義*****/

/*****名前空間*****/
using namespace std;

/*****グローバル変数置き場*****/

/*****その他関数置き場*****/

/*****main関数*****/
int main() {
  /*****ファイルオープン*****/
#ifdef DEBUG
  ofstream fout("output.txt");
  ifstream fin("input.txt");
  if (!fout || !fin) {
    cout << "Can't open the file.\\n";
    return;
  }
#endif
  /*****変数置き場*****/
  char letter;
  /*****処理部*****/
  while (1) {
    letter = getchar();
    if (letter == '\\0')
      break;
    if (islower((int)letter)) {
      letter = toupper(letter);
    }
    putchar(letter);
  }
  /*****処理終了後*****/
#ifdef DEBUG
  fout.close();
  fin.close();
#endif
  return 0;
}
Problem p00020 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <stdio.h>

int main() {
  char c;
  while (1) {
    if ((c = getchar()) == EOF)
      break;
    if (c >= 'a' && c <= 'z')
      printf("%c", c + ('A' - 'a'));
    else
      printf("%c", c);
  }
  return 0;
}

Error: TLE

Fixed submission:

#include <stdio.h>

int main() {
  char c;
  while (1) {
    if ((c = getchar()) == NULL)
      break;
    if (c >= 'a' && c <= 'z')
      printf("%c", c + ('A' - 'a'));
    else
      printf("%c", c);
  }
}
Problem p00020 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <algorithm>
#include <cmath>
#include <complex>
#include <cstdio>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;

#define reps(i, f, n) for (int i = f; i < int(n); i++)
#define rep(i, n) reps(i, 0, n)

int main() {

  string a;
  getline(cin, a);

  rep(i, a.size()) {
    if (a[i] <= 'z' && 'a' <= a[i]) {
      a[i] += 'A' - 'a';
    }
  }

  cout << a << endl;
}

Error: TLE

Fixed submission:

#include <stdio.h>

int main() {
  char str[200];
  while (1) {
    fgets(str, 200, stdin);
  }
}
Problem p00020 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>

int main() {
  int a;
  while (1) {
    a = getchar();
    if (a == EOF)
      break;
    if ('a' <= a && a <= 'z') {
      a += 'A' - 'a';
    }
    putchar(a);
  }
  return 0;
}

Error: TLE

Fixed submission:

#include <iostream>

using namespace std;

int main() {
  int f = 0;
  while (1) {
    int a, b;
    cin >> a >> b;
    if (a == 0)
      break;
    if (f == 1)
      cout << endl;
    f = 1;
    int f2 = 0;
    for (int i = a; i <= b; i++) {
      if (i % 400 == 0 || (i % 4 == 0 && i % 100 != 0)) {
        f2 = 1;
        cout << i << endl;
      }
    }
    if (f2 == 0)
      cout << "NA" << endl;
  }
  return 0;
}
Problem p00020 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <cstdio>
#include <iostream>
#include <string>

using namespace std;

int main() {
  string a;

  while (getline(cin, a)) {
    for (int i = 0; i < a.length(); ++i)
      if ('a' <= a[i] && a[i] <= 'z')
        a[i] -= ('a' - 'A');
    cout << a << endl;
  }

  return 0;
}

Error: TLE

Fixed submission:

#include <cstdio>
#include <cstring>
#include <iostream>

using namespace std;

int main() {
  char a;

  while (a = fgetc(stdin)) {
    if ('a' <= a && a < 'z')
      a -= ('a' - 'A');
    fputc(a, stdout);
  }

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

#include <cctype>
#include <cstdio>
#include <iostream>
using namespace std;
int main() {
  char c;
  while (scanf("%c", &c) != EOF) {
    if (islower(c))
      c = toupper(c);
    cout << c;
  }
}

Error: TLE

Fixed submission:

#include <cctype>
#include <cstdio>
#include <iostream>
using namespace std;
int main() {
  char c;
  while (scanf("%c", &c)) {
    if (islower(c))
      c = toupper(c);
    cout << c;
  }
  cout << endl;
}
Problem p00020 (C++) — buggy submission, verdict: Time Limit Exceeded

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

using namespace std;

int main() {

  char ch;

  while (1) {

    scanf("%c", &ch);

    if (ch == '\\n') {
      cout << endl;
      break;
    }

    ch = toupper(ch);

    cout << ch;
  }

  return 0;
}

Error: TLE

Fixed submission:

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

using namespace std;

int main() {

  char ch;

  while (1) {

    scanf("%c", &ch);

    if (ch == '\\n') {
      cout << endl;
    }

    ch = toupper(ch);

    cout << ch;
  }

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

#include <ctype.h>
#include <stdio.h>
#include <string.h>

int main(void) {
  int len, cut_i;
  char str[1000];

  scanf("%[a-z .]", str);

  len = strlen(str);

  for (cut_i = 0; cut_i < len; cut_i++) {
    str[cut_i] = toupper(str[cut_i]);
  }

  puts(str);

  return 0;
}

Error: -11

Fixed submission:

#include <stdio.h>

int main(void) {
  char s;
  while (s = getchar() != '\\n' && s != EOF) {
    if ('a' <= s && s <= 'z')
      s -= 'a' + 'A';
    printf("%s", s);
  }
  return 0;
}
Problem p00020 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>
#define rep(i, a, n) for (int i = a; i < n; i++)
using namespace std;

int main() {
  string s;
  getline(cin, s);
  rep(i, 0, s.length()) {
    if ('a' <= s[i] && s[i] <= 'z')
      s[i] -= 32;
  }
  cout << s << endl;
}

Error: TLE

Fixed submission:

#include <iostream>
using namespace std;
long long int fact(int x) {
  if (x == 1)
    return 1;
  else
    return x * fact(x - 1);
}

int main() {
  long long int n;
  cin >> n;
  cout << fact(n) << endl;
  return 0;
}
Problem p00020 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>
#include <string>

using namespace std;

int main() {
  string ch;
  int i;

  getline(cin, ch);

  for (i = 0; i < ch.size(); i++) {

    if (isalpha(ch[i])) {
      ch[i] = toupper(ch[i]);
    }
  }

  cout << ch << endl;
}

Error: TLE

Fixed submission:

#include <iostream>

using namespace std;

int main() {
  char ch;

  while (1) {
    cin >> ch;

    if (ch == '\\n') {
      cout << endl;
      break;
    } else {
      ch = toupper(ch);
      cout << ch;
    }
  }
}
Problem p00020 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <stdio.h>

int main(void) {
  char a;

  while ((a = getchar()) != EOF) {
    if ('a' <= a && a <= 'z')
      a -= 32;
    putchar(a);
  }

  return 0;
}

Error: TLE

Fixed submission:

#include <stdio.h>

int main(void) {
  char a;

  while ((a = getchar()) != '\\0') {
    if ('a' <= a && a <= 'z')
      a -= 32;
    putchar(a);
  }

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

#include <cstdio>
#include <iostream>

using namespace std;

char data1[26] = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i',
                  'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r',
                  's', 't', 'u', 'v', 'w', 'x', 'y', 'z'};
char data2[26] = {'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I',
                  'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R',
                  'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'};
char mozi;
int flag = 0;

int main() {
  while (flag == 0) {
    scanf("%c", &mozi);
    if (mozi == ' ') {
      printf(" ");
    } else if (mozi == '.') {
      printf(".");
    } else if (mozi == '\\n') {
      printf("\\n");
      flag = 1;
    } else {
      for (int i = 0; i < 26; i++) {
        if (data1[i] == mozi) {
          printf("%c", data2[i]);
          break;
        }
      }
    }
  }
}

Error: TLE

Fixed submission:

#include <cstdio>
#include <iostream>

using namespace std;

char data1[26] = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i',
                  'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r',
                  's', 't', 'u', 'v', 'w', 'x', 'y', 'z'};
char data2[26] = {'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I',
                  'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R',
                  'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'};
char mozi;

int main() {
  while (scanf("%c", &mozi)) {
    if (mozi == ' ') {
      printf(" ");
    } else if (mozi == '.') {
      printf(".");
    } else if (mozi == '\\n') {
      printf("\\n");
    } else {
      for (int i = 0; i < 26; i++) {
        if (data1[i] == mozi) {
          printf("%c", data2[i]);
          break;
        }
      }
    }
  }
}
Problem p00020 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <ctype.h>
#include <stdio.h>

int main() {
  char c;
  while (scanf("%c", &c) != EOF)
    printf("%c", toupper(c));
}

Error: TLE

Fixed submission:

#include <ctype.h>
#include <stdio.h>

int main() {
  char c;
  while (scanf("%c", &c))
    printf("%c", toupper(c));
  puts("");
}
Problem p00021 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <cmath>
#include <iostream>
using namespace std;
bool EQ(double a, double b) {
  return abs(a - b) < 0.000000000001;
  //  return a-0.0000001<b&&b<a+0.0000001;
}
int main() {
  int n;
  double x[4], y[4];
  cin >> n;
  while (n--) {
    for (int j = 0; j < 4; j++)
      cin >> x[j] >> y[j];
    if (EQ((y[3] - y[2]) * (x[1] - x[0]), (y[1] - y[0]) * (x[3] - x[2])))
      cout << "YES" << endl;
    else
      cout << "NO" << endl;
  }
  return 0;
}

Error: TLE

Fixed submission:

#include <iostream>
using namespace std;
int main() {
  int n;
  double xa, ya, xb, yb, xc, yc, xd, yd, a2, a1;
  while (1) {
    cin >> n;
    for (int i = 0; i < n; i++) {
      cin >> xa >> ya >> xb >> yb >> xc >> yc >> xd >> yd;
      a1 = (yb - ya) / (xb - xa);
      a2 = (yd - yc) / (xd - xc);
      if (a1 == a2)
        cout << "YES" << endl;
      else
        cout << "NO" << endl;
    }
  }
  return 0;
}
Problem p00021 (C++) — buggy submission, verdict: Runtime Error

#include <cmath>
#include <complex>
#include <iostream>
#include <queue>
#include <string>
using namespace std;
typedef complex<double> xy_t;
int main() {
  const double eps = 1e-11;
  int n;
  double x[4], y[4];
  queue<string> qs;
  cin >> n;
  for (int i = 0; i < n; ++i) {
    xy_t p[4];
    for (int j = 0; j < 4; ++j) {
      cin >> x[j] >> y[j];
      p[j] = xy_t(x[j], y[j]);
    }
    double S;
    S = (conj(p[0] - p[1]) * (p[2] - p[3])).imag();
    if (abs(S) < eps)
      qs.push("YES");
    else
      qs.push("NO");
  }
  while (!qs.empty()) {
    cout << qs.front() << endl;
    qs.pop();
  }
}

Error: 0

Fixed submission:

#include <cmath>
#include <complex>
#include <iostream>
#include <queue>
#include <string>
using namespace std;
int main() {
  int n;
  double x, y;
  queue<string> qs;
  cin >> n;
  for (int i = 0; i < n; ++i) {
    complex<double> p[4];
    for (int j = 0; j < 4; ++j) {
      cin >> x >> y;
      p[i] = complex<double>(x, y);
    }
    int S = (conj(p[1] - p[2]) * (p[3] - p[4])).imag();
    if (S == 0)
      qs.push("YES");
    else
      qs.push("NO");
  }
  while (!qs.empty()) {
    cout << qs.front() << endl;
    qs.pop();
  }
}
Problem p00021 (C++) — buggy submission, verdict: Runtime Error

#include <cmath>
#include <iostream>
using namespace std;
int main() {
  int n;
  cin >> n;
  while (n--) {
    double x[4], y[4];
    for (int i = 0; i < 4; i++) {
      cin >> x[i] >> y[i];
    }
    if (abs((x[3] - x[2]) * (y[1] - y[0]) - (x[1] - x[0]) * (y[3] - y[2])) <
        1e-10) {
      cout << "YES" << endl;
    } else {
      cout << "NO" << endl;
    }
  }
}


Error: -8

Fixed submission:

#include <iostream>
using namespace std;

int main() {
  int n;
  int x1, y1, x2, y2, x3, y3, x4, y4;
  int d1, d2;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3 >> x4 >> y4;
    d1 = (y2 - y1) / (x2 - x1);
    d2 = (y4 - y3) / (x4 - x3);
    if (d1 == d2) {
      cout << "YES" << endl;
    } else {
      cout << "NO" << endl;
    }
  }
}
Problem p00021 (C++) — buggy submission, verdict: Runtime Error

#include <algorithm>
#include <bitset>
#include <cmath>
#include <complex>
#include <cstdio>
#include <iostream>
#include <stack>
#include <vector>
#define EPS 1e-6

using namespace std;
typedef complex<double> coor;

double cross(coor a, coor b) {
  return a.real() * b.imag() - a.imag() * b.real();
}

double dot(coor a, coor b) { return a.real() * b.real() + a.imag() * b.imag(); }

int main() {
  int N;
  scanf(" %d ", &N);

  for (int i = 0; i < N; i++) {
    coor c[4];
    for (int j = 0; j < 4; j++) {
      double x, y;
      scanf(" %lf %lf ", &x, &y);
      c[j] = coor(x, y);
    }

    if (cross(c[1] - c[0], c[3] - c[2]) == 0) {
      printf("YES\\n");
    } else {
      printf("NO\\n");
    }
  }
  return 0;
}

Error: WA

Fixed submission:

#include <algorithm>
#include <bitset>
#include <cmath>
#include <complex>
#include <cstdio>
#include <iostream>
#include <stack>
#include <vector>
#define EPS 1e-6

using namespace std;
typedef complex<double> coor;

double cross(coor a, coor b) {
  return a.real() * b.imag() - a.imag() * b.real();
}

double dot(coor a, coor b) { return a.real() * b.real() + a.imag() * b.imag(); }

int main() {
  int N;
  scanf(" %d ", &N);

  for (int i = 0; i < N; i++) {
    coor c[4];
    for (int j = 0; j < 4; j++) {
      int x, y;
      scanf(" %d %d ", &x, &y);
      c[i] = coor(x, y);
    }
    if (cross(c[1] - c[0], c[3] - c[2])) {
      printf("YES\\n");
    } else {
      printf("NO\\n");
    }
  }
  return 0;
}
Problem p00021 (C++) — buggy submission, verdict: Runtime Error

#include <complex>
#include <iostream>
#define REP(i, n) for (int i = 0; i < (n); ++i)
using namespace std;

// ?¨±?????????????????
#define EPS (1e-10)
// 2??????????????????????????????????????????
#define EQ(a, b) (abs((a) - (b)) < EPS)

typedef complex<double> P;

// ?????? (cross product) : a??b = |a||b|sin??
double cross(P a, P b) { return (a.real() * b.imag() - a.imag() * b.real()); }

// 2??´?????????????????? : a//b <=> cross(a, b) = 0
int is_parallel(P a1, P a2, P b1, P b2) {
  return EQ(cross(a1 - a2, b1 - b2), 0.0);
}

int main() {
  int n;
  cin >> n;
  double x1, y1, x2, y2, x3, y3, x4, y4;
  for (int i = 0; i < n; ++i) {
    cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3 >> x4 >> y4;
    P a(x1, y1), b(x2, y2), c(x3, y3), d(x4, y4);
    if (is_parallel(a, b, c, d)) {
      cout << "YES" << endl;
    } else {
      cout << "NO" << endl;
    }
  }
  return 0;
}

Error: 0
1 1
0.666667 -0.666667


Fixed submission:

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

#define REP(i, n) for (int i = 0; i < (n); ++i)
using namespace std;

int main() {

  int n;
  cin >> n;

  double x[4], y[4];
  REP(i, n) {
    REP(j, 4) cin >> x[j] >> y[j];
    cerr << (y[1] - y[0]) / (x[1] - x[0]) << " "
         << (y[3] - y[2]) / (x[3] - x[2]) << endl;
    if ((y[1] - y[0]) / (x[1] - x[0]) == (y[3] - y[2]) / (x[3] - x[2]))
      cout << "YES" << endl;
    else
      cout << "NO" << endl;
  }
}
Problem p00021 (C++) — buggy submission, verdict: Time Limit Exceeded

#define _USE_MATH_DEFINES
#include <algorithm>
#include <cfloat>
#include <cmath>
#include <cstdio>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <stack>
#include <string>
#include <vector>
using namespace std;

int main() {

  int n;
  cin >> n;
  float x1, y1, x2, y2, x3, y3, x4, y4;
  while (n > 0) {

    float a = 999999, b = 999999;
    cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3 >> x4 >> y4;

    if (x2 != x1) {
      a = (y2 - y1) / (x2 - x1);
    }
    if (x3 != x4) {
      b = (y4 - y3) / (x4 - x3);
    }

    if (a == b)
      cout << "YES" << endl;
    else
      cout << "NO" << endl;

    n--;
  }
}

Error: TLE

Fixed submission:

#define _USE_MATH_DEFINES
#include <algorithm>
#include <cfloat>
#include <cmath>
#include <cstdio>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <stack>
#include <string>
#include <vector>
using namespace std;

int main() {

  int n;
  cin >> n;
  double x1, y1, x2, y2, x3, y3, x4, y4;

  while (n > 0) {
    double a, b;
    cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3 >> x4 >> y4;

    a = (y2 - y1) / (x2 - x1);
    b = (y4 - y3) / (x4 - x3);

    if (a == b)
      cout << "YES" << endl;
    else
      cout << "NO" << endl;
  }
}
Problem p00021 (C++) — buggy submission, verdict: Runtime Error

#include <stdio.h>

int main(void) {
  int n, i;
  long double x1, y1, x2, y2, x3, y3, x4, y4;
  int ans[100];

  scanf("%d", &n);
  for (i = 0; i < n; i++) {
    scanf("%Lf %Lf %Lf %Lf %Lf %Lf %Lf %Lf", &x1, &y1, &x2, &y2, &x3, &y3, &x4,
          &y4);

    if ((y2 - y1) * (x4 - x3) == (y4 - y3) * (x2 - x1)) {
      ans[i] = 1;
    } else {
      ans[i] = 0;
    }
  }

  for (i = 0; i < n; i++) {
    if (ans[i] == 1) {
      printf("YES\\n");
    } else {
      printf("NO\\n");
    }
  }
  return 0;
}

Error: WA

Fixed submission:

#include <stdio.h>

int main(void) {
  long double x1, y1, x2, y2, x3, y3, x4, y4;
  int i, n;
  int ans[10];

  scanf("%d", &n);

  for (i = 0; i < n; i++) {
    scanf("%lf %lf %lf %lf %lf %lf %lf %lf", &x1, &y1, &x2, &y2, &x3, &y3, &x4,
          &y4);
    if ((y2 - y1) * (x4 - x3) == (y4 - y3) * (x2 - x1)) {
      ans[i] = 1;
    } else {
      ans[i] = 0;
    }
  }
  for (i = 0; i < n; i++) {
    if (ans[i] == 1) {
      printf("YES\\n");
    } else {
      printf("NO\\n");
    }
  }
  return 0;
}
Problem p00021 (C++) — buggy submission, verdict: Runtime Error

#include <iostream>

using namespace std;

int main() {
  double x1, y1, x2, y2, x3, y3, x4, y4;
  int n;
  cin >> n;
  while (n--) {
    cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3 >> x4 >> y4;
    if ((y2 - y1) / (x2 - x1) == (y4 - y3) / (x4 - x3))
      cout << "YES" << endl;
    else
      cout << "NO" << endl;
  }
  return 0;
}

Error: WA

Fixed submission:

#include <iostream>

using namespace std;

int main() {
  int a, b, c, d, e, f, g, h;
  int n;
  cin >> n;
  while (n--) {
    cin >> a >> b >> c >> d >> e >> f >> g >> h;
    if ((c - a) / (d - b) == (g - e) / (h - f))
      cout << "YES" << endl;
    else
      cout << "NO" << endl;
  }
  return 0;
}