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

#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <fstream>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;

bool is_prime(int p) {
  if (p <= 1)
    return false;
  if (p == 2)
    return true;
  if (!(p & 1))
    return false;
  for (int x = 3; x <= sqrt(p); ++x)
    if (!(p % x))
      return false;
  return true;
}

int main() {
  bool primes[10002];
  memset(primes, 0, sizeof(primes));
  for (int x = 2; x <= 10000; ++x)
    if (is_prime(x))
      primes[x] = true;
  int n;
  while (scanf("%d", &n) == 1) {
    int c = 0;
    int l = n / 2;
    if (n % 2 == 1) {
      ++l;
      if (primes[l])
        --c;
    }
    for (int x = 1; x <= l; ++x) {
      if (primes[x] && primes[n - x + 1])
        c += 2;
    }
    cout << c << endl;
  }
  return 0;
}

Error: TLE

Fixed submission:

#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <fstream>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;

bool is_prime(int p) {
  if (p <= 1)
    return false;
  if (p == 2)
    return true;
  if (!(p & 1))
    return false;
  for (int x = 3; x <= sqrt(p); ++x)
    if (!(p % x))
      return false;
  return true;
}

int main() {
  bool primes[10002];
  memset(primes, 0, sizeof(primes));
  for (int x = 2; x <= 10000; ++x)
    if (is_prime(x))
      primes[x] = true;
  int n;
  while (scanf("%d", &n) == 1, n) {
    int c = 0;
    int l = n / 2;
    if (n % 2 == 1) {
      ++l;
      if (primes[l])
        --c;
    }
    for (int x = 1; x <= l; ++x) {
      if (primes[x] && primes[n - x + 1])
        c += 2;
    }
    cout << c << endl;
  }
  return 0;
}
Problem p00590 (C++) — buggy submission, verdict: Runtime Error

#include <iostream>
#define LEN 10000

using namespace std;
int prime_pair(int N);
int is_prime(int p);
int prime_list(int MAX);
int prime[LEN];

int main(void) {
  int input;
  int j = 0;
  prime_list(LEN);
  while (cin >> input) {
    cout << prime_pair(input) << endl;
  }
  return 0;
}

int prime_list(int MAX) {
  int i = 0;
  int j = 0;
  int flag = 1;
  prime[0] = 2;
  for (i = 2; i < MAX; i++) {
    while (prime[j] != 0) {
      if (i % prime[j] == 0) {
        flag = 0;
      }
      j++;
    }
    if (flag) {
      prime[j] = i;
    }
    flag = 1;
    j = 0;
  }
  return 0;
}

int prime_pair(int N) {
  int count = 0;
  int i = 0;
  while ((prime[i] < N) && (prime[i] != 0)) {
    if (is_prime(N - prime[i] + 1))
      count++;
    i++;
  }
  return count;
}

int is_prime(int p) {
  int flag = 0;
  int i = 0;
  while ((prime[i] != 0) && (i < p)) {
    if (p == prime[i]) {
      flag = 1;
      break;
    }
    i++;
  }
  return flag;
}

Error: 0

Fixed submission:

#include <iostream>
#define LEN 10000

using namespace std;
int prime_pair(int N);
int is_prime(int p);
int prime_list(int MAX);
int prime[LEN];

int main(void) {
  int input;
  int j = 0;
  prime_list(LEN);
  while (cin >> input) {
    cout << prime_pair(input) << endl;
  }
  return 0;
}

int prime_list(int MAX) {
  int i = 0;
  int j = 0;
  int flag = 1;
  prime[0] = 2;
  for (i = 2; i < MAX; i++) {
    while (prime[j] != 0) {
      if (i % prime[j] == 0) {
        flag = 0;
      }
      j++;
    }
    if (flag) {
      prime[j] = i;
    }
    flag = 1;
    j = 0;
  }
  return 0;
}

int prime_pair(int N) {
  int count = 0;
  int i = 1;
  if (is_prime(2) && is_prime(N - 2 + 1))
    count++;
  while (prime[i] < N) {
    if (is_prime(N - prime[i] + 1))
      count++;
    i++;
  }
  return count;
}

int is_prime(int p) {
  int flag = 0;
  int i = 0;
  while ((prime[i] != 0) && (i < p)) {
    if (p == prime[i]) {
      flag = 1;
      break;
    }
    i++;
  }
  return flag;
}
Problem p00590 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>
using namespace std;

const int MAX = 1000001;
char p[MAX] = {0};

void f() {
  for (int i = 2; i < MAX; i++)
    p[i] = 1;
  for (int i = 2; i * i < MAX; i++) {
    if (p[i]) {
      for (int j = i + i; j < MAX; j += i) {
        p[j] = 0;
      }
    }
  }
}

int main() {
  int n;
  f();
  while (cin >> n) {
    int ans = 0;
    for (int a = 1; a <= n; a++) {
      int b = n + 1 - a;
      if (p[a] && p[b])
        ans++;
    }
    cout << ans << endl;
  }
}

Error: TLE

Fixed submission:

//============================================================================
// Name        : TopCoderCompetition.cpp
// Author      : taguchi
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <sstream>
#include <string>
#include <vector>
using namespace std;
// #define P pair<int,int>
// #define max 999999
typedef unsigned int uint;
typedef unsigned long ul;
typedef long long ll;
typedef unsigned long long ull;
#define rep(i, n) for (ull i = 0; i < n; i++)
#define pb(n) push_back(n)
#define clear(n) memset(n, 0, sizeof(n))

typedef vector<int> vi;
typedef vector<string> vs;
struct edge {
  int cost, to;
};

vector<string> split(string &in, char delimiter) {
  vector<string> re;
  uint cur = 0, next;
  while ((next = in.find_first_of(delimiter, cur)) != string::npos) {
    re.pb(string(in, cur, next - cur));
    cur = next + 1;
  }
  re.pb(string(in, cur, in.size() - cur));
  return re;
}
vector<int> split_int(string &in, char delimiter) {
  vector<string> str = split(in, delimiter);
  vector<int> re;
  rep(i, str.size()) { re.pb(strtol(str[i].c_str(), NULL, 10)); }
  return re;
}

class Range {
public:
  int a, b;
  Range(int an, int bn) : a(an), b(bn) {}

  bool operator()(int n) { return a <= n && n <= b; }
  bool isCross(Range x) { return x(a) || x(b); }
  bool contains(Range x) { return this->a <= x.a && x.b <= this->b; }
};

bool isnprime[10010];
uint indexpri[10010];
int main() {
  int cnt = 0;
  for (int i = 2; i < 10010; i++) {
    if (!isnprime[i]) {
      indexpri[cnt++] = i;
      for (int j = 2; i * j < 10010; j++) {
        isnprime[i * j] = true;
      }
    }
  }
  isnprime[0] = true;
  isnprime[1] = true;
  while (1) {
    int n;
    uint result = 0;
    cin >> n;
    if (!n)
      break;
    for (int i = 0; i < cnt; i++) {
      if (n - indexpri[i] + 1 < 2)
        break;
      if (binary_search(indexpri, indexpri + cnt, n - indexpri[i] + 1))
        result++;
    }
    cout << result << endl;
  }

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

#include <iostream>
using namespace std;
int main(void) {
  int N[10000];
  for (int i = 0; i < 10000; i++) {
    N[i] = 0;
    cin >> N[i];
  }

  int p = 0, prime[10000];
  bool is_prime[10001];
  is_prime[1] = false;

  for (int i = 2; i <= 10000; i++) {
    is_prime[i] = true;
  }

  for (int i = 2; i <= 10000; i++) {
    if (is_prime[i]) {
      prime[p++] = i;
      for (int j = i + i; j <= 10000; j += i) {
        is_prime[j] = false;
      }
    }
  }

  int i = 0;
  while (N[i] != 0) {
    int ans = 0;

    for (int j = 0; prime[j] <= N[i] / 2; j++) {
      if (is_prime[N[i] + 1 - prime[j]]) {
        ans += 2;
      }
    }
    if (N[i] == 3) {
      cout << 1 << endl;
    } else if (N[i] % 2 != 0 && is_prime[N[i] / 2 + 1]) {
      cout << ans + 1 << endl;
    } else {
      cout << ans << endl;
    }

    i++;
  }
}

Error: 0

Fixed submission:

#include <iostream>
using namespace std;
int main(void) {
  int N[10000];
  for (int i = 0; i < 10000; i++) {
    N[i] = 0;
    cin >> N[i];
  }

  int p = 0, prime[10000];
  bool is_prime[10001];
  is_prime[1] = false;

  for (int i = 2; i <= 10000; i++) {
    is_prime[i] = true;
  }

  for (int i = 2; i <= 10000; i++) {
    if (is_prime[i]) {
      prime[p++] = i;
      for (int j = i + i; j <= 10000; j += i) {
        is_prime[j] = false;
      }
    }
  }

  int i = 0;
  while (N[i] != 0) {
    int ans = 0;
    for (int j = 0; prime[j] <= N[i]; j++) {
      if (is_prime[N[i] + 1 - prime[j]]) {
        ans++;
      }
    }
    cout << ans << endl;
    i++;
  }
}
Problem p00590 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>
using namespace std;

int main() {
  int N, count = 0, p[10001];

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

  while (cin >> N) {
    count = 0;
    for (int i = 2; i <= N; i++) {
      if (p[i] == 1 && p[N - i + 1] == 1)
        count++;
    }

    cout << count << endl;
  }
  return 0;
}

Error: TLE

Fixed submission:

#include <iostream>
using namespace std;

int so(int);
int main() {
  int N, count = 0;

  while (cin >> N) {
    count = 0;
    for (int i = 2; i <= N; i++) {

      if (so(i) == 1 && so(N - i + 1) == 1)
        count++;
    }

    cout << count << endl;
  }
  return 0;
}

int so(int x) {
  for (int i = 2; i < x / 2; i++) {
    if (x % i == 0)
      return 0;
  }
  return 1;
}
Problem p00590 (C++) — buggy submission, verdict: Time Limit Exceeded

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

using namespace std;

bool prime[10500];
// bool used[(1<<15) + 50][(1<<15) + 50];

void mp(void) {
  fill(prime, prime + 10500, true);
  prime[0] = prime[1] = false;
  for (int i = 2; i < 10500; i++) {
    if (prime[i]) {
      for (int j = i * 2; j < 10500; j += i) {
        prime[j] = false;
      }
    }
  }

  return;
}

int main(void) {
  int n;

  mp();
  while (scanf("%d", &n) != EOF) {
    int ret = 0;

    for (int i = 1; i <= n; i++) {
      if (prime[i] && prime[n - i + 1]) {
        // cout << i << " " << n - i + 1 << endl;
        ret++;
      }
    }
    cout << ret << endl;
  }

  return 0;
}

Error: TLE

Fixed submission:

#include <algorithm>
#include <cstring>
#include <iostream>

using namespace std;

bool prime[10500];
// bool used[(1<<15) + 50][(1<<15) + 50];

void mp(void) {
  fill(prime, prime + 10500, true);
  prime[0] = prime[1] = false;
  for (int i = 2; i < 10500; i++) {
    if (prime[i]) {
      for (int j = i * 2; j < 10500; j += i) {
        prime[j] = false;
      }
    }
  }

  return;
}

int main(void) {
  int n;

  mp();
  while (cin >> n, n) {
    int ret = 0;

    for (int i = 1; i <= n; i++) {
      if (prime[i] && prime[n - i + 1]) {
        // cout << i << " " << n - i + 1 << endl;
        ret++;
      }
    }
    cout << ret << endl;
  }

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

#include <iostream>
#include <vector>
#define MAX 10001
using namespace std;
bool prime[MAX];

void isPrime() {}
int main(void) {
  // isPrime();
  fill(prime, prime + MAX, true);
  prime[0] = prime[1] = false;
  for (int i = 0; i < MAX; i++)
    if (prime[i])
      for (int j = i + i; j < MAX; j += i)
        prime[j] = false;

  int n;
  while (1) {
    cin >> n;
    if (cin.eof())
      break;
    int cnt = 0;
    for (int i = 1; i <= n; i++)
      if (prime[i] * prime[n - i + 1])
        cnt++;
    cout << cnt << endl;
  }
}

Error: TLE

Fixed submission:

#include <iostream>
#include <vector>
#define MAX 10001
using namespace std;
bool prime[MAX];

void isPrime() {}
int main(void) {
  // isPrime();
  fill(prime, prime + MAX, true);
  prime[0] = prime[1] = false;
  for (int i = 0; i < MAX; i++)
    if (prime[i])
      for (int j = i + i; j < MAX; j += i)
        prime[j] = false;

  int n;
  while (1) {
    cin >> n;
    int cnt = 0;
    for (int i = 1; i <= n; i++)
      if (prime[i] * prime[n - i + 1])
        cnt++;
    cout << cnt << endl;
  }
}
Problem p00590 (C++) — buggy submission, verdict: Runtime Error

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

void sieve(bool *primes, int n) {
  int m = ceil(sqrt(n));
  int k = 2;

  for (int i = 0; i <= n; i++)
    primes[i] = true;
  primes[0] = primes[1] = false;

  for (int i = 2; i <= m; i++) {
    if (primes[i]) {
      for (int k = 2 * i; k <= n; k += i)
        primes[k] = false;
    }
  }
}

int main() {
  bool primes[10001];
  int ns[10000];
  int num = 0;
  int maxn = 0;
  int n;

  while (cin >> n) {
    ns[num] = n;
    maxn = max(maxn, n);
    num++;
  }

  sieve(primes, maxn);

  for (int i = 0; i < num; i++) {
    int p = 1;
    int q = ns[i];
    int ans = 0;
    for (int j = 0; j < ns[i]; j++) {
      if (primes[p] && primes[q])
        ans++;
      p++;
      q--;
    }
    cout << ans << endl;
  }

  return 0;
}

Error: 0

Fixed submission:

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

void sieve(bool *primes, int n) {
  int m = ceil(sqrt(n));
  int k = 2;

  while (k < m) {
    while (!primes[k])
      k++;
    int q = k;
    while (q < n) {
      q = q + k;
      primes[q] = false;
    }
    k++;
  }
}

int main() {
  bool primes[10001];
  int ns[10000];
  int num = 0;
  int maxn = 0;
  int n;

  while (cin >> n) {
    ns[num] = n;
    maxn = max(maxn, n);
    num++;
  }

  for (int i = 0; i <= maxn; i++)
    primes[i] = true;
  primes[0] = primes[1] = false;
  sieve(primes, maxn);

  for (int i = 0; i < num; i++) {
    int p = 1;
    int q = ns[i];
    int ans = 0;
    for (int j = 0; j < ns[i]; j++) {
      if (primes[p] && primes[q])
        ans++;
      p++;
      q--;
    }
    cout << ans << endl;
  }

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

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

void prime();
bool num[10001];

int main() {
  int m, count;
  prime();
  while (cin >> m) {
    count = 0;
    for (int i = 1; i <= m; i++) {
      if (num[i] && num[m - i + 1]) {
        count++;
      }
    }
    cout << count << endl;
  }
  return 0;
}

void prime() {
  vector<int> p;
  for (int i = 0; i < 10001; i++) {
    num[i] = true;
  }
  num[0] = false;
  num[1] = false;
  for (int i = 2; i <= 100; i++) {
    for (int j = i * 2; j <= 10001; j += i) {
      if (!num[j]) {
        continue;
      }
      num[j] = false;
    }
  }
}

Error: TLE

Fixed submission:

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

bool prime(int n);

int main() {
  int m, count;
  while (scanf("%d", &m)) {
    count = 0;
    for (int i = 1; i <= m; i++) {
      if (prime(i) && prime(m - i + 1)) {
        count++;
      }
    }
    cout << count << endl;
  }
  return 0;
}

bool prime(int n) {
  vector<int> prime;
  bool num[10001];
  for (int i = 0; i < 10001; i++) {
    num[i] = true;
  }

  num[0] = false;
  num[1] = false;

  for (int i = 2; i <= 100; i++) {
    for (int j = i * 2; j <= 100; j += i) {
      if (!num[j]) {
        continue;
      }
      num[j] = false;
    }
  }

  for (int i = 0; i < 10001; i++) {
    if (num[i]) {
      prime.push_back(i);
    }
  }

  bool flag = false;
  for (int i = 0; i < prime.size(); i++) {
    if (n == prime[i]) {
      flag = true;
    }
  }
  return flag;
}
Problem p00590 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>
using namespace std;
int prime[30];
int main() {
  int count = 1;
  prime[0] = 2;
  for (int i = 3; i < 100; i += 2) {
    bool t = true;
    for (int j = 1; j < count; j++) {
      if (i % prime[j] == 0)
        t = false;
    }
    if (t == true) {
      prime[count] = i;
      count++;
    }
  }
  int n;
  while (cin >> n) {
    n++;
    int ans = 0;
    for (int cut = 2; cut < n - 1; cut++) {
      bool t = true, f = true;
      for (int i = 0; i < count; i++) {
        if (cut % prime[i] == 0 && cut != prime[i])
          t = false;
      }
      for (int i = 0; i < count; i++) {
        if ((n - cut) % prime[i] == 0 && n - cut != prime[i])
          f = false;
      }
      if (t == true && f == true)
        ans++;
    }
    cout << ans << endl;
  }
  return 0;
}

Error: TLE

Fixed submission:

#include <iostream>
#include <string>
using namespace std;
int prime[1250];
int main() {
  int count = 1;
  prime[0] = 2;
  for (int i = 3; i < 10000; i += 2) {
    bool t = true;
    for (int j = 1; j < count; j++) {
      if (i % prime[j] == 0)
        t = false;
    }
    if (t == true) {
      prime[count] = i;
      count++;
    }
  }
  int n;
  while (cin >> n) {
    n++;
    int ans = 0;
    for (int i = 0; i < count; i++) {
      for (int j = 0; j < count; j++) {
        if (prime[i] + prime[j] == n)
          ans++;
      }
    }
    cout << ans << endl;
  }
  return 0;
}
Problem p00590 (C++) — buggy submission, verdict: Runtime Error

#include <iostream>
#include <vector>

using namespace std;

bool IsPrime[10010];
void PrimeCalc() {
  for (int i = 0; i < 10010; ++i) {
    IsPrime[i] = true;
  }
  IsPrime[0] = IsPrime[1] = false;
  for (int i = 2; i < 10010; ++i) {
    if (IsPrime[i]) {
      for (int j = 2 * i; j < 10010; j += i) {
        IsPrime[j] = false;
      }
    }
  }
}

void solve() {
  PrimeCalc();
  int N;
  while (cin >> N) {
    int count = 0;
    for (int i = 1; i <= N; ++i) {
      if (IsPrime[i] == true && IsPrime[N - i + 1] == true) {
        ++count;
      }
    }
    cout << count << endl;
  }
}

int main() {
  solve();
  return (0);
}

Error: 0

Fixed submission:

#include <iostream>
#include <vector>

using namespace std;

bool IsPrime[1001];
void PrimeCalc() {
  for (int i = 0; i < 1001; ++i) {
    IsPrime[i] = true;
  }
  IsPrime[0] = IsPrime[1] = false;
  for (int i = 2; i < 1001; ++i) {
    if (IsPrime[i]) {
      for (int j = 2 * i; j < 1001; j += i) {
        IsPrime[j] = false;
      }
    }
  }
}

void solve() {
  PrimeCalc();
  int N;
  while (cin >> N) {
    int count = 0;
    for (int i = 1; i <= N; ++i) {
      if (IsPrime[i] == true && IsPrime[N - i + 1] == true) {
        ++count;
      }
    }
    cout << count << endl;
  }
}

int main() {
  solve();
  return (0);
}
Problem p00591 (C++) — buggy submission, verdict: Runtime Error

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

int a[110][110];

int main() {
  int n, i, j;
  while (scanf("%d", &n) && n) {
    for (i = 1; i <= n; ++i) {
      for (j = 1; j <= n; ++j) {
        scanf("%d", &a[i][j]);
      }
    }
    bool flag = false;
    for (i = 1; i <= n; ++i) {
      int id = 1;
      ;
      for (j = 1; j <= n; ++j) {
        if (a[i][j] < a[i][id]) {
          id = j;
        }
      }
      for (j = 1; j <= n; ++j) {
        if (a[i][id] < a[j][id])
          break;
      }
      if (j <= n)
        continue;
      printf("%d\\n", a[i][id]);
      flag = true;
      break;
    }
    if (flag)
      continue;
    printf("0\\n");
  }
  return 0;
}

Error: -11

Fixed submission:

#include <cstdio>
#include <iostream>
#include <memory.h>
using namespace std;
int a[100][100];
int main() {
  int n, i, j, row[100], col[100], s;
  while (cin >> n && n != 0) {
    for (i = 0; i < n; i++) {
      col[i] = 0;
      row[i] = 1000000000;
    }
    // 陦?        for(i=0;i<n;i++)
    {
      // 蛻?            for(j=0;j<n;j++)
      {
        cin >> a[i][j];
        if (a[i][j] < row[i]) {
          row[i] = a[i][j];
        }
      }
    }
    for (j = 0; j < n; j++) {
      for (i = 0; i < n; i++) {
        if (a[i][j] > col[j]) {
          col[j] = a[i][j];
        }
      }
    }
    s = -1;
    for (i = 0; i < n, s != 101; i++)
      for (j = 0; j < n; j++) {
        if (a[i][j] == row[i] && a[i][j] == col[j]) {
          s = 101;
          cout << a[i][j] << endl;
        }
      }
    if (s == -1)
      cout << 0 << endl;
    // for(i=0;i<n;i++) cout<<row[i]<<" ";
    // for(j=0;j<n;j++) cout<<col[j]<<" ";
    /* for(i=0;i<n;i++)
     {
         for(j=0;j<n;j++)
         cout<<flag[i][j]<<" ";
     }
     }*/
  }
  return 0;
}
Problem p00591 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
#define N 100
using namespace std;
int n, a[N][N], ans;

bool checkx(int y, int x, int p) {
  for (int i = 0; i < n; i++)
    if (x != i && p > a[y][i])
      return false;
  return true;
}

bool checky(int y, int x, int p) {
  for (int i = 0; i < n; i++)
    if (y != i && p < a[i][x])
      return false;
  return true;
}

int main() {
  while (1) {
    cin >> n;
    if (!n)
      break;
    for (int i = 0; i < n; i++)
      for (int j = 0; j < n; j++)
        cin >> a[i][j];
    ans = 0;
    for (int i = 0; i < n; i++)
      for (int j = 0; j < n; j++)
        if (checkx(i, j, a[i][j]) && checky(i, j, a[i][j]))
          ans = a[i][j];
    cout << ans << endl;
  }
  return 0;
}

Error: -6
b38fb438-f2c3-430b-be41-a7ec53482648.out: /home/alex/Documents/bug-detection/input/Project_CodeNet/data/p00591/C++/s311613661.cpp:31: int main(): Assertion `f' failed.


Fixed submission:

#include <bits/stdc++.h>
#define N 100
using namespace std;
int n, a[N][N];
bool x[N][N], y[N][N];

int main() {
  while (1) {
    cin >> n;
    if (!n)
      break;
    for (int i = 0; i < n; i++)
      for (int j = 0; j < n; j++)
        cin >> a[i][j];
    memset(x, 0, sizeof(x));
    memset(y, 0, sizeof(y));
    for (int i = 0; i < n; i++) {
      int idx, mina = (1e9);
      for (int j = 0; j < n; j++)
        if (mina > a[i][j])
          idx = j, mina = a[i][j];
      x[i][idx] = true;
    }
    for (int i = 0; i < n; i++) {
      int idx, maxa = 0;
      for (int j = 0; j < n; j++)
        if (maxa < a[j][i])
          idx = j, maxa = a[j][i];
      y[idx][i] = true;
    }
    int f = 0;
    for (int i = 0; i < n; i++)
      for (int j = 0; j < n; j++) {

        if (x[i][j] && y[i][j])
          assert(f), cout << a[i][j] << endl, f = 1;
      }
  }
  return 0;
}
Problem p00592 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <algorithm>
#include <iostream>
using namespace std;
bool F[10000][1440];
int n, K, a, b, s, t;
int main() {
  while (true) {
    cin >> n >> s >> t;
    if (n == 0)
      break;
    s = s / 100 * 60 + s % 100;
    t = t / 100 * 60 + t % 100;
    for (int i = 0; i < 14400000; i++)
      F[i / 1440][i % 1440] = false;
    for (int i = 0; i < n; i++) {
      cin >> K;
      for (int j = 0; j < K; j++) {
        cin >> a >> b;
        a = a / 100 * 60 + a % 100;
        b = b / 100 * 60 + b % 100;
        for (int k = a; k < b; k++)
          F[i][k] = true;
      }
    }
    int sum = 0, maxn = 0;
    for (int i = s; i < t; i++) {
      bool OK = false;
      for (int j = 0; j < n; j++) {
        if (F[j][i] == false)
          OK = true;
      }
      if (OK == true)
        sum++;
      else {
        sum = 0;
      }
      maxn = max(maxn, sum);
    }
    cout << maxn << endl;
  }
  return 0;
}

Error: TLE

Fixed submission:

#include <iostream>
using namespace std;
bool F[10000][1440], n, K, a, b, s, t;
int main() {
  while (true) {
    cin >> n >> s >> t;
    if (n == 0)
      break;
    s = s / 100 * 60 + s % 60;
    t = t / 100 * 60 + t % 60;
    for (int i = 0; i < 14400000; i++)
      F[i / 1440][i % 1440] = false;
    for (int i = 0; i < n; i++) {
      cin >> K;
      for (int j = 0; j < K; j++) {
        cin >> a >> b;
        a = a / 100 * 60 + a % 60;
        b = b / 100 * 60 + b % 60;
        for (int k = a; k < b; k++)
          F[i][k] = true;
      }
    }
    int sum = 0;
    for (int i = s; i < t; i++) {
      bool OK = false;
      for (int j = 0; j < n; j++) {
        if (F[j][i] == false)
          OK = true;
      }
      if (OK == true)
        sum++;
    }
    cout << sum << endl;
  }
  return 0;
}