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

#include <bits/stdc++.h>
using namespace std;
int main(void) {
  long long k;
  cin >> k;
  long long tmp = 7 % k;
  set<int> s;
  s.insert(7);
  if (tmp == 0) {
    cout << 1 << endl;
    return 0;
  }
  s.insert(tmp);
  for (long long i = 2;; i++) {
    tmp = ((tmp * 10) % k + 7 % k) % k;
    if (tmp == 0) {
      cout << i << endl;
      return 0;
    }

    if (s.find(tmp) != s.end()) {
      cout << -1 << endl;
      return 0;
    }
    s.insert(tmp);
  }
  return 0;
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
int main(void) {
  long long k;
  cin >> k;
  long long tmp = 7 % k;
  set<int> s;
  s.insert(7);
  if (tmp == 0) {
    cout << 1 << endl;
    return 0;
  }
  s.insert(tmp);
  for (long long i = 2;; i++) {
    tmp = ((tmp * 10) % k + 7 % k) % k;
    if (tmp == 0) {
      cout << i << endl;
      return 0;
    }

    if (s.find(tmp) != s.end()) {
      cout << -1 << endl;
      return 0;
    }
  }
  return 0;
}
Problem p02596 (C++) — buggy submission, verdict: Time Limit Exceeded

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

int main() {
  int k, L;
  cin >> k;
  if (k % 7 == 0)
    k /= 7;
  L = 9 * k;

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

  int tmp = 10, cnt = 1;
  while (1) {
    if (tmp % L == 1) {
      cout << cnt << '\\n';
      return 0;
    }
    tmp %= L;
    tmp *= 10;
    cnt++;
  }
}


Error: TLE

Fixed submission:

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

int main() {
  int k, L;
  cin >> k;
  if (k % 7 == 0)
    k /= 7;
  L = 9 * k;

  if (L == 2 || L == 5) {
    cout << -1 << '\\n';
    return 0;
  }

  int tmp = 10, cnt = 1;
  while (1) {
    if (tmp % L == 1) {
      cout << cnt << '\\n';
      return 0;
    }
    tmp %= L;
    tmp *= 10;
    cnt++;
  }
}
Problem p02596 (C++) — buggy submission, verdict: Time Limit Exceeded

// Author : Prakhar Asaiya
#include <bits/stdc++.h>
using namespace std;
#define REP(i, a, b) for (int i = a; i < b; ++i)
#define REPN(i, a, b) for (int i = a; i <= b; ++i)
#define REPV(i, a, b) for (int i = a; i >= b; --i)
#define db1(x) cout << #x << "=" << x << '\\n'
#define db2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << '\\n'
#define db3(x, y, z)                                                           \\
  cout << #x << "=" << x << "," << #y << "=" << y << "," << #z << "=" << z     \\
       << '\\n'
#define ll long long
#define INF 100000
#define ff first
#define ss second
const int M = 1e9 + 7;

void solve() {
  int k;
  cin >> k;
  if (k & 1 ^ 1)
    cout << "-1\\n";
  else {
    int rem = 7 % k;
    int ans = 0;
    REP(i, 1, (int)1e7) {
      if (!rem) {
        cout << i << "\\n";
        return;
      }
      rem = (rem * 10 + 7) % k;
    }
    cout << "-1\\n";
  }
}

int main() { /*
            #ifndef ONLINE_JUDGE
                freopen("input.txt","r",stdin);
                freopen("output.txt","w",stdout);
            #*/
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  solve();
  return 0;
}


Error: TLE

Fixed submission:

// Author : Prakhar Asaiya
#include <bits/stdc++.h>
using namespace std;
#define REP(i, a, b) for (int i = a; i < b; ++i)
#define REPN(i, a, b) for (int i = a; i <= b; ++i)
#define REPV(i, a, b) for (int i = a; i >= b; --i)
#define db1(x) cout << #x << "=" << x << '\\n'
#define db2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << '\\n'
#define db3(x, y, z)                                                           \\
  cout << #x << "=" << x << "," << #y << "=" << y << "," << #z << "=" << z     \\
       << '\\n'
#define ll long long
#define INF 100000
#define ff first
#define ss second
const int M = 1e9 + 7;

void solve() {
  int k;
  cin >> k;
  if (k & 1 ^ 1)
    cout << "-1\\n";
  else {
    int rem = 7 % k;
    int ans = 0;
    while (rem) {
      rem = rem * 10 + 7;
      rem %= k;
      ++ans;
    }
    cout << ans + 1 << "\\n";
  }
}

int main() { /*
            #ifndef ONLINE_JUDGE
                freopen("input.txt","r",stdin);
                freopen("output.txt","w",stdout);
            #*/
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  solve();
  return 0;
}
Problem p02596 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <algorithm>
#include <iostream>
#include <vector>

using ll = long long;
using namespace std;

int main() {
  long a = 0;
  long K;
  cin >> K;
  if (K % 7 == 0)
    K /= 7;
  if (K % 2 == 0 || K % 5 == 0) {
    cout << -1;
    exit(0);
  }
  long n = 1;
  long r = 1 % K;
  while (r != 0) {
    r = (10 * r + 1) % K;
    n += 1;
  }
  cout << n;
  return 0;
}

Error: TLE

Fixed submission:

#include <algorithm>
#include <iostream>
#include <vector>

using ll = long long;
using namespace std;

int main() {
  long a = 0;
  long K;
  cin >> K;
  if (K % 7 == 0)
    K /= 7;
  if (K % 2 == 0) {
    cout << -1;
    exit(0);
  }
  long n = 1;
  long r = 1 % K;
  while (r != 0) {
    r = (10 * r + 1) % K;
    n += 1;
  }
  cout << n;
  return 0;
}
Problem p02596 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <algorithm>
#include <cmath>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>

#define ll long long
#define REP(i, n) for (int i = 0; i < n; i++)
#define PI 3.141592653589
#define MOD 1000000007

using namespace std;

template <typename T> T gcd(T a, T b) { return (a % b) ? gcd(b, a % b) : b; }
template <typename T> T lcm(T a, T b) { return a * b / gcd(a, b); }

int main(void) {
  ll k;
  cin >> k;
  if (k % 2 == 0 || k % 5 == 0) {
    cout << -1 << endl;
  } else {
    int i = 1;
    ll rem = 0;
    ll num = 7;
    while (1) {
      num = num % k;
      rem += num;
      if (rem % k == 0) {
        cout << i << endl;
        break;
      }
      num *= 10;
      i++;
    }
  }
  return 0;
}

Error: TLE

Fixed submission:

#include <algorithm>
#include <cmath>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>

#define ll long long
#define REP(i, n) for (int i = 0; i < n; i++)
#define PI 3.141592653589
#define MOD 1000000007

using namespace std;

template <typename T> T gcd(T a, T b) { return (a % b) ? gcd(b, a % b) : b; }
template <typename T> T lcm(T a, T b) { return a * b / gcd(a, b); }

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

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;

typedef pair<int, int> pi;
typedef pair<ll, ll> pl;

typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<vi> vvi;

#define FOR(i, a, b) for (int i = a; i < (b); i++)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()

template <class T> bool ckmin(T &a, const T &b) { return b < a ? a = b, 1 : 0; }
template <class T> bool ckmax(T &a, const T &b) { return a < b ? a = b, 1 : 0; }

#define trav(container, it)                                                    \\
  for (typeof(container.begin()) it = container.begin();                       \\
       it != container.end(); it++)

const int MOD = 1000000007;
const char nl = '\\n';

int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int n;
  cin >> n;

  ll temp = 7 % n, count = 1;

  if (n % 2 == 0)
    cout << -1;
  else {
    while (temp != 0) {
      ++count;
      temp = (temp * 10 + 7) % n;
      if (count > n) {
        count = -1;
        break;
      }
    }
    cout << count;
  }
}


Error: TLE

Fixed submission:

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;

typedef pair<int, int> pi;
typedef pair<ll, ll> pl;

typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<vi> vvi;

#define FOR(i, a, b) for (int i = a; i < (b); i++)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()

template <class T> bool ckmin(T &a, const T &b) { return b < a ? a = b, 1 : 0; }
template <class T> bool ckmax(T &a, const T &b) { return a < b ? a = b, 1 : 0; }

#define trav(container, it)                                                    \\
  for (typeof(container.begin()) it = container.begin();                       \\
       it != container.end(); it++)

const int MOD = 1000000007;
const char nl = '\\n';

int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int n;
  cin >> n;

  ll temp = 7, count = 1;

  if (n % 2 == 0)
    cout << -1;
  else {
    while (temp % n != 0) {
      ++count;
      temp = temp * 10 + 7;
    }
    cout << count;
  }
}
Problem p02596 (C++) — buggy submission, verdict: Time Limit Exceeded

// author-Shivam gupta

#include <bits/stdc++.h>

using namespace std;

#define MEM(a, b) memset(a, (b), sizeof(a))

#define FOREACH(it, l) for (auto it = l.begin(); it != l.end(); it++)

#define IN(A, B, C) assert(B <= A && A <= C)

#define MP make_pair
#define FOR(i, a) for (int i = 0; i < a; i++)

#define FOR1(i, j, a) for (int i = j; i < a; i++)

#define EB emplace_back

#define INF (int)1e9

#define EPS 1e-9

#define PI 3.1415926535897932384626433832795

#define MOD 1000000007

#define read(type) readInt<type>()
#define max1 100001
#define out(x) cout << x << '\\n'
#define out1(x) cout << x << " "
#define END cout << '\\n'
#define int long long
void fast() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
}

signed main() {

  int n;
  cin >> n;
  if (n % 2 == 0) {
    out(-1);
    return 0;
  }
  int x = 0;
  int p = n;
  int cnt = 0;
  while (p > 0) {
    x *= 10;
    x += 7;
    p = p / 10;
    cnt++;
  }
  if (x < n) {
    x *= 10;
    x += 7;
    cnt++;
  }
  int a = x % n;
  if (a == 0) {
    out(cnt);
    return 0;
  }
  p = a;
  while (p < n) {
    p *= 10;
    p += 7;
    cnt++;
  }
  int w = 1000000;
  while (w--) {
    a = p % n;
    if (a == 0) {
      out(cnt);
      return 0;
    }

    p = a;
    while (p < n) {
      p *= 10;
      p += 7;
      cnt++;
    }
  }
  out(-1);
}


Error: TLE

Fixed submission:

// author-Shivam gupta

#include <bits/stdc++.h>

using namespace std;

#define MEM(a, b) memset(a, (b), sizeof(a))

#define FOREACH(it, l) for (auto it = l.begin(); it != l.end(); it++)

#define IN(A, B, C) assert(B <= A && A <= C)

#define MP make_pair
#define FOR(i, a) for (int i = 0; i < a; i++)

#define FOR1(i, j, a) for (int i = j; i < a; i++)

#define EB emplace_back

#define INF (int)1e9

#define EPS 1e-9

#define PI 3.1415926535897932384626433832795

#define MOD 1000000007

#define read(type) readInt<type>()
#define max1 100001
#define out(x) cout << x << '\\n'
#define out1(x) cout << x << " "
#define END cout << '\\n'
#define int long long
void fast() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
}

signed main() {

  int n;
  cin >> n;
  if (n % 2 == 0) {
    out(-1);
    return 0;
  }
  int x = 0;
  int p = n;
  int cnt = 0;
  while (p > 0) {
    x *= 10;
    x += 7;
    p = p / 10;
    cnt++;
  }
  if (x < n) {
    x *= 10;
    x += 7;
    cnt++;
  }
  int a = x % n;
  if (a == 0) {
    out(cnt);
    return 0;
  }
  p = a;
  while (p < n) {
    p *= 10;
    p += 7;
    cnt++;
  }
  while (1) {
    a = p % n;
    if (a == 0) {
      out(cnt);
      return 0;
    }

    p = a;
    while (p < n) {
      p *= 10;
      p += 7;
      cnt++;
    }
  }
  out(-1);
}
Problem p02596 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long int n, k;
  int count = 1;
  cin >> n;
  k = 7;
  long long int sum = 7;
  if (n % 2 == 0 || n % 5 == 0) {
    cout << "-1\\n";
    return 0;
  }
  while (sum % n != 0) {
    sum = sum + ((k % n) * (10 % n)) % n;
    k = ((k % n) * (10 % n));
    count++;
  }
  cout << count << "\\n";
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long int n, k;
  int count = 1;
  cin >> n;
  k = 7;
  long long int sum = 7;
  if (n % 2 == 0 || n == 5) {
    cout << "-1\\n";
    return 0;
  }
  while (sum % n != 0) {
    sum = sum + ((k % n) * (10 % n)) % n;
    k = ((k % n) * (10 % n));
    count++;
  }
  cout << count << "\\n";
}
Problem p02596 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
#define rep(i, n)                                                              \\
  ;                                                                            \\
  for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> state;
long double pi = acos(-1);
const int INF = 1001001001;

// 最小公倍数を求める
int euqlid(int a, int b) {
  int temp;
  temp = a % b;
  if (temp == 0)
    return b;
  return euqlid(b, temp);
}
ll conbination(ll a, ll b) {
  ll u = 1;
  ll d = 1;
  while (b != 0) {
    u *= a;
    d *= b;
    a--;
    b--;
  }
  return u / d;
}
int strtoint(char s) { return (int(s - '0')); }
char changeS(char alpha) {
  if (0x41 <= alpha and alpha <= 0x5A)
    return (alpha + 0x20);
  else if (0x61 <= alpha and alpha <= 0x7A)
    return (alpha - 0x20);
  return alpha;
}
int fact(int n) {
  if (n == 1)
    return 1;
  return n * fact(n - 1);
}
int ceil(int a, int b) {
  // a/bの切り上げを考える
  return (a + b - 1) / b;
}

int main() {
  int k;
  cin >> k;
  int ans = -1;

  if (k % 2 == 0) {
    cout << ans << endl;
    return 0;
  }
  int seven = 7;
  int cnt = 1;
  seven %= k;
  while (1) {
    if (seven == 0)
      break;
    else {
      seven = (7 + seven * 10) % k;
      cnt++;
    }
    if (cnt > k) {
      cout << ans << endl;
      return 0;
    }
  }
  cout << cnt << endl;
}


Error: TLE

Fixed submission:

#include <bits/stdc++.h>
#define rep(i, n)                                                              \\
  ;                                                                            \\
  for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> state;
long double pi = acos(-1);
const int INF = 1001001001;

// 最小公倍数を求める
int euqlid(int a, int b) {
  int temp;
  temp = a % b;
  if (temp == 0)
    return b;
  return euqlid(b, temp);
}
ll conbination(ll a, ll b) {
  ll u = 1;
  ll d = 1;
  while (b != 0) {
    u *= a;
    d *= b;
    a--;
    b--;
  }
  return u / d;
}
int strtoint(char s) { return (int(s - '0')); }
char changeS(char alpha) {
  if (0x41 <= alpha and alpha <= 0x5A)
    return (alpha + 0x20);
  else if (0x61 <= alpha and alpha <= 0x7A)
    return (alpha - 0x20);
  return alpha;
}
int fact(int n) {
  if (n == 1)
    return 1;
  return n * fact(n - 1);
}
int ceil(int a, int b) {
  // a/bの切り上げを考える
  return (a + b - 1) / b;
}

int main() {
  int k;
  cin >> k;
  int ans = -1;

  if (k % 2 == 0) {
    cout << ans << endl;
    return 0;
  }
  int seven = 7;
  int cnt = 1;
  seven %= k;
  while (1) {
    if (seven == 0)
      break;
    else {
      seven = (7 + seven * 10) % k;
      cnt++;
    }
  }
  cout << cnt << endl;
}
Problem p02596 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>
using namespace std;

long long all7(long long a) {
  long long count = 0;
  while (a > 0) {
    if (a % 10 != 7) {
      count = 0;
      break;
    }
    a /= 10;
    count++;
  }

  return count;
}

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

  K *= 9;
  if (K % 7 == 0) {
    K /= 7;
  }

  long long amari = 10 % K;
  int i = 1;
  while (i <= 9e6) {
    if (amari == 1) {
      cout << i << endl;
      return 0;
    }
    amari *= 10;
    amari %= K;
    i++;
  }

  cout << -1 << endl;

  return 0;
}

Error: TLE

Fixed submission:

#include <iostream>
using namespace std;

long long all7(long long a) {
  long long count = 0;
  while (a > 0) {
    if (a % 10 != 7) {
      count = 0;
      break;
    }
    a /= 10;
    count++;
  }

  return count;
}

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

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

  if (K % 7 != 0) {
    K *= 7;
  }

  long long i = 1;
  while (true) {
    long long ans = all7(K * i);
    if (ans != 0) {
      cout << ans << endl;
      return 0;
    }

    i += 2;
  }
}
Problem p02596 (C++) — buggy submission, verdict: Time Limit Exceeded

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

typedef long long ll;
typedef long double ld;
typedef vector<ll> vl;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector<vl> vvl;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef vector<pii> vpii;
typedef vector<vpll> vvpll;
typedef vector<vpii> vvpii;

#define pb push_back
#define eb emplace_back
#define pf push_front
#define all(c) (c).begin(), (c).end()
#define ff first
#define ss second
#define mp(x, y) make_pair((x), (y))
#define boost                                                                  \\
  ios_base::sync_with_stdio(false);                                            \\
  cin.tie(NULL)

void solve() {

  int k;
  cin >> k;
  bool rem[k];
  memset(rem, false, sizeof(rem));
  int n = 7;
  int cnt = 0;
  while (1) {
    cnt++;
    if (n % k == 0) {
      cout << cnt << '\\n';
      return;
    }
    if (rem[n % k]) {
      cout << -1 << '\\n';
      return;
    }
    rem[n % k] = true;
    n = (n * 10 + 7) % k;
  }
}

int main() {
#ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
#endif

  boost;

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

  for (int i = 1; i <= t; i++) {
    // cout << "Case #" << i << ": ";

    solve();
  }
  return 0;
}

Error: TLE

Fixed submission:

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

typedef long long ll;
typedef long double ld;
typedef vector<ll> vl;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector<vl> vvl;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef vector<pii> vpii;
typedef vector<vpll> vvpll;
typedef vector<vpii> vvpii;

#define pb push_back
#define eb emplace_back
#define pf push_front
#define all(c) (c).begin(), (c).end()
#define ff first
#define ss second
#define mp(x, y) make_pair((x), (y))
#define boost                                                                  \\
  ios_base::sync_with_stdio(false);                                            \\
  cin.tie(NULL)

void solve() {

  int k;
  cin >> k;
  bool rem[k];
  memset(rem, false, sizeof(rem));
  int n = 7;
  int cnt = 0;
  while (1) {
    cnt++;
    if (n % k == 0) {
      cout << cnt << '\\n';
      return;
    }
    if (rem[n % k]) {
      cout << -1 << '\\n';
      return;
    }
    n = (n * 10 + 7) % k;
  }
}

int main() {
#ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
#endif

  boost;

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

  for (int i = 1; i <= t; i++) {
    // cout << "Case #" << i << ": ";

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

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

int main() {
  int A = 7;
  int K, ans;
  cin >> K;
  if (K % 2 == 0 || K % 5 == 0) {
    cout << -1 << endl;
    return 0;
  }
  long long amari = 0;
  for (int i = 1;; i++) {
    amari += A % K;
    if (amari % K == 0) {
      ans = i;
      break;
    } else {
      A *= 10;
      A %= K;
    }
  }
  cout << ans << endl;
  return 0;
}

Error: TLE

Fixed submission:

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

int main() {
  int A = 7;
  int K, ans;
  cin >> K;
  if (K % 2 == 0) {
    cout << -1 << endl;
    return 0;
  }
  long long amari = 0;
  for (int i = 1;; i++) {
    amari += A % K;
    if (amari % K == 0) {
      ans = i;
      break;
    } else {
      A *= 10;
      A %= K;
    }
  }
  cout << ans << endl;
  return 0;
}
Problem p02596 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>
#include <set>

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

  int x = 7 % k;
  for (int i = 1; i <= k; i++) {
    if (x == 0) {
      std::cout << i << std::endl;
      return 0;
    }
    x = (x * 10 + 7) % k;
  }
  std::cout << -1 << std::endl;

  return 0;
}

Error: TLE

Fixed submission:

#include <iostream>

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

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

  int count = 0;
  int n = 0;
  while (1) {
    n = n * 10 + 7;
    count++;
    if (n % k == 0) {
      break;
    }
  }

  std::cout << count << std::endl;

  return 0;
}
Problem p02596 (C++) — buggy submission, verdict: 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() {
  ll d;
  cin >> d;
  if (d % 2 == 0) {
    cout << -1 << endl;
    return 0;
  }
  if (d == 1) {
    cout << 1 << endl;
    return 0;
  }

  ll i = 1;
  ll x = 7;
  while (1) {
    int rem = x % d;
    if (rem == 0) {
      cout << i << endl;
      return 0;
    }
    x = rem * 10 + 7;

    ++i;
    if (i > 1000000)
      break;
  }
  cout << -1 << endl;

  return 0;
}

Error: TLE

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() {
  ll d;
  cin >> d;
  if (d % 2 == 0) {
    cout << -1 << endl;
    return 0;
  }
  if (d == 1) {
    cout << 1 << endl;
    return 0;
  }

  ll i = 1;
  ll x = 7;
  while (1) {
    int rem = x % d;
    if (rem == 0) {
      cout << i << endl;
      return 0;
    }
    x = rem * 10 + 7;

    ++i;
  }

  return 0;
}