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

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

using namespace std;

int main(int argc, char *argv[]) {
  double lhs, rhs;
  int al = 0;
  int ar = 0;
  int bl = 0;
  int br = 0;
  int cl = 0;
  int cr = 0;
  int dl = 0;
  int dr = 0;
  while (cin >> lhs >> rhs) {
    if (lhs >= 1.1)
      al++;
    if (rhs >= 1.1)
      ar++;
    if (1.1 > lhs && lhs >= 0.6)
      bl++;
    if (1.1 > rhs && rhs >= 0.6)
      br++;
    if (0.6 > lhs && lhs >= 0.2)
      cl++;
    if (0.6 > rhs && rhs >= 0.2)
      cr++;
    if (0.2 > lhs && lhs >= 0.1)
      dl++;
    if (0.2 > rhs && rhs >= 0.1)
      dr++;
  }
  cout << al << " " << ar << endl;
  cout << bl << " " << br << endl;
  cout << cl << " " << cr << endl;
  cout << dl << " " << dr << endl;
  return 0;
}


Error: TLE

Fixed submission:

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

using namespace std;

int main(int argc, char *argv[]) {
  double lhs, rhs;
  int al = 0;
  int ar = 0;
  int bl = 0;
  int br = 0;
  int cl = 0;
  int cr = 0;
  int dl = 0;
  int dr = 0;
  while (cin >> lhs >> rhs, lhs || rhs) {
    if (lhs >= 1.1)
      al++;
    if (rhs >= 1.1)
      ar++;
    if (1.1 > lhs && lhs >= 0.6)
      bl++;
    if (1.1 > rhs && rhs >= 0.6)
      br++;
    if (0.6 > lhs && lhs >= 0.2)
      cl++;
    if (0.6 > rhs && rhs >= 0.2)
      cr++;
    if (0.2 > lhs && lhs >= 0.1)
      dl++;
    if (0.2 > rhs && rhs >= 0.1)
      dr++;
  }
  cout << al << " " << ar << endl;
  cout << bl << " " << br << endl;
  cout << cl << " " << cr << endl;
  cout << dl << " " << dr << endl;
  return 0;
}
Problem p00149 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <cstdio>
int et[2][4] = {0};

void etest(int eangle, float epower) {
  if (epower >= 1.1) {
    et[eangle][0]++;
  } else if (epower >= 0.6 && epower < 1.1) {
    et[eangle][1]++;
  } else if (epower >= 0.2 && epower < 0.6) {
    et[eangle][2]++;
  } else {
    et[eangle][3]++;
  }
  return;
}

int main() {
  float l, r;
  while (~scanf("%f%f", &l, &r)) {
    etest(0, l), etest(1, r);
  }
  for (int i = 0; i < 4; i++) {
    printf("%d %d\\n", et[0][i], et[1][i]);
  }
  return 0;
}

Error: TLE

Fixed submission:

#include <cstdio>
int et[2][4] = {0};

void etest(int eangle, float epower) {
  if (epower >= 1.1) {
    et[eangle][0]++;
  } else if (epower >= 0.6 && epower < 1.1) {
    et[eangle][1]++;
  } else if (epower >= 0.2 && epower < 0.6) {
    et[eangle][2]++;
  } else {
    et[eangle][3]++;
  }
  return;
}

int main() {
  float l, r;
  while (scanf("%f%f", &l, &r)) {
    if (!l)
      break;
    etest(0, l), etest(1, r);
  }
  for (int i = 0; i < 4; i++) {
    printf("%d %d\\n", et[0][i], et[1][i]);
  }
}
Problem p00149 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>
using namespace std;

int main() {
  int LA, LB, LC, LD, RA, RB, RC, RD;
  LA = LB = LC = LD = RA = RB = RC = RD = 0;
  while (1) {
    double a, b;
    cin >> a >> b;
    if (cin.fail())
      break;
    if (a < 0.2)
      LD++;
    else if (a < 0.6)
      LC++;
    else if (a < 1.1)
      LB++;
    else
      LA++;
    if (b < 0.2)
      RD++;
    else if (b < 0.6)
      RC++;
    else if (b < 1.1)
      RB++;
    else
      RA++;
  }
  cout << LA << " " << RA << endl
       << LB << " " << RB << endl
       << LC << " " << RC << endl
       << LD << " " << RD << endl;
}

Error: TLE

Fixed submission:

#include <iostream>
using namespace std;

int main() {
  int LA, LB, LC, LD, RA, RB, RC, RD;
  LA = LB = LC = LD = RA = RB = RC = RD = 0;
  while (1) {
    double a, b;
    cin >> a >> b;
    if (cin.fail())
      ;
    if (a < 0.2)
      LD++;
    else if (a < 0.6)
      LC++;
    else if (a < 1.1)
      LB++;
    else
      LA++;
    if (b < 0.2)
      RD++;
    else if (b < 0.6)
      RC++;
    else if (b < 1.1)
      RB++;
    else
      RA++;
  }
  cout << LA << " " << RA << endl
       << LB << " " << RB << endl
       << LC << " " << RC << endl
       << LD << " " << RD << endl;
}
Problem p00149 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
#define R(i, n) for (int i = 0; i < n; i++)
using namespace std;
int main() {
  double c, b;
  int a[4][2] = {0};
  while (cin >> c >> b) {
    if (c > 1.0)
      a[0][0]++;
    else if (c > 0.5)
      a[1][0]++;
    else if (c > 0.1)
      a[2][0]++;
    else
      a[3][0]++;
    if (b > 1.0)
      a[0][1]++;
    else if (b > 0.5)
      a[1][1]++;
    else if (b > 0.1)
      a[2][1]++;
    else
      a[3][1]++;
  }
  R(i, 4) cout << a[i][0] << ' ' << a[i][1] << endl;
}

Error: WA

Fixed submission:

#include <bits/stdc++.h>
#define R(i, n) for (int i = 0; i < n; i++)
using namespace std;
int main() {
  double c, b;
  int a[4][2] = {0};
  while (cin >> c >> b) {
    if (c > 1.0)
      a[0][0]++;
    else if (c > 0.5)
      a[0][1]++;
    else if (c > 0.1)
      a[0][2]++;
    else
      a[0][3]++;
    if (b > 1.0)
      a[1][0]++;
    else if (b > 0.5)
      a[1][1]++;
    else if (b > 0.1)
      a[1][2]++;
    else
      a[1][3]++;
  }
  R(i, 4) cout << a[0][i] << ' ' << a[1][i] << endl;
}
Problem p00150 (C++) — buggy submission, verdict: Time Limit Exceeded

#include "stdio.h"
const int MAX_V = 10000; // 1????????§????´???°??¨?????????
int prime[MAX_V + 1];    // 1????´???°,0????´???°??§?????????
int main() {
  int i, k, n;
  for (i = 2; i <= MAX_V; i++) {
    prime[i] = 1; // 2??\\???????´???°??¨??????
  }
  for (i = 2; i * i <= MAX_V; i++) {
    if (prime[i]) {
      for (k = 2 * i; k <= MAX_V; k += i) {
        prime[k] = 0; // ?´???°???2?????\\???????????°????´???°??§?????????
      }
    }
  }
  while (1) {
    scanf("%d", &n);
    if (n == 0)
      break;
    //        while(scanf("%d", &n) != 0) {
    int p1 = 0, q1 = 0;
    for (i = n; 3 <= i; i--) {
      if (prime[i] == 1 && prime[i - 2] == 1) { //??????????´???°
        q1 = i;
        p1 = i - 2;
        break;
      }
    }
    printf("%d %d\\n", p1, q1); // for?????????????????????
  }
  return 0;
}
//????¨??????¨????????????????????????

Error: TLE

Fixed submission:

#include "stdio.h"
const int MAX_V = 10000; // 1????????§????´???°??¨?????????
int prime[MAX_V + 1];    // 1????´???°,0????´???°??§?????????
int main() {
  int i, k, n;
  for (i = 2; i <= MAX_V; i++) {
    prime[i] = 1; // 2??\\???????´???°??¨??????
  }
  for (i = 2; i * i <= MAX_V; i++) {
    if (prime[i]) {
      for (k = 2 * i; k <= MAX_V; k += i) {
        prime[k] = 0; // ?´???°???2?????\\???????????°????´???°??§?????????
      }
    }
  }
  while (scanf("%d", &n) != 0) {
    int p1 = 0, q1 = 0;
    for (i = n; 3 <= i; i--) {
      if (prime[i] == 1 && prime[i - 2] == 1) { //??????????´???°
        q1 = i;
        p1 = i - 2;
        break;
      }
    }
    printf("%d %d\\n", p1, q1); // for?????????????????????
  }
  return 0;
}
//????¨??????¨????????????????????????
Problem p00150 (C++) — buggy submission, verdict: Time Limit Exceeded

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

int isprime(int n) {
  int i;
  for (i = 2; i * i <= n; i++) {
    if (n % i == 0)
      return 0;
  }
  return 1;
}

int main() {
  int n, i, a, b, max, data[10000];
  while (1) {
    a = 0;
    b = 0;
    max = 0;
    scanf("%d", &n);
    if (n == 0)
      break;
    for (i = n; i >= 1; i--) {
      if (isprime(i) == 1) {
        a = b;
        b = i;
      }
      if (a - b == 2)
        break;
    }
    //		for(i	=	1;	i	<=	cnt;	i++){
    //			if(data[i]	-	data[i	-	1]	==	2)max	=
    //i;
    //		}
    printf("%d %d\\n", b, a);
  }
  return 0;
}

Error: TLE

Fixed submission:

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

int Prime(int x) {
  int n;
  if (x == 2)
    return 1;
  if (x < 2 || x % 2 == 0)
    return 0;
  for (n = 3; n <= sqrt((double)x); n += 2) {
    if (x % n == 0)
      return 0;
  }
  return 1;
}

int main() {
  int n, i, cnt = 0, max = 0, data[100000];
  while (1) {
    cnt = 0;
    max = 0;
    scanf("%d", &n);
    if (n == 0)
      break;
    for (i = 0; i <= n; i++) {
      if (Prime(i) == 1) {
        data[cnt] = i;
        cnt++;
      }
    }
    for (i = 1; i <= cnt; i++) {
      if (data[i] - data[i - 1] == 2)
        max = i;
    }
    if (max != 0)
      printf("%d %d\\n", data[max - 1], data[max]);
  }
  return 0;
}
Problem p00150 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <stdio.h>
const int MAX_V = 10000;
int prime[MAX_V + 1];
int main() {
  int i, k, v;
  for (i = 2; i <= MAX_V; i++) {
    prime[i] = 1;
  }
  for (i = 2; i * i <= MAX_V; i++) {
    if (prime[i]) {
      for (k = 2 * i; k <= MAX_V; k += i) {
        prime[k] = 0;
      }
    }
  }

  while (scanf("%d", &v) != EOF) {
    if (v == 0) {
      break;
    }
    while (1) {
      if (prime[v] == 0 || prime[v - 2] == 0) {
        v--;
      } else {
        printf("%d %d\\n", v - 2, v);
        break;
      }
    }
  }
  return 0;
}

Error: TLE

Fixed submission:

#include <stdio.h>
const int MAX_V = 10000;
int prime[MAX_V + 1];
int hurui(int v) {
  int i, k;
  for (i = 2; i <= MAX_V; i++) {
    prime[i] = 1;
  }
  for (i = 2; i * i <= MAX_V; i++) {
    if (prime[i]) {
      for (k = 2 * i; k <= MAX_V; k += i) {
        prime[k] = 0;
      }
    }
  }
  int isprime = prime[v];
  if (isprime) {
    return 1;
  } else {
    return 0;
  }
}

int main() {
  int v;
  while (scanf("%d", &v) != EOF) {
    while (1) {
      if (hurui(v) == 0 || hurui(v - 2) == 0) {
        v--;
      } else {
        printf("%d %d\\n", v - 2, v);
        break;
      }
    }
    if (v == 0) {
      break;
    }
  }
  return 0;
}
Problem p00150 (C++) — buggy submission, verdict: Time Limit Exceeded

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

const int MAX_N = 10000;
bool is_prime[MAX_N + 1];

bool sieve(int n) {
  if (n % 2 == 0)
    return false;

  bool ret = true;
  for (int i = 3; i * i <= n; i += 2) {
    if (n % i == 0) {
      ret = false;
      break;
    }
  }
  return ret;
}

int main() {
  int n, p;
  is_prime[1] = true;
  is_prime[2] = true;

  for (int i = 3; i <= MAX_N; i++)
    is_prime[i] = sieve(i);

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

Error: TLE

Fixed submission:

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

bool is_sieve(int n) {
  if (n % 2 == 0)
    return false;

  bool ret = true;
  for (int i = 3; i * i <= n; i += 2) {
    if (n % i == 0) {
      ret = false;
      break;
    }
  }
  return ret;
}

int main() {
  int n, p;
  while (cin >> n && n) {
    p = 0;
    for (int i = 5; i <= n; i += 2) {
      if (is_sieve(i - 2) && is_sieve(i)) {
        p = i;
      }
    }
    cout << p - 2 << " " << p << endl;
  }
}
Problem p00150 (C++) — buggy submission, verdict: Runtime Error

#include <algorithm>
#include <iostream>
#include <iterator>
#include <numeric>
#include <vector>

using namespace std;
typedef unsigned int val;

struct pred {
  bool operator()(int m, int n) { return m - n == 2; }
};

int main() {
  int n;
  while (cin >> n && n) {
    vector<int> so(10000);
    so.clear();
    bool flag[10010];
    for (int i = 0; i <= 10010; i++)
      flag[i] = true;
    flag[0] = flag[1] = false;
    for (int i = 2; i <= n; i++) {
      if (flag[i]) {
        so.push_back(i);
        for (int j = i * 2; j <= n; j += i)
          flag[j] = false;
      }
    }
    vector<int>::reverse_iterator ite =
        adjacent_find(so.rbegin(), so.rend(), pred());
    cout << *(ite + 1) << " " << *ite << endl;
  }
  return 0;
}

Error: -11

Fixed submission:

#include <algorithm>
#include <iostream>
#include <iterator>
#include <numeric>
#include <vector>

using namespace std;
typedef unsigned int val;

struct pred {
  bool operator()(int m, int n) { return m - n == 2; }
};

int main() {
  int n;
  while (cin >> n && n) {
    vector<int> so;
    bool flag[10010];
    flag[0] = flag[1] = false;
    for (int i = 2; i <= n; i++) {
      if (flag[i]) {
        so.push_back(i);
        for (int j = i * 2; j < n; j += i)
          flag[j] = false;
      }
    }
    vector<int>::reverse_iterator ite =
        adjacent_find(so.rbegin(), so.rend(), pred());
    cout << *(ite + 1) << " " << *ite << endl;
  }
  return 0;
}
Problem p00150 (C++) — buggy submission, verdict: Time Limit Exceeded

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

const int MAXN = 10001;
bool isPrime[MAXN];

int main() {
  fill(isPrime, isPrime + MAXN, true);
  isPrime[0] = isPrime[1] = false;
  for (int i = 2; i < MAXN; ++i) {
    if (isPrime[i])
      for (int j = i * 2; j < MAXN; j += i)
        isPrime[j] = false;
  }

  int n;
  while (cin >> n && n) {
    int p, q;
    for (int x = 3; x + 2 <= n; ++x) {
      if (isPrime[x] && isPrime[x + 2]) {
        p = x;
        q = x + 2;
      }
    }
    cout << p << " " << q << endl;
  }
  return 0;
}

Error: TLE

Fixed submission:

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

bool isPrime(int x) {
  if (x == 0 || x == 1)
    return false;
  for (int i = 2; i * i <= x; ++i) {
    if (x % i == 0)
      return false;
  }
  return true;
}

int main() {
  int n;
  while (cin >> n && n) {
    int p, q;
    for (int x = 3; x + 2 <= n; ++x) {
      if (isPrime(x) && isPrime(x + 2)) {
        p = x;
        q = x + 2;
      }
    }
    cout << p << " " << q << endl;
  }
  return 0;
}
Problem p00150 (C++) — buggy submission, verdict: Runtime Error

#include <iostream>

using namespace std;

int prime(int n, int k = 2) {
  if (n < k * k) {
    return 1;
  }

  if (n % k == 0) {
    return 0;
  }

  return prime(n, k + 1);
}

int solve(int n) {
  for (int i = n; i >= 3; i--) {
    if (prime(i) * prime(i - 2)) {
      return i;
    }
  }

  return -1;
}

int main() {
  int n;

  while (true) {
    cin >> n;

    if (n == 0) {
      break;
    }

    cout << solve(n) - 2 << ' ' << solve(n) << endl;
  }

  return 0;
}

Error: WA

Fixed submission:

#include <cmath>
#include <iostream>

using namespace std;

bool prime_check(int N) {
  if (N == 1) {
    return false;
  }

  for (int i = 2; i <= sqrt(N); i++) {
    if (N % i == 0) {
      return false;
    }
  }

  return true;
}

int main() {
  int N[100], I[100], c = 0;

  while (cin >> N[c]) {
    if (N[c] == 0) {
      goto END;
    }

    for (int i = (N[c] - 1); i > 1; i--) {
      if (prime_check(i) == true && prime_check(i - 2) == true) {
        I[c] = i;
        goto Exit;
      }
    }
  Exit:;

    c++;
  }

END:;

  for (int i = 0; i < c; i++) {
    cout << I[i - 2] << ' ' << I[i] << endl;
  }

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

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

using namespace std;

int s[10001];

void sieve() {
  for (int i = 0; i < 10001; i++)
    s[i] = 1;
  s[0] = s[1] = 0;

  for (int i = 2; i <= sqrt(10001); i++) {
    if (s[i]) {
      for (int j = i * i; j < 10001; j += i) {
        s[j] = 0;
      }
    }
  }
}

int main() {
  sieve();
  int n;
  while (~scanf("%d", &n)) {
    if (n == 0)
      break;
    for (int i = n; i >= 2; i--) {
      if (s[i] && s[i - 2]) {
        printf("%d %d\\n", i - 2, i);
        goto end;
      }
    }
  end:;
  }
}

Error: TLE

Fixed submission:

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

using namespace std;

int s[10001];

void sieve() {
  for (int i = 0; i < 10001; i++)
    s[i] = 1;
  s[0] = s[1] = 0;

  for (int i = 2; i <= sqrt(10001); i++) {
    if (s[i]) {
      for (int j = i * i; j < 10001; j += i) {
        s[j] = 0;
      }
    }
  }
}

int tabs(int a) { return a > 0 ? a : -a; }

int main() {
  sieve();
  int n;
  while (~scanf("%d", &n)) {
    if (n == 0)
      break;
    for (int i = n; i >= 2; i--) {
      for (int j = i; j >= 2; j--) {
        if (s[i] && s[j] && tabs(i - j) == 2) {
          printf("%d %d\\n", j, i);
          goto end;
        }
      }
    }
  end:;
  }
}
Problem p00150 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <stdio.h>
#include <time.h>
int isprime(int n) {
  for (int i = 2; i * i <= n; i++) {
    if (n % i == 0) {
      return 0;
    }
  }
  return 1;
}
int main() {
  int i, p, q, n;
  while (1) {
    scanf("%d", &n);
    if (n == 0) {
      break;
    }
    for (i = n; i >= 2; i--) {
      if (isprime(i) && isprime(i - 2)) {
        break;
      }
    }
    printf("%d %d\\n", i - 2, i);
  }
  return 0;
}

// clock_t start, now;
// now = clock();
// printf("%f\\n",(double)(now - start) / CLOCKS_PER_SEC);

Error: TLE

Fixed submission:

#include <stdio.h>
#include <time.h>
int isprime(int n) {
  for (int i = 2; i < n; i++) {
    if (n % i == 0) {
      return 0;
    }
  }
  return 1;
}
int main() {
  int i, p, q, n;
  while (1) {
    scanf("%d", &n);
    if (n == 0) {
      break;
    }
    for (i = n; i >= 2; i--) {
      if (isprime(i) && isprime(i - 2)) {
        break;
      }
    }
    printf("%d %d\\n", i - 2, i);
  }
  return 0;
}

// clock_t start, now;
// now = clock();
// printf("%f\\n",(double)(now - start) / CLOCKS_PER_SEC);
Problem p00150 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <stdio.h>
const int size = 10000;
int main() {
  int i, k, n;
  int data[size];
  for (i = 2; i < size; i++) {
    data[i] = 1;
  }
  for (i = 2; i < size; i++) {
    if (data[i]) {
      for (k = 2 * i; k <= size; k += i) {
        data[k] = 0;
      }
    }
  }
  while (1) {
    scanf("%d", &n);
    if (n == 0)
      break;
    for (i = n; i >= 0; i--) {
      if (data[i] == 1 && data[i - 2] == 1) {
        break;
      }
    }
    printf("%d %d\\n", i - 2, i);
  }
  return 0;
}

Error: TLE

Fixed submission:

#include <stdio.h>
int isprime(int n) {
  int i;
  for (i = 2; i * i <= n; i++) {
    if (n % i == 0)
      return 0;
  }
  return 1;
}
int main() {
  int i, n;
  int data[10000] = {1};
  while (1) {
    scanf("%d", &n);
    if (n == 0)
      break;
    for (i = 0; i < n; i++) {
      data[i] = isprime(i);
      // printf("%d %d\\n",i,data[i]);
    }
    for (i = n; i >= 0; i--) {
      if (data[i] == 1 && data[i - 2] == 1) {
        break;
      }
    }
    printf("%d %d\\n", i - 2, i);
  }
  return 0;
}
Problem p00150 (C++) — buggy submission, verdict: Runtime Error

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

int fl[10001] = {0};

void isfl(int);
void twlf(int);

int main(void) {
  int tag;

  while (1) {
    cin >> tag;
    if (tag == 0)
      break;
    isfl(tag);
    twlf(tag);
  }
  return 0;
}

void isfl(int tag) {
  int i, lim, idx = 2;
  fl[0] = 1;
  fl[1] = 1;

  lim = sqrt(tag);

  while (idx <= lim) {
    if (fl[idx] == 0)
      for (i = idx * 2; i <= tag; i += idx)
        fl[i] = 1;
    idx++;
  }
  return;
}

void twlf(int tag) {
  int k = 0, data[10000];
  for (int i = 1; i <= tag; i++)
    if (fl[i] == 0) {
      data[k] = i;
      k++;
    }
  for (int i = k - 1; i >= 0; i--) {
    if (data[i] - data[i - 1] == 2) {
      cout << data[i - 1] << " " << data[i] << endl;
      break;
    }
  }
  return;
}

Error: 0

Fixed submission:

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

int fl[10001] = {0};

void isfl(int);
void twlf(int);

int main(void) {
  int tag;

  while (1) {
    scanf("%d", &tag);
    if (tag == 0)
      break;
    isfl(tag);
    twlf(tag);
  }
  return 0;
}

void isfl(int tag) {
  int i, lim, idx = 2;
  fl[0] = 1;
  fl[1] = 1;

  lim = sqrt(tag);

  while (idx <= lim) {
    if (fl[idx] == 0)
      for (i = idx * 2; i <= tag; i += idx)
        fl[i] = 1;
    idx++;
  }
  return;
}

void twlf(int tag) {
  int i, k = -1, data[1000];
  for (i = 1; i <= tag; i++)
    if (fl[i] == 0) {
      k++;
      data[k] = i;
    }
  for (i = k; i >= 0; i--) {
    if (data[i] - data[i - 1] == 2) {
      printf("%d %d\\n", data[i - 1], data[i]);
      break;
    }
  }
  return;
}
Problem p00150 (C++) — buggy submission, verdict: Runtime Error

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

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

using namespace std;

int prime[10001];

void CreatePrime(int n) {
  rep(i, n) { prime[i] = 1; }

  prime[0] = prime[1] = 0;

  REP(i, 2, sqrt(n)) {
    if (prime[i]) {
      for (int j = 0; i * (j + 2) < n; j++) {
        prime[i * (j + 2)] = 0;
      }
    }
  }
}

int main() {
  int n;
  CreatePrime(10001);

  while (cin >> n && n) {
    for (int i = n; i >= 0; i--) {
      if (prime[i] && prime[i - 2]) {
        cout << i - 2 << " " << i << endl;
        break;
      }
    }
  }
  return 0;
}

Error: 0

Fixed submission:

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

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

using namespace std;

int prime[10001];

void CreatePrime(int n) {
  rep(i, n) { prime[i] = 1; }

  prime[0] = prime[1] = 0;

  REP(i, 2, sqrt(n)) {
    if (prime[i]) {
      for (int j = 0; i * (j + 2) < n; j++) {
        prime[i * (j + 2)] = 0;
      }
    }
  }
}

int main() {
  int n;
  vector<int> v;
  vector<pair<int, int>> ans;

  CreatePrime(10001);
  while (cin >> n && n) {
    rep(i, n + 1) {
      if (prime[i])
        v.push_back(i);
    }

    rep(i, v.size() - 1) {
      REP(j, i + 1, v.size()) {
        if (v[j] - v[i] == 2) {
          ans.push_back(make_pair(v[i], v[j]));
        }

        else if (v[j] - v[i] > 2) {
          break;
        }
      }
    }

    cout << ans[ans.size() - 1].first << " " << ans[ans.size() - 1].second
         << endl;
  }
  return 0;
}
Problem p00150 (C++) — buggy submission, verdict: Time Limit Exceeded

#include "stdio.h"
// #include "time.h"
//?????§??????????´???°?????????????????????
//  5<= n <= 10000
// p1=?°????????´???°p2=??§???????´???°

int isprime(int n) {
  int i;
  for (i = 2; i * i <= n;
       i++) { //??????????§????????????¨??§??¶??°??§??????????´???°??¨??????
    if (n % i == 0)
      return 0; //????????????????????§?´???°??§?????????
  }
  return 1;
}
int main() {
  int i, n, p1, q1;
  //     clock_t start, now;//??£?¨?
  while (1) {
    scanf("%d", &n);
    //   start = clock(); // ????§???????
    if (n == 0)
      break;
    for (i = n; 3 <= i; i--) {
      if (isprime(i) == 1 && isprime(i - 2) == 1)
        break;
    }
    p1 = i - 2;
    q1 = i;
    // now = clock(); // ????????????
    // printf("%f\\n", (double)(now - start) / CLOCKS_PER_SEC);//??¬???
    printf("%d %d\\n", p1, q1);
  }
  return 0;
}

Error: TLE

Fixed submission:

#include "stdio.h"
// #include "time.h"
//?????§??????????´???°?????????????????????
//  5<= n <= 10000
// p1=?°????????´???°p2=??§???????´???°

int isprime(int n) {
  int i;
  for (i = 2; i < n;
       i++) { //??????????§????????????¨??§??¶??°??§??????????´???°??¨??????
    if (n % i == 0)
      return 0; //????????????????????§?´???°??§?????????
  }
  return 1;
}
int main() {
  int i, n, p1, q1;
  //     clock_t start, now;//??£?¨?
  while (1) {
    scanf("%d", &n);
    //   start = clock(); // ????§???????
    if (n == 0)
      break;
    for (i = n; 3 <= i; i--) {
      if (isprime(i) == 1 && isprime(i - 2) == 1)
        break;
    }
    p1 = i - 2;
    q1 = i;
    // now = clock(); // ????????????
    // printf("%f\\n", (double)(now - start) / CLOCKS_PER_SEC);//??¬???
    printf("%d %d\\n", p1, q1);
  }
  return 0;
}