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

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
using namespace std;
#define INF 2000000007
#define LINF 100000000000000007
#define MOD 1000000007
#define int long long
#define rep(i, n) for (int i = 0; i < n; i++)
#define repb(i, n) for (int i = n - 1; i >= 0; i--)
// #define MODE 1
#ifdef MODE
#define DEB(X) cout << #X << ": " << X << " ";
#define ARDEB(i, X) cout << #X << "[" << i << "]: " << X[i] << " ";
#define END cout << endl;
#else
#define DEB(X)                                                                 \
  {}
#define ARDEB(i, X)                                                            \
  {}
#define END                                                                    \
  {}
#endif
// typedef long long int ll;
typedef pair<int, int> P;
struct edge {
  int to, cost;
};
int ceil2(int a, int b) {
  if (a % b) {
    return a / b + 1;
  } else {
    return a / b;
  }
}
int n, k, ans;
int a[111111], b[111111];
signed main() {

  cin >> n >> k;
  rep(i, n) cin >> a[i] >> b[i];
  rep(i, n) {
    if (a[i] * a[i] + b[i] * b[i] <= k * k)
      ans++;
  }
  cout << ans << endl;
}

Fixed submission:
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
using namespace std;
#define INF 2000000007
#define LINF 100000000000000007
#define MOD 1000000007
#define int long long
#define rep(i, n) for (int i = 0; i < n; i++)
#define repb(i, n) for (int i = n - 1; i >= 0; i--)
// #define MODE 1
#ifdef MODE
#define DEB(X) cout << #X << ": " << X << " ";
#define ARDEB(i, X) cout << #X << "[" << i << "]: " << X[i] << " ";
#define END cout << endl;
#else
#define DEB(X)                                                                 \
  {}
#define ARDEB(i, X)                                                            \
  {}
#define END                                                                    \
  {}
#endif
// typedef long long int ll;
typedef pair<int, int> P;
struct edge {
  int to, cost;
};
int ceil2(int a, int b) {
  if (a % b) {
    return a / b + 1;
  } else {
    return a / b;
  }
}
int n, k, ans;
int a[211111], b[211111];
signed main() {

  cin >> n >> k;
  rep(i, n) cin >> a[i] >> b[i];
  rep(i, n) {
    if (a[i] * a[i] + b[i] * b[i] <= k * k)
      ans++;
  }
  cout << ans << endl;
}
Problem p02595 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
typedef long long lint;
using namespace std;
#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)

int main() {
  lint n, d;
  cin >> n >> d;
  lint x[2000], y[2000];
  rep(i, n) cin >> x[i] >> y[i];
  lint ans = 0;
  rep(i, n) {
    lint t = x[i] * x[i] + y[i] * y[i];
    if (t <= d * d)
      ans++;
  }
  cout << ans << endl;
}

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

int main() {
  lint n, d;
  cin >> n >> d;
  lint x[200000], y[200000];
  rep(i, n) cin >> x[i] >> y[i];
  lint ans = 0;
  rep(i, n) {
    lint t = x[i] * x[i] + y[i] * y[i];
    if (t <= d * d)
      ans++;
  }
  cout << ans << endl;
}
Problem p02595 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
int a[250][3], n, d, ans = 0;
int main() {
  cin >> n >> d;
  for (int i = 1; i <= n; i++)
    cin >> a[i][1] >> a[i][2];
  for (int i = 1; i <= n; i++) {
    double x, y, z;
    x = a[i][1];
    y = a[i][2];
    z = sqrt(x * x + y * y);
    if (z <= d)
      ans++;
  }
  cout << ans << endl;
  return 0;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
int a[200010][3], n, d, ans = 0;
int main() {
  cin >> n >> d;
  for (int i = 1; i <= n; i++)
    cin >> a[i][1] >> a[i][2];
  for (int i = 1; i <= n; i++) {
    double x, y, z;
    x = a[i][1];
    y = a[i][2];
    z = sqrt(x * x + y * y);
    if (z <= d)
      ans++;
  }
  cout << ans << endl;
  return 0;
}
Problem p02595 (C++)

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

using namespace std;

int main() {
  long long int D, N, ans = 0;
  long long int X[100001], Y[100001];
  cin >> N >> D;
  for (int i = 0; i < N; i++) {
    cin >> X[i] >> Y[i];
  }
  for (int i = 0; i < N; i++) {
    if (X[i] * X[i] + Y[i] * Y[i] <= D * D)
      ans++;
  }
  cout << ans << endl;
  return 0;
}

Fixed submission:
#include <iostream>
#include <string>
#include <vector>

using namespace std;

int main() {
  long long int D, N, ans = 0;
  long long int X[1000001], Y[1000001];
  cin >> N >> D;
  for (int i = 0; i < N; i++) {
    cin >> X[i] >> Y[i];
  }
  for (int i = 0; i < N; i++) {
    if (X[i] * X[i] + Y[i] * Y[i] <= D * D)
      ans++;
  }
  cout << ans << endl;
  return 0;
}
Problem p02595 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;

P p[100010];
int main() {
  ll n, d;
  ll dis = 0;
  int res = 0;
  cin >> n >> d;
  for (int i = 0; i < n; i++) {
    cin >> p[i].first >> p[i].second;
  }
  for (int i = 0; i < n; i++) {
    ll x = p[i].first;
    ll y = p[i].second;
    dis = x * x + y * y;
    if (dis <= d * d)
      res++;
  }
  cout << res << endl;
  return 0;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;

P p[200010];
int main() {
  ll n, d;
  ll dis = 0;
  int res = 0;
  cin >> n >> d;
  for (int i = 0; i < n; i++) {
    cin >> p[i].first >> p[i].second;
  }
  for (int i = 0; i < n; i++) {
    ll x = p[i].first;
    ll y = p[i].second;
    dis = x * x + y * y;
    if (dis <= d * d)
      res++;
  }
  cout << res << endl;
  return 0;
}
Problem p02595 (C++)

Buggy submission (status: Runtime Error):
#include <iostream>
using namespace std;
#include <vector>
#define re(i, n) for (int i = 0; i < n; i++)

int main() {
  int n;
  cin >> n;
  long long x[10000];
  long long y[10000];
  long long d;
  cin >> d;
  d *= d;
  int cnt = 0;
  long long z;
  re(i, n) {
    cin >> x[i] >> y[i];
    z = x[i] * x[i] + y[i] * y[i];
    if (z <= d)
      cnt++;
  }

  cout << cnt << endl;

  return 0;
}

Fixed submission:
#include <iostream>
using namespace std;
#include <vector>
#define re(i, n) for (int i = 0; i < n; i++)

int main() {
  int n;
  cin >> n;
  long long x[300000];
  long long y[300000];
  long long d;
  cin >> d;
  d *= d;
  int cnt = 0;
  long long z;
  re(i, n) {
    cin >> x[i] >> y[i];
    z = x[i] * x[i] + y[i] * y[i];
    if (z <= d)
      cnt++;
  }

  cout << cnt << endl;

  return 0;
}
Problem p02595 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, d, x, y, ans = 0;
  scanf("%d%d", &n, &d);
  d *= d;
  for (int i = 0; i < n; i++) {
    scanf("%lld%lld", &x, &y);
    ans += (x * x + y * y <= d);
  }
  printf("%d", ans);
  return 0;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, d, x, y, ans = 0;
  scanf("%lld%lld", &n, &d);
  d *= d;
  for (int i = 0; i < n; i++) {
    scanf("%lld%lld", &x, &y);
    ans += (x * x + y * y <= d);
  }
  printf("%d", ans);
  return 0;
}
Problem p02595 (C++)

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

int32_t main() {
  int n, d;
  scanf("%lld%lld", &n, &d);
  int ans = 0;
  d *= d;
  for (int i = 0; i < n; i++) {
    int x, y;
    scanf("%lld%lld", x, y);
    if (x * x + y * y == d)
      ans++;
  }
  printf("%lld\n", ans);
}

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

int32_t main() {
  int n, d;
  scanf("%lld%lld", &n, &d);
  int ans = 0;
  d *= d;
  for (int i = 0; i < n; i++) {
    int x, y;
    scanf("%lld%lld", &x, &y);
    if (x * x + y * y <= d)
      ans++;
  }
  printf("%lld\n", ans);
}
Problem p02596 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
ll n, m, t, a[100005];
vector<ll> adj[100005];
#define ari                                                                    \
  for (int i = 0; i < n; i++)                                                  \
    cin >> a[i];
#define ginp                                                                   \
  for (int i = 0; i < m; i++) {                                                \
    int u, v;                                                                  \
    cin >> u >> v;                                                             \
    adj[u].push_back(v);                                                       \
    adj[v].push_back(u);                                                       \
  }
#define pb push_back
#define ss second
#define ff first
#define fs first.second
#define fff first.first
#define sss second.second
#define sf second.first
#define mp make_pair

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ll k;
  cin >> k;
  if (k % 2 == 0) {
    cout << "-1" << endl;
    return (0);
  }
  ll po = (7 % k), prev = 0, ans = 0;
  for (int i = 1;; i++) {
    if ((po + prev) % k == 0) {
      ans = i;
      break;
    }
    prev = (po + prev) % k;
    po = (po * 10) % k;
  }
  cout << ans << endl;
  return (0);
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
ll n, m, t, a[100005];
vector<ll> adj[100005];
#define ari                                                                    \
  for (int i = 0; i < n; i++)                                                  \
    cin >> a[i];
#define ginp                                                                   \
  for (int i = 0; i < m; i++) {                                                \
    int u, v;                                                                  \
    cin >> u >> v;                                                             \
    adj[u].push_back(v);                                                       \
    adj[v].push_back(u);                                                       \
  }
#define pb push_back
#define ss second
#define ff first
#define fs first.second
#define fff first.first
#define sss second.second
#define sf second.first
#define mp make_pair

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ll k;
  cin >> k;
  if (k % 2 == 0 or k % 5 == 0) {
    cout << "-1" << endl;
    return (0);
  }
  ll po = (7 % k), prev = 0, ans = 0;
  for (int i = 1;; i++) {
    if ((po + prev) % k == 0) {
      ans = i;
      break;
    }
    prev = (po + prev) % k;
    po = (po * 10) % k;
  }
  cout << ans << endl;
  return (0);
}
Problem p02596 (C++)

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

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<double> vd;
typedef vector<string> vs;
typedef pair<int, int> P;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

void YN(bool flg) {
  if (flg)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
}
void Yn(bool flg) {
  if (flg)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}
void yn(bool flg) {
  if (flg)
    cout << "yes" << endl;
  else
    cout << "no" << endl;
}

template <class T> inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T> inline bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}

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

  if (k % 2 == 0) {
    cout << -1 << endl;
    return 0;
  }

  int mod = 7 % k;
  int cnt = 1;
  set<int> s;
  while (!s.count(mod)) {
    if (mod == 0) {
      cout << cnt << endl;
      return 0;
    }
    s.count(mod);
    mod = (mod * 10 + 7) % k;
    cnt++;
  }

  cout << -1 << endl;

  return 0;
}


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

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<double> vd;
typedef vector<string> vs;
typedef pair<int, int> P;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

void YN(bool flg) {
  if (flg)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
}
void Yn(bool flg) {
  if (flg)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}
void yn(bool flg) {
  if (flg)
    cout << "yes" << endl;
  else
    cout << "no" << endl;
}

template <class T> inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T> inline bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}

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

  if (k % 2 == 0) {
    cout << -1 << endl;
    return 0;
  }

  int mod = 7 % k;
  int cnt = 1;
  set<int> s;
  while (!s.count(mod)) {
    if (mod == 0) {
      cout << cnt << endl;
      return 0;
    }
    s.insert(mod);
    mod = (mod * 10 + 7) % k;
    cnt++;
  }

  cout << -1 << endl;

  return 0;
}
Problem p02596 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <iostream>

using namespace std;

int main(void) {
  long long k;

  cin >> k;
  if (k % 2 == 0) {
    cout << -1 << endl;
    return 0;
  }

  long long next_inc = 70;
  long long ex = 7;
  int cnt = 1;
  while (ex % k != 0) {
    ex %= k;
    ex += next_inc;

    next_inc *= 10;
    next_inc %= k;
    cnt += 1;
  }

  cout << cnt << endl;

  return 0;
}

Fixed submission:
#include <iostream>

using namespace std;

int main(void) {
  long long k;

  cin >> k;
  if (k % 2 == 0 || k % 5 == 0) {
    cout << -1 << endl;
    return 0;
  }

  long long next_inc = 70;
  long long ex = 7;
  int cnt = 1;
  while (ex % k != 0) {
    ex %= k;
    ex += next_inc;

    next_inc *= 10;
    next_inc %= k;
    cnt += 1;
  }

  cout << cnt << endl;

  return 0;
}
Problem p02596 (C++)

Buggy submission (status: Time Limit Exceeded):
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define pll pair<ll, ll>
#define pq priority_queue
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define ios ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define lb(c, x) distance(c.begin(), lower_bound(all(c), x))
#define ub(c, x) distance(c.begin(), upper_bound(all(c), x))

using namespace std;

template <class T> inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T> inline bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}

const ll INF = 1e18;
const ll mod = 1e9 + 7;

int main() {
  ll k;
  cin >> k;
  if (k == 2 || k == 5) {
    cout << -1 << endl;
    return 0;
  }
  ll v = 0;
  ll cnt = 0;
  while (true) {
    cnt++;
    v = v * 10 + 7;
    v %= k;
    if (v == 0)
      break;
  }
  cout << cnt << endl;
  return 0;
}

Fixed submission:
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define pll pair<ll, ll>
#define pq priority_queue
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define ios ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define lb(c, x) distance(c.begin(), lower_bound(all(c), x))
#define ub(c, x) distance(c.begin(), upper_bound(all(c), x))

using namespace std;

template <class T> inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T> inline bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}

const ll INF = 1e18;
const ll mod = 1e9 + 7;

int main() {
  ll k;
  cin >> k;
  if (k % 2 == 0 || k % 5 == 0) {
    cout << -1 << endl;
    return 0;
  }
  ll v = 0;
  ll cnt = 0;
  while (true) {
    cnt++;
    v = v * 10 + 7;
    v %= k;
    if (v == 0)
      break;
  }
  cout << cnt << endl;
  return 0;
}
Problem p02596 (C++)

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

int main() {
  ll k;
  cin >> k;
  if (k % 2 == 0) {
    cout << -1 << endl;
    return 0;
  }

  ll s = k;
  ll cnt = 0;
  while (1) {
    if (s == 7) {
      cnt++;
      break;
    } else if (s % 10 == 7) {
      s /= 10;
      cnt++;
    } else {
      s += k;
    }
    if (cnt > 999982) {
      cnt = -1;
      break;
    }
  }

  cout << cnt << endl;

  return 0;
}


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

int main() {
  ll k;
  cin >> k;
  if (k % 2 == 0) {
    cout << -1 << endl;
    return 0;
  }
  if (k % 5 == 0) {
    cout << -1 << endl;
    return 0;
  }

  ll s = k;
  ll cnt = 0;
  while (1) {
    if (s == 7) {
      cnt++;
      break;
    } else if (s % 10 == 7) {
      s /= 10;
      cnt++;
    } else {
      s += k;
    }
    if (cnt > 999982) {
      cnt = -1;
      break;
    }
  }

  cout << cnt << endl;

  return 0;
}
Problem p02596 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int n;
  cin >> n;
  if (n % 2 == 0) {
    cout << "-1" << endl;
    return 0;
  }
  long long int k = 7;
  long long int cnt = 1;
  while (1) {
    if (k % n == 0) {
      cout << cnt << endl;
      break;
    }
    if (cnt > n) {
      cout << "-1" << endl;
    }
    k = (k % n) * 10 + 7;
    cnt++;
  }
}


Fixed submission:
#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int n;
  cin >> n;
  if (n % 2 == 0) {
    cout << "-1" << endl;
    return 0;
  }
  long long int k = 7;
  long long int cnt = 1;
  while (1) {
    if (k % n == 0) {
      cout << cnt << endl;
      break;
    }
    if (cnt > n) {
      cout << "-1" << endl;
      break;
    }
    k = (k % n) * 10 + 7;
    cnt++;
  }
}
Problem p02596 (C++)

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

int main() {
  int K, sum = 0;
  cin >> K;
  if (K % 2 == 0 || K % 5 == 0) {
    sum = -1;
  } else {
    K *= 9;
    if (K % 7 == 0) {
      K /= 7;
    }
    int s = 0, i = 10;
    while (s == 0) {
      sum++;
      if (i % K == 1) {
        s = 1;
      }
      i *= 10;
    }
  }
  cout << sum << endl;
}

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

int main() {
  int K, sum = 0;
  cin >> K;
  if (K % 2 == 0 || K % 5 == 0) {
    sum = -1;
  } else {
    K *= 9;
    if (K % 7 == 0) {
      K /= 7;
    }
    int s = 0, i = 10;
    while (s == 0) {
      sum++;
      i %= K;
      if (i == 1) {
        s = 1;
      }
      i *= 10;
    }
  }
  cout << sum << endl;
}
Problem p02596 (C++)

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

int main() {
  int k, n = 1;
  cin >> k;
  if (k % 2 == 0) {
    cout << -1 << endl;
  } else {
    int r = 7 % k;
    while (r != 0) {
      r = (10 * r + 7) % k;
      n++;
    }
    cout << n << endl;
  }
}


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

int main() {
  int k, n = 1;
  cin >> k;
  if (k % 2 == 0 || k % 5 == 0) {
    cout << -1 << endl;
  } else {
    int r = 7 % k;
    while (r != 0) {
      r = (10 * r + 7) % k;
      n++;
    }
    cout << n << endl;
  }
}
Problem p02596 (C++)

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

#define int long long

using namespace std;

signed main(void) {
  int n, i, k, now = 7, ans = 1;

  cin >> n;

  if (n % 2 == 0 || n % 5 == 0) {
    cout << -1 << "\n";
  } else {
    while (1) {
      if (now % n == 0) {
        cout << ans << "\n";

        break;
      } else {
        ans++;

        n = n % 1000000;

        now = now * 10 + 7;

        now = now % 1000000;
      }
    }
  }

  return 0;
}

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

#define int long long

using namespace std;

signed main(void) {
  int n, i, k, now = 7, ans = 1;

  cin >> n;

  if (n % 2 == 0 || n % 5 == 0) {
    cout << -1 << "\n";
  } else {
    while (1) {
      if (now % n == 0) {
        cout << ans << "\n";

        break;
      } else {
        ans++;

        now = (now * 10 + 7) % n;
      }
    }
  }

  return 0;
}
Problem p02596 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
#define ll long long
#define pll pair<ll, ll>
#define pii pair<int, int>
#define rep(i, a, b) for (int i = a; i <= b; ++i)
#define per(i, a, b) for (int i = a; i >= b; --i)
#define mem0(x) memset(x, 0, sizeof(x))
#define meminf(x) memset(x, 0x3f, sizeof(x))
#define VI vector<int>
#define VL vector<ll>
using namespace std;

int main() {
  ios::sync_with_stdio(0);
  int k;
  cin >> k;
  if (k % 2 == 0) {
    cout << -1 << '\n';
  } else {
    ll num = 7;
    ll cnt = 1;
    while (1) {
      if (num % k != 0) {
        num = (num * 10 + 7) % k;
        ++cnt;
      } else {
        break;
      }
    }
    cout << cnt << '\n';
  }
}


Fixed submission:
#include <bits/stdc++.h>
#define ll long long
#define pll pair<ll, ll>
#define pii pair<int, int>
#define rep(i, a, b) for (int i = a; i <= b; ++i)
#define per(i, a, b) for (int i = a; i >= b; --i)
#define mem0(x) memset(x, 0, sizeof(x))
#define meminf(x) memset(x, 0x3f, sizeof(x))
#define VI vector<int>
#define VL vector<ll>
using namespace std;

int main() {
  ios::sync_with_stdio(0);
  int k;
  cin >> k;
  if (k % 2 == 0 || k % 5 == 0) {
    cout << -1 << '\n';
  } else {
    ll num = 7;
    ll cnt = 1;
    while (1) {
      if (num % k != 0) {
        num = (num * 10 + 7) % k;
        ++cnt;
      } else {
        break;
      }
    }
    cout << cnt << '\n';
  }
}
Problem p02596 (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>;

void solve() {
  int k;
  cin >> k;
  if (k % 2 == 0) {
    cout << -1 << endl;
    return;
  }

  int cnt = 1;
  int r = 7;
  map<int, int> check;
  while (true) {
    if (r % k == 0)
      break;
    if (check[r] > 0) {
      cout << -1 << endl;
    }
    check[r]++;
    r = r * 10 + 7;
    r %= k;
    cnt++;
  }

  cout << cnt << endl;
}

int main() {
  solve();
  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>;

void solve() {
  int k;
  cin >> k;
  if (k % 2 == 0) {
    cout << -1 << endl;
    return;
  }

  int cnt = 1;
  int r = 7;
  map<int, int> check;
  while (true) {
    if (r % k == 0)
      break;
    if (check[r] > 0) {
      cout << -1 << endl;
      return;
    }
    check[r]++;
    r = r * 10 + 7;
    r %= k;
    cnt++;
  }

  cout << cnt << endl;
}

int main() {
  solve();
  return 0;
}
Problem p02596 (C++)

Buggy submission (status: Time Limit Exceeded):
using namespace std;
#include <algorithm>
#include <assert.h>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>

typedef long long ll;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long k;
  cin >> k;
  long long nm = 1;
  long long md = 7;
  if (k == 1 || k == 7) {
    cout << 1 << endl;
    return 0;
  }
  while (true) {
    if (md % k == 7 % k && nm > 1) {
      cout << -1 << endl;
      break;
    }
    if (md == 0) {
      cout << nm << endl;
      break;
    }
    nm++;
    md *= 10;
    md += 7;
    md %= k;
  }
}

Fixed submission:
using namespace std;
#include <algorithm>
#include <assert.h>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>

typedef long long ll;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long k;
  cin >> k;
  long long nm = 1;
  long long md = 7;
  if (k == 1 || k == 7) {
    cout << 1 << endl;
    return 0;
  }
  while (true) {
    if ((md % k == 7 % k && nm > 1) || nm > 1000100) {
      cout << -1 << endl;
      break;
    }
    if (md == 0) {
      cout << nm << endl;
      break;
    }
    nm++;
    md *= 10;
    md += 7;
    md %= k;
  }
}
Problem p02596 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;
// #define int long long int
void solve() {
  int k, cnt = 0, rem = 0, num = 7;
  cin >> k;
  if (k % 2 == 0)
    cout << "-1"
         << "\n";
  else {
    while (1) {
      rem += (num % k);
      num %= k;
      num *= 10;
      cnt++;
      rem %= k;
      if (rem % k == 0)
        break;
    }
    cout << cnt << "\n";
  }
}

signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int t = 1;
  // cin>>t;
  while (t--) {
    solve();
  }
  return 0;
}


Fixed submission:
#include <bits/stdc++.h>
using namespace std;
// #define int long long int
void solve() {
  int k, cnt = 0, rem = 0, num = 7;
  cin >> k;
  if (k % 2 == 0)
    cout << "-1"
         << "\n";
  else {
    while (1) {
      rem += (num % k);
      num %= k;
      num *= 10;
      cnt++;
      rem %= k;
      if (rem % k == 0)
        break;
      if (cnt > 1000000) {
        cnt = -1;
        break;
      }
    }
    cout << cnt << "\n";
  }
}

signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int t = 1;
  // cin>>t;
  while (t--) {
    solve();
  }
  return 0;
}
Problem p02596 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

#define FOR_LT(i, beg, end) for (int i = (int)(beg); i < (int)(end); i++)
#define FOR_LE(i, beg, end) for (int i = (int)(beg); i <= (int)(end); i++)
#define FOR_DW(i, beg, end) for (int i = (int)(beg); (int)(end) <= i; i--)
#define REP(n) for (int repeat_index = 0; repeat_index < (int)n; repeat_index++)

using namespace std;

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

  int64_t k;
  cin >> k;

  if (!(k & 1)) {
    cout << -1 << endl;
    return 0;
  }

  int64_t r = 1;
  int64_t n = 0;
  int64_t c = 1;

  while (true) {
    n += r * 7;
    n %= k;
    if (n == 0) {
      cout << c << endl;
      return 0;
    }
    r = (r * 10) % k;
    c++;
  }

  return 0;
}

Fixed submission:
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

#define FOR_LT(i, beg, end) for (int i = (int)(beg); i < (int)(end); i++)
#define FOR_LE(i, beg, end) for (int i = (int)(beg); i <= (int)(end); i++)
#define FOR_DW(i, beg, end) for (int i = (int)(beg); (int)(end) <= i; i--)
#define REP(n) for (int repeat_index = 0; repeat_index < (int)n; repeat_index++)

using namespace std;

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

  int64_t k;
  cin >> k;

  if (!(k & 1) || (k % 10) == 5) {
    cout << -1 << endl;
    return 0;
  }

  int64_t r = 1;
  int64_t n = 0;
  int64_t c = 1;

  while (true) {
    n += r * 7;
    n %= k;
    if (n == 0) {
      cout << c << endl;
      return 0;
    }
    r = (r * 10) % k;
    c++;
  }

  return 0;
}
Problem p02596 (C++)

Buggy submission (status: Time Limit Exceeded):
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;
#define rep(i, begin, n) for (int i = begin; i < n; i++)
#define repe(i, begin, n) for (int i = begin; i <= n; i++)
#define repr(i, begin, n) for (int i = begin; i > begin - n; i--)
#define repre(i, begin, end) for (int i = begin; i >= end; i--)

template <class T> inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}

template <class T> inline bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}

const int inf = 1000000007;
const int MOD = 1000000007;
const long long INF = 1000000000000000007;

// -------------------------------------------------------

ll K;

int main() {
  //
  cin >> K;

  if (K % 2 == 0) {
    cout << -1;
    return 0;
  }

  ll cur = 7 % K;
  ll ans = 1;
  for (;;) {
    if (cur == 0) {
      cout << ans;
      return 0;
    }

    cur = (10 % K) * (cur % K) + 7 % K;
    cur %= K;
    ++ans;

    if (ans > 100000000) {
      cout << -1;
      return 0;
    }
  }
}


Fixed submission:
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;
#define rep(i, begin, n) for (int i = begin; i < n; i++)
#define repe(i, begin, n) for (int i = begin; i <= n; i++)
#define repr(i, begin, n) for (int i = begin; i > begin - n; i--)
#define repre(i, begin, end) for (int i = begin; i >= end; i--)

template <class T> inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}

template <class T> inline bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}

const int inf = 1000000007;
const int MOD = 1000000007;
const long long INF = 1000000000000000007;

// -------------------------------------------------------

ll K;

int main() {
  //
  cin >> K;

  if (K % 2 == 0) {
    cout << -1;
    return 0;
  }

  ll cur = 7 % K;
  ll ans = 1;
  for (;;) {
    if (cur == 0) {
      cout << ans;
      return 0;
    }

    cur = (10 % K) * (cur % K) + 7 % K;
    cur %= K;
    ++ans;

    if (ans > 10000000) {
      cout << -1;
      return 0;
    }
  }
}
Problem p02596 (C++)

Buggy submission (status: Time Limit Exceeded):
// #include<i_am_noob_orz>
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define int ll
#define ull unsigned long long
#define pii pair<int, int>
#define X first
#define Y second
#define mod ((ll)1e9 + 7)
#define pb push_back
#define mp make_pair
#define abs(x) ((x) > 0 ? (x) : (-(x)))
#define F(n) Fi(i, n)
#define Fi(i, n) Fl(i, 0, n)
#define Fl(i, l, n) for (int i = l; i < n; i++)
#define memres(a) memset(a, 0, sizeof(a))
#define all(a) a.begin(), a.end()
#define sz(a) ((int)a.size())
#define ceiling(a, b) (((a) + (b)-1) / (b))
#define endl '\n'
#define bit_count(x) __builtin_popcount((x))
#define ykh mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
// #define LOCAL
#ifdef LOCAL
#define debug(a) cerr << #a << " " << a << endl;
#else
#define debug(a)
#endif
int gcd(int a, int b) {
  if (b == 0)
    return a;
  return gcd(b, a % b);
}
bool ar[1000010];
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int n, ct = 0, p = 7, s = 0;
  cin >> n;
  bool tag = true;
  while (1) {
    s += p;
    ct++;
    s = s % n;
    if (s == 0)
      break;
    if (ar[s]) {
      tag = false;
      break;
    }
    p = (p * 10) % n;
  }
  if (tag)
    cout << ct << endl;
  else
    cout << "-1" << endl;
  return 0;
}


Fixed submission:
// #include<i_am_noob_orz>
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define int ll
#define ull unsigned long long
#define pii pair<int, int>
#define X first
#define Y second
#define mod ((ll)1e9 + 7)
#define pb push_back
#define mp make_pair
#define abs(x) ((x) > 0 ? (x) : (-(x)))
#define F(n) Fi(i, n)
#define Fi(i, n) Fl(i, 0, n)
#define Fl(i, l, n) for (int i = l; i < n; i++)
#define memres(a) memset(a, 0, sizeof(a))
#define all(a) a.begin(), a.end()
#define sz(a) ((int)a.size())
#define ceiling(a, b) (((a) + (b)-1) / (b))
#define endl '\n'
#define bit_count(x) __builtin_popcount((x))
#define ykh mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
// #define LOCAL
#ifdef LOCAL
#define debug(a) cerr << #a << " " << a << endl;
#else
#define debug(a)
#endif
int gcd(int a, int b) {
  if (b == 0)
    return a;
  return gcd(b, a % b);
}
bool ar[1000010];
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int n, ct = 0, p = 7, s = 0;
  cin >> n;
  bool tag = true;
  while (1) {
    s += p;
    ct++;
    s = s % n;
    if (s == 0)
      break;
    if (ar[s]) {
      tag = false;
      break;
    }
    ar[s] = true;
    p = (p * 10) % n;
  }
  if (tag)
    cout << ct << endl;
  else
    cout << "-1" << endl;
  return 0;
}
Problem p02596 (C++)

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

using namespace std;
#define ll long long int

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  ll n;
  cin >> n;
  if (n % 2 == 0) {
    cout << "-1" << endl;
    return 0;
  }
  ll count = 1, num = 7;
  while (num % n) {
    num %= n;
    num *= 10;
    num += 7;
    count++;
    // cout<<num<<endl;
  }
  cout << count << endl;
  return 0;
}


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

using namespace std;
#define ll long long int

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  ll n;
  cin >> n;
  if (n % 2 == 0) {
    cout << "-1" << endl;
    return 0;
  }
  ll count = 1, num = 7;
  while (num % n) {
    num %= n;
    num *= 10;
    num += 7;
    count++;
    if (count > n) {
      cout << "-1" << endl;
      return 0;
    }
    // cout<<num<<endl;
  }
  cout << count << endl;
  return 0;
}
Problem p02596 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;
bool checkValue(long long v) {
  while (v > 0) {
    if ((v % 7 != 0) || (v % 10 == 0))
      return false;
    v /= 10;
  }
  return true;
}
int main() {
  long long x;
  cin >> x;
  unsigned long long value = 7;
  vector<long long> result;
  long long cnt = 0;
  while (value > 0) {
    cnt++;
    // cout << value%x << endl;
    value = value % x;
    if (value == 0) {
      cout << cnt << endl;
      return 0;
    }
    if (result.size() != 0) {
      for (long long i = 0; i < result.size(); i++) {
        if (result[i] == value) {
          cout << -1 << endl;
          return 0;
        }
      }
    }
    result.push_back(value);
    value = value * 10 + 7;
  }
  return 0;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
bool checkValue(long long v) {
  while (v > 0) {
    if ((v % 7 != 0) || (v % 10 == 0))
      return false;
    v /= 10;
  }
  return true;
}
int main() {
  long long x;
  cin >> x;
  unsigned long long value = 7;
  vector<long long> result;
  long long cnt = 0;
  while (value > 0) {
    cnt++;
    // cout << value%x << endl;
    value = value % x;
    if (value == 0) {
      cout << cnt << endl;
      return 0;
    }
    // if(result.size()%10000!=0){
    // for(long long i = 0; i < result.size(); i++){
    // if(result[i]==value){
    // cout << -1 << endl;
    // return 0;
    //}
    //}
    //}
    if (result.size() >= 10000000) {
      cout << -1 << endl;
      return 0;
    }
    result.push_back(value);
    value = value * 10 + 7;
  }
  return 0;
}
Problem p02596 (C++)

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

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);

  // freopen("input.txt","r",stdin);

  long long n, i = 1, k = 7;
  cin >> n;
  while (1) {
    if (n % 2 == 0) {
      cout << -1 << endl;
      break;
    } else {
      if (k % n) {
        k = 10 * (k % n) + 7;
      } else {
        cout << i << endl;
        break;
      }
      i++;
    }
  }

  return 0;
}


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

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);

  // freopen("input.txt","r",stdin);

  long long n, i = 1, k = 7;
  cin >> n;
  while (1) {
    if (n % 2 == 0 || n % 5 == 0) {
      cout << -1 << endl;
      break;
    } else {
      if (k % n) {
        k = 10 * (k % n) + 7;
      } else {
        cout << i << endl;
        break;
      }
      i++;
    }
  }

  return 0;
}
Problem p02596 (C++)

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

const ll INF = 1e18;
const ll MOD = 1000000007;
const ll MX = 0; // 最大値

#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define ALL(x) (x).begin(), (x).end()
#define MAX(x) *max_element(ALL(x))
#define PB push_back
#define F first
#define S second

int main() {
  ll n;
  cin >> n;
  ll res = 7 % n, cnt = 1;
  while (res != 0) {
    cnt++;
    res = res * 10 + 7;
    res %= n;
  }
  cout << cnt << endl;
  return 0;
}

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

const ll INF = 1e18;
const ll MOD = 1000000007;
const ll MX = 0; // 最大値

#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define ALL(x) (x).begin(), (x).end()
#define MAX(x) *max_element(ALL(x))
#define PB push_back
#define F first
#define S second

int main() {
  ll n;
  cin >> n;
  ll res = 7 % n, cnt = 1;

  if (n % 5 == 0 || n % 2 == 0) {
    cout << -1 << endl;
    return 0;
  }

  while (res != 0) {
    cnt++;
    res = res * 10 + 7;
    res %= n;
  }
  cout << cnt << endl;
  return 0;
}
Problem p02596 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;
int main() {
  int64_t n;
  cin >> n;
  int64_t L, s = 1;
  if (n % 7 == 0) {
    L = 9 * n / 7;
    s = 10 % L;
    for (int64_t i = 1;; i++) {
      if (s % L == 1) {
        cout << i << endl;
        break;
      }
      s = (s % L) * 10;
    }
  } else {
    L = 9 * n;
    s = 10 % L;
    for (int64_t i = 1;; i++) {
      if (s % L == 1) {
        cout << i << endl;
        break;
      }
      s = (s % L) * 10;
    }
  }
}


Fixed submission:
#include <bits/stdc++.h>
using namespace std;
int main() {
  int64_t n;
  cin >> n;
  int64_t L, s = 1;
  if (n % 2 == 0 || n % 5 == 0) {
    cout << -1 << endl;
  } else if (n % 7 == 0) {
    L = 9 * n / 7;
    s = 10 % L;
    for (int64_t i = 1;; i++) {
      if (s % L == 1) {
        cout << i << endl;
        break;
      }
      s = (s % L) * 10;
    }
  } else {
    L = 9 * n;
    s = 10 % L;
    for (int64_t i = 1;; i++) {
      if (s % L == 1) {
        cout << i << endl;
        break;
      }
      s = (s % L) * 10;
    }
  }
}
Problem p02596 (C++)

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

int main() {
  int k;
  cin >> k;
  if (k % 2 == 0) {
    cout << -1 << endl;
    return 0;
  }
  int n = 0;
  int k1 = k;
  int num = 0;
  int des = 1;
  while (k1) {
    n++;
    num = 7 * des + num;
    des *= 10;
    k1 /= 10;
  }
  // cout<<des<<endl;
  int count = 0;
  while (1) {
    num = num % k;
    if (num == 0) {

      // cout<<num<<endl;
      cout << n << endl;
      return 0;
    } else {

      n++;

      num = num * 10 + 7;
    }
  }
}

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

int main() {
  int k;
  cin >> k;
  if (k % 2 == 0 || k % 5 == 0) {
    cout << -1 << endl;
    return 0;
  }
  int n = 0;
  int k1 = k;
  int num = 0;
  int des = 1;
  while (k1) {
    n++;
    num = 7 * des + num;
    des *= 10;
    k1 /= 10;
  }
  // cout<<des<<endl;
  int count = 0;
  while (1) {
    num = num % k;
    if (num == 0) {

      // cout<<num<<endl;
      cout << n << endl;
      return 0;
    } else {

      n++;

      num = num * 10 + 7;
    }
  }
}
Problem p02596 (C++)

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

using namespace std;

int gcd(int a, int b) {
  if (b == 0) {
    return a;
  }
  return gcd(b, a % b);
}

int main() {
  int k;
  cin >> k;
  if (k % 7 == 0) {
    k = k / 7;
  }
  if (gcd(10, k) != 1) {
    cout << -1 << endl;
  }
  long long int l = 1, v = 1 % k;
  while (v != 0) {
    l++;
    v = (v * 10 + 1) % k;
  }
  cout << l << endl;
  return 0;
}

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

using namespace std;

int gcd(int a, int b) {
  if (b == 0) {
    return a;
  }
  return gcd(b, a % b);
}

int main() {
  int k;
  cin >> k;
  if (k % 7 == 0) {
    k = k / 7;
  }
  if (gcd(10, k) != 1) {
    cout << -1 << endl;
    return 0;
  }
  long long int l = 1, v = 1 % k;
  while (v != 0) {
    l++;
    v = (v * 10 + 1) % k;
  }
  cout << l << endl;
  return 0;
}
Problem p02596 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i, m, n) for (int i = (m); i < (n); i++)
#define rep(i, n) REP(i, 0, n)
#define pb push_back
#define all(a) a.begin(), a.end()
#define rall(c) (c).rbegin(), (c).rend()
#define mp make_pair
#define endl '\n'
#define vec vector<ll>
#define mat vector<vector<ll>>
#define fi first
#define se second
typedef long long ll;
typedef pair<ll, ll> pll;
typedef long double ld;
const ll inf = 1e9 + 7;
const ll mod = 998244353;
signed main() {
  ll k;
  cin >> k;
  ll ans = -1;
  vector<ll> a(k + 1);
  a[0] = 7 % k;
  rep(i, k + 1) {
    if (a[i] % k == 0) {
      ans = i + 1;
      break;
    }
    if (i < k + 1)
      a[i + 1] = (a[i] * 10 + 7) % k;
  }
  cout << ans << endl;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i, m, n) for (int i = (m); i < (n); i++)
#define rep(i, n) REP(i, 0, n)
#define pb push_back
#define all(a) a.begin(), a.end()
#define rall(c) (c).rbegin(), (c).rend()
#define mp make_pair
#define endl '\n'
#define vec vector<ll>
#define mat vector<vector<ll>>
#define fi first
#define se second
typedef long long ll;
typedef pair<ll, ll> pll;
typedef long double ld;
const ll inf = 1e9 + 7;
const ll mod = 998244353;
signed main() {
  ll k;
  cin >> k;
  ll ans = -1;
  vector<ll> a(k + 1);
  a[0] = 7 % k;
  rep(i, k + 1) {
    if (a[i] % k == 0) {
      ans = i + 1;
      break;
    }
    if (i < k)
      a[i + 1] = (a[i] * 10 + 7) % k;
  }
  cout << ans << endl;
}
Problem p02596 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <algorithm>
#include <bits/stdc++.h>
#include <iomanip>
#include <iostream>
#include <math.h>
#include <set>
#include <sstream>
#include <stdio.h>
#include <string>
#include <vector>
using namespace std;
int main(void) {
  long long int k;
  cin >> k;
  if (k % 2 == 0) {
    cout << -1 << endl;
  } else {
    long long int now = 7;
    long long int count = 1;
    while (true) {
      if (now % k == 0) {
        cout << count << endl;
        break;
      } else {
        now *= 10;
        now += 7;
        now %= k;
        count++;
      }
    }
  }
}

Fixed submission:
#include <algorithm>
#include <bits/stdc++.h>
#include <iomanip>
#include <iostream>
#include <math.h>
#include <set>
#include <sstream>
#include <stdio.h>
#include <string>
#include <vector>
using namespace std;
int main(void) {
  long long int k;
  cin >> k;
  if (k % 2 == 0 || k % 5 == 0) {
    cout << -1 << endl;
  } else {
    long long int now = 7;
    long long int count = 1;
    while (true) {
      if (now % k == 0) {
        cout << count << endl;
        break;
      } else {
        now *= 10;
        now += 7;
        now %= k;
        count++;
      }
    }
  }
}
Problem p02596 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
#define ll long long
#define MM(arr, x) memset(arr, x, sizeof(arr))
#define INF 0x3f3f3f3f
#define Maxn 1e5 + 10;
using namespace std;
int main() {
  ios::sync_with_stdio(0);
  ll ans = 0, k, now = 0;
  cin >> k;
  while (ans <= 999999999) {
    ans++;
    now = (now * 10 + 7) % k;
    if (now == 0) {
      cout << ans;
      return 0;
    }
  }
  cout << -1;
  return 0;
}

Fixed submission:
#include <bits/stdc++.h>
#define ll long long
#define MM(arr, x) memset(arr, x, sizeof(arr))
#define INF 0x3f3f3f3f
#define Maxn 1e5 + 10;
using namespace std;
int main() {
  ios::sync_with_stdio(0);
  ll ans = 0, k, now = 0;
  cin >> k;
  while (ans <= 99999999) {
    ans++;
    now = (now * 10 + 7) % k;
    if (now == 0) {
      cout << ans;
      return 0;
    }
  }
  cout << -1;
  return 0;
}
Problem p02596 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
#define ll long long
#define rep(i, a, b) for (long long i = a; i < b; i += 1)
#define repr(i, a, b) for (long long i = a; i <= b; i += 1)
#define vec vector<ll>
#define map map<char, int>
#define repa(p, A) for (auto p : A)
#define pb push_back
#define sort(a) sort(a.begin(), a.end())
#define reverse(a) reverse(a.begin(), a.end())
const double PI = acos(-1);
const ll INF = 1000000;
using namespace std;

int main() {
  ll K;
  cin >> K;
  vec A(K);
  A[0] = 7;
  rep(i, 0, K) { A[i + 1] = (A[i] * 10 + 7) % K; }
  rep(i, 0, K) {
    if (A[i] % K == 0) {
      cout << i + 1 << endl;
      return 0;
    }
  }
  cout << "-1" << endl;
}


Fixed submission:
#include <bits/stdc++.h>
#define ll long long
#define rep(i, a, b) for (long long i = a; i < b; i += 1)
#define repr(i, a, b) for (long long i = a; i <= b; i += 1)
#define vec vector<ll>
#define map map<char, int>
#define repa(p, A) for (auto p : A)
#define pb push_back
#define sort(a) sort(a.begin(), a.end())
#define reverse(a) reverse(a.begin(), a.end())
const double PI = acos(-1);
const ll INF = 1000000;
using namespace std;

int main() {
  ll K;
  cin >> K;
  vec A(K);
  A[0] = 7;
  rep(i, 0, K - 1) { A[i + 1] = (A[i] * 10 + 7) % K; }
  rep(i, 0, K) {
    if (A[i] % K == 0) {
      cout << i + 1 << endl;
      return 0;
    }
  }
  cout << "-1" << endl;
}
Problem p02596 (C++)

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

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);

  ll n, d, cnt = 1;
  set<ll> s;
  cin >> n;
  ll aux = 1;
  if (n % 7 == 0)
    n %= 7;
  while (1) {
    if (s.find(aux) != s.end()) {
      cout << "-1";
      return 0;
    }

    if (aux % n == 0)
      break;

    s.insert(aux);
    cnt++;
    aux %= n;
    aux = aux * 10 + 1;
  }
  cout << cnt;
}

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

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);

  ll n, d, cnt = 1;
  set<ll> s;
  cin >> n;
  ll aux = 1;
  if (n % 7 == 0)
    n /= 7;

  while (1) {
    if (s.find(aux) != s.end()) {
      cout << "-1";
      return 0;
    }

    if (aux % n == 0)
      break;

    s.insert(aux);
    cnt++;
    aux %= n;
    aux = aux * 10 + 1;
  }
  cout << cnt;
}
Problem p02596 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <iostream>
#include <stdio.h>

#include <algorithm>
#include <cctype>
#include <cmath>
#include <cstring>
#include <string>
#include <vector>

using namespace std;

int main() {
  long long k;
  cin >> k;

  // 偶数は排除
  if (k % 2 == 0 || k % 5 == 0) {
    cout << -1 << endl;
    return 0;
  }

  long long count = 0;
  long long i = 1;
  long long number = 7;
  while (1) {
    if (number % k == 0) {
      count = i;
      break;
    }

    number = number * 10 + 7;
    i++;
  }

  cout << count << endl;

  return 0;
}

Fixed submission:
#include <iostream>
#include <stdio.h>

#include <algorithm>
#include <cctype>
#include <cmath>
#include <cstring>
#include <string>
#include <vector>

using namespace std;

int main() {
  long long k;
  cin >> k;

  // 偶数は排除
  if (k % 2 == 0 || k % 5 == 0) {
    cout << -1 << endl;
    return 0;
  }

  long long count = 0;
  long long i = 1;
  long long number = 7;
  while (1) {
    if (number % k == 0) {
      count = i;
      break;
    }

    number = (number % k) * 10 + 7;
    i++;
  }

  cout << count << endl;

  return 0;
}