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

#include <iostream>
using namespace std;

int main() {
  int a, b, c;
  int x = 0;
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a >> b >> c;
    if (a < b && c < b) {
      x = a;
      a = b;
      b = x;
    } else if (a < c && b < c) {
      x = a;
      a = c;
      c = x;
    }

    if ((b * b) + (c * c) == (a * a))
      cout << "YES" << endl;
    else
      cout << "NO" << endl;
  }
  return 0;
}

Error: TLE

Fixed submission:

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

  int a[100], b[100], c[100];
  int x = 0;
  int n;

  while (true) {
    cin >> n;

    if (n == 0)
      break;
    for (int i = 0; i < n; i++) {

      cin >> a[i] >> b[i] >> c[i];

      if (a[i] < b[i]) {
        x = a[i];
        a[i] = b[i];
        b[i] = x;
      }
      if (b[i] < c[i]) {
        x = b[i];
        b[i] = c[i];
        c[i] = x;
      }
      if (a[i] < b[i]) {
        x = a[i];
        a[i] = b[i];
        b[i] = x;
      }
      a[i] = a[i] * a[i];
      b[i] = b[i] * b[i];
      c[i] = c[i] * c[i];
    }
    for (int i = 0; i < n; i++) {

      if (a[i] == b[i] + c[i])
        cout << "YES" << endl;
      else
        cout << "NO" << endl;
    }
  }
  return 0;
}
Problem p00003 (C++) — buggy submission, verdict: Runtime Error

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

int main() {

  int size;
  cin >> size;

  struct triangle {
    int elm[3];

    bool isRightTriangle() {
      for (int x = 0; x < 3; x++) {
        for (int y = 0; y < 3; y++) {
          for (int z = 0; z < 3; z++) {
            if (x == z)
              continue;
            if (y == z)
              continue;
            if (elm[x] * elm[x] + elm[y] * elm[y] == elm[z] * elm[z])
              return true;
          }
        }
      }
      return false;
    }
  };

  triangle *ary = new triangle[size];

  for (int i = 0; i < size; i++) {
    cin >> ary[i].elm[0] >> ary[i].elm[1] >> ary[i].elm[2];
  }

  for (int i = 0; i < size; i++) {
    cout << (ary[i].isRightTriangle() ? "YES" : "NO") << endl;
  }

  delete[] ary;

  return 0;
}

Error: WA

Fixed submission:

#include <iostream>
using namespace std;

int main() {

  int size;
  cin >> size;

  struct triangle {
    int elm[3];

    bool isRightTriangle() {
      for (int y = 0; y < 3; y++) {
        for (int x = 0; x < 3; x++) {
          if (y == x)
            continue;
          if (elm[x] != 0 && elm[y] / elm[x] == 2) {
            return true;
          }
        }
      }
      return false;
    }
  };

  triangle *ary = new triangle[3];

  for (int i = 0; i < size; i++) {
    cin >> ary[i].elm[0] >> ary[i].elm[1] >> ary[i].elm[2];
  }

  for (int i = 0; i < size; i++) {
    cout << (ary[i].isRightTriangle() ? "YES" : "NO") << endl;
  }

  delete[] ary;

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

#include <iostream>
int main() {
  int a, b, c, n, i;
  std::cin >> n;
  for (i = 0; i < n; i++) {
    std::cin >> a >> b >> c;
    if (a * a == b * b + c * c)
      std::cout << "YES" << std::endl;
    else if (b * b == a * a + c * c)
      std::cout << "YES" << std::endl;
    else if (c * c == a * a + b * b)
      std::cout << "YES" << std::endl;
    else
      std::cout << "NO" << std::endl;
  }
  return 0;
}

Error: TLE

Fixed submission:

#include <iostream>
int main() {
  int a, b, c, n, i;
  std::cin >> n;
  for (i = 0; i = n; i++) {
    std::cin >> a >> b >> c;
    if (a * a == b * b + c * c)
      std::cout << "YES" << std::endl;
    else if (b * b == a * a + c * c)
      std::cout << "YES" << std::endl;
    else if (c * c == a * a + b * b)
      std::cout << "YES" << std::endl;
    else
      std::cout << "NO" << std::endl;
  }
  return 0;
}
Problem p00003 (C++) — buggy submission, verdict: Runtime Error

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

using namespace std;

int main() {
  int input[3];
  int N;

  cin >> N;

  for (int i = 0; i < N; i++) {
    cin >> input[0] >> input[1] >> input[2];
    sort(input, input + 3);
    cout << ((input[2] == sqrt(pow(input[1], 2) + pow(input[0], 2))) ? "YES"
                                                                     : "NO")
         << endl;
  }
  return 0;
}

Error: 0

Fixed submission:

#include "string"
#include <iostream>
#include <math.h>
#include <stdlib.h>

using namespace std;

int main() {
  int a, b, c;
  int N;
  string *str;

  cin >> N;

  str = (string *)malloc(sizeof(string) * N);

  for (int i = 0; i < N; i++) {
    cin >> a >> b >> c;
    if (c == sqrt((pow((double)a, (double)2) + pow((double)b, (double)2))))
      str[i] = "YES";
    else
      str[i] = "NO";
  }

  for (int i = 0; i < N; i++)
    cout << str[i] << endl;

  free(str);

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

#include <algorithm>
#include <stdio.h>
using namespace std;
int main() {
  int N, i;
  int count = 0;
  int a[3];
  scanf("%d ", &N);
  while (count != N) {
    for (i = 0; i < 3; i++) {
      scanf("%d ", &a[i]);
    }
    sort(a, a + 3);
    if (a[2] * a[2] == a[0] * a[0] + a[1] * a[1]) {
      printf("YES\\n");
      count++;
    } else {
      printf("NO\\n");
      count++;
    }
  }
  return 0;
}

Error: -11

Fixed submission:

#include <algorithm>
#include <stdio.h>
using namespace std;
int main() {
  int N;
  int count = 0;
  int a[3];
  scanf("%d ", &N);
  while (count != N) {
    for (int i = 0; i < 3; i++) {
      scanf("%d ", a[i]);
    }
    sort(a, a + 3);
    if (a[2] < (a[0] + a[1])) {
      printf("YES");
      count++;
    } else {
      printf("NO");
      count++;
    }
  }
  return 0;
}
Problem p00003 (C++) — buggy submission, verdict: Runtime Error

#include <cstdio>

int i, a, b, c;
int main() {
  scanf("%d", &i);
  while (i != 0) {
    scanf("%d %d %d", &a, &b, &c);

    if (a * a + b * b == c * c || b * b + c * c == a * a ||
        c * c + a * a == b * b) {
      printf("YES\\n");
    } else
      printf("NO\\n");
    i--;
  }

  return 0;
}

Error: -11

Fixed submission:

#include <cstdio>

int i, a, b, c;
int main() {
  scanf("%d", i);
  while (i != 0) {
    scanf("%d %d %d", a, b, c);

    if (a + b > c && b + c > a && c + a > b) {
      printf("YES\\n");
    } else if (c >= a + b || b + c >= a || c + a >= b) {
      printf("NO\\n");
    }
    i--;
  }

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

//
//  main.cpp
//  Sample
//
//  Created by h3037183 on 2017/07/31.
//  Copyright ?? 2017??´ ?°????. All rights reserved.
//

#include <iostream>
using namespace std;
int main() {
  int a, b, c, i;
  cin >> i;
  for (int n = 0; n < i; n++) {
    cin >> a >> b >> c;
    if (a * a == b * b + c * c) {
      cout << "YES" << endl;
    } else if (b * b == a * a + c * c) {
      cout << "YES" << endl;
    } else if (c * c == b * b + a * a) {
      cout << "YES" << endl;
    } else {
      cout << "NO" << endl;
    }
  }
  return 0;
}

Error: TLE

Fixed submission:

//
//  main.cpp
//  Sample
//
//  Created by h3037183 on 2017/07/31.
//  Copyright ?? 2017??´ ?°????. All rights reserved.
//

#include <iostream>
using namespace std;
int main() {
  int a, b, c;
  for (;;) {
    cin >> a >> b >> c;
  }
  if ((a * a) + (b * b) == (c * c)) {
    cout << "YES";
  } else if ((a * a) + (b * b) != (c * c)) {
    cout << "NO";
  } else if ((a * a) + (c * c) == (b * b)) {
    cout << "YES";
  } else if ((a * a) + (c * c) != (b * b)) {
    cout << "NO";
  } else if ((c * c) + (b * b) == (a * a)) {
    cout << "YES";
  } else if ((c * c) + (b * b) != (a * a)) {
    cout << "NO";
  }

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

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

static const int DataMax = 1000; // Max value of elements

typedef struct _triangle {
  int count; // Number of elements
  std::vector<int> vec[DataMax];
} triangle_t;

static void inputData(triangle_t &data, int &num) {
  int v1, v2, v3;

  if (0x00 == &data) {
    std::cerr << "data is null" << std::endl;
    return;
  }

  std::cin >> num;
  for (int i = 0; i < num; i++) {
    std::cin >> v1 >> v2 >> v3;
    data.vec[data.count].push_back(v1);
    data.vec[data.count].push_back(v2);
    data.vec[data.count].push_back(v3);
    data.count++;
  }
}

static bool isRightTriangle(std::vector<int> &vec) {
  if (0x00 == &vec) {
    std::cerr << "vec is null" << std::endl;
    return false;
  }

  if ((int)pow((double)vec.at(0), 2.0) + (int)pow((double)vec.at(1), 2.0) ==
      (int)pow((double)vec.at(2), 2.0)) {
    return true;
  } else if ((int)pow((double)vec.at(1), 2.0) +
                 (int)pow((double)vec.at(2), 2.0) ==
             (int)pow((double)vec.at(0), 2.0)) {
    return true;
  } else if ((int)pow((double)vec.at(0), 2.0) +
                 (int)pow((double)vec.at(2), 2.0) ==
             (int)pow((double)vec.at(1), 2.0)) {
    return true;
  }

  return false;
}

int main() {
  triangle_t triangle = {0};
  int num = 0;

  inputData(triangle, num);
  for (int i = 0; i < num; i++) {
    if (true == isRightTriangle(triangle.vec[i])) {
      std::cout << "YES" << std::endl;
    } else {
      std::cout << "NO" << std::endl;
    }
  }

  return 0;
}

Error: 0

Fixed submission:

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

static const int DataMax = 200; // Max value of elements

typedef struct _triangle {
  int count; // Number of elements
  std::vector<int> vec[DataMax];
} triangle_t;

static void inputData(triangle_t &data, int &num) {
  int v1, v2, v3;

  if (0x00 == &data) {
    std::cerr << "data is null" << std::endl;
    return;
  }

  std::cin >> num;
  for (int i = 0; i < num; i++) {
    std::cin >> v1 >> v2 >> v3;
    data.vec[data.count].push_back(v1);
    data.vec[data.count].push_back(v2);
    data.vec[data.count].push_back(v3);
    data.count++;
  }
}

static bool isRightTriangle(std::vector<int> &vec) {
  if (0x00 == &vec) {
    std::cerr << "vec is null" << std::endl;
    return false;
  }

  if ((int)pow((double)vec.at(0), 2.0) + (int)pow((double)vec.at(1), 2.0) ==
      (int)pow((double)vec.at(2), 2.0)) {
    return true;
  }

  return false;
}

int main() {
  triangle_t triangle = {0};
  int num = 0;

  inputData(triangle, num);
  for (int i = 0; i < num; i++) {
    if (true == isRightTriangle(triangle.vec[i])) {
      std::cout << "YES" << std::endl;
    } else {
      std::cout << "NO" << std::endl;
    }
  }

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

#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, a, b, c;
  cin >> n;
  long long tmp[3];
  for (int i = 0; i < n; i++) {
    cin >> a >> b >> c;
    tmp[0] = a;
    tmp[1] = b;
    tmp[2] = c;
    sort(tmp, tmp + 3);
    if (tmp[0] * tmp[0] + tmp[1] * tmp[1] == tmp[2] * tmp[2]) {
      cout << "YES" << endl;
    } else {
      cout << "NO" << endl;
    }
  }
  return 0;
}


Error: 0

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, a, b, c;
  cin >> n;
  long long tmp[3];
  for (int i = 0; i < n; i++) {
    cin >> a >> b >> c;
    tmp[0] = a;
    tmp[1] = b;
    tmp[2] = c;
    sort(tmp, tmp + n);
    if (tmp[0] * tmp[0] + tmp[1] * tmp[1] == tmp[2] * tmp[2]) {
      cout << "YES" << endl;
    } else {
      cout << "NO" << endl;
    }
  }
  return 0;
}
Problem p00003 (C++) — buggy submission, verdict: Runtime Error


#include <algorithm>
#include <iostream>
#include <queue>
using namespace std;
/*
int main()
{
        int n, a, b, c;
        cin >> n;
        for (int i = 0; i < n; i++) {
                cin >> a >> b >> c;
                int m = max(a, max(b, c));
                int l = min(a, b);
                int n = min(b, c);
                if (l == n) {
                        n = min(a, c);
                }
                if (m*m == n*n + l*l) {
                        cout << "YES" << endl;
                }
                else {
                        cout << "NO" << endl;
                }
        }
    return 0;
}

*/
int main() {
  priority_queue<int> pq;
  int n, a;
  cin >> n;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < 3; j++) {
      cin >> a;
      pq.push(a);
    }
    int a, b, c;
    a = pq.top();
    pq.pop();
    b = pq.top();
    pq.pop();
    c = pq.top();
    pq.pop();
    cout << (a * a == b * b + c * c ? "YES" : "NO") << endl;
  }
  return 0;
}

Error: -6
munmap_chunk(): invalid pointer


Fixed submission:

#include <algorithm>
#include <iostream>
#include <queue>
using namespace std;
/*
int main()
{
        int n, a, b, c;
        cin >> n;
        for (int i = 0; i < n; i++) {
                cin >> a >> b >> c;
                int m = max(a, max(b, c));
                int l = min(a, b);
                int n = min(b, c);
                if (l == n) {
                        n = min(a, c);
                }
                if (m*m == n*n + l*l) {
                        cout << "YES" << endl;
                }
                else {
                        cout << "NO" << endl;
                }
        }
    return 0;
}

*/
int main() {
  priority_queue<int> pq;
  int n, a;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a;
    pq.push(a);

    int a, b, c;
    a = pq.top();
    pq.pop();
    b = pq.top();
    pq.pop();
    c = pq.top();
    pq.pop();
    cout << (a * a == b * b + c * c ? "YES" : "NO") << endl;
  }
  return 0;
}
Problem p00003 (C++) — buggy submission, verdict: Runtime Error

#include <iostream>
using namespace std;
int main() {
  int a[10000], b[10000], c[10000], n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a[i] >> b[i] >> c[i];
    a[i] *= a[i];
    b[i] *= b[i];
    c[i] *= c[i];
  }
  for (int i = 0; i < n; i++) {
    if (a[i] + b[i] == c[i] || a[i] + c[i] == b[i] || b[i] + c[i] == a[i]) {
      cout << "YES" << endl;
    } else {
      cout << "NO" << endl;
    }
  }
  return (0);
}


Error: 0

Fixed submission:

#include <iostream>
using namespace std;
int main() {
  int a[100], b[100], c[100], n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a[i] >> b[i] >> c[i];
    a[i] *= a[i];
    b[i] *= b[i];
    c[i] *= c[i];
  }
  for (int i = 0; i < n; i++) {
    if (a[i] + b[i] == c[i] || a[i] + c[i] == b[i] || b[i] + c[i] == a[i]) {
      cout << "YES" << endl;
    } else {
      cout << "NO" << endl;
    }
  }
  return (0);
}
Problem p00003 (C++) — buggy submission, verdict: Runtime Error

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

int ary[1010][3];
int main() {
  priority_queue<int> que;
  int N;
  cin >> N;
  int a;
  for (int i = 1; i <= N; i++) {
    for (int j = 0; j <= 2; j++) {
      cin >> a;
      que.push(a);
    }
    for (int j = 0; j <= 2; j++) {
      ary[i][j] = que.top();
      que.pop();
    }
  }
  for (int i = 1; i <= N; i++) {
    if (ary[i][0] * ary[i][0] ==
        ary[i][1] * ary[i][1] + ary[i][2] * ary[i][2]) {
      cout << "YES" << endl;
    } else {
      cout << "NO" << endl;
    }
  }
  return 0;
}

Error: 0

Fixed submission:

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

int ary[3][1010];
int main() {
  priority_queue<int> que;
  int N;
  cin >> N;
  int a;
  for (int i = 1; i <= N; i++) {
    for (int j = 0; j <= 2; j++) {
      cin >> a;
      que.push(a);
    }
    for (int j = 0; j <= 2; j++) {
      ary[i][j] = que.top();
      que.pop();
    }
  }
  for (int i = 1; i <= N; i++) {
    if (ary[i][0] * ary[i][0] ==
        ary[i][1] * ary[i][1] + ary[i][2] * ary[i][2]) {
      cout << "YES" << endl;
    } else {
      cout << "NO" << endl;
    }
  }
  return 0;
}
Problem p00003 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>

using namespace std;

void swap(int *x, int *y) {
  int temp;
  temp = *x;
  *x = *y;
  *y = temp;
}

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

  cin >> n;

  for (int i = 0; i < n; i++) {
    cin >> a >> b >> c;

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

    if (a * a + b * b == c * c) {
      cout << "YES" << endl;
    } else {
      cout << "NO" << endl;
    }
  }

  return 0;
}

Error: TLE

Fixed submission:

#include <iostream>

using namespace std;

void swap(int x, int y) {
  int temp;
  temp = x;
  x = y;
  y = temp;
}

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

  cin >> n;
  while (1) {
    cin >> a >> b >> c;

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

    if (a * a + b * b == c * c) {
      cout << "YES" << endl;
    } else {
      cout << "NO" << endl;
    }
  }

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

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

// 0003
int main() {
  int n;
  int a, b, c, a2, b2, c2;
  cin >> n;
  while (n--) {
    cin >> a >> b >> c;
    a2 = a * a;
    b2 = b * b;
    c2 = c * c;

    if (a == b && b == c) {
      cout << "NO" << endl;
      continue;
    }
    if (a2 == b2 + c2 || b2 == a2 + c2 || c2 == a2 + b2) {
      cout << "YES" << endl;
    } else {
      cout << "NO" << endl;
    }
  }
  return 0;
}

Error: TLE

Fixed submission:

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

// 0003
int main() {
  int n;
  int a, b, c, a2, b2, c2;
  while (--n) {
    cin >> a >> b >> c;
    a2 = a ^ 2;
    b2 = b ^ 2;
    c2 = c ^ 2;

    if (a == b == c)
      cout << "NO" << endl;
    if (a2 == b2 + c2 || b2 == a2 + c2 || c2 == a2 + b2) {
      cout << "YES" << endl;
    } else {
      cout << "NO" << endl;
    }
  }
  return 0;
}
Problem p00003 (C++) — buggy submission, verdict: Time Limit Exceeded

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

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

  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    int a[3];
    for (int j = 0; j < 3; j++)
      scanf("%d", &a[j]);
    std::sort(a, a + 3);

    if (a[0] == 3 && a[1] == 4 && a[2] == 5)
      puts("YES");
    else if (a[0] * a[0] + a[1] * a[1] == a[2] * a[2])
      puts("YES");
    else
      puts("NO");
  }
}

Error: TLE

Fixed submission:

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

#define add push_back
#define inf 2147000000

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

using namespace std;

int main(void) {
  int a, b;

  while (scanf("%d%d", &a, &b)) {

    a += b;
    int i = 0;
    for (i = 0; a >= 10; i++) {
      a /= 10;
    }

    cout << i + 1 << endl;
  }
}
Problem p00003 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>

using namespace std;
bool TestPythagoras(int a, int b, int c) {
  if (a * a == b * b + c * c)
    return true;
  else
    return false;
}

int main() {
  int x, y, z;
  int test;
  cin >> test;
  for (int loop = 0; loop < test; loop++) {
    cin >> x >> y >> z;
    if (TestPythagoras(x, y, z) || TestPythagoras(y, x, z) ||
        TestPythagoras(z, x, y))
      cout << "YES" << endl;
    else
      cout << "NO" << endl;
  }
}

Error: TLE

Fixed submission:

#include <iostream>

using namespace std;
int loop;
int panjang[1000][1000];
int y = 0;
int temp = 0;
int main() {
  cin >> loop;
  for (int x = 0; x < loop; x++) {
    cin >> panjang[x][y] >> panjang[x][y + 1] >> panjang[x][y + 2];
  }
  for (int looper = 0; looper < loop; looper++) {
    for (int looper2 = 0; looper2 < 4; looper2++) {
      if ((panjang[looper][y + 1]) < (panjang[looper][y + 2])) {
        temp = panjang[looper][y + 1];
        panjang[looper][y + 1] = panjang[looper][y + 2];
        panjang[looper][y + 2] = temp;
        temp = 0;
        if ((panjang[looper][y]) < (panjang[looper][y + 1])) {
          temp = panjang[looper][y];
          panjang[looper][y] = panjang[looper][y + 1];
          panjang[looper][y + 1] = temp;
          temp = 0;
        }
      }
    }

    for (int pyth = 0; pyth < loop; pyth++) {
      if (panjang[pyth][y] * panjang[pyth][y] ==
          panjang[pyth][y + 1] * panjang[pyth][y + 1] +
              panjang[pyth][y + 2] * panjang[pyth][y + 2])
        cout << "YES" << endl;
      else
        cout << "NO" << endl;
    }
  }
}
Problem p00003 (C++) — buggy submission, verdict: Runtime Error

#include <algorithm>
#include <iostream>
#include <math.h>
using namespace std;
#define MAX_N 1000
int A[3];        // 三辺の長さの情報
bool Tri[MAX_N]; // その三角形が直角三角形かどうか
int N;           // データの個数

int main() {
  scanf("%d", &N);
  for (int j = 0; j < N; j++) {
    for (int i = 0; i < 3; i++) {
      cin >> A[i];
    }
    sort(A, A + 3);
    Tri[j] = false;
    if (pow(A[2], 2) == pow(A[1], 2) + pow(A[0], 2)) {
      Tri[j] = true;
    }
    if (Tri[j])
      cout << "YES" << endl;
    else
      cout << "NO" << endl;
  }
  return 0;
}

Error: 0

Fixed submission:

#include <algorithm>
#include <iostream>

using namespace std;
#define MAX_N 1000
int A[3];        // 三辺の長さの情報
bool Tri[MAX_N]; // その三角形が直角三角形かどうか
int N;           // データの個数

int main() {
  scanf("%d", &N);
  for (int j = 0; j < N; j++) {
    for (int i = 0; i < 3; i++) {
      cin >> A[i];
    }
    sort(A, A + N);
    Tri[j] = false;
    if (A[2] * A[2] == A[1] * A[1] + A[0] * A[0] && A[0] != 0) {
      Tri[j] = true;
    }
    if (Tri[j])
      cout << "YES" << endl;
    else
      cout << "NO" << endl;
  }
  return 0;
}
Problem p00003 (C++) — buggy submission, verdict: Runtime Error

#include <iostream>
using namespace std;
bool RightAngle(int a, int b, int c) {
  if ((a * a + b * b == c * c || a * a + c * c == b * b) ||
      b * b + c * c == a * a)
    return true;
  else
    return false;
}
int main() {
  int a, b, c, n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a >> b >> c;
    if (RightAngle(a, b, c))
      cout << "YES\\n";
    else
      cout << "NO\\n";
  }
}

Error: WA

Fixed submission:

#include <iostream>
using namespace std;

int main() {
  int a, b, c[4], d;
  cin >> a;
  for (b = 1; b <= a; b++) {
    for (d = 1; d <= 3; d++)
      cin >> c[b];
    if (c[1] * c[1] == c[2] * c[2] + c[3] * c[3] ||
        c[2] * c[2] == c[1] * c[1] + c[3] * c[3] ||
        c[3] * c[3] == c[2] * c[2] + c[1] * c[1])
      cout << "YES" << endl;
    else
      cout << "NO" << endl;
  }
  return 0;
}
Problem p00003 (C++) — buggy submission, verdict: Runtime Error

#include <iostream>
using namespace std;
int main() {
  long long int a, b, c, f, t;
  cin >> t;
  while (t--) {
    f = 0;
    cin >> a >> b >> c;
    if (a > b && a > c) {
      if ((b * b) + (c * c) == (a * a))
        f = 1;
    } else if (b > a && b > c) {
      if ((a * a) + (c * c) == (b * b))
        f = 1;
    } else if (c > b && c > a) {
      if ((b * b) + (a * a) == (c * c))
        f = 1;
    }
    if (f == 1)
      cout << "YES" << endl;
    else
      cout << "NO" << endl;
  }
}

Error: -11

Fixed submission:

#include <stdio.h>

int main() {
  int n, a, b, c;
  scanf("%d", &n);
  while (n--) {
    scanf("%d %d %d", a, b, c);
    if ((a * a == b * b + c * c) || (b * b == a * a + c * c) ||
        (c * c == a * a + b * b))
      printf("YES\\n");
    else
      printf("NO\\n");
  }

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

#include <algorithm>
#include <cmath>
#include <cstdio>

using namespace std;

int main() {
  int t, a[3];
  scanf("%d", &t);
  while (t--) {
    scanf("%d%d%d", &a[0], &a[1], &a[2]);
    sort(a, a + 3);
    if (a[2] * a[2] == a[0] * a[0] + a[1] * a[1])
      printf("YES\\n");
    else
      printf("NO\\n");
  }

  return 0;
}

Error: TLE

Fixed submission:

#include <math.h>
#include <stdio.h>
#include <stdlib.h>
int main() {
  long a, b, c;
  int n;
  while (scanf("%d", &n)) {
    for (int i = 0; i < n; i++) {
      scanf("%ld %ld %ld", &a, &b, &c);
      if (abs(a * a - b * b) == c * c || a * a + b * b == c * c) {
        printf("YES\\n");
      } else {
        printf("NO\\n");
      }
    }
  }
  return 0;
}