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

#include <algorithm>
#include <bits/stdc++.h>
#include <cstdint>
#include <fstream>
#include <iterator>
#include <string>
#include <unordered_map>

using namespace std;

#define FAST_IO                                                                \\
  ios::sync_with_stdio(false);                                                 \\
  cin.tie(NULL);                                                               \\
  cout.tie(NULL);
#define Int int_fast64_t

int main() {
  FAST_IO;

  Int k, count = 1, temp = 7;
  cin >> k;
  temp = 7 % k;
  if (k % 2 == 0 || k % 5 == 0)
    count = -1;
  else {
    for (;;) {
      if (temp % k == 0)
        break;
      else {
        temp *= 10;
        temp += 7;
        temp = temp % k;
        count++;
      }
    }
  }
  cout << count << endl;

  return 0;
}


Error: TLE

Fixed submission:

#include <algorithm>
#include <bits/stdc++.h>
#include <cstdint>
#include <fstream>
#include <iterator>
#include <string>
#include <unordered_map>

using namespace std;

#define FAST_IO                                                                \\
  ios::sync_with_stdio(false);                                                 \\
  cin.tie(NULL);                                                               \\
  cout.tie(NULL);
#define Int int_fast64_t

int main() {
  FAST_IO;

  Int k, count = 1, temp = 7;
  cin >> k;
  if (k % 2 == 0 || k % 5 == 0)
    count = -1;
  else {
    for (;;) {
      if (temp % k == 0)
        break;
      else {
        temp *= 10;
        temp += 7;
        count++;
      }
    }
  }
  cout << count << endl;

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

#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <list>
#include <vector>

using namespace std;

int main() {
  int k, ans;
  int num;
  while (cin >> k) {
    ans = 1;
    num = 7;

    while (num % k != 0 && ans < 1000000) {
      num %= k;
      num = num * 10 + 7;
      ans++;
    }
    if (ans != 1000000)
      cout << ans << endl;
    else
      cout << "-1" << endl;
  }
}

Error: WA

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
#define int long long
signed main() {
  int n;
  cin >> n;
  if (n % 2 == 0) {
    cout << -1;
  } else {
    for (int i = 1; i < 11; i++) {
      string s(i, '7');
      int p = stoi(s);
      if (p % n == 0) {
        cout << i;
        return 0;
      };
    }
  }
  cout << -1;
}
Problem p02596 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
#define mp make_pair
#define ff first
#define ss second
#define bg begin()
#define en end()
#define pb push_back
#define w(x)                                                                   \\
  scanf("%d", &x);                                                             \\
  while (x--)
#define ws(x)                                                                  \\
  scanf("%d", &x);                                                             \\
  getchar();                                                                   \\
  while (x--)
#define rep(i, b) for (i = 0; i <= b; i++)
#define ios                                                                    \\
  ios_base::sync_with_stdio(0);                                                \\
  cin.tie(0);                                                                  \\
  cout.tie(0);
#define pi 2 * acos(0.0)
#define endl "\\n"
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;
typedef vector<int> vi;

const int N = 1e6 + 2;
long long mod = 1e9 + 9;
int t, j, cs = 0, n, b, i, a;
string s;

int main() {
  ios scanf("%d", &n);
  int a = 0, cnt = 0;
  while (a < n) {
    a = 10 * a + 7;
    cnt++;
  }

  if (n % 2 == 0 || n % 5 == 0) {
    printf("-1\\n");
    return 0;
  }
  while (a % n != 0) {
    a = a % n;
    a = a * 10 + 7;
    cnt++;

    // cout<<a<<endl;
  }
  printf("%d\\n", cnt);
}


Error: TLE

Fixed submission:

#include <bits/stdc++.h>
#define mp make_pair
#define ff first
#define ss second
#define bg begin()
#define en end()
#define pb push_back
#define w(x)                                                                   \\
  scanf("%d", &x);                                                             \\
  while (x--)
#define ws(x)                                                                  \\
  scanf("%d", &x);                                                             \\
  getchar();                                                                   \\
  while (x--)
#define rep(i, b) for (i = 0; i <= b; i++)
#define ios                                                                    \\
  ios_base::sync_with_stdio(0);                                                \\
  cin.tie(0);                                                                  \\
  cout.tie(0);
#define pi 2 * acos(0.0)
#define endl "\\n"
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;
typedef vector<int> vi;

const int N = 1e6 + 2;
long long mod = 1e9 + 9;
int t, j, cs = 0, n, b, i, a;
string s;

int main() {
  ios scanf("%d", &n);
  int a = 0, cnt = 0;
  while (a < n) {
    a = 10 * a + 7;
    cnt++;
  }

  if (n % 2 == 0) {
    printf("-1\\n");
    return 0;
  }
  while (a % n != 0) {
    a = a % n;
    a = a * 10 + 7;
    cnt++;

    // cout<<a<<endl;
  }
  printf("%d\\n", cnt);
}
Problem p02596 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
#define fastio                                                                 \\
  ios::sync_with_stdio(0);                                                     \\
  cin.tie(0);                                                                  \\
  cout.tie(0);
#define endl "\\n"
#define int long long int
using namespace std;
int mod = 1e9 + 7;

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

  int k;
  cin >> k;
  int n = 7 % k;
  for (int i = 1; i <= k; i++) {
    if (n == 0) {
      cout << i;
      return 0;
    }
    n = (n * 10 + 7) % k;
  }
  cout << -1;
  return 0;
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>
#define fastio                                                                 \\
  ios::sync_with_stdio(0);                                                     \\
  cin.tie(0);                                                                  \\
  cout.tie(0);
#define endl "\\n"
#define int long long int
using namespace std;
int mod = 1e9 + 7;

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

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

#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repi(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
using namespace std;
typedef long long ll;

int K;

int main() {
  cin >> K;
  int X = 0;
  int ans = 0;
  int cnt = 1;

  if (K % 2 == 0)
    ans = -1;
  else {
    rep(i, K) {
      X = (X * 10 + 7) % K;
      if (X % K == 0) {
        ans = cnt;
        break;
      }
      cnt++;
    }
  }
  if (X % K == 0)
    cout << ans << endl;
  else
    cout << -1 << endl;
}


Error: TLE

Fixed submission:

#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repi(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
using namespace std;
typedef long long ll;

int K;

int main() {
  cin >> K;
  int X = 0;
  int ans = 0;
  int cnt = 1;

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

#include <bits/stdc++.h>
using namespace std;
#define int long long
#define pb push_back
// #define mp              make_pair
#define pii pair<int, int>
#define vec vector<int>
#define mii map<int, int>
#define pqb priority_queue<int>
#define inf 1e18
#define ps(x, y) fixed << setprecision(y) << x
#define no_of_test(x)                                                          \\
  int x;                                                                       \\
  cin >> x;                                                                    \\
  while (x--)

const int mod = 1e9 + 7;
void very_fast() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
#ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
#endif
}
int gcd(int a, int b) {
  if (b == 0)
    return a;
  return gcd(b, a % b);
}
int binary_exponentation(int a, int b) {
  int ret = 1;
  while (b) {
    if (b & 1)
      ret = (ret * a) % mod;
    b >>= 1;
    a = (a * a) % mod;
  }
  return ret;
}
int32_t main() {
  very_fast();
  // no_of_test(x)
  {
    int n;
    cin >> n;
    if (n % 2 == 0) {
      cout << -1 << endl;
      return 0;
    }
    int m = 0;
    for (int i = 1; i <= 1e7; i++) {
      m = (m * 10 + 7) % n;
      if (m == 0) {
        cout << i << endl;
        return 0;
        // break;
      }
    }
    cout << -1 << endl;
    return 0;
  }
  return 0;
}


Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
#define int long long
#define pb push_back
// #define mp              make_pair
#define pii pair<int, int>
#define vec vector<int>
#define mii map<int, int>
#define pqb priority_queue<int>
#define inf 1e18
#define ps(x, y) fixed << setprecision(y) << x
#define no_of_test(x)                                                          \\
  int x;                                                                       \\
  cin >> x;                                                                    \\
  while (x--)

const int mod = 1e9 + 7;
void very_fast() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
#ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
#endif
}
int gcd(int a, int b) {
  if (b == 0)
    return a;
  return gcd(b, a % b);
}
int binary_exponentation(int a, int b) {
  int ret = 1;
  while (b) {
    if (b & 1)
      ret = (ret * a) % mod;
    b >>= 1;
    a = (a * a) % mod;
  }
  return ret;
}
int32_t main() {
  very_fast();
  // no_of_test(x)
  {
    int n;
    cin >> n;
    if (n % 2 == 0) {
      cout << -1 << endl;
      return 0;
    }
    int m = 0;
    for (int i = 1; 1 <= 1e7; i++) {
      m = (m * 10 + 7) % n;
      if (m == 0) {
        cout << i << endl;
        return 0;
        // break;
      }
    }
    cout << -1 << endl;
    return 0;
  }
  return 0;
}
Problem p02596 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
  int K;
  cin >> K;
  int x = 7 % K;
  set<int> s;
  int i = 1;
  while (s.count(x) == 0) {
    if (x == 0) {
      cout << i << endl;
      return 0;
    }
    s.insert(x);
    x = (x * 10 + 7) % K;
    ++i;
  }
  cout << -1 << endl;
  return 0;
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
  int K;
  cin >> K;
  if (K % 2 == 0) {
    cout << -1 << endl;
    return 0;
  }
  ll val = 0;
  ll count = to_string(K).size();
  rep(i, to_string(K).size()) { val = val * 10 + 7; }
  while (1) {
    if (val % K == 0) {
      cout << count << endl;
      break;
    }
    val = val * 10 + 7;
    count++;
  }
  return 0;
}
Problem p02596 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>

using namespace std;
typedef long long int ll;
typedef long double ld;
#define REP(i, n) for (ll i = 0LL; i < (ll)(n); i++)
#define REPR(i, n) for (ll i = (ll)(n)-1; i >= 0; i--)
#define FOR(i, n, m) for (ll i = (ll)n; i < (ll)(m); i++)
#define ALL(x) (x).begin(), (x).end()
#define MOD 1000000007
#define INF (1LL << 62)

#define PI (acos(-1))
#define PRINT(x) std::cout << x << endl

ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
ll countDigit(ll n) { return floor(log10(n) + 1); }
typedef pair<ll, ll> P;
static const ll dx[8] = {0, 1, 0, -1, 1, -1, 1, -1},
                dy[8] = {1, 0, -1, 0, 1, 1, -1, -1};

template <typename T> ostream &operator<<(ostream &os, const vector<T> &v) {
  for (int i = 0; i < (int)v.size(); ++i)
    os << v[i] << " ";
  return os;
}

template <typename T1, typename T2>
ostream &operator<<(ostream &os, const map<T1, T2> &m) {
  for (auto p : m)
    os << "<" << p.first << ", " << p.second << "> ";
  return os;
}

int main() {
  ll K;
  cin >> K;
  if (K % 2 == 0) {
    PRINT(-1);
    return 0;
  }
  ll seven = 7;
  ll ans = 1;
  set<ll> se;
  se.insert(seven);
  while (!(seven % K == 0)) {
    seven *= 10;
    seven += 7;
    seven %= K;
    if (se.find(seven) != se.end()) {
      PRINT(-1);
      return 0;
    }
    se.insert(seven);
    ans++;
  }
  PRINT(ans);
  return 0;
}


Error: TLE

Fixed submission:

#include <bits/stdc++.h>

using namespace std;
typedef long long int ll;
typedef long double ld;
#define REP(i, n) for (ll i = 0LL; i < (ll)(n); i++)
#define REPR(i, n) for (ll i = (ll)(n)-1; i >= 0; i--)
#define FOR(i, n, m) for (ll i = (ll)n; i < (ll)(m); i++)
#define ALL(x) (x).begin(), (x).end()
#define MOD 1000000007
#define INF (1LL << 62)

#define PI (acos(-1))
#define PRINT(x) std::cout << x << endl

ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
ll countDigit(ll n) { return floor(log10(n) + 1); }
typedef pair<ll, ll> P;
static const ll dx[8] = {0, 1, 0, -1, 1, -1, 1, -1},
                dy[8] = {1, 0, -1, 0, 1, 1, -1, -1};

template <typename T> ostream &operator<<(ostream &os, const vector<T> &v) {
  for (int i = 0; i < (int)v.size(); ++i)
    os << v[i] << " ";
  return os;
}

template <typename T1, typename T2>
ostream &operator<<(ostream &os, const map<T1, T2> &m) {
  for (auto p : m)
    os << "<" << p.first << ", " << p.second << "> ";
  return os;
}

int main() {
  ll K;
  cin >> K;
  if (K % 2 == 0) {
    PRINT(-1);
    return 0;
  }
  ll seven = 7;
  ll ans = 1;
  while (!(seven % K == 0)) {
    seven *= 10;
    seven += 7;
    seven %= K;
    ans++;
  }
  PRINT(ans);
  return 0;
}
Problem p02596 (C++) — buggy submission, verdict: Time Limit Exceeded

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

#define mx 100005
#define ll long long

int ar[mx];
char ch[mx];

int m, n, k, ii;

void solve() {
  cin >> n;
  if (n % 2 == 0) {
    cout << -1 << endl;
    return;
  }
  int cnt = 0;
  ll hate = 0;
  while (1) {
    cnt++;
    hate *= 10;
    hate += 7;
    hate %= n;
    if (hate == 0)
      break;
    if (cnt > 1000000) {
      cout << -1 << endl;
      return;
    }
  }
  cout << cnt << endl;
}

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

  int t = 1;
  while (t--) {
    solve();
  }
  return 0;
}

Error: TLE

Fixed submission:

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

#define mx 100005
#define ll long long

int ar[mx];
char ch[mx];

int m, n, k, ii;

void solve() {
  cin >> n;
  if (n % 2 == 0) {
    cout << -1 << endl;
    return;
  }
  int cnt = 0;
  ll hate = 0;
  while (1) {
    cnt++;
    hate *= 10;
    hate += 7;
    hate %= n;
    if (hate == 0)
      break;
  }
  cout << cnt << endl;
}

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

  int t = 1;
  while (t--) {
    solve();
  }
  return 0;
}
Problem p02596 (C++) — buggy submission, verdict: Time Limit Exceeded

#include "bits/stdc++.h"

using namespace std;

#define all(v) v.begin(), v.end()
#define pb push_back
#define sz(x) (int)(x.size())
#define endl "\\n"
#define isOdd(n) (n & 1)
#define pow(n, m) (ll) powl(n, m)
#define clr(x, val) memset(x, val, sizeof(x))
#define EPS 1e-7

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;

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

  ll k, c = 1, x = 7;
  cin >> k;
  if (!isOdd(k))
    return cout << -1, 0;
  while (x % k != 0 && c < (int)1e7) {
    x = ((x * 10 % k) + 7) % k;
    c++;
  }
  if (x % k != 0)
    c = -1;
  cout << c;
  return 0;
}


Error: TLE

Fixed submission:

#include "bits/stdc++.h"

using namespace std;

#define all(v) v.begin(), v.end()
#define pb push_back
#define sz(x) (int)(x.size())
#define endl "\\n"
#define isOdd(n) (n & 1)
#define pow(n, m) (ll) powl(n, m)
#define clr(x, val) memset(x, val, sizeof(x))
#define EPS 1e-7

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;

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

  ll k, c = 1, x = 7;
  cin >> k;
  if (!isOdd(k))
    return cout << -1, 0;
  while (x % k != 0 && c < (int)1e8) {
    x = ((x * 10 % k) + 7) % k;
    c++;
  }
  if (x % k != 0)
    c = -1;
  cout << c;
  return 0;
}
Problem p02596 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)

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

  int re = 7 % k;
  int cnt = 1;
  rep(i, k) {
    if (re == 0)
      break;
    re = (re * 10 + 7) % k;
    cnt++;
  }

  if (cnt > k)
    cnt = -1;

  cout << cnt << endl;

  return 0;
}


Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)

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

  int re, be;
  re = be = 7 % k;
  int cnt = 1;
  while (re != 0) {
    re = (re * 10 + 7) % k;
    cnt++;
    if (re == be) {
      cnt = -1;
      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;
static const ll INF = 1ll << 60;
static const int MOD = 1e9 + 7;

int main() {
  int K;
  cin >> K;
  int cur = 7;
  int ans = 0;

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

  while (1) {
    ans++;
    if (ans > 1e8)
      break;
    if (cur < K) {
      cur *= 10;
      cur += 7;
      continue;
    } else {
      cur = cur % K;
      if (cur == 0)
        break;
      cur *= 10;
      cur += 7;
    }
  }

  if (ans > 1e8)
    cout << "-1" << endl;
  else
    cout << ans << endl;
  return 0;
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
static const ll INF = 1ll << 60;
static const int MOD = 1e9 + 7;

int main() {
  int K;
  cin >> K;
  int cur = 7;
  int ans = 0;

  while (1) {
    ans++;
    if (ans > MOD)
      break;
    if (cur < K) {
      cur *= 10;
      cur += 7;
      continue;
    } else {
      cur = cur % K;
      if (cur == 0)
        break;
      cur *= 10;
      cur += 7;
    }
  }

  if (ans > MOD)
    cout << "-1" << endl;
  else
    cout << ans << 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 k;
  cin >> k;
  if (k % 2 == 0) {
    cout << -1 << endl;
    return 0;
  }
  ll a = 7;
  int ans = 1;
  vector<bool> v(1000000, false);
  while (true) {
    a = a % k;
    if (a == 0)
      break;
    if (v.at(a)) {
      ans = -1;
      break;
    }
    v.at(a) = true;
    a = a * 10 + 7;
    ans++;
  }
  cout << ans << endl;
}


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 k;
  cin >> k;
  if (k % 2 == 0) {
    cout << -1 << endl;
    return 0;
  }
  ll a = 7;
  int ans = 1;
  while (true) {
    a = a % k;
    if (a == 0)
      break;

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


#include <algorithm>
#include <functional>
#include <iomanip> //! for setprecision(10)
#include <iostream>
#include <math.h>
#include <string>
#include <vector>

#include <cstring>
#include <map>
#include <queue>
#include <set>
#include <utility>

using namespace std;

typedef long long LL;

#define dump(c)                                                                \\
  {                                                                            \\
    for (auto it = c.begin(); it != c.end(); ++it)                             \\
      if (it == c.begin())                                                     \\
        cout << *it;                                                           \\
      else                                                                     \\
        cout << ' ' << *it;                                                    \\
    cout << endl;                                                              \\
  }
#define rep(i, n) for (int i = 0; i < (n); ++i)

const int MOD = 1000000007;

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

  int K;
  cin >> K;

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

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

  int base = 1;
  int currMod = 1;
  int ans = 1;
  while (ans <= 1100000 && currMod % K != 0) {
    base = (base * 10) % K;
    currMod = (currMod + base) % K;
    ++ans;
  }
  if (1000000 < ans) {
    ans = -1;
  }
  cout << ans << endl;

  return 0;
}


Error: TLE

Fixed submission:


#include <algorithm>
#include <functional>
#include <iomanip> //! for setprecision(10)
#include <iostream>
#include <math.h>
#include <string>
#include <vector>

#include <cstring>
#include <map>
#include <queue>
#include <set>
#include <utility>

using namespace std;

typedef long long LL;

#define dump(c)                                                                \\
  {                                                                            \\
    for (auto it = c.begin(); it != c.end(); ++it)                             \\
      if (it == c.begin())                                                     \\
        cout << *it;                                                           \\
      else                                                                     \\
        cout << ' ' << *it;                                                    \\
    cout << endl;                                                              \\
  }
#define rep(i, n) for (int i = 0; i < (n); ++i)

const int MOD = 1000000007;

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

  int K;
  cin >> K;

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

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

  int base = 1;
  int currMod = 1;
  int ans = 1;
  while (currMod % K != 0) {
    base = (base * 10) % K;
    currMod = (currMod + base) % K;
    ++ans;
  }
  cout << ans << endl;

  return 0;
}