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

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

int main(void) {
  // prime numbers table
  vector<bool> isPrime(60000 + 1, false);
  isPrime[2] = true;
  for (int i = 3; i < 60000; i += 2) {
    isPrime[i] = true;
  }

  for (int i = 3; i < 60000; i += 2) {
    for (int j = i + i; j < 60000; j += i) {
      isPrime[j] = false;
    }
  }

  vector<int> primes;
  primes.push_back(2);
  for (int i = 3; i < 60000; i += 2) {
    if (isPrime[i])
      primes.push_back(i);
  }

  int n;
  while (cin >> n && n != 0) {
    int kotae = 0;
    for (int i = 0; i < primes.size(); i++) {
      if (primes[i] <= n / 2) {
        if (isPrime.at(n - primes[i]))
          kotae++;
      }
    }
    cout << kotae << endl;
  }
}

Error: TLE

Fixed submission:

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

int main(void) {
  // prime numbers table
  vector<bool> isPrime(110000, false);
  isPrime[2] = true;
  for (int i = 3; i < 110000; i += 2) {
    isPrime[i] = true;
  }

  for (int i = 3; i < 110000; i += 2) {
    for (int j = i + i; j <= 110000; j += i) {
      isPrime[j] = false;
    }
  }

  vector<int> primes;
  for (int i = 3; i < 110000; i += 2) {
    if (isPrime[i])
      primes.push_back(i);
  }

  cout << primes.size() << endl;

  int n;
  while (cin >> n && n != 0) {
    int kotae = 0;
    if (n % 2 == 0) {
      for (int i = 0; i < primes.size(); i++) {
        if (primes[i] > (n / 2))
          break;
        for (int j = i; j < primes.size(); j++) {
          int sum = primes[i] + primes[j];
          if (sum > n)
            break;
          else if (sum == n)
            kotae++;
        }
      }
    }
    cout << kotae << endl;
  }
}
Problem p00056 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <cmath>
#include <iostream>
#include <vector>

using namespace std;

int main() {

  int n;

  int not_prime[51000];
  int ans;

  int idx;

  not_prime[0] = not_prime[1] = 1;

  for (int i = 2; i <= 50000; i++)
    not_prime[i] = 0;

  for (int i = 2; i <= sqrt(50000); i++) {

    if (not_prime[i] == 0) {

      for (int j = 2 * i; j <= 50000; j += i) {

        not_prime[j] = 1;
      }
    }
  }

  // for(int i=0;i<=50000;i++) cout << not_prime[i] << " ";

  while (1) {

    cin >> n;

    if (n == 0)
      break;

    ans = 0;

    for (int i = 2; i <= n / 2; i++) {

      if (not_prime[i] == 0 && not_prime[n - i] == 0)
        ans++;
    }

    cout << ans << endl;
  }

  return 0;
}


Error: TLE

Fixed submission:

#include <cmath>
#include <iostream>
#include <vector>

using namespace std;

int main() {

  int n;

  int prime[51000];
  int not_prime[51000];
  int ans;

  int idx;

  not_prime[0] = not_prime[1] = 1;

  for (int i = 2; i <= 50000; i++)
    not_prime[i] = 0;

  for (int i = 2; i <= sqrt(50000); i++) {

    if (not_prime[i] == 0) {

      for (int j = 2 * i; j <= 50000; j += i) {

        not_prime[j] = 1;
      }
    }
  }

  // for(int i=0;i<=50000;i++) cout << not_prime[i] << " ";

  idx = 0;

  for (int i = 0; i <= 50000; i++) {

    if (not_prime[i] == 0) {

      prime[idx] = i;
      idx++;
    }
  }

  for (int i = 0; i < idx; i++)
    cout << prime[i] << " ";

  while (1) {

    cin >> n;

    if (n == 0)
      break;

    ans = 0;

    for (int i = 0; i < idx; i++) {

      int temp = n - prime[i];

      for (int j = i; i <= j && j < idx; j++) {

        if (temp == prime[j])
          ans++;
      }
    }

    cout << ans << endl;
  }

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

#include <iostream>

using namespace std;

int main() {

  int *data;
  data = new int[50001];

  data[0] = 0;
  data[1] = 0;
  data[2] = 1;
  data[3] = 1;

  for (int i = 3; i <= 50000; i++) {
    int flag = 0;
    for (int j = 3; j * j <= i; j += 2) {
      if (i % j == 0) {
        flag = 1;
        break;
      }
    }
    if (flag == 1) {
      data[i] = 0;
    } else {
      data[i] = 1;
    }
  }

  int n;
  while (1) {
    cin >> n;
    if (n == 0)
      break;
    if (n <= 3) {
      cout << 0 << endl;
      continue;
    } else if (n % 2 == 1) {
      if (data[n - 2] == 1) {
        cout << 1 << endl;
      } else {
        cout << 0 << endl;
      }
      continue;
    } else if (n == 4) {
      cout << 1 << endl;
    } else {
      int cnt = 0;
      for (int i = 3; i <= n / 2; i += 2) {
        if (data[i] == 1 && data[n - i] == 1) {
          //	cout<<i<<" "<<n-i<<endl;
          cnt++;
        }
      }
      cout << cnt << endl;
    }
  }
  return 0;
}

Error: TLE

Fixed submission:

#include <iostream>

using namespace std;

int main() {

  int *data;
  data = new int[50001];

  data[0] = 0;
  data[1] = 0;
  data[2] = 1;
  data[3] = 1;

  for (int i = 3; i <= 50000; i++) {
    int flag = 0;
    for (int j = 3; j * j <= i; j += 2) {
      if (i % j == 0) {
        flag = 1;
        break;
      }
    }
    if (flag == 1) {
      data[i] = 0;
    } else {
      data[i] = 1;
    }
  }

  int n;
  while (1) {
    cin >> n;
    if (n == 0)
      break;
    if (n <= 3) {
      cout << 0 << endl;
      continue;
    } else if (n % 2 == 1) {
      if (data[n - 2] == 1) {
        cout << 1 << endl;
      } else {
        cout << 0 << endl;
      }
      continue;
    } else if (n == 4) {
      cout << 1 << endl;
    } else {
      int cnt = 0;
      for (int i = 3; i <= n / 2; i += 2) {
        if (data[i] == 1 && data[n - i] == 1) {
          cout << i << " " << n - i << endl;
          cnt++;
        }
      }
      cout << cnt << endl;
    }
  }
  return 0;
}
Problem p00056 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>
using namespace std;

int main(void) {
  long long sosu[50001], i, j, n;

  sosu[0] = 1;
  sosu[1] = 1;

  for (i = 2; i < 50001; i++)
    sosu[i] = 0;

  for (i = 2; i < 50001; i++) {
    if (sosu[i] == 0) {
      for (j = i * i; j < 50001; j += i)
        sosu[j] = 1;
    }
  }

  while (1) {
    int count = 0;
    cin >> n;
    if (n == 0)
      break;

    for (i = 0; i < n / 2 + 1; i++) {
      if (sosu[i] == 0 && sosu[n - i] == 0)
        count++;
    }

    /*   for(i=0;i<n;i++){
      for(j=0;j<n/2+1;j++){
        if(sosu[i]==0&&sosu[j]==0&&n==i+j)count++;
      }
      }*/
    cout << count << endl;
  }
  return 0;
}

Error: TLE

Fixed submission:

#include <iostream>
using namespace std;

int main(void) {
  long long sosu[50001], i, j, n;

  sosu[0] = 1;
  sosu[1] = 1;

  for (i = 2; i < 50001; i++)
    sosu[i] = 0;

  for (i = 2; i < 50001; i++) {
    if (sosu[i] == 0) {
      for (j = i * i; j < 50001; j += i)
        sosu[j] = 1;
    }
  }

  while (1) {
    int count = 0;
    cin >> n;
    if (n == 0)
      break;

    for (i = 0; i < n; i++) {
      for (j = 0; j < n / 2 + 1; j++) {
        if (sosu[i] == 0 && sosu[j] == 0 && n == i + j)
          count++;
      }
    }
    cout << count << endl;
  }
  return 0;
}
Problem p00056 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <stdio.h>
int main() {
  int n, now = 1, a[10000], ans;
  bool prime[60000], f;
  a[0] = 2;
  for (int i = 3; i < 60000; i += 2) {
    prime[i] = true;
  }
  for (int i = 3; i <= 60000; i += 2) {
    if (prime[i]) {
      a[now] = i;
      now++;
      if ((long long)i * i < 60000) {
        for (int j = i * i; j < 60000; j += i) {
          prime[j] = false;
        }
      }
    }
  }
  while (1) {
    scanf("%d", &n);
    if (n == 0)
      return 0;
    ans = now = 0;
    if (n % 2 == 1) {
      f = true;
      n -= 2;
      for (int i = 0; a[i] <= n && f; i++) {
        if (a[i] == n) {
          printf("1\\n");
          f = false;
        }
      }
      if (f)
        printf("0\\n");
    } else {
      while (a[now] <= n)
        now++;
      now--;
      for (int i = 0; i <= now; i++) {
        while (a[i] + a[now] > n)
          now--;
        if (i > now)
          continue;
        for (int j = i; a[j] + a[now] <= n && j <= now; j++) {
          if (a[j] + a[now] == n) {
            ans++;
            now--;
            break;
          }
        }
      }
      printf("%d\\n", ans);
    }
  }
}

Error: TLE

Fixed submission:

#include <stdio.h>
int main() {
  int n, now = 1, a[10000], ans;
  bool prime[50000], f;
  a[0] = 2;
  for (int i = 3; i < 50000; i += 2) {
    prime[i] = true;
  }
  for (int i = 3; i * i <= 50000; i += 2) {
    if (prime[i]) {
      a[now] = i;
      now++;
      if ((long long)i * i < 50000) {
        for (int j = i * i; j < 50000; j += i) {
          prime[j] = false;
        }
      }
    }
  }
  while (1) {
    scanf("%d", &n);
    if (n == 0)
      return 0;
    ans = now = 0;
    if (n % 2 == 1) {
      f = true;
      n -= 2;
      for (int i = 0; a[i] <= n && f; i++) {
        if (a[i] == n) {
          printf("1\\n");
          f = false;
        }
      }
      if (f)
        printf("0\\n");
    } else {
      while (a[now] <= n)
        now++;
      now--;
      for (int i = 0; i <= now; i++) {
        while (a[i] + a[now] > n)
          now--;
        if (i > now)
          continue;
        for (int j = i; a[j] + a[now] <= n && j <= now; j++) {
          if (a[j] + a[now] == n) {
            ans++;
            now--;
            break;
          }
        }
      }
      printf("%d\\n", ans);
    }
  }
}
Problem p00056 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <cstdio>
#include <vector>
using namespace std;

bool isprime[50010];
int ans[50010];

int main() {
  for (int i = 2; i <= 50000; i++) {
    isprime[i] = true;
  }
  for (int i = 2; i < 300; i++) {
    if (isprime[i]) {
      for (int j = i * i; j <= 50000; j += i) {
        isprime[j] = false;
      }
    }
  }

  vector<int> primes;
  for (int i = 2; i <= 50000; i++) {
    if (isprime[i])
      primes.push_back(i);
  }
  for (int i = 0; primes[i] <= 25000; i++) {
    for (int j = i; primes[i] + primes[j] <= 50000; j++) {
      ans[primes[i] + primes[j]]++;
    }
  }

  int n;
  while (scanf("%d", &n), n) {
    printf("%d\\n", ans[n]);
  }
  return 0;
}

Error: TLE

Fixed submission:

#include <iostream>
using namespace std;

void prime(int primal[5132]) {
  int count = 0;
  bool flag = true;
  for (int i = 2;; i++) {
    for (int j = 2; j < i / 2 + 1; j++) {
      if (i % j == 0) {
        flag = false;
        break;
      }
    }
    if (flag) {
      primal[count] = i;
      count++;
    } else {
      flag = true;
    }
    if (count == 5132) {
      return;
    }
  }
}

int main() {
  int n, primal[5132];
  prime(primal);
  while (cin >> n, n) {
    int count = 0;
    if (n % 2 == 1) {
      cout << 0 << endl;
      continue;
    }
    for (int i = 0; i < 2900; i++) {
      for (int j = i; j < 5132; j++) {
        if (n == primal[i] + primal[j]) {
          count++;
        }
      }
    }
    cout << count << endl;
  }
  return 0;
}
Problem p00056 (C++) — buggy submission, verdict: Runtime Error

#include <iostream>
#include <string.h>

using namespace std;

bool p[50001];
int cnt;
int n;

void prime() {

  for (int i = 2; i * i <= 50000; i++) {
    if (!p[i]) {
      for (int j = i * i; j <= 50000; j += i) {
        p[j] = true;
      }
    }
  }
  p[0] = p[1] = true;
}

int main(void) {

  prime();

  while (cin >> n && n) {
    cnt = 0;
    for (int i = 2; i <= n / 2; i++) {
      if (!p[i] && !p[n - i]) {
        cnt++;
      }
    }
    cout << cnt << endl;
  }

  return 0;
}

Error: 0

Fixed submission:

#include <iostream>
#include <string.h>

using namespace std;

bool p[5001];
int cnt;
int n;

void prime() {

  for (int i = 2; i * i <= 5000; i++) {
    if (!p[i]) {
      for (int j = i + i; j <= 5000; j += i) {
        p[j] = true;
      }
    }
  }
  p[0] = p[1] = true;
}

int main(void) {

  prime();

  while (cin >> n && n) {
    cnt = 0;
    for (int i = 2; i <= n / 2; i++) {
      if (!p[i] && !p[n - i] && i + n - i == n) {
        cnt++;
      }
    }
    cout << cnt << endl;
  }

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

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

#define rep(x, to) for (int x = 0; x < to; x++)
#define rep2(x, from, to) for (int x = from; x < to; x++)

using namespace std;

// 素数num以下のふるい
void sosuu(int num, vector<bool> &Find) {
  //	bool Find[num] ; // 探索リスト
  for (int i = 2; i <= num; i++) {
    //        Find[i] = true;
    if (i % 2 == 0)
      Find[i] = false;
  }
  for (int i = 2; i * i < num; i++) {
    if (Find[i] == false)
      continue; // すでに除いた数は飛ばす
    for (int j = i * 2; j < num; j += i) {
      if (Find[j])
        Find[j] = false;
    }
  }
  Find[2] = true;
}

int main(void) {

  int n;
  vector<bool> ssu(50100, true);
  sosuu(50100, ssu);
  vector<int> ss2;
  rep(i, 50100) if (ssu[i]) ss2.push_back(i);
  while (cin >> n) {
    if (cin.eof() || n == 0)
      break;
    int cnt = 0;
    int zx = min(n, (int)ss2.size());
    rep2(i, 2, zx) {
      if (ss2[i] > n - ss2[i])
        break;
      if (ssu[n - ss2[i]])
        cnt++;
    }
    cout << cnt << endl;
  }
  return 0;
}

Error: TLE

Fixed submission:

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

#define rep(x, to) for (int x = 0; x < to; x++)
#define rep2(x, from, to) for (int x = from; x < to; x++)

using namespace std;

// 素数num以下のふるい
void sosuu(int num, vector<bool> &Find) {
  //	bool Find[num] ; // 探索リスト
  for (int i = 2; i <= num; i++) {
    //        Find[i] = true;
    if (i % 2 == 0)
      Find[i] = false;
  }
  for (int i = 2; i * i < num; i++) {
    if (Find[i] == false)
      continue; // すでに除いた数は飛ばす
    for (int j = i * 2; j < num; j += i) {
      if (Find[j])
        Find[j] = false;
    }
  }
  Find[2] = true;
}

int main(void) {

  int n;
  vector<bool> ssu(50100, true);
  sosuu(50100, ssu);
  vector<int> ss2;
  rep(i, 50100) if (ssu[i]) ss2.push_back(i);
  while (cin >> n) {
    if (cin.eof())
      break;
    int cnt = 0;
    int zx = min(n, (int)ss2.size());
    rep2(i, 2, zx) {
      rep2(j, i, zx) if (ss2[i] + ss2[j] == n) {
        cnt++;
        break;
      }
    }
    cout << cnt << endl;
  }
  return 0;
}
Problem p00057 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <cstdio>
#include <iostream>
using namespace std;
int main() {
  int n;
  while (cin >> n) {
    printf("%d\\n", (1 + n * (n + 1) / 2));
  }
}

Error: TLE

Fixed submission:

#include <iostream>
using namespace std;
int main() {
  int n;
  while (cin >> n, n) {
    cout << 0.5 * n * (n + 1) << endl;
  }
}
Problem p00057 (C++) — buggy submission, verdict: Time Limit Exceeded

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

int main() {
  int n, x;

  while (cin >> n) {
    for (int i = 0; i < n; ++i) {
      if (i == 0) {
        x = 2;
      } else
        x += (1 + i);
    }
    cout << x << endl;
  }

  return 0;
}


Error: TLE

Fixed submission:

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

int main() {
  int n, x;

  while (true) {
    cin >> n;
    for (int i = 0; i < n; ++i) {
      x += (2 + i);
    }
  }

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

#include <iostream>
using namespace std;
int main() {
  int n, i, s;
  int a[10000];
  a[0] = 2;
  for (i = 1; i < 10000; i++) {
    a[i] = a[i - 1] + i + 1;
  }
  while (cin >> n) {
    cout << a[n - 1] << endl;
  }
  return 0;
}

Error: 0

Fixed submission:

#include <iostream>
using namespace std;
int main() {
  int n, i, s;
  int a[1000];
  a[0] = 2;
  for (i = 1; i < 1000; i++) {
    a[i] = a[i - 1] + i + 1;
  }
  while (cin >> n) {
    cout << a[n - 1] << endl;
  }
  return 0;
}
Problem p00057 (C++) — buggy submission, verdict: Runtime Error

#include <iostream>
#include <vector>

using namespace std;

typedef long long ll;

int main() {
  vector<ll> vec(10001);
  vec[0] = 1;
  for (int i = 1; i <= 10000; i++) {
    vec[i] = vec[i - 1] + i;
  }
  int n;
  while (cin >> n) {
    cout << vec[n] << endl;
  }
  return 0;
}
// int main(){
//      int n;
//      while(cin >> n){
//          cout << n*(n-1)/2 +1 << endl;
//      }
//      return 0;
// }

Error: -11

Fixed submission:

#include <iostream>
#include <vector>

using namespace std;

typedef long long ll;

int main() {
  vector<ll> vec;
  vec[0] = 1;
  for (int i = 1; i <= 10000; i++) {
    vec[i] = vec[i - 1] + i;
  }
  int n;
  while (cin >> n) {
    cout << vec[n] << endl;
  }
  return 0;
}
// int main(){
//      int n;
//      while(cin >> n){
//          cout << n*(n-1)/2 +1 << endl;
//      }
//      return 0;
// }
Problem p00057 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>

using namespace std;

int main() {
  int n;

  while (cin >> n) {

    int line[n + 1];
    line[0] = 1;

    for (int i = 1; i <= n; i++) {
      line[i] = line[i - 1] + i;
    }
    cout << line[n] << endl;
  }
  return 0;
}


Error: TLE

Fixed submission:

#include <bits/stdc++.h>

using namespace std;

int main() {
  int n;
  int ans = 0;

  while (1) {
    cin >> n;
    if (n == EOF)
      break;

    int line[n + 1];
    line[0] = 1;

    for (int i = 1; i <= n; i++) {
      line[i] = line[i - 1] + i;
    }
    cout << line[n] << endl;
  }
  return 0;
}
Problem p00057 (C++) — buggy submission, verdict: Time Limit Exceeded

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

using namespace std;

int keisan(int a) {
  if (a == 1) {
    return 2;
  } else {
    return a + keisan(a - 1);
  }
}

int main() {
  int n;
  while (cin >> n) {
    cout << keisan(n) << endl;
  }
  return 0;
}

Error: TLE

Fixed submission:

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

using namespace std;

int keisan(int a) {
  if (a == 1) {
    return 2;
  } else {
    return a + keisan(a - 1);
  }
}

int main() {
  int n;
  while (1) {
    cin >> n;
    cout << keisan(n) << endl;
  }
  return 0;
}
Problem p00057 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>

using namespace std;

int main(void) {
  while (1) {
    int n;
    if (!(cin >> n))
      break;
    cout << 1 + n * (n + 1) / 2 << endl;
  }
}

Error: TLE

Fixed submission:

#include <iostream>

using namespace std;

int main(void) {
  while (1) {
    int n;
    cin >> n;
    if (n == 0)
      break;
    cout << 1 + n * (n + 1) / 2 << endl;
  }
}
Problem p00057 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>

int heimen(int nn) {
  int a;
  a = ((nn * nn) + nn + 2) / 2;
  return a;
}
using namespace std;

int main() {
  int n, ans;
  while (cin >> n) {
    ans = heimen(n);
    cout << ans << endl;
  }
}

Error: TLE

Fixed submission:

#include <iostream>

int heimen(int nn) {
  int a;
  a = ((nn * nn) + nn + 2) / 2;
  return a;
}
using namespace std;

int main() {
  int n, ans;
  while (cin >> n, n) {
    ans = heimen(n);
    cout << ans << endl;
  }
}
Problem p00057 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <cstdio>
main() {
  int n;
  while (~scanf("%d", &n)) {
    printf("%d\\n", n * (n + 1) / 2 + 1);
  }
}

Error: TLE

Fixed submission:

#include <cstdio>
int main() {
  int n;
  while (scanf("%d", &n)) {
    printf("%d\\n", n * (n + 1) / 2 + 1);
  }
  return 0;
}
Problem p00057 (C++) — buggy submission, verdict: Runtime Error

#include <cstdio>

int main() {
  int n, a[10001];
  a[1] = 2;
  for (int i = 2; i <= 10000; i++) {
    a[i] = a[i - 1] + i;
  }

  while (~scanf("%d", &n)) {
    printf("%d\\n", a[n]);
  }
  return 0;
}

Error: 0

Fixed submission:

#include <cstdio>

int main() {
  int n, a[1001];
  a[1] = 2;
  for (int i = 2; i <= 1000; i++) {
    a[i] = a[i - 1] + i;
  }

  while (~scanf("%d", &n)) {
    printf("%d\\n", a[n]);
  }
  return 0;
}
Problem p00057 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
using namespace std;

int main() {

  int n;

  while (cin >> n) {
    int s = 1;

    for (int i = 1; i <= n; i++)
      s += i;

    cout << s << endl;
  }
}

Error: TLE

Fixed submission:

#include <cmath>
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
int aaa(int n) {
  if (n == 0)
    return 1;
  else if (n < 0)
    return 0;
  else
    return aaa(n - 1) + aaa(n - 2) + 1;
}

int main() {

  int n;

  while (cin >> n) {
    cout << aaa(n) << endl;
  }
}
Problem p00058 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <cstdio>

double point[4][2];

double p(double b) {

  if (0 > b)
    return -b;
  return b;
}

int main() {
  while (true) {
    for (int i = 0; i < 4; i++) {
      for (int j = 0; j < 2; j++) {
        if (scanf("%lf", &point[i][j]) == EOF)
          goto end;
      }
    }
    if (((point[0][0] - point[1][0]) * (point[2][0] - point[3][0]) ==
         -(point[2][1] - point[3][1]) * (point[0][1] - point[1][1])))
      printf("YES\\n");
    else
      printf("NO\\n");
  }
end:
  return 0;
}

Error: TLE

Fixed submission:

#include <cstdio>

double point[4][2];

double p(double b) {

  if (0 > b)
    return -b;
  return b;
}

int main() {
  while (true) {
    for (int i = 0; i < 4; i++) {
      for (int j = 0; j < 2; j++) {
        if (scanf("%lf", &point[i][j]) == EOF)
          break;
      }
    }
    if (((point[0][0] - point[1][0]) / (point[0][1] - point[1][1]) *
             (point[2][0] - point[3][0]) / (point[2][1] - point[3][1]) ==
         -1))
      printf("YES\\n");
    else
      printf("NO\\n");
  }
}
Problem p00058 (C++) — buggy submission, verdict: Runtime Error

#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;
int inf = 1e9;

int main() {

  vector<double> x(4);
  vector<double> y(4);
  while (cin >> x[0] >> y[0] >> x[1] >> y[1] >> x[2] >> y[2] >> x[3] >> y[3]) {
    double ax = x[1] - x[0];
    double ay = y[1] - y[0];
    double bx = x[3] - x[2];
    double by = y[3] - y[2];
    if (fabs(ax * bx + ay * by) < 1e-10) {
      cout << "YES" << endl;
    } else
      cout << "NO" << endl;
  }

  return 0;
}

// EOF

Error: 0
0
6
22.42
0


Fixed submission:

#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;
int inf = 1e9;

int main() {

  vector<double> x(4);
  vector<double> y(4);
  while (cin >> x[0] >> y[0] >> x[1] >> y[1] >> x[2] >> y[2] >> x[3] >> y[3]) {
    double ax = x[1] - x[0];
    double ay = y[1] - y[0];
    double bx = x[3] - x[2];
    double by = y[3] - y[2];
    cerr << ax * bx + ay * by << endl;
    if (ax * bx + ay * by < 1e-10) {
      cout << "YES" << endl;
    } else
      cout << "NO" << endl;
  }

  return 0;
}

// EOF
Problem p00058 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>

using namespace std;

const double EPS = 1e-12;

double abs_d(double x) { return (x < 0 ? -x : x); }

int main() {
  double x[4], y[4];
  while (cin >> x[0] >> y[0]) {
    for (int i = 1; i < 4; i++)
      cin >> x[i] >> y[i];

    double ab1 = x[1] - x[0];
    double ab2 = y[1] - y[0];
    double cd1 = x[3] - x[2];
    double cd2 = y[3] - y[2];
    double naiseki = ab1 * cd1 + ab2 * cd2;

    if (abs_d(naiseki) < EPS)
      cout << "YES"
           << "\\n";
    else
      cout << "NO"
           << "\\n";
  }

  return 0;
}

Error: TLE

Fixed submission:

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

const double EPS = 1e-7;
double x[4], y[4];

int main() {
  while (1) {
    cin >> x[0] >> y[0];
    for (int i = 1; i < 4; i++)
      cin >> x[i] >> y[i];

    double vab1 = x[0] - x[1];
    double vab2 = y[0] - y[1];
    double vcd1 = x[2] - x[3];
    double vcd2 = y[2] - y[3];

    if (abs(vab1 * vcd1 + vab2 * vcd2) < EPS)
      cout << "YES"
           << "\\n";
    else
      cout << "NO"
           << "\\n";
  }

  return 0;
}