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

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

using ll = long long;
using pll = pair<ll, ll>;
const int MAX = 1e6 + 5;

ll n;
ll arr[MAX];

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

  cin >> n;
  arr[1] = 7 % n;
  if (n == 7 || n == 1)
    return cout << 1 << endl, 0;
  for (int i = 2; i <= n; i++) {
    arr[i] = arr[i - 1] * 10 + 7;
    arr[i] %= n;
    if (arr[i] == 0)
      return cout << i << endl, 0;
  }
  cout << -1 << endl;

  return 0;
}


Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll k;
ll bm(ll a, ll b) {
  if (b == 0)
    return 1;
  ll t = bm(a, b / 2);
  if (b % 2 == 0)
    return t * t % k;
  else
    return a * (t * t % k) % k;
}
int main() {
  cin >> k;
  if (k % 2 == 0) {
    cout << "-1" << endl;
    return 0;
  }
  if (k % 7 == 0)
    k /= 7;
  k *= 9;
  ll i = 1;
  while (i) {
    ll now = bm(10, i);
    if (now == 1) {
      cout << i << endl;
      return 0;
    }
    i++;
  }
}
Problem p02596 (C++) — buggy submission, verdict: 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++;
      i %= K;
      if (i == 1) {
        s = 1;
      }
      i *= 10;
    }
  }
  cout << sum << endl;
}

Error: TLE

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++;
      if (i % K == 1) {
        s = 1;
      }
      i *= 10;
    }
  }
  cout << sum << endl;
}
Problem p02596 (C++) — buggy submission, verdict: 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) || (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;
}

Error: TLE

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

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

int main() {
  int k;
  cin >> k;
  int n = 7 % k;
  if (!(k % 2) || !(k % 5))
    cout << "-1" << endl;
  else {
    for (int cnt = 1;;) {
      if (!n) {
        cout << cnt << endl;
        break;
      }
      n = (n * 10 + 7) % k;
      cnt++;
    }
  }
  return 0;
}

Error: TLE

Fixed submission:

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

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

#include <bits/stdc++.h>
#define ll long long
#define IOS                                                                    \\
  ios_base::sync_with_stdio(false);                                            \\
  cin.tie(NULL);                                                               \\
  cout.tie(NULL);
#define deb(x) cout << #x << "=" << x << endl;
#define endl '\\n'
#define M 1000000007
#define int long long
#define INF 1e18
#define max_n 1000000

using namespace std;

void solve() {
  ll k;
  cin >> k;
  if (k % 2 == 0)
    cout << -1 << endl;
  else {
    ll ans = 1;
    ll x = 7;
    while (x % k != 0) {
      if (ans > k) {
        cout << -1 << endl;
        return;
      }
      x *= 10;
      x += 7;
      x %= k;
      ans++;
    }
    cout << ans << endl;
  }
}

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

Error: TLE

Fixed submission:

#include <bits/stdc++.h>
#define ll long long
#define IOS                                                                    \\
  ios_base::sync_with_stdio(false);                                            \\
  cin.tie(NULL);                                                               \\
  cout.tie(NULL);
#define deb(x) cout << #x << "=" << x << endl;
#define endl '\\n'
#define M 1000000007
#define int long long
#define INF 1e18
#define max_n 1000000

using namespace std;

void solve() {
  ll k;
  cin >> k;
  if (k % 2 == 0)
    cout << -1 << endl;
  else {
    ll ans = 1;
    ll x = 7;
    while (x % k != 0) {
      x *= 10;
      x += 7;
      x %= k;
      ans++;
    }
    cout << ans << endl;
  }
}

int32_t main() {
  IOS ll T = 1;
  // 	cin >> T;
  for (ll 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 MOD 1000000007LL
using namespace std;
typedef long long ll;
typedef pair<int, int> P;

int k;
ll val[10000005];
ll ko[11];

int main(void) {
  scanf("%d", &k);
  if (k % 2 == 0) {
    printf("-1\\n");
    return 0;
  }
  ll sum = k;
  int dig = 0;
  int mx = 0;
  while (sum > 0) {
    ko[dig] = sum % 10LL;
    val[dig] = sum % 10LL;
    dig++;
    sum /= 10LL;
  }
  mx = dig - 1;
  int cur = 0;
  while ((cur - 1) != mx) {
    if (cur >= 1000000) {
      printf("-1\\n");
      return 0;
    }
    int cc = 0;
    while (val[cur] != 7) {
      cc++;
      if (cc >= 20) {
        printf("-1\\n");
        return 0;
      }
      for (int i = 0; i < dig; i++) {
        val[cur + i] += ko[i];
        mx = max(cur + i, mx);
      }
      for (int i = 0; i < dig; i++) {
        if (val[cur + i] >= 10) {
          val[cur + i + 1]++;
          val[cur + i] -= 10;
          mx = max(cur + i + 1, mx);
        }
      }
      int j = cur + dig;
      while (val[j] >= 10) {
        val[j + 1]++;
        val[j] -= 10;
        mx = max(j + 1, mx);
        j++;
      }
    }
    cur++;
  }
  printf("%lld\\n", mx + 1);
  return 0;
}


Error: TLE

Fixed submission:

#include <bits/stdc++.h>
#define MOD 1000000007LL
using namespace std;
typedef long long ll;
typedef pair<int, int> P;

int k;
ll val[10000005];
ll ko[11];

int main(void) {
  scanf("%d", &k);
  if (k % 2 == 0) {
    printf("-1\\n");
    return 0;
  }
  ll sum = k;
  int dig = 0;
  int mx = 0;
  while (sum > 0) {
    ko[dig] = sum % 10LL;
    val[dig] = sum % 10LL;
    dig++;
    sum /= 10LL;
  }
  mx = dig - 1;
  int cur = 0;
  while ((cur - 1) != mx) {
    if (cur >= 2000000) {
      printf("-1\\n");
      return 0;
    }
    while (val[cur] != 7) {
      for (int i = 0; i < dig; i++) {
        val[cur + i] += ko[i];
        mx = max(cur + i, mx);
      }
      for (int i = 0; i < dig; i++) {
        if (val[cur + i] >= 10) {
          val[cur + i + 1]++;
          val[cur + i] -= 10;
          mx = max(cur + i + 1, mx);
        }
      }
      int j = cur + dig;
      while (val[j] >= 10) {
        val[j + 1]++;
        val[j] -= 10;
        mx = max(j + 1, mx);
        j++;
      }
    }
    cur++;
  }
  printf("%lld\\n", mx + 1);
  return 0;
}
Problem p02596 (C++) — buggy submission, verdict: Time Limit Exceeded

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

int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n;
  cin >> n;
  int now = 0;
  for (int i = 0; i < 1e7; i++) {
    now = (now * 10 + 7) % n;
    if (now == 0) {
      cout << i + 1;
      return 0;
    }
  }
  cout << -1;
  return 0;
}


Error: TLE

Fixed submission:

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

int main() {
  ios::sync_with_stdio(false);
  ll n;
  cin >> n;
  ll k = 7;
  ll cnt = 1;
  while (k % n != 0) {
    k = k * 10 + 7;
    cnt++;
  }
  cout << cnt << endl;
  return 0;
}
Problem p02596 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define mod 1000000007
#define pi 3.141592653589793
typedef vector<ll> vcl;

ll gcd(ll a, ll b) {
  if (b > a)
    swap(a, b);
  if (b == 0)
    return a;
  return gcd(b, a % b);
}
ll lcm(ll a, ll b) {
  ll g = gcd(a, b);
  return a / g * b;
}
ll rep_jijo(ll n, ll x) {
  if (x == 0)
    return 1;
  if (x % 2 == 0) {
    ll t = rep_jijo(n, x / 2);
    return t * t % mod;
  }
  return n * rep_jijo(n, x - 1) % mod;
}
ll c2(ll n) { return n * (n - 1) / 2; }

int main() {
  ll k, l;
  cin >> k;
  ll i = 0;
  if (k % 7 == 0)
    l = 9 * k / 7;
  else
    l = 9 * k;
  ll n = l;
  if (l % 2 == 0 || l % 5 == 0) {
    cout << "-1" << endl;
    return 0;
  }
  while (n > 0) {
    n = n / 10;
    i++;
  }
  ll r = rep_jijo(10, i);
  r = r % l;
  while (r != 1) {
    r = 10 * r % l;
    i++;
  }
  cout << i << endl;
}


Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define mod 1000000007
#define pi 3.141592653589793
typedef vector<ll> vcl;

ll gcd(ll a, ll b) {
  if (b > a)
    swap(a, b);
  if (b == 0)
    return a;
  return gcd(b, a % b);
}
ll lcm(ll a, ll b) {
  ll g = gcd(a, b);
  return a / g * b;
}
ll rep_jijo(ll n, ll x) {
  if (x == 0)
    return 1;
  if (x % 2 == 0) {
    ll t = rep_jijo(n, x / 2);
    return t * t % mod;
  }
  return n * rep_jijo(n, x - 1) % mod;
}
ll c2(ll n) { return n * (n - 1) / 2; }

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

#include <bits/stdc++.h>
using namespace std;
#define REP(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) REP(i, 0, n)
#define rrep(i, n) for (int i = (int)(n - 1); i >= 0; i--)
#define sz(x) int(x.size())
#define bitsz(x) int(__builtin_popcount(x))
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pb(x) push_back(x)
#define INF 1e9
#define LINF 1e18
#define mod 1000000007
template <class T> inline bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T> inline bool chmin(T &a, const T &b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
template <typename T> inline string toString(const T &a) {
  ostringstream oss;
  oss << a;
  return oss.str();
};
typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
const int di[4] = {1, 0, -1, 0};
const int dj[4] = {0, 1, 0, -1};

int main() {
  int k;
  cin >> k;
  int n = 7;
  int ans = 0;
  int amari;
  rep(i, k) {
    ans++;
    amari = n % k;
    if (amari == 0)
      break;
    n = n * 10 + 7;
    n %= k;
  }
  if (amari == 0)
    cout << ans << endl;
  else
    cout << -1 << endl;
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
#define REP(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) REP(i, 0, n)
#define rrep(i, n) for (int i = (int)(n - 1); i >= 0; i--)
#define sz(x) int(x.size())
#define bitsz(x) int(__builtin_popcount(x))
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pb(x) push_back(x)
#define INF 1e9
#define LINF 1e18
#define mod 1000000007
template <class T> inline bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T> inline bool chmin(T &a, const T &b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
template <typename T> inline string toString(const T &a) {
  ostringstream oss;
  oss << a;
  return oss.str();
};
typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
const int di[4] = {1, 0, -1, 0};
const int dj[4] = {0, 1, 0, -1};

int main() {
  int k;
  cin >> k;
  if (k % 2 == 0) {
    cout << -1 << endl;
    return 0;
  }
  int n = 7;
  int ans = 0;
  while (1) {
    ans++;
    int amari = n % k;
    if (amari == 0)
      break;
    n = n * 10 + 7;
    n %= k;
  }
  cout << ans << endl;
}
Problem p02596 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define MOD 1000000007
#define INF 1234567890
#define pii pair<int, int>
#define LL long long
using namespace std;

LL fpow(LL a, LL b, LL k) {
  LL ans = 1;
  while (b) {
    if (b & 1) {
      ans *= a;
      ans %= k;
    }
    a *= a;
    a %= k;
    b >>= 1;
  }
  return ans;
}

int main() {
  // clock_t start = clock();
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  LL k;
  cin >> k;
  int ans = -2;
  LL p = 0;
  for (int i = 0; i <= 1000000; i++) {
    // cout << (7 * (fpow(10,i,k)-1) / 9) << endl;
    p += 7 * fpow(10, i, k);
    p %= k;
    if (p == 0) {
      ans = i;
      break;
    }
  }
  cout << ans + 1 << endl;
  // cerr << fixed << setprecision(3) << (clock()-start)*1./CLOCKS_PER_SEC <<
  // endl;
  return 0;
}

Error: 0

Fixed submission:

#include <bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define MOD 1000000007
#define INF 1234567890
#define pii pair<int, int>
#define LL long long
using namespace std;

LL fpow(LL a, LL b, LL k) {
  LL ans = 1;
  while (b) {
    if (b & 1) {
      ans *= a;
      ans %= k;
    }
    a *= a;
    a %= k;
    b >>= 1;
  }
  return ans;
}

int mul_inv(int a, int b) {
  int b0 = b, t, q;
  int x0 = 0, x1 = 1;
  if (b == 1)
    return 1;
  while (a > 1) {
    q = a / b;
    t = b, b = a % b, a = t;
    t = x0, x0 = x1 - q * x0, x1 = t;
  }
  if (x1 < 0)
    x1 += b0;
  return x1;
}

int main() {
  // clock_t start = clock();
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int k;
  cin >> k;
  int ans = -1;
  for (int i = 1; i <= 1000000; i++) {
    // cout << (7 * (fpow(10,i,k)-1) / 9) << endl;
    if ((7 * (fpow(10, i, k) - 1) * mul_inv(9, k)) % k == 0) {
      ans = i;
      break;
    }
  }
  cout << ans << endl;
  // cerr << fixed << setprecision(3) << (clock()-start)*1./CLOCKS_PER_SEC <<
  // endl;
  return 0;
}
Problem p02596 (C++) — buggy submission, verdict: 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;
      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;
}


Error: TLE

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;
    }
    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, verdict: 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) || nm > 1000100) {
      cout << -1 << endl;
      break;
    }
    if (md == 0) {
      cout << nm << endl;
      break;
    }
    nm++;
    md *= 10;
    md += 7;
    md %= k;
  }
}

Error: TLE

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) {
      cout << -1 << endl;
      break;
    }
    if (md == 0) {
      cout << nm << endl;
      break;
    }
    nm++;
    md *= 10;
    md += 7;
    md %= k;
  }
}
Problem p02596 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const long long INF = 1LL << 60;

int main() {
  int K, X = 7, count = 1;
  cin >> K;
  int N = X % K;
  if (K % 2 == 0 || K % 5 == 0) {
    cout << -1 << endl;
    return 0;
  }

  while (N != 0) {
    N = N * 10 + 7;
    N %= K;
    count++;
  }
  cout << count << endl;
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const long long INF = 1LL << 60;

int main() {
  int K, X = 7, count = 1;
  cin >> K;
  int N = X % K;
  if (K % 2 == 0) {
    cout << -1 << endl;
    return 0;
  }

  while (N != 0) {
    N = N * 10 + 7;
    N %= K;
    count++;
  }
  cout << count << endl;
}
Problem p02596 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define reps(i, a, b) for (int i = a; i < b; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

int main() {
  ll k;
  cin >> k;
  vector<ll> vec(k + 1, 0);
  ll x = 7 % k;
  for (ll i = 1; i <= k; i++) {
    if (x == 0) {
      cout << i << endl;
      return 0;
    }
    x = (x * 10 + 7) % k;
  }

  cout << -1 << endl;

  return 0;
}

Error: 0

Fixed submission:

#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define reps(i, a, b) for (int i = a; i < b; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int main() {
  ll k;
  cin >> k;
  vector<ll> vec(k + 1, 0);
  vec[1] = 7 % k;
  for (ll i = 2; i <= k + 1; i++) {
    vec[i] = (vec[i - 1] * 10 + 7) % k;
    if (vec[i] == 0) {
      cout << i << endl;
      return 0;
    }
  }

  cout << -1 << endl;

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

#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define reps(i, a, b) for (int i = a; i < b; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

int main() {
  ll k;
  cin >> k;
  vector<ll> vec(k + 2, 0);
  vec.at(1) = 7 % k;
  for (ll i = 2; i <= k + 1; i++) {
    if (vec.at(i - 1) == 0) {
      cout << i - 1 << endl;
      return 0;
    }
    vec.at(i) = (vec.at(i - 1) * 10 + 7) % k;
  }

  cout << -1 << endl;

  return 0;
}

Error: 0

Fixed submission:

#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define reps(i, a, b) for (int i = a; i < b; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

int main() {
  ll k;
  cin >> k;
  vector<ll> vec(k + 1, 0);
  vec.at(1) = 7 % k;
  for (ll i = 2; i <= k + 1; i++) {
    if (vec.at(i - 1) == 0) {
      cout << i - 1 << endl;
      return 0;
    }
    vec.at(i) = (vec.at(i - 1) * 10 + 7) % k;
  }

  cout << -1 << endl;

  return 0;
}