alexjercan/bugnet huggingface dataset:
Problem p02596 (C++) — buggy submission, verdict: Runtime Error

#include <algorithm>
#include <bitset>
#include <cassert>
#include <chrono>
#include <climits>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#include <cmath>
using namespace std;
typedef long long ll;

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: WA

Fixed submission:

#include <algorithm>
#include <bitset>
#include <cassert>
#include <chrono>
#include <climits>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#include <cmath>
using namespace std;

int main() {
  string S;
  cin >> S;
  int cnt = 0;
  for (int i = 0; i <= 2; i++) {
    if (S.at(i) == '1') {
      cnt++;
    }
  }
  cout << cnt << endl;
  return 0;
}
Problem p02596 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h> //线段树维护区间和
#define ll long long
#define inf 0x3f3f3f3f
using namespace std;
const int maxn = 1e5 + 10;

int main() {
  int k;
  scanf("%d", &k);
  ll n = 7;
  int ans = 1;
  if (k % 2 == 0 || k % 5 == 0) {
    printf("-1");
    return 0;
  }
  while (1) {
    if (n % k == 0) {
      printf("%d", ans);
      break;
    }
    ans++;
    n = n * 10 + 7;
    n %= k;
  }

  return 0;
}


Error: TLE

Fixed submission:

#include <bits/stdc++.h> //线段树维护区间和
#define ll long long
#define inf 0x3f3f3f3f
using namespace std;
const int maxn = 1e5 + 10;

int main() {
  int k;
  scanf("%d", &k);
  ll n = 7;
  int ans = 1;
  if (k % 2 == 0 || k == 5) {
    printf("-1");
    return 0;
  }
  while (1) {
    if (n % k == 0) {
      printf("%d", ans);
      break;
    }
    ans++;
    n = n * 10 + 7;
    n %= k;
  }

  return 0;
}
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) {
    return cout << "-1\\n", 0;
  }
  int cur = 7 % k;
  int ans = 1;
  while (cur != 0) {
    cur = cur * 10 + 7;
    cur %= k;
    ans++;
  }
  cout << ans << endl;
}


Error: TLE

Fixed submission:

#include <bits/stdc++.h>

using namespace std;

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

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

int main(void) {
  ll k;
  cin >> k;
  ll x = 7 % k;
  int count = 0;
  if (k % 2 == 0)
    count = -1;
  else if (k % 5 == 0)
    count = -1;
  else {
    rep(i, k) {
      if (x == 0) {
        count = i + 1;
        break;
      }
      x = (x * 10 + 7) % k;
    }
  }
  cout << count << endl;
}

Error: TLE

Fixed submission:

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

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

#pragma GCC optimize("Ofast", 3, "inline")
#include <bits/stdc++.h>
using namespace std;
#define fir first
#define sec second
#define m_p make_pair
#define y1 ygftgfgcdtfgxffgx
#define y2 yfdsesgvtyghftfvv
#define x1 xvyr6cf6fgcfgf676
#define x2 xcr6rfc5r66y6r6fr
#define up_bound upper_bound
#define low_bound lower_bound
#define next_per next_permutation
#define pb push_back
#define i_to_s to_string
typedef priority_queue<int> p_queue;
typedef priority_queue<int, vector<int>, greater<int>> min_p_queue;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
int mon[20] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
ll gcd(ll x, ll y) { return ((y == 0) ? x : gcd(y, x % y)); }
inline int read() {
  int x = 0;
  char ch = getchar();
  while (ch < '0' || ch > '9')
    ch = getchar();
  while (ch >= '0' && ch <= '9') {
    x = x * 10 + ch - '0';
    ch = getchar();
  }
  return x;
}
int k;
int x = 7;
int cnt;
map<int, bool> mp;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  //	freopen(".in","r",stdin);
  //	freopen(".out","w",stdout);
  cin >> k;
  if (!(k & 1)) {
    cout << -1;
    return 0;
  }
  while (x % k) {
    x %= k;
    if (mp[x]) {
      cout << -1;
      return 0;
    }
    mp[x] = 1;
    x = x * 10 + 7;
    cnt++;
  }
  cout << cnt + 1;
  return 0;
}


Error: TLE

Fixed submission:

#pragma GCC optimize("Ofast", 3, "inline")
#include <bits/stdc++.h>
using namespace std;
#define fir first
#define sec second
#define m_p make_pair
#define y1 ygftgfgcdtfgxffgx
#define y2 yfdsesgvtyghftfvv
#define x1 xvyr6cf6fgcfgf676
#define x2 xcr6rfc5r66y6r6fr
#define up_bound upper_bound
#define low_bound lower_bound
#define next_per next_permutation
#define pb push_back
#define i_to_s to_string
typedef priority_queue<int> p_queue;
typedef priority_queue<int, vector<int>, greater<int>> min_p_queue;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
int mon[20] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
ll gcd(ll x, ll y) { return ((y == 0) ? x : gcd(y, x % y)); }
inline int read() {
  int x = 0;
  char ch = getchar();
  while (ch < '0' || ch > '9')
    ch = getchar();
  while (ch >= '0' && ch <= '9') {
    x = x * 10 + ch - '0';
    ch = getchar();
  }
  return x;
}
int k;
int x = 7;
int cnt;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  //	freopen(".in","r",stdin);
  //	freopen(".out","w",stdout);
  cin >> k;
  if (!(k & 1)) {
    cout << -1;
    return 0;
  }
  while (x % k) {
    x %= k;
    x = x * 10 + 7;
    cnt++;
  }
  cout << cnt + 1;
  return 0;
}
Problem p02596 (C++) — buggy submission, verdict: Time Limit Exceeded

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

#define ALL(a) (a).begin(), (a).end()
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) for (int i = n - 1; i <= 0; --i)
#define loop while (true)
typedef long long ll;
const ll INF = 1LL << 60;
const ll MOD = 1000000007;
const ll MAX = 10000000;
const ll MIN = 0;
template <class T> inline bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template <class T> inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
using pint = pair<int, int>;
using pstring = pair<int, string>;

int main() {
  ll N;
  cin >> N;
  if (N % 2 == 0 || N % 5 == 0) {
    cout << -1 << endl;
    return 0;
  }
  ll ans = 1;
  ll mod = 7 % N;

  while (mod % N) {
    mod *= 10;
    mod += 7;
    mod %= N;
    ans++;
  }

  cout << ans << endl;
  return 0;
}


Error: TLE

Fixed submission:

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

#define ALL(a) (a).begin(), (a).end()
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) for (int i = n - 1; i <= 0; --i)
#define loop while (true)
typedef long long ll;
const ll INF = 1LL << 60;
const ll MOD = 1000000007;
const ll MAX = 10000000;
const ll MIN = 0;
template <class T> inline bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template <class T> inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
using pint = pair<int, int>;
using pstring = pair<int, string>;

int main() {
  ll N;
  cin >> N;
  if (N % 2 == 0 || N % 2 == 0) {
    cout << -1 << endl;
    return 0;
  }
  ll ans = 1;
  ll mod = 7 % N;

  while (mod % N) {
    mod *= 10;
    mod += 7;
    mod %= N;
    ans++;
  }

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

#include <bits/stdc++.h>

using namespace std;
typedef unsigned long long int ll;
int gcd(int a, int b) {
  if (b == 0)
    return a;
  return gcd(b, a % b);
}

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


Error: WA

Fixed submission:

/******************************************************************************

Welcome to GDB Online.
GDB online is an online compiler and debugger tool for C, C++, Python, PHP,
Ruby, C#, VB, Perl, Swift, Prolog, Javascript, Pascal, HTML, CSS, JS Code,
Compile, Run and Debug online from anywhere in world.

*******************************************************************************/
#include <bits/stdc++.h>

using namespace std;
typedef unsigned long long int ll;
int gcd(int a, int b) {
  if (b == 0)
    return a;
  return gcd(b, a % b);
}

int main() {
  ll n;
  cin >> n;
  if (n % 2 == 0) {
    cout << "-1";
    return 0;
  }
  if (n < 7) {
    cout << "-1";
    return 0;
  }
  string s = "7";
  ll count = 1;
  ll x = stoi(s);
  while (x <= 1000000000) {
    x = stoi(s);
    if (x % n == 0) {
      cout << count;
      return 0;
    } else {
      s += '7';
      count++;
    }
  }
  cout << "-1";
}
Problem p02596 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <cmath>
#include <cstdint>
#include <iostream>
#include <string>

using namespace std;

int main() {
  int K;
  cin >> K;
  if (K % 2 == 0) {
    cout << -1 << endl;
    return 0;
  }
  int64_t unit = log10(K) + 1;
  int sevens = stoi(string(unit, '7'));
  while (true) {
    sevens %= K;
    if (sevens % K == 0) {
      break;
    }
    sevens = sevens * 10 + 7;
    ++unit;

    if (unit > 10000000) {
      cout << -1 << endl;
      return 0;
    }
  }
  cout << unit << endl;

  return 0;
}


Error: TLE

Fixed submission:

#include <cmath>
#include <cstdint>
#include <iostream>
#include <string>

using namespace std;

int main() {
  int K;
  cin >> K;
  if (K % 2 == 0) {
    cout << -1 << endl;
    return 0;
  }
  int64_t unit = log10(K) + 1;
  int sevens = stoi(string(unit, '7'));
  while (true) {
    sevens %= K;
    if (sevens % K == 0) {
      break;
    }
    sevens = sevens * 10 + 7;
    ++unit;
  }
  cout << unit << endl;

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

#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, res, count = 1;
  cin >> n;
  if (n % 2 == 0 || n % 5 == 0)
    count = -1;
  else {
    long long m = 7 % n;
    while (m != 0) {
      m = (m * 10 + 7) % n;
      count++;
    }
  }
  cout << count << "\\n";
  return 0;
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, res, count = 1;
  cin >> n;
  if (n % 2 == 0 || n % 5 == 0)
    count = -1;
  else {
    string s = "7";
    stringstream(s) >> res;
    while (res % n != 0) {
      s += "7";
      stringstream(s) >> res;
      count++;
    }
  }
  cout << count << "\\n";
  return 0;
}
Problem p02596 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>

using namespace std;

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

  int k;
  cin >> k;
  if (k % 2 == 0 or k % 5 == 0) {
    cout << -1;
    return 0;
  }
  if (k % 7 == 0)
    k /= 7;
  int p = 1;
  int m = 0;
  int cnt = 0;
  do {
    m += p;
    m %= k;
    p *= 10;
    p %= k;
    ++cnt;
  } while (m);
  cout << cnt;

  return 0;
}


Error: TLE

Fixed submission:

#include <bits/stdc++.h>

using namespace std;

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

  int k;
  cin >> k;
  if (k % 2 == 0) {
    cout << -1;
    return 0;
  }
  if (k % 7 == 0)
    k /= 7;
  int p = 1;
  int m = 0;
  int cnt = 0;
  do {
    m += p;
    m %= k;
    p *= 10;
    p %= k;
    ++cnt;
  } while (m);
  cout << cnt;

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

#include <iostream>
int main() {
  int k;
  std::cin >> k;
  int r = 0;
  int tmp = 0;
  if (k % 10 == 0 or k % 10 == 2 or k % 10 == 4 or k % 10 == 5 or k % 10 == 6 or
      k % 10 == 8)
    std::cout << "-1" << std::endl;
  else {
    while (++r) {
      tmp = (tmp * 10 + 7) % k;
      if (tmp == 0) {
        std::cout << r << std::endl;
        break;
      }
    }
  }
}

Error: TLE

Fixed submission:

#include <iostream>
int main() {
  int k;
  std::cin >> k;
  int r = 1;
  int tmp = 7;
  if (k % 10 == 0 or k % 10 == 2 or k % 10 == 4 or k % 10 == 5 or k % 10 == 6 or
      k % 10 == 8)
    std::cout << "-1" << std::endl;
  else {
    while (true) {
      if (tmp % k == 0) {
        std::cout << r << std::endl;
        break;
      }
      r++;
      tmp = tmp * 10 + 7;
    }
  }
}
Problem p02596 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
using namespace std;
using lint = long long;
constexpr lint inf = 1LL << 60;
constexpr lint mod = 1000000007;

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int k;
  cin >> k;
  if (k % 2 == 0) {
    cout << -1 << "\\n";
    return 0;
  }
  lint res = 7 % k;
  lint ret = 1;
  while (res != 0) {
    res = (res * 10 + 7) % k;
    ret++;
    if (ret > k) {
      cout << -1 << "\\n";
      return 0;
    }
  }
  cout << ret << "\\n";
  return 0;
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
using lint = long long;
constexpr lint inf = 1LL << 60;
constexpr lint mod = 1000000007;

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int k;
  cin >> k;
  if (k % 2 == 0) {
    cout << -1 << "\\n";
    return 0;
  }
  lint res = 7 % k;
  lint ret = 1;
  while (res != 0) {
    res = (res * 10 + 7) % k;
    ret++;
  }
  cout << ret << "\\n";
  return 0;
}
Problem p02596 (C++) — buggy submission, verdict: Time Limit Exceeded


// Problem : C - Repsept
// Contest : AtCoder - AtCoder Beginner Contest 174
// URL : https://atcoder.jp/contests/abc174/tasks/abc174_c
// Memory Limit : 1024.000000 MB
// Time Limit : 2000.000000 milisec

#include <bits/stdc++.h>
#define ll long long int
#define pb push_back
#define F first
#define S second
#define mp make_pair
#define MOD 1000000007
#define vi vector<int>
#define vll vector<ll>
#define pll pair<ll, ll>
#define pii pair<int, int>
#define all(p) p.begin(), p.end()
#define mid(s, e) (s + (e - s) / 2)
#define eb emplace_back
#define ull unsigned long long
#define bug(x) cout << "  [ " #x << " = " << x << " ]" << endl;
#define KAMEHAMEHA ios_base::sync_with_stdio(0);
#define RASENGAN                                                               \\
  ios_base::sync_with_stdio(0);                                                \\
  cin.tie(0);                                                                  \\
  cout.tie(0);
using namespace std;
void solve() {
  ll k;
  cin >> k;
  ll num = 7, cnt = 1;
  unordered_map<int, int> prev;
  while (num % k) {
    prev[num % k]++;
    if (prev[num % k] > 1) {
      cout << -1 << endl;
      return;
    }
    num = ((num % k) * 10) + 7;
    cnt++;
  }
  cout << cnt << endl;
}
int main() {
  KAMEHAMEHA
  int t = 1;
  // cin>>t;
  for (int cn = 1; cn <= t; cn++) {
    solve();
  }
  return 0;
}


Error: TLE

Fixed submission:


// Problem : C - Repsept
// Contest : AtCoder - AtCoder Beginner Contest 174
// URL : https://atcoder.jp/contests/abc174/tasks/abc174_c
// Memory Limit : 1024.000000 MB
// Time Limit : 2000.000000 milisec

#include <bits/stdc++.h>
#define ll long long int
#define pb push_back
#define F first
#define S second
#define mp make_pair
#define MOD 1000000007
#define vi vector<int>
#define vll vector<ll>
#define pll pair<ll, ll>
#define pii pair<int, int>
#define all(p) p.begin(), p.end()
#define mid(s, e) (s + (e - s) / 2)
#define eb emplace_back
#define ull unsigned long long
#define bug(x) cout << "  [ " #x << " = " << x << " ]" << endl;
#define KAMEHAMEHA ios_base::sync_with_stdio(0);
#define RASENGAN                                                               \\
  ios_base::sync_with_stdio(0);                                                \\
  cin.tie(0);                                                                  \\
  cout.tie(0);
using namespace std;
void solve() {
  ll k;
  cin >> k;
  ll num = 7, cnt = 1, prev = 7;
  while (num % k) {
    num = ((num % k) * 10) + 7;
    if (num == prev) {
      cout << -1 << endl;
      return;
    }
    prev = num;
    cnt++;
  }
  cout << cnt << endl;
}
int main() {
  KAMEHAMEHA
  int t = 1;
  // cin>>t;
  for (int cn = 1; cn <= t; cn++) {
    solve();
  }
  return 0;
}
Problem p02596 (C++) — buggy submission, verdict: Time Limit Exceeded

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

int main() {
  long long k;
  cin >> k;
  long long mod;
  mod = 7;
  int count = 1;
  for (int i = 0; i < 10000000; i++) {

    if (i == 9999999) {
      cout << -1 << endl;
    }

    else if (mod % k == 0) {
      cout << count << endl;
      break;
    } else if (mod > k) {
      mod %= k;
    } else {
      mod *= 10;
      mod += 7;
      count++;
    }
  }
}


Error: TLE

Fixed submission:

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

int main() {
  long long k;
  cin >> k;
  long long mod;
  mod = 7;
  int count = 1;
  for (int i = 0; i < 10000000000; i++) {
    mod *= 10;
    mod += 7;
    if (mod == k) {
      cout << count << endl;
      break;
    } else if (mod > k) {
      mod -= k;
      count++;
    } else {
      count++;
    }
  }
}
Problem p02596 (C++) — buggy submission, verdict: Runtime Error

#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("no-stack-protector")
#pragma GCC optimize("fast-math")
#pragma GCC optimize("trapv")
#pragma GCC target("sse4")

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define deb(x) cout << #x << " is " << x << "\\n"
#define int long long
#define mod 1000000007LL
#define PI acosl(-1)

template <typename T>
using ordered_set =
    tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

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

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

Error: WA

Fixed submission:

#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("no-stack-protector")
#pragma GCC optimize("fast-math")
#pragma GCC optimize("trapv")
#pragma GCC target("sse4")

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define deb(x) cout << #x << " is " << x << "\\n"
#define int long long
#define mod 1000000007LL
#define PI acosl(-1)

template <typename T>
using ordered_set =
    tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

void solve() {
  int k, ans = -1;
  cin >> k;
  for (int i = 1; i <= k; i++) {
    int curr = (7 * ((int)pow(10, i) - 1)) / 9;
    if (curr >= 1e18)
      break;
    // deb(i);
    // deb(curr);
    if (curr % k == 0) {
      ans = i;
      break;
    }
  }
  cout << ans;
}

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

#pragma GCC optimize("O3")
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;

#define REP(i, n) for (ll i = 0; i < ll(n); i++)
#define REPD(i, n) for (ll i = n - 1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = a; i < ll(b); i++)
#define FORD(i, a, b) for (ll i = a; i > ll(b); i--)
#define ALL(x) x.begin(), x.end()
#define SIZE(x) ll(x.size())
#define INF 1000000000000
#define MOD 1000000007
#define MAXR 100000
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define Umap unordered_map
#define Uset unordered_set

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

  ll K;
  cin >> K;

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

  ll cnt = 1;
  ll warareru = 7;
  while (true) {
    ll amari = warareru % K;
    if (amari == 0)
      break;

    warareru = (amari * 10 + 7);
    cnt++;
  }

  cout << cnt << endl;

  return 0;
}

Error: TLE

Fixed submission:

#pragma GCC optimize("O3")
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;

#define REP(i, n) for (ll i = 0; i < ll(n); i++)
#define REPD(i, n) for (ll i = n - 1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = a; i < ll(b); i++)
#define FORD(i, a, b) for (ll i = a; i > ll(b); i--)
#define ALL(x) x.begin(), x.end()
#define SIZE(x) ll(x.size())
#define INF 1000000000000
#define MOD 1000000007
#define MAXR 100000
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define Umap unordered_map
#define Uset unordered_set

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

  ll K;
  cin >> K;

  ll ans = 0;
  if (K % 2 == 0 || K % 5 == 0)
    ans = -1;

  ll cnt = 1;
  ll warareru = 7;
  while (true) {
    ll amari = warareru % K;
    if (amari == 0)
      break;

    warareru = (amari * 10 + 7);
    cnt++;
  }

  cout << cnt << endl;

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

#include <bits/stdc++.h>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <queue>
typedef long long int ll;
using namespace std;
int f;

ll division(ll n) {
  // char ans[MAX_N];
  ll con = 0;
  bool flag = true;
  ll k = 0, s = 0, t = 0;

  while (1) {
    ll it = s;
    t = s * 10 + 7;
    con++;
    if (t / n > 0 || t == 0) {

      s = t % n;
      flag = false;
    } else {
      s = t;
    }
    if (!flag) {
      if (it == s) {
        f = 0;
        return con;
      }
    }
    if (!flag) {
      if (s == 0) {
        f = 1;
        return con;
      }
    }
  }
}
int main() {

  ll k;
  cin >> k;
  int y = k % 10;
  int iu = 0, i;
  for (i = 1; i <= 9; i++)
    if (i * y % 10 == 7)
      iu = 1;
  if (iu == 0) {
    printf("-1\\n");
    return 0;
  }
  ll c = division(k);
  if (f == 1 || c == 1)
    printf("%lld\\n", c);
  else
    printf("-1\\n");
  return 0;
}


Error: 0

Fixed submission:

#include <bits/stdc++.h>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <queue>
typedef long long int ll;
using namespace std;
int f;

ll division(ll n) {
  // char ans[MAX_N];
  ll con = 0;
  bool flag = true;
  ll k = 0, s = 0, t = 0;
  ll g = 10000000;
  while (g--) {
    ll it = s;
    t = s * 10 + 7;
    con++;
    if (t / n > 0 || t == 0) {

      s = t % n;
      flag = false;
    } else {
      s = t;
    }
    if (!flag) {
      if (it == s) {
        f = 0;
        return con;
      }
    }
    if (!flag) {
      if (s == 0) {
        f = 1;
        return con;
      }
    }
  }
  f = 0;
}

int main() {

  ll k;
  cin >> k;
  ll c = division(k);
  if (f == 1 || c == 1)
    printf("%lld\\n", c);
  else
    printf("-1\\n");
  return 0;
}