prithivMLmods/Coder-Stat huggingface dataset:
Problem p02818 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;
int main() {
  long long a, b, k;
  cin >> a >> b >> k;
  while (k > 0) {
    if (a > 0) {
      a -= 1;
      k -= 1;
    } else if (b > 0) {
      b -= 1;
      k -= 1;
    } else {
      k -= 1;
      break;
    }
  }
  cout << a << " " << b;
  return 0;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
int main() {
  long long a, b, k;
  cin >> a >> b >> k;
  if (k > a) {
    k -= a;
    a = 0;
  } else {
    a -= k;
    k = 0;
  }
  if (k > b) {
    k -= b;
    b = 0;
  } else {
    b -= k;
    k = 0;
  }
  cout << a << " " << b;
  return 0;
}
Problem p02818 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG

using namespace std;
typedef long long ll;

#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define REP(a, b, m) for (ll a = (ll)(b); a < (ll)(m); a++)

int main() {
  ll a, b, k;
  cin >> a >> b >> k;
  rep(i, k) {
    if (a >= 1)
      a--;
    else if (b >= 1)
      b--;
    else
      break;
  }
  cout << a << ' ' << b << endl;
}

Fixed submission:
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG

using namespace std;
typedef long long ll;

#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define REP(a, b, m) for (ll a = (ll)(b); a < (ll)(m); a++)

int main() {
  ll a, b, k;
  cin >> a >> b >> k;
  if (k <= a) {
    cout << a - k << ' ' << b << endl;
  } else if (k <= a + b) {
    cout << 0 << ' ' << b - (k - a) << endl;
  } else
    cout << 0 << ' ' << 0 << endl;
}
Problem p02818 (C++)

Buggy submission (status: Runtime Error):
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
#include <unordered_map>
#define endl "\n"
#define all(v) v.begin(), v.end()
#define allr(s) s.rbegin(), s.rend()
#define RT(s) return cout << s, 0
#define watch(x) cout << (#x) << " = " << x << endl
#define sz(s) (int)(s.size())
#define PI acos(-1)
#define EPS 1e-8
using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
int dy[] = {1, -1, 0, 0, -1, 1, 1, -1};
int dx[] = {0, 0, 1, -1, 1, -1, 1, -1};
void file() {
#ifndef ONLINE_JUDGE
  freopen("in.txt", "r", stdin);
  // freopen("out.txt", "w", stdout);
#else
  // freopen("street.in", "r", stdin);
  // freopen("out.txt", "w", stdout);
#endif
}
void fast() {
  std::ios_base::sync_with_stdio(0);
  cin.tie(NULL);
}

int main() {
  file();
  fast();
  ll a, b, k;
  cin >> a >> b >> k;
  ll mn = min(a, k);
  a -= mn, k -= mn;
  b -= k;
  b = max(b, 0LL);
  cout << a << ' ' << b << endl;
  return 0;
}

Fixed submission:
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
#include <unordered_map>
#define endl "\n"
#define all(v) v.begin(), v.end()
#define allr(s) s.rbegin(), s.rend()
#define RT(s) return cout << s, 0
#define watch(x) cout << (#x) << " = " << x << endl
#define sz(s) (int)(s.size())
#define PI acos(-1)
#define EPS 1e-8
using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
int dy[] = {1, -1, 0, 0, -1, 1, 1, -1};
int dx[] = {0, 0, 1, -1, 1, -1, 1, -1};
void file() {
#ifndef ONLINE_JUDGE
  freopen("in.txt", "r", stdin);
  // freopen("out.txt", "w", stdout);
#else
  // freopen("street.in", "r", stdin);
  // freopen("out.txt", "w", stdout);
#endif
}
void fast() {
  std::ios_base::sync_with_stdio(0);
  cin.tie(NULL);
}

int main() {
  // file();
  fast();
  ll a, b, k;
  cin >> a >> b >> k;
  ll mn = min(a, k);
  a -= mn, k -= mn;
  b -= k;
  b = max(b, 0LL);
  cout << a << ' ' << b << endl;
  return 0;
}
Problem p02818 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;

int main() {
  long long a, b, k;
  cin >> a >> b >> k;
  while (a > 0) {
    a--;
    k--;
    if (k == 0)
      break;
  }
  while (b > 0) {
    b--;
    k--;
    if (k == 0)
      break;
  }
  cout << a << " " << b;
  return 0;
}

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

int main() {
  long long a, b, k;
  cin >> a >> b >> k;
  if (a >= k)
    cout << a - k << " " << b;
  else if (a < k && a + b >= k)
    cout << 0 << " " << b - k + a;
  else if (a < k && b < k)
    cout << 0 << " " << 0;
  return 0;
}
Problem p02818 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <iostream>
using namespace std;

int main() {
  long long a, b, k;
  cin >> a >> b >> k;
  if (a + b <= k) {
    cout << "0 0" << endl;
  } else {
    for (long i = 0; i < k; i++) {
      if (a > 0)
        --a;
      else if (b > 0)
        --b;
    }
    cout << a << " " << b << endl;
  }
  return 0;
}

Fixed submission:
#include <iostream>
using namespace std;

int main() {
  long long a, b, k;
  cin >> a >> b >> k;
  if (a + b <= k) {
    cout << "0 0" << endl;
  } else {
    if (k <= a)
      cout << a - k << " " << b << endl;
    else
      cout << "0 " << b + a - k;
  }
  return 0;
}
Problem p02818 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
int main() {
  long long A, B, K;
  cin >> A >> B >> K;
  if (A > K) {
    A -= K;
  } else {
    B -= K - A;
    A = 0;
  }
  printf("%llf %llf\n", A, max(0LL, B));
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
int main() {
  long long A, B, K;
  cin >> A >> B >> K;
  if (A > K) {
    A -= K;
  } else {
    B -= K - A;
    A = 0;
  }
  printf("%lld %lld\n", A, max(0LL, B));
}
Problem p02818 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <iostream>
using namespace std;

long A, B, K;

int main() {
  cin >> A >> B >> K;

  for (long i = 0; i < K; i++) {
    if (A >= 1) {
      A--;
    } else if (B >= 1) {
      B--;
    } else {
      break;
    }
  }

  cout << A << ' ' << B;
}

Fixed submission:
#include <iostream>
using namespace std;

long A, B, K;

int main() {
  cin >> A >> B >> K;

  if (K < A) {
    A = A - K;
  } else {
    B = B - (K - A);
    A = 0;
  }

  if (B < 0) {
    B = 0;
  }

  cout << A << ' ' << B;
}
Problem p02818 (Python)

Buggy submission (status: Time Limit Exceeded):
A, B, K = map(int, input().split())

for _ in range(K):
    if A > 0:
        A -= 1
    elif B > 0:
        B -= 1
    else:
        continue
print(A, B)


Fixed submission:
A, B, K = map(int, input().split())

C = max(0, A - K)
K -= A - C
print(C, max(0, B - K))
Problem p02819 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
#include <cmath>
#include <iostream>
#include <vector>
using namespace std;

const int N = pow(10, 9);

vector<bool> isp(N + 1, true);

void sieve() {
  isp[0] = false;
  isp[1] = false;
  for (int i = 2; pow(i, 2) <= N; i++) {
    if (isp[i])
      for (int j = 2; i * j <= N; j++)
        isp[i * j] = false;
  }
}

int main() {
  long long N, a, b = 0;
  long long counter = 0;
  cin >> N;
  long long counter1 = 0;
  vector<long long> vec(100005);
  vector<long long> ves(100005);
  // N以下の整数に対して素数判定をしてくれます。
  // nが素数ならば isp(n)=true、そうでなければ isp(n)=false
  sieve();
  // ex. 51から80までの素数を出力
  for (long long i = N; i > 0; i++) {
    if (isp[i]) {
      counter1 = i;
      break;
    }
  }
  cout << counter1 << endl;
}


Fixed submission:
#include <bits/stdc++.h>
#include <cmath>
#include <iostream>
#include <vector>
using namespace std;

const int N = pow(10, 6);

vector<bool> isp(N + 1, true);

void sieve() {
  isp[0] = false;
  isp[1] = false;
  for (int i = 2; pow(i, 2) <= N; i++) {
    if (isp[i])
      for (int j = 2; i * j <= N; j++)
        isp[i * j] = false;
  }
}

int main() {
  long long N, a, b = 0;
  long long counter = 0;
  cin >> N;
  long long counter1 = 0;
  vector<long long> vec(100005);
  vector<long long> ves(100005);
  // N以下の整数に対して素数判定をしてくれます。
  // nが素数ならば isp(n)=true、そうでなければ isp(n)=false
  sieve();
  // ex. 51から80までの素数を出力
  for (long long i = N; i > 0; i++) {
    if (isp[i]) {
      counter1 = i;
      break;
    }
  }
  cout << counter1 << endl;
}
Problem p02819 (C++)

Buggy submission (status: Time Limit Exceeded):
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for (int i = 1; i < (int)(n); i++)
#define dunk(n) cout << n << endl
#define all(a) (a).begin(), (a).end()
typedef pair<int, int> P;
typedef long long ll;

bool is_prime(ll num) {
  if (num < 2)
    return false;
  else if (num == 2)
    return true;
  else if (num % 2 == 0)
    return false;

  for (ll i = 3; i <= (ll)sqrt(num); i += 2) {
    if (num % i == 0)
      return false;
  }

  return true;
}

int main() {
  int x;
  cin >> x;
  for (int i = x;; i++) {
    if (is_prime(i)) {
      dunk(i);
    }
  }
  return 0;
}

Fixed submission:
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for (int i = 1; i < (int)(n); i++)
#define dunk(n) cout << n << endl
#define all(a) (a).begin(), (a).end()
typedef pair<int, int> P;
typedef long long ll;

bool is_prime(ll num) {
  if (num < 2)
    return false;
  else if (num == 2)
    return true;
  else if (num % 2 == 0)
    return false;

  for (ll i = 3; i <= (ll)sqrt(num); i += 2) {
    if (num % i == 0)
      return false;
  }

  return true;
}

int main() {
  int x;
  cin >> x;
  for (int i = x;; i++) {
    if (is_prime(i)) {
      dunk(i);
      return 0;
    }
  }
  return 0;
}
Problem p02819 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;

int main() {
  int x, s;
  int a[100009][2];
  for (int i = 2; i < 100009; i++) {
    a[i][0] = i;
    a[i][1] = 0;
  }
  for (int i = 2; i < 400; i++) {
    if (a[i][1] == 0) {
      a[i][1] = 2;
      s = 2;
      while (i * s < 100009) {
        a[i * s][1] = 1;
        s++;
      }
    }
  }
  s = 0;
  cin >> x;
  while (s == 0) {
    if (a[x][1] == 2) {
      cout << x << endl;
      s++;
    } else
      x++;
  }
}

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

int main() {
  int x, s;
  int a[100009][2];
  for (int i = 2; i < 100009; i++) {
    a[i][0] = i;
    a[i][1] = 0;
  }
  for (int i = 2; i < 100009; i++) {
    if (a[i][1] == 0) {
      a[i][1] = 2;
      s = 2;
      while (i * s < 100009) {
        a[i * s][1] = 1;
        s++;
      }
    }
  }
  s = 0;
  cin >> x;
  while (s == 0) {
    if (a[x][1] == 2) {
      cout << x << endl;
      s++;
    } else
      x++;
  }
}
Problem p02819 (C++)

Buggy submission (status: Runtime Error):
/**
 * @copyright (c) 2020 Daisuke Hashimoto
 */

#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
using Pair = pair<int32_t, int32_t>;

// std::cout << std::setprecision(20) << 1.1 << endl;

int32_t f(const int32_t n) { return (n % 2 == 0) ? n / 2 : 3 * n + 1; }

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);

  int32_t X;
  cin >> X;
  const int32_t max_search = max(100, 2 * X);
  vector<bool> is_prime(max_search, true);
  int32_t result = -1;
  for (int32_t i = 2; i <= max_search; ++i) {
    if (is_prime[i]) {
      if (i >= X) {
        result = i;
        break;
      }
      int32_t j = 2 * i;
      while (j <= max_search) {
        is_prime[j] = false;
        j += i;
      }
    }
  }
  cout << result << endl;

  return 0;
}


Fixed submission:
/**
 * @copyright (c) 2020 Daisuke Hashimoto
 */

#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
using Pair = pair<int32_t, int32_t>;

// std::cout << std::setprecision(20) << 1.1 << endl;

int32_t f(const int32_t n) { return (n % 2 == 0) ? n / 2 : 3 * n + 1; }

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);

  int32_t X;
  cin >> X;
  const int32_t max_search = max(100, 2 * X);
  vector<bool> is_prime(max_search + 1, true);
  int32_t result = -1;
  for (int32_t i = 2; i <= max_search; ++i) {
    if (is_prime[i]) {
      if (i >= X) {
        result = i;
        break;
      }
      int32_t j = 2 * i;
      while (j <= max_search) {
        is_prime[j] = false;
        j += i;
      }
    }
  }
  cout << result << endl;

  return 0;
}
Problem p02819 (C++)

Buggy submission (status: Time Limit Exceeded):
#include "bits/stdc++.h"
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
  int x;
  int ans;
  cin >> x;
  ans = 0;
  int x2;
  x2 = x;
  while (ans == 0) {
    rep(i, x2 - 2) {
      if (x % (i + 2) == 0) {
        break;
      }
      if (i == x2 - 3) {
        ans = x;
      }
    }
    ++x;
  }
  cout << ans << endl;

  return 0;
}

Fixed submission:
#include "bits/stdc++.h"
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
  int x;
  int ans;
  cin >> x;
  ans = 0;
  int x2;
  x2 = x;
  while (ans == 0) {
    if (x == 2) {
      ans = 2;
      break;
    }
    rep(i, x2 - 2) {
      if (x % (i + 2) == 0) {
        break;
      }
      if (i == x2 - 3) {
        ans = x;
      }
    }
    ++x;
  }
  cout << ans << endl;

  return 0;
}
Problem p02819 (Python)

Buggy submission (status: Time Limit Exceeded):
# ABC149C - Next Prime
def is_prime(n: int) -> bool:
    """
    Evaluate whether a number is prime or not.

    Args:
        n: a number to evaluate

    Returns: whether n is prime or not
    """
    if n == 2:
        return True
    if n == 1 or n % 2 == 0:
        return False
    for i in range(3, int(n**0.5) + 1, 2):
        if n % i == 0:
            return False
    return True


def main():
    N = int(input())
    while not is_prime(N):
        N += 2
    print(N)


if __name__ == "__main__":
    main()


Fixed submission:
# ABC149C - Next Prime
def is_prime(n: int) -> bool:
    """
    Evaluate whether a number is prime or not.

    Args:
        n: a number to evaluate

    Returns: whether n is prime or not
    """
    if n == 2:
        return True
    if n == 1 or n % 2 == 0:
        return False
    for i in range(3, int(n**0.5) + 1, 2):
        if n % i == 0:
            return False
    return True


def main():
    N = int(input())
    if N != 2 and N % 2 == 0:
        N += 1
    while not is_prime(N):
        N += 2
    print(N)


if __name__ == "__main__":
    main()
Problem p02819 (Python)

Buggy submission (status: Time Limit Exceeded):
import math

x = int(input())

primes = []

for n in range(2, 10000000000, 2):
    f = True
    mp = math.ceil(math.sqrt(n))
    for p in primes:
        if p > mp:
            break
        if n % p == 0:
            f = False
            break
    if f:
        primes.append(n)
        if n >= x:
            print(n)
            exit(0)


Fixed submission:
import math

x = int(input())

primes = []

if x == 2:
    print(2)
    exit(0)

for n in range(3, 10000000000, 2):
    f = True
    mp = math.ceil(math.sqrt(n))
    for p in primes:
        if p > mp:
            break
        if n % p == 0:
            f = False
            break
    if f:
        primes.append(n)
        if n >= x:
            print(n)
            exit(0)
Problem p02819 (C++)

Buggy submission (status: Runtime Error):
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <vector>
using namespace std;
using lli = long long int;

int main() {
  int x;
  cin >> x;
  int m = min(x * x, 100010);
  vector<bool> p(m, true);
  p[0] = p[1] = false;
  for (int i = 2; i < (int)sqrt(m); i++) {
    if (p[i] == false) {
      continue;
    }
    for (int j = i * 2; j < m; j += i) {
      p[j] = false;
    }
  }
  for (int i = x; i < m; i++) {
    if (p[i]) {
      cout << i << endl;
      break;
    }
  }
  return 0;
}

Fixed submission:
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <vector>
using namespace std;
using lli = long long int;

int main() {
  int x;
  cin >> x;
  int m = 100010;
  vector<bool> p(m, true);
  p[0] = p[1] = false;
  for (int i = 2; i < (int)sqrt(m); i++) {
    if (p[i] == false) {
      continue;
    }
    for (int j = i * 2; j < m; j += i) {
      p[j] = false;
    }
  }
  for (int i = x; i < m; i++) {
    if (p[i]) {
      cout << i << endl;
      break;
    }
  }
  return 0;
}
Problem p02819 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;
bool is_prime(int x) {
  if (x <= 1)
    return false;
  for (int i = 2; i * i <= x; i++) {
    if (x % i == 0)
      return false;
  }
  return false;
}

int main() {
  int n;
  cin >> n;
  while (!is_prime(n))
    n++;
  cout << n;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
bool is_prime(int x) {
  if (x <= 1)
    return false;
  for (int i = 2; i * i <= x; i++) {
    if (x % i == 0)
      return false;
  }
  return true;
}

int main() {
  int n;
  cin >> n;
  while (!is_prime(n))
    n++;
  cout << n;
}
Problem p02819 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;

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

int main() {
  int X;
  cin >> X;

  while (true) {
    if (isPrime(X)) {
      cout << X << endl;
      return 0;
    }
    X++;
  }
}

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

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

int main() {
  int X;
  cin >> X;

  while (true) {
    if (isPrime(X)) {
      cout << X << endl;
      return 0;
    }
    X++;
  }
}
Problem p02819 (C++)

Buggy submission (status: Runtime Error):
#include <iostream>

using namespace std;

int const NMAX = 1e6;

bool ciur[1 + NMAX];

int computeCiur() {
  for (long long i = 2; i * i <= NMAX; i++) {
    if (ciur[i] == 0) {
      for (long long j = i * i; j <= NMAX; j += i) {
        ciur[j] = 1;
      }
    }
  }
}

int main() {

  int n;
  cin >> n;
  computeCiur();
  while (ciur[n] == 1) {
    n++;
  }
  cout << n;
  return 0;
}


Fixed submission:
#include <iostream>

using namespace std;

int const NMAX = 1e6;

bool ciur[1 + NMAX];

void computeCiur() {
  for (long long i = 2; i * i <= NMAX; i++) {
    if (ciur[i] == 0) {
      for (long long j = i * i; j <= NMAX; j += i) {
        ciur[j] = 1;
      }
    }
  }
}

int main() {

  int n;
  cin >> n;
  computeCiur();
  while (ciur[n] == 1) {
    n++;
  }
  cout << n;
  return 0;
}
Problem p02819 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <algorithm>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <random>
#include <set>
#include <stdio.h>
#include <string>
#include <time.h>
#include <vector>
#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;

int main() {
  int x;
  cin >> x;
  while (true) {
    bool fig = true;
    for (int i = 1; i <= sqrt(x); i++) {
      if (x % i == 0)
        fig = false;
    }
    if (fig) {
      cout << x << endl;
      return 0;
    }
    x++;
  }
  return 0;
}


Fixed submission:
#include <algorithm>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <random>
#include <set>
#include <stdio.h>
#include <string>
#include <time.h>
#include <vector>
#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;

int main() {
  int x;
  cin >> x;
  while (true) {
    bool fig = true;
    for (int i = 2; i <= sqrt(x); i++) {
      if (x % i == 0)
        fig = false;
    }
    if (fig) {
      cout << x << endl;
      return 0;
    }
    x++;
  }
  return 0;
}
Problem p02819 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;
#define int long long

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

  return true;
}
int32_t main() {
  int n;
  cin >> n;

  int p = n;

  while (!isPrime(p)) {
    p++;
  }
  cout << p << endl;
  return 0;
}


Fixed submission:
#include <bits/stdc++.h>
using namespace std;
#define int long long

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

  return true;
}
int32_t main() {
  int n;
  cin >> n;

  int p = n;

  while (!isPrime(p)) {
    p++;
  }
  cout << p << endl;
  return 0;
}
Problem p02819 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <iostream>
using namespace std;

int main() {
  int x;
  cin >> x;

  while (1) {
    bool ok = true;
    for (int i = 2; i < x; ++i) {
      if (x % 1 == 0) {
        ok = false;
        break;
      }
    }
    if (ok)
      break;
    ++x;
  }
  cout << x << endl;
  return 0;
}


Fixed submission:
#include <iostream>
using namespace std;

int main() {
  int x;
  cin >> x;

  while (1) {
    bool ok = true;
    for (int i = 2; i < x; ++i) {
      if (x % i == 0) {
        ok = false;
        break;
      }
    }
    if (ok)
      break;
    ++x;
  }
  cout << x << endl;
  return 0;
}
Problem p02819 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <string>
#include <vector>
#define rep(i, n) for (long long i = 0; (i) < (n); (i)++)
using namespace std;
using ll = long long;
const ll mod = 1000000007;

int main() {
  ll N;
  cin >> N;
  if (N == 2) {
    cout << 2 << endl;
    return 0;
  }
  vector<ll> prime;
  prime.push_back(2);
  for (int i = 3; i <= 100003; i++) {
    bool flag = true;
    for (auto k : prime) {
      if (i % k == 0)
        flag = false;
    }
    if (flag) {
      if (i >= N) {
        cout << i << endl;
        return 0;
      }
      prime.push_back(i);
    }
  }
  return 0;
}

Fixed submission:
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <string>
#include <vector>
#define rep(i, n) for (long long i = 0; (i) < (n); (i)++)
using namespace std;
using ll = long long;
const ll mod = 1000000007;

int main() {
  ll N;
  cin >> N;
  if (N == 2) {
    cout << 2 << endl;
    return 0;
  }
  vector<ll> prime;
  prime.push_back(2);
  for (int i = 3; i <= 100003; i++) {
    bool flag = true;
    for (auto k : prime) {
      if (k * k > i)
        break;
      if (i % k == 0)
        flag = false;
    }
    if (flag) {
      if (i >= N) {
        cout << i << endl;
        return 0;
      }
      prime.push_back(i);
    }
  }
  return 0;
}
Problem p02819 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
#define rep(i, a, b) for (int i = a; i < (b); ++i)
#define trav(a, x) for (auto &a : x)
#define sz(x) (int)(x).size()
typedef vector<int> vi;
// #define ll long long
#define int long long
#define ld long double
#define fi first
#define se second
#define pb push_back
#define pii pair<int, int>
#define all(x) (x).begin(), (x).end()
const int MOD = 1e9 + 7;
int mpow(int a, int b, int p = MOD) {
  a = a % p;
  int res = 1;
  while (b > 0) {
    if (b & 1)
      res = (res * a) % p;
    a = (a * a) % p;
    b = b >> 1;
  }
  return res % p;
}
const int N = 2 * 1e5 + 2;
bool prime(int x) {
  for (int i = 2; i * i <= x; i++) {
    if (x % i == 0)
      return false;
  }
  return true;
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
#ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
// freopen("out10.txt","w",stdout);
#endif
  int x;
  cin >> x;
  for (int i = x;; i++) {
    if (prime(i)) {
      cout << i;
      return 0;
    }
  }
}
// I never lose. I either win or I learn

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
#define rep(i, a, b) for (int i = a; i < (b); ++i)
#define trav(a, x) for (auto &a : x)
#define sz(x) (int)(x).size()
typedef vector<int> vi;
// #define ll long long
#define int long long
#define ld long double
#define fi first
#define se second
#define pb push_back
#define pii pair<int, int>
#define all(x) (x).begin(), (x).end()
const int MOD = 1e9 + 7;
int mpow(int a, int b, int p = MOD) {
  a = a % p;
  int res = 1;
  while (b > 0) {
    if (b & 1)
      res = (res * a) % p;
    a = (a * a) % p;
    b = b >> 1;
  }
  return res % p;
}
const int N = 2 * 1e5 + 2;
bool prime(int x) {
  for (int i = 2; i * i <= x; i++) {
    if (x % i == 0)
      return false;
  }
  return true;
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  int x;
  cin >> x;
  for (int i = x;; i++) {
    if (prime(i)) {
      cout << i;
      return 0;
    }
  }
}
// I never lose. I either win or I learn
Problem p02819 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rep2(i, s, n) for (int i = s; i < n; ++i)
#define all(a) a.begin(), a.end()
#define tmax(a, b, c) max(a, max(b, c))
#define tmin(a, b, c) min(a, min(b, c))
#define pb push_back
using namespace std;
using ll = long long;
using P = pair<int, int>;
template <class T> inline bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template <class T> inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
const int inf = 1001001001;

struct Sieve {
  int n;
  vector<int> f, primes;
  Sieve(int n = 1) : n(n), f(n + 1) {
    f[0] = f[1] = -1;
    for (ll i = 2; i <= n; ++i) {
      if (f[i])
        continue;
      primes.push_back(i);
      f[i] = i;
      for (ll j = i * i; j <= n; j += i) {
        if (!f[j])
          f[j] = i;
      }
    }
  }
  bool isPrime(int x) { return f[x] == x; }
  vector<int> factorList(int x) {
    vector<int> res;
    while (x != 1) {
      res.push_back(f[x]);
      x /= f[x];
    }
    return res;
  }
  vector<P> factor(int x) {
    vector<int> fl = factorList(x);
    if (fl.size() == 0)
      return {};
    vector<P> res(1, P(fl[0], 0));
    for (int p : fl) {
      if (res.back().first == p) {
        res.back().second++;
      } else {
        res.emplace_back(p, 1);
      }
    }
    return res;
  }
} s(100000);

int main() {
  int x;
  cin >> x;
  while (true) {
    if (s.isPrime(x)) {
      cout << x << endl;
      return 0;
    }
    x++;
  }
}

Fixed submission:
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rep2(i, s, n) for (int i = s; i < n; ++i)
#define all(a) a.begin(), a.end()
#define tmax(a, b, c) max(a, max(b, c))
#define tmin(a, b, c) min(a, min(b, c))
#define pb push_back
using namespace std;
using ll = long long;
using P = pair<int, int>;
template <class T> inline bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template <class T> inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
const int inf = 1001001001;

struct Sieve {
  int n;
  vector<int> f, primes;
  Sieve(int n = 1) : n(n), f(n + 1) {
    f[0] = f[1] = -1;
    for (ll i = 2; i <= n; ++i) {
      if (f[i])
        continue;
      primes.push_back(i);
      f[i] = i;
      for (ll j = i * i; j <= n; j += i) {
        if (!f[j])
          f[j] = i;
      }
    }
  }
  bool isPrime(int x) { return f[x] == x; }
  vector<int> factorList(int x) {
    vector<int> res;
    while (x != 1) {
      res.push_back(f[x]);
      x /= f[x];
    }
    return res;
  }
  vector<P> factor(int x) {
    vector<int> fl = factorList(x);
    if (fl.size() == 0)
      return {};
    vector<P> res(1, P(fl[0], 0));
    for (int p : fl) {
      if (res.back().first == p) {
        res.back().second++;
      } else {
        res.emplace_back(p, 1);
      }
    }
    return res;
  }
} s(200000);

int main() {
  int x;
  cin >> x;
  while (true) {
    if (s.isPrime(x)) {
      cout << x << endl;
      return 0;
    }
    x++;
  }
}
Problem p02819 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>

#define PI 3.1415926535897932
#define MOD 1000000007
#define INF 1e9

#define REP(i, n) for (int i = 0; i < (n); i++)
#define REP1(i, n) for (int i = 1; i <= (n); i++)
#define ALL(v) (v).begin(), (v).end()

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef vector<bool> vb;

void solve() {
  ll X;
  cin >> X;
  ll MAX = 1000000;
  vb isPrime(MAX);
  fill(ALL(isPrime), true);
  isPrime[0] = isPrime[1] = false;
  for (ll i = 2; i * i <= MAX; i++) {
    if (isPrime[i]) {
      for (ll j = i * 2; j <= MAX; j += i) {
        isPrime[j] = false;
      }
    }
  }

  for (ll i = X; i <= MAX; i++) {
    if (isPrime[i]) {
      cout << i << endl;
      return;
    }
  }
}

int main() {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(20);

  solve();

  return 0;
}

Fixed submission:
#include <bits/stdc++.h>

#define PI 3.1415926535897932
#define MOD 1000000007
#define INF 1e9

#define REP(i, n) for (int i = 0; i < (n); i++)
#define REP1(i, n) for (int i = 1; i <= (n); i++)
#define ALL(v) (v).begin(), (v).end()

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef vector<bool> vb;

void solve() {
  ll X;
  cin >> X;
  ll MAX = 1000000;
  vb isPrime(MAX + 1);
  fill(ALL(isPrime), true);
  isPrime[0] = isPrime[1] = false;
  for (ll i = 2; i * i <= MAX; i++) {
    if (isPrime[i]) {
      for (ll j = i * 2; j <= MAX; j += i) {
        isPrime[j] = false;
      }
    }
  }

  for (ll i = X; i <= MAX; i++) {
    if (isPrime[i]) {
      cout << i << endl;
      return;
    }
  }
}

int main() {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(20);

  solve();

  return 0;
}
Problem p02819 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;

const int MAX_N = 120000;
vector<bool> IsPrime(MAX_N, true);

void sieve() {
  IsPrime[0] = false;
  IsPrime[1] = false;
  for (int i = 2; i * i <= MAX_N; i++) {
    if (IsPrime[i]) {
      for (int j = 2; i * j <= MAX_N; j++) {
        IsPrime[i * j] = false;
      }
    }
  }
}

int main() {
  int x;
  cin >> x;
  int ans = 0;
  sieve();
  for (int i = 2; i <= MAX_N; i++) {
    if (IsPrime[i] && i >= x) {
      ans = i;
      break;
    }
  }
  cout << ans << endl;
}


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

const int MAX_N = 101010;
vector<bool> IsPrime(MAX_N, true);

void sieve() {
  IsPrime[0] = false;
  IsPrime[1] = false;
  for (int i = 2; i * i <= MAX_N; i++) {
    if (IsPrime[i]) {
      for (int j = 2; i * j <= MAX_N; j++) {
        IsPrime[i * j] = false;
      }
    }
  }
}

int main() {
  int x;
  cin >> x;
  int ans = 0;
  sieve();
  for (int i = 2; i <= MAX_N; i++) {
    if (IsPrime[i] && i >= x) {
      ans = i;
      break;
    }
  }
  cout << ans << endl;
}
Problem p02819 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
#include <iostream>
#include <string>
#define UB upper_bound
#define LB lower_bound
#define BS binary_search
#define IN insert
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define NL cout << endl
#define ll long long int
#define ld long double
#define vl vector<ll>
#define sl set<ll>
#define ml map<ll, ll>
#define sc set<char>
#define li list<ll>
#define vp vector<pair<ll, ll>>
#define vs vector<string>
#define ss set<string>
#define REP(i, a, b) for (ll i = a; i < b; i++)
#define REPI(i, a, b) for (ll i = b - 1; i >= a; i--)
#define REPIT(it, a) for (auto it = a.begin(); it != a.end(); it++)
#define N (ll) pow(2, 32) - 1
#define mod (ll)1000000007
using namespace std;
vl p;
vl sieve(ll m) {
  vl f;
  REP(i, 1, sqrt(m) + 1) {
    if (m % i == 0) {
      f.PB(i);
      if (m / i != i)
        f.PB(m / i);
    }
  }
  return f;
}
void fill(ll n) {
  p.PB(2);
  p.PB(3);
  p.PB(5);
  p.PB(7);
  REP(i, 11, n) {
    vl v = sieve(i);
    if (v.size() == 2)
      p.PB(i);
  }
}
int main() {

  ios::sync_with_stdio(0);
  cin.tie(0);
  ll t = 1;
  // cin>>t;
  while (t--) {
    p.clear();
    fill(1000000ll);
    ll n;
    cin >> n;
    auto it = LB(p.begin(), p.end(), n);
    cout << *it << endl;
  }
  return 0;
}

Fixed submission:
#include <bits/stdc++.h>
#include <iostream>
#include <string>
#define UB upper_bound
#define LB lower_bound
#define BS binary_search
#define IN insert
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define NL cout << endl
#define ll long long int
#define ld long double
#define vl vector<ll>
#define sl set<ll>
#define ml map<ll, ll>
#define sc set<char>
#define li list<ll>
#define vp vector<pair<ll, ll>>
#define vs vector<string>
#define ss set<string>
#define REP(i, a, b) for (ll i = a; i < b; i++)
#define REPI(i, a, b) for (ll i = b - 1; i >= a; i--)
#define REPIT(it, a) for (auto it = a.begin(); it != a.end(); it++)
#define N (ll) pow(2, 32) - 1
#define mod (ll)1000000007
using namespace std;
vl p;
vl sieve(ll m) {
  vl f;
  REP(i, 1, sqrt(m) + 1) {
    if (m % i == 0) {
      f.PB(i);
      if (m / i != i)
        f.PB(m / i);
    }
  }
  return f;
}
void fill(ll n) {
  p.PB(2);
  p.PB(3);
  p.PB(5);
  p.PB(7);
  REP(i, 11, n) {
    vl v = sieve(i);
    if (v.size() == 2)
      p.PB(i);
  }
}
int main() {

  ios::sync_with_stdio(0);
  cin.tie(0);
  ll t = 1;
  // cin>>t;
  while (t--) {
    p.clear();
    fill(150000ll);
    ll n;
    cin >> n;
    auto it = LB(p.begin(), p.end(), n);
    cout << *it << endl;
  }
  return 0;
}
Problem p02819 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL << 62
#define inf 1000000007

int main() {
  ll n;
  cin >> n;
  vector<ll> so;
  for (ll i = 2;; i++) {
    bool ch = true;
    for (auto itr = so.begin(); itr != so.end(); itr++) {
      if (i % *itr == 0) {
        ch = false;
      }
    }
    if (ch) {
      if (i >= n) {
        cout << i << endl;
        return 0;
      }
      so.push_back(i);
    }
  }
  // your code goes here
  return 0;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL << 62
#define inf 1000000007

int main() {
  ll n;
  cin >> n;
  vector<ll> so;
  for (ll i = 2;; i++) {
    bool ch = true;
    for (auto itr = so.begin(); itr != so.end(); itr++) {
      if (i % *itr == 0) {
        ch = false;
      }
      if (*itr > sqrt(i)) {
        break;
      }
    }
    if (ch) {
      if (i >= n) {
        cout << i << endl;
        return 0;
      }
      so.push_back(i);
    }
  }
  // your code goes here
  return 0;
}
Problem p02819 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;
int main() {
  int X;
  cin >> X;
  bool prime = true;
  int count = 0; // 約数の数
  if (X == 2) {
    cout << 2 << endl;
  } else {
    while (prime) {
      for (int j = 2; j * j <= X; j++) {
        if (X % j == 0) {
          count++;
          break;
        }
      } // j
      if (count == 0) {
        prime = false;
      }
      X += 1;
    } // while
    cout << X - 1 << endl;
  } // else
}


Fixed submission:
#include <bits/stdc++.h>
using namespace std;
int main() {
  int X;
  cin >> X;
  bool prime = true;
  int count = 0; // 約数の数
  if (X == 2) {
    cout << 2 << endl;
  } else {
    while (prime) {
      count = 0;
      for (int j = 2; j * j <= X; j++) {
        if (X % j == 0) {
          count++;
          break;
        }
      } // j
      if (count == 0) {
        prime = false;
      }
      X += 1;
    } // while
    cout << X - 1 << endl;
  } // else
}
Problem p02819 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
#define rep(i, a) for (int i = 0; i < int(a); ++i)
using ll = long long;
using namespace std;
ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }
vector<bool> isprime(2 * 1e5, true);
int main() {
  ll x;
  cin >> x;
  isprime[0] = false;
  isprime[1] = false;
  for (ll i = 2; pow(i, 2) <= 2 * x; i++) {
    if (isprime[i]) {
      for (ll j = 2; i * j <= 2 * x; j++)
        isprime[i * j] = false;
    }
  }
  rep(i, x + x) {
    if (isprime[i] && i >= x) {
      cout << i << endl;
      return 0;
    }
  }
}


Fixed submission:
#include <bits/stdc++.h>
#define rep(i, a) for (int i = 0; i < int(a); ++i)
using ll = long long;
using namespace std;
ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }
vector<bool> isprime(1e6, true);
int main() {
  ll x;
  cin >> x;
  isprime[0] = false;
  isprime[1] = false;
  for (ll i = 2; pow(i, 2) <= 2 * x; i++) {
    if (isprime[i]) {
      for (ll j = 2; i * j <= 2 * x; j++)
        isprime[i * j] = false;
    }
  }
  rep(i, x + x) {
    if (isprime[i] && i >= x) {
      cout << i << endl;
      return 0;
    }
  }
}
Problem p02819 (C++)

Buggy submission (status: Runtime Error):
// define DEBUG for debug
#define DEBUG

#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define MAX 100000 + 100
#define MOD 1000000007
typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
int asallar[100000], asalsay = 0;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
#ifdef DEBUG
  freopen("i.txt", "r", stdin);
  freopen("o.txt", "w", stdout);
#endif
  ll x;
  cin >> x;
  for (ll i = 2; i < 100004; i++) {
    bool asal = true;
    for (ll a = 0; a < asalsay; a++) {
      if (i % asallar[a] == 0) {
        asal = false;
        break;
      }
    }
    if (asal) {
      if (i >= x) {
        cout << i;
        return 0;
      }
      asallar[asalsay] = i;
      asalsay++;
    }
  }
  return 0;
}

Fixed submission:
// define DEBUG for debug
// #define DEBUG

#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define MAX 100000 + 100
#define MOD 1000000007
typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
int asallar[100000], asalsay = 0;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
#ifdef DEBUG
  freopen("i.txt", "r", stdin);
  freopen("o.txt", "w", stdout);
#endif
  ll x;
  cin >> x;
  for (ll i = 2; i < 100004; i++) {
    bool asal = true;
    for (ll a = 0; a < asalsay; a++) {
      if (i % asallar[a] == 0) {
        asal = false;
        break;
      }
    }
    if (asal) {
      if (i >= x) {
        cout << i;
        return 0;
      }
      asallar[asalsay] = i;
      asalsay++;
    }
  }
  return 0;
}
Problem p02819 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>

using namespace std;

int main() {
  long long a;
  cin >> a;
  if (a == 0) {
    cout << 1;
  } else if (a == 1) {
    cout << 2;
  } else {
    for (long long i = 2; i <= a * a; i++) {
      long long flag = 1;
      for (long long j = 2; j <= i / 2; ++j) {
        if (i % j == 0) {
          flag = 0;
          break;
        }
      }
      if (flag && i >= a) {
        cout << i;
        break;
      }
    }
  }

  return 0;
}


Fixed submission:
#include <bits/stdc++.h>

using namespace std;

int main() {
  long long a;
  cin >> a;
  if (a == 0) {
    cout << 1;
  } else if (a == 1) {
    cout << 2;
  } else {
    for (long long i = a; i <= a * a; i++) {
      long long flag = 1;
      for (long long j = 2; j <= i / 2; ++j) {
        if (i % j == 0) {
          flag = 0;
          break;
        }
      }
      if (flag && i >= a) {
        cout << i;
        break;
      }
    }
  }

  return 0;
}
Problem p02819 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
vector<bool> isp;
int N;

void sieve() {
  isp[0] = false;
  isp[1] = false;
  for (int i = 2; pow(i, 2) <= N; i++) {
    if (isp[i])
      for (int j = 2; i * j <= N; j++)
        isp[i * j] = false;
  }
}

void solve(long long X) {
  N = X;

  isp = vector<bool>(N + 1, true);

  for (int i = 0; i < 100; i++) {
    sieve();
    if (isp[N]) {
      cout << N << endl;
      break;
    }
    N++;
  }
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You
// use the default template now. You can remove this line by using your custom
// template)
int main() {
  long long X;
  scanf("%lld", &X);
  solve(X);
  return 0;
}


Fixed submission:
#include <bits/stdc++.h>
using namespace std;
vector<bool> isp;
int N;

void sieve() {
  isp[0] = false;
  isp[1] = false;
  for (int i = 2; pow(i, 2) <= N; i++) {
    if (isp[i])
      for (int j = 2; i * j <= N; j++)
        isp[i * j] = false;
  }
}

void solve(long long X) {
  N = X;

  isp = vector<bool>(N + 100, true);

  for (int i = 0; i < 100; i++) {
    sieve();
    if (isp[N]) {
      cout << N << endl;
      break;
    }
    N++;
  }
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You
// use the default template now. You can remove this line by using your custom
// template)
int main() {
  long long X;
  scanf("%lld", &X);
  solve(X);
  return 0;
}
Problem p02819 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;

int main() {
  int X;
  cin >> X;
  for (;;) {
    for (int i = X - 1; 1 <= i; i--) {
      if (X % i == 0) {
        continue;
        ;
      }
      if (i == 1) {
        cout << X << endl;
        return 0;
        ;
      }
    }
    X++;
  }
}

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

int main() {
  int X;
  cin >> X;
  for (;;) {
    for (int i = X - 1; 1 <= i; i--) {
      if (X % i == 0 && (!(i == 1))) {
        break;
        ;
      }
      if (i == 1) {
        cout << X << endl;
        return 0;
        ;
      }
    }
    X++;
  }
}
Problem p02819 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
using vs = vector<string>;
using vpii = vector<pair<int, int>>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using vvs = vector<vector<string>>;
using pii = pair<int, int>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, n) for (int i = 1; i <= (int)(n); i++)
#define rrep(i, n) for (int i = (int)(n)-1; i >= 0; i--)
#define rreps(i, n) for (int i = (int)(n); i > 0; i--)
#define FOR(i, a, b) for (int i = (int)(a); i <= (int)(b); i++)
#define RFOR(i, a, b) for (int i = (int)(a); i >= (int)(b); i--)
#define all(x) (x).begin(), (x).end()
#define MAX(x) *max_element(all(x))
#define MIN(x) *min_element(all(x))
template <class T> bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T> bool chmin(T &a, const T &b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
const int INF = INT_MAX;
const int MOD = 1000000007;

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

int main() {
  int n;
  cin >> n;
  int i = n;
  while (true) {
    if (is_prime(n))
      break;
    else
      i++;
  }
  cout << i << endl;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
using vs = vector<string>;
using vpii = vector<pair<int, int>>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using vvs = vector<vector<string>>;
using pii = pair<int, int>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, n) for (int i = 1; i <= (int)(n); i++)
#define rrep(i, n) for (int i = (int)(n)-1; i >= 0; i--)
#define rreps(i, n) for (int i = (int)(n); i > 0; i--)
#define FOR(i, a, b) for (int i = (int)(a); i <= (int)(b); i++)
#define RFOR(i, a, b) for (int i = (int)(a); i >= (int)(b); i--)
#define all(x) (x).begin(), (x).end()
#define MAX(x) *max_element(all(x))
#define MIN(x) *min_element(all(x))
template <class T> bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T> bool chmin(T &a, const T &b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
const int INF = INT_MAX;
const int MOD = 1000000007;

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

int main() {
  int n;
  cin >> n;
  int i = n;
  while (!is_prime(i))
    i++;
  cout << i << endl;
}
Problem p02819 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <cmath>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stdlib.h>
#include <unordered_map>
#include <vector>

using namespace std;
typedef long long ll;

const int N = 1000000;
vector<bool> isp(N, true);
void sieve() {
  isp[0] = false;
  isp[1] = false;
  for (auto i = 0; i <= N; i++) {
    if (isp[i]) {
      for (auto j = 2; i * j <= N; j++)
        isp[i * j] = false;
    }
  }
}

int main() {
  sieve();
  ll k;
  cin >> k;

  for (auto i = k; i <= N; i++) {
    if (isp[i]) {
      cout << i << endl;
      return 0;
    }
  }
  return 0;
}


Fixed submission:
#include <algorithm>
#include <cmath>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stdlib.h>
#include <unordered_map>
#include <vector>

using namespace std;
typedef long long ll;

const int N = 100003 + 1;
vector<bool> isp(N, true);
void sieve() {
  isp[0] = false;
  isp[1] = false;
  for (auto i = 0; i <= N; i++) {
    if (isp[i]) {
      for (auto j = 2; i * j <= N; j++)
        isp[i * j] = false;
    }
  }
}

int main() {
  sieve();
  ll k;
  cin >> k;

  for (auto i = k; i <= N; i++) {
    if (isp[i]) {
      cout << i << endl;
      return 0;
    }
  }
  return 0;
}
Problem p02819 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
#define ll long long
#define pii pair<int, int>
#define pb push_back
#define f first
#define s second
#define MOD 1000000007

using namespace std;

bool prime[200001];

void solve() {
  ll x;
  cin >> x;

  for (int i = 2; i < 200001; i++) {
    if (!prime[i]) {
      for (int j = i; i * j <= 200000; j++) {
        prime[j * i] = 1;
      }
    }
  }
  for (int i = 2; i <= 200000; i++) {
    if (prime[i] == 0 && i >= x) {
      cout << i;
      break;
    }
  }
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  // cout<<fixed<<setprecision(12);

  int t = 1;
  // cin>>t;

  for (int i = 1; i <= t; i++) {
    solve();
    cout << "\n";
  }
  return 0;
}


Fixed submission:
#include <bits/stdc++.h>
#define ll long long
#define pii pair<int, int>
#define pb push_back
#define f first
#define s second
#define MOD 1000000007

using namespace std;

bool prime[200001];

void solve() {
  ll x;
  cin >> x;

  for (int i = 2; i < 200001; i++) {
    if (!prime[i] && (ll)i * i <= 200001) {
      for (int j = i; i * j <= 200000; j++) {
        prime[j * i] = 1;
      }
    }
  }
  for (int i = 2; i <= 200000; i++) {
    if (prime[i] == 0 && i >= x) {
      cout << i;
      break;
    }
  }
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  // cout<<fixed<<setprecision(12);

  int t = 1;
  // cin>>t;

  for (int i = 1; i <= t; i++) {
    solve();
    cout << "\n";
  }
  return 0;
}