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

#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rng(i, a, b) for (int i = int(a); i < int(b); i++)
#define rep(i, b) rng(i, 0, b)
#define gnr(i, a, b) for (int i = int(b) - 1; i >= int(a); i--)
#define per(i, b) gnr(i, 0, b)
#define bg begin()
#define ed end()
#define rbg rbegin()
#define red rend()
#define all(x) x.bg, x.ed
#define rall(x) x.rbg, x.red
#define pb push_back
#define pf push_front
#define eb emplace_back
using namespace std;
typedef long long ll;
template <class t, class u> bool chmax(t &a, u b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <class t, class u> bool chmin(t &a, u b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template <class t, class u> t MAX(t a, u b) {
  if (a >= b)
    return a;
  return b;
}
template <class t, class u> t MIN(t a, u b) {
  if (a <= b)
    return a;
  return b;
}
template <class t> int SIZE(t s) { return (int)s.size(); }
template <class t> using vc = vector<t>;
template <class t> using vvc = vc<vc<t>>;
using vvi = vc<vc<int>>;
using pi = pair<int, int>;
using vi = vc<int>;
void yes() { cout << "Yes" << endl; }
void no() { cout << "No" << endl; }
const long long INF = 1LL << 60;

int main() {
  cout << fixed << setprecision(20);
  int k;
  cin >> k;
  ll num = 0;
  ll ans = 0;
  rep(i, k) {
    ans++;
    num *= 10;
    num += 7;
    if (num % k == 0) {
      cout << ans << endl;
      return 0;
    }
    num %= k;
  }
  cout << -1 << endl;
  return 0;
}


Error: TLE

Fixed submission:

#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rng(i, a, b) for (int i = int(a); i < int(b); i++)
#define rep(i, b) rng(i, 0, b)
#define gnr(i, a, b) for (int i = int(b) - 1; i >= int(a); i--)
#define per(i, b) gnr(i, 0, b)
#define bg begin()
#define ed end()
#define rbg rbegin()
#define red rend()
#define all(x) x.bg, x.ed
#define rall(x) x.rbg, x.red
#define pb push_back
#define pf push_front
#define eb emplace_back
using namespace std;
typedef long long ll;
template <class t, class u> bool chmax(t &a, u b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <class t, class u> bool chmin(t &a, u b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template <class t, class u> t MAX(t a, u b) {
  if (a >= b)
    return a;
  return b;
}
template <class t, class u> t MIN(t a, u b) {
  if (a <= b)
    return a;
  return b;
}
template <class t> int SIZE(t s) { return (int)s.size(); }
template <class t> using vc = vector<t>;
template <class t> using vvc = vc<vc<t>>;
using vvi = vc<vc<int>>;
using pi = pair<int, int>;
using vi = vc<int>;
void yes() { cout << "Yes" << endl; }
void no() { cout << "No" << endl; }
const long long INF = 1LL << 60;

int main() {
  cout << fixed << setprecision(20);
  int k;
  cin >> k;
  if (k % 2 == 0 || k % 5 == 0)
    cout << -1 << endl;
  ll num = 0;
  ll ans = 0;
  while (1) {
    ans++;
    num *= 10;
    num += 7;
    if (num % k == 0)
      break;
    num %= k;
  }
  cout << ans << endl;
  return 0;
}
Problem p02596 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int N;
  cin >> N;
  int value = 7;
  int count = 1;
  for (long long int i = 0; i < N; i++) {
    if (value % N == 0) {
      cout << count << endl;
      return 0;
    } else {
      value = ((value * 10) + 7) % N;
    }
    count += 1;
  }
  cout << "-1" << endl;
  return 0;
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int N;
  cin >> N;
  vector<int> vec;
  long long int value = 7 % N;
  long long int count = 1;
  while (find(vec.begin(), vec.end(), value) == vec.end()) {
    if (value == 0) {
      cout << count << endl;
      return 0;
    }
    if (count >= 1e7) {
      cout << "-1" << endl;
      return 0;
    }
    vec.push_back(value);
    value = (value * 10 + 7) % N;
    count += 1;
  }
  cout << "-1" << endl;
  return 0;
}
Problem p02596 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <algorithm>
#include <bitset>
#include <cmath>
#include <fstream>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <unordered_set>
#include <vector>

int MOD_BIG = 1000000007;
int MOD_BIG2 = 998244353;
using std::cerr;
using std::cin;
using std::cout;
using std::endl;
using std::string;
using ll = long long;
using pint = std::pair<int, int>;
using pll = std::pair<ll, ll>;
using std::vector;

#define FOR(i, begin, end)                                                     \\
  for (int i = (begin), i##_end_ = (end); i < i##_end_; i++)
#define IFOR(i, begin, end)                                                    \\
  for (int i = (end)-1, i##_begin_ = (begin); i >= i##_begin_; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)

//////////////////////////////////////

//////////////////////////////////////

int main() {

  ll K;
  cin >> K;
  if (K % 2 == 0) {
    cout << -1 << endl;
    return 0;
  }
  ll ans = 0;
  ll m = 0;
  ll n = 7;
  while (true) {
    m += n;
    m %= K;
    ans++;
    n = (n * 10) % K;
    if (m == 0)
      break;
    if (ans > 10000000) {
      cout << -1 << endl;
      return 0;
    }
  }
  cout << ans << endl;

  return 0;
}


Error: TLE

Fixed submission:

#include <algorithm>
#include <bitset>
#include <cmath>
#include <fstream>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <unordered_set>
#include <vector>

int MOD_BIG = 1000000007;
int MOD_BIG2 = 998244353;
using std::cerr;
using std::cin;
using std::cout;
using std::endl;
using std::string;
using ll = long long;
using pint = std::pair<int, int>;
using pll = std::pair<ll, ll>;
using std::vector;

#define FOR(i, begin, end)                                                     \\
  for (int i = (begin), i##_end_ = (end); i < i##_end_; i++)
#define IFOR(i, begin, end)                                                    \\
  for (int i = (end)-1, i##_begin_ = (begin); i >= i##_begin_; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)

//////////////////////////////////////

//////////////////////////////////////

int main() {

  ll K;
  cin >> K;
  if (K % 2 == 0) {
    cout << -1 << endl;
  }
  ll ans = 0;
  ll m = 0;
  ll n = 7;
  while (true) {
    m += n;
    m %= K;
    ans++;
    n = (n * 10) % K;
    if (m == 0)
      break;
  }
  cout << ans << endl;

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

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

typedef long long i64;
typedef pair<int, int> ii;
typedef pair<i64, i64> ll;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<ll> vll;
typedef vector<vi> vvi;

#define fastIO() ios_base::sync_with_stdio(0), cin.tie(0)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define ms(a, x) memset(a, x, sizeof(a))
#define len(x) (x).size()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second

const double eps = 1e-9;
const double pi = acos(-1.0);
const int inf = 1e9;
const int maxn = 2e5 + 5;
const int mod = 1e9 + 7;

i64 k, cur, ans, ct;
bool ok;

int main() {
  fastIO();
  cin >> k;
  if (k % 2 == 0) {
    cout << "-1\\n";
    return 0;
  }
  cur = 7;
  ans = 1;
  while (true) {
    ct++;
    if (ct == 2000000LL) {
      break;
    }
    if (cur % k == 0) {
      ok = true;
      break;
    }
    ans++;
    cur = (cur * 10LL % k + 7LL) % k;
  }
  if (!ok)
    cout << "-1\\n";
  else
    cout << ans << '\\n';
  return 0;
}


Error: TLE

Fixed submission:

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

typedef long long i64;
typedef pair<int, int> ii;
typedef pair<i64, i64> ll;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<ll> vll;
typedef vector<vi> vvi;

#define fastIO() ios_base::sync_with_stdio(0), cin.tie(0)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define ms(a, x) memset(a, x, sizeof(a))
#define len(x) (x).size()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second

const double eps = 1e-9;
const double pi = acos(-1.0);
const int inf = 1e9;
const int maxn = 2e5 + 5;
const int mod = 1e9 + 7;

i64 k, cur, ans;
bool ok;

int main() {
  fastIO();
  cin >> k;
  if (k % 2 == 0) {
    cout << "-1\\n";
    return 0;
  }
  cur = 7;
  ans = 1;
  while (true) {
    if (cur % k == 0) {
      ok = true;
      break;
    }
    ans++;
    cur = (cur * 10LL % k + 7LL) % k;
  }
  if (!ok)
    cout << "-1\\n";
  else
    cout << ans << '\\n';
  return 0;
}
Problem p02596 (C++) — buggy submission, verdict: Time Limit Exceeded

#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;
  }
}

Error: TLE

Fixed submission:

#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;
  }
}
Problem p02596 (C++) — buggy submission, verdict: 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 == 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;
}


Error: TLE

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 || 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;
}
Problem p02596 (C++) — buggy submission, verdict: 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;
  }
  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;
}


Error: TLE

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;
  }

  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, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
using namespace std;
#define LL long long int
int main() {

  LL N;
  cin >> N;
  if (N % 2 == 0)
    cout << "-1";
  else {
    LL num = 7;
    LL temp = N;
    bool flag = false;
    for (LL i = 1; i <= (LL)(1e7); i++) {
      if (num % N == 0) {
        cout << i;
        flag = true;
        break;
      }
      num = ((num * 10) % N + 7) % N;
    }
    if (flag == false)
      cout << -1;
  }
}


Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
#define LL long long int
int main() {

  LL N;
  cin >> N;
  if (N % 2 == 0)
    cout << "-1";
  else {
    LL num = 7;
    for (LL i = 1; i <= (LL)(1e8); i++) {
      if (num % N == 0) {
        cout << i;
        break;
      }
      num = ((num * 10) % N + 7) % N;
    }
  }
}
Problem p02596 (C++) — buggy submission, verdict: Time Limit Exceeded

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

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

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

  int ans = 1;
  int seven = 7 % K;
  while (seven != 0) {
    seven = (seven * 10 + 7) % K;
    ++ans;
  }

  cout << ans << endl;
}


Error: TLE

Fixed submission:

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

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

  if (K % 2 == 0 || K % 5 == 0) {
    cout << -1 << endl;
  } else {
    int ans = 0;
    int seven = 0;
    while (true) {
      seven = (seven * 10 + 7) % K;
      ++ans;
    }

    cout << ans << endl;
  }
}
Problem p02596 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>
using namespace std;
int main() {
  int k;
  cin >> k;
  if (k % 2 == 0)
    cout << "-1" << endl;
  else {
    int ans = 7;
    int i;
    for (i = 1;; i++) {
      if (ans % k == 0) {
        cout << i << endl;
        break;
      } else
        ans = (ans % k) * 10 + 7;
      if (i == 5000000) {
        cout << -1 << endl;
        break;
      }
    }
  }
}

Error: TLE

Fixed submission:

#include <iostream>
using namespace std;
int main() {
  int k;
  cin >> k;
  if (k % 2 == 0)
    cout << "-1" << endl;
  else {
    int ans = 7;
    int i;
    for (i = 1;; i++) {
      if (ans % k == 0)
        break;
      else
        ans = (ans % k) * 10 + 7;
    }
    cout << i << endl;
  }
}
Problem p02596 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double d;
#define for(i, a, b) for (int i = a; i < b; i++)
#define f(i, a, b) for (int i = a; i <= b; i++)
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int k, c = 0;
  long long n = 0;
  cin >> k;
  if (k % 2 == 0)
    return cout << -1 << endl, 0;
  while (c <= k) {
    n = n * 10 + 7;
    c += 1;
    n = n % k;
    if (n == 0) {
      return cout << c << endl, 0;
    }
  }

  cout << -1 << endl;
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double d;
#define for(i, a, b) for (int i = a; i < b; i++)
#define f(i, a, b) for (int i = a; i <= b; i++)
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int k, c = 1;
  long long n;
  cin >> k;
  if (k % 2 == 0)
    return cout << -1 << endl, 0;
  string s = "7";
  while (c <= k) {
    stringstream a(s);
    a >> n;
    n = n % k;
    if (n == 0) {
      return cout << c << endl, 0;
    }
    c += 1;
    s += "7";
  }

  cout << -1 << endl;
}
Problem p02596 (C++) — buggy submission, verdict: Time Limit Exceeded

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

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

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

  int cnt = 1;

  int m = 7 % K;

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

    if (m == 0) {
      cout << cnt << endl;
      break;
    }

    cnt++;

    m = (m * 10 + 7) % K;
  }
}


Error: TLE

Fixed submission:

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

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

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

  int cnt = 1;

  int m = 7;

  for (int i = 0; i < K * K; i++) {

    if (m % K == 0) {
      cout << cnt << endl;
      break;
    }

    cnt++;

    m = m * 10 + 7;
  }
}
Problem p02596 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <algorithm>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;

typedef long long ll;
typedef vector<int> vi;

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

  ll m = 7 % k;

  vector<bool> vis(k, false);

  ll ans = 1;
  while (1) {
    if (m % k == 0)
      break;
    vis[m] = true;

    m *= 10;
    m += 7;
    m %= k;

    if (vis[m]) {
      ans = -1;
      break;
    }

    ans++;
  }

  cout << ans << endl;

  return 0;
}

Error: TLE

Fixed submission:

#include <algorithm>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;

typedef long long ll;
typedef vector<int> vi;

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

  ll s = 7 % k;
  ll m = s;

  ll ans = 1;
  while (1) {
    if (m % k == 0)
      break;

    m *= 10;
    m += 7;
    m %= k;

    if (m == s) {
      ans = -1;
      break;
    }

    ans++;
  }

  cout << ans << endl;

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

#include <cmath>
#include <iostream>
#define IOS                                                                    \\
  ios_base::sync_with_stdio(0);                                                \\
  cin.tie(0);                                                                  \\
  cout.tie(0);
using namespace std;
int main() {
  IOS;
  long long n;
  cin >> n;
  long long k = 7, answer = 0;
  if (n % 2 == 0 || n % 5 == 0)
    cout << -1;
  else {
    while (1) {
      k %= n;
      // cout<<k<<endl;
      answer++;
      if (k == 0)
        break;
      k = k * 10 + 7;
      // getchar();
    }
    cout << answer;
  }
}

Error: TLE

Fixed submission:

#include <iostream>
#define IOS                                                                    \\
  ios_base::sync_with_stdio(0);                                                \\
  cin.tie(0);                                                                  \\
  cout.tie(0);
using namespace std;
int main() {
  IOS;
  long long n;
  cin >> n;
  long long k = 7, answer = 0;
  if (n % 2 == 0)
    cout << -1;
  else {
    while (1) {
      k %= n;
      // cout<<k<<endl;
      answer++;
      if (k == 0)
        break;
      k = k * 10 + 7;
      // getchar();
    }
    cout << answer;
  }
}
Problem p02596 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define F first
#define S second
#define N 1000002
#define mod 1000000007
#define pb push_back
#define IOS                                                                    \\
  ios_base::sync_with_stdio(false);                                            \\
  cin.tie(NULL);                                                               \\
  cout.tie(NULL);
const int mxN = 2005;
void solve() {
  ll k;
  cin >> k;
  ll i = 7;
  ll cnt = 1;
  ll rem = i % k;
  if (k % 2 == 0) {
    cout << "-1\\n";
    return;
  }
  if (rem == 0) {
    cout << cnt << '\\n';
    return;
  }
  map<ll, ll> mp;
  mp[rem] = 1;
  while (rem != 0) {
    rem *= 10;
    rem += 7;
    rem %= k;
    if (mp[rem])
      break;
    mp[rem] = 1;
    cnt++;
  }
  if (rem == 0)
    cout << cnt << '\\n';
  else
    cout << "-1\\n";
}

int main() {
  IOS ll T;
  // cin>>T;
  T = 1;
  // ll i = 1;
  while (T--) {
    // cout<<"Case #"<<i<<": ";
    solve();
    // i++;
  }
  return 0;
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define F first
#define S second
#define N 1000002
#define mod 1000000007
#define pb push_back
#define IOS                                                                    \\
  ios_base::sync_with_stdio(false);                                            \\
  cin.tie(NULL);                                                               \\
  cout.tie(NULL);
const int mxN = 2005;
void solve() {
  ll k;
  cin >> k;
  ll i = 7;
  ll cnt = 1;
  ll rem = i % k;
  if (k % 2 == 0) {
    cout << "-1\\n";
    return;
  }
  if (rem == 0) {
    cout << cnt << '\\n';
    return;
  }
  while (rem != 0) {
    rem *= 10;
    rem += 7;
    rem %= k;
    cnt++;
  }
  cout << cnt << '\\n';
}

int main() {
  IOS ll T;
  // cin>>T;
  T = 1;
  // ll i = 1;
  while (T--) {
    // cout<<"Case #"<<i<<": ";
    solve();
    // i++;
  }
  return 0;
}
Problem p02596 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <algorithm>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

typedef long long ll;
constexpr double PI = 3.141592653589793;
constexpr int INF = 1e9 + 10;
constexpr ll INFL = 1e18 + 10;

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;
}

using namespace std;
//    cout << setprecision(20) << ans << "\\n";

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

  ll k;
  cin >> k;

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

  ll l = 9 * k;
  if (k % 7 == 0) {
    l = 9 * k / 7;
  } else {
    l = 9 * k;
  }

  int digit = 0;
  ll target = 1;
  while (true) {
    target *= 10;
    digit++;
    if (target >= l && target % l == 1) {
      break;
    }

    if (target > l) {
      target %= l;
    }
  }
  cout << digit << "\\n";
  return 0;
}


Error: TLE

Fixed submission:

#include <algorithm>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

typedef long long ll;
constexpr double PI = 3.141592653589793;
constexpr int INF = 1e9 + 10;
constexpr ll INFL = 1e18 + 10;

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;
}

using namespace std;
//    cout << setprecision(20) << ans << "\\n";

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

  ll k;
  cin >> k;

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

  ll l = 9 * k;
  if (k % 7 == 0) {
    l = 9 * k / 7;
  } else {
    l = 9 * k;
  }

  int digit = 0;
  ll target = 1;
  while (true) {
    target *= 10;
    digit++;
    if (target % l == 1) {
      break;
    }
    if (target > l) {
      target %= l;
    }
  }
  cout << digit << "\\n";
  return 0;
}