qyliang/CodeNanoFix huggingface dataset:
Buggy code:
k = int(input())
n = 7

if k % 2 == 0 or k % 5 == 0:
    print(-1)
    exit()

ans = 1
while True:
    if n % k == 0:
        print(ans)
        exit()
    n = (n*10 + 7)
    ans += 1

Fixed code:
k = int(input())
n = 7

if k % 2 == 0 or k % 5 == 0:
    print(-1)
    exit()

ans = 1
while True:
    if n % k == 0:
        print(ans)
        exit()
    n = (n*10 + 7)%k
    ans += 1
Buggy code:
num = int(input())
temp = num
ans = 1
while temp > 10:
    temp %= 10
# print(temp)
if temp in [1, 3, 7, 9]:
    sa = 7
    while True:
        if sa % num == 0:
            print(ans)
            break
        else:
            sa *= 10
            sa += 7
            ans += 1
else:
    print(-1) 

Fixed code:
num = int(input())
temp = num
ans = 1
while temp > 10:
    temp %= 10
# print(temp)
if temp in [1, 3, 7, 9]:
    sa = 7
    while True:
        if sa % num == 0:
            print(ans)
            break
        else:
            sa *= 10
            sa += 7
            sa %= num
            ans += 1
else:
    print(-1)
Buggy code:
k = int(input())
d1 = k % 10
mae = 0
sd = [0]*10
cnt = 0
if not d1 in (1, 3, 7, 9):
  print(-1)
  exit()
for i in range(1,10) :
  sd[d1 * i % 10] = i
print(sd)

d2 = 7 - mae % 10
s = str(sd[d2] * k)
for j in range(9):
  print("s1=",s)
  for i in range(len(s)-1, -1, -1):
    print("s[",i,"]=",s[i])
    if (s[i]) == "7":
      cnt += 1
    else:
      s = s[0:i+1]
#      mae = int(s)
      print("s2=",s)
#      d2 = 7 - mae % 10
#      s = str(sd[d2] * k)
      break
print("cnt=",cnt)

Fixed code:
k = int(input())
d1 = k % 10
mae = 0
sd = [0]*10
cnt = 0
if not d1 in (1, 3, 7, 9):
  print(-1)
  exit()
for i in range(1,10) :
  sd[d1 * i % 10] = i
#print(sd)

for j in range(999999):
  d2 = 7 - mae % 10
  s = str(sd[d2] * k + mae)
#  print("mae ", mae,"",sd[d2] * k )
#  print("s1=",s)
  for i in range(len(s)-1, -1, -1):
#    print("s[",i,"]=",s[i])
    if (s[i]) == "7":
      cnt += 1
    else:
      s = s[0:i+1]
      mae = int(s)
#      print("s2=",s)
      break
#    print("i= ",i)
    if i == 0 :
      print(cnt)
      exit()
Buggy code:
from math import ceil,floor,factorial,gcd,sqrt,log2,cos,sin,tan,acos,asin,atan,degrees,radians,pi,inf,comb
from itertools import accumulate,groupby,permutations,combinations,product,combinations_with_replacement
from collections import deque,defaultdict,Counter
from bisect import bisect_left,bisect_right
from operator import itemgetter
from heapq import heapify,heappop,heappush
from queue import Queue,LifoQueue,PriorityQueue
from copy import deepcopy
from time import time
from functools import reduce
import string
import sys
sys.setrecursionlimit(10 ** 7)
def input() : return sys.stdin.readline().strip()
def INT()   : return int(input())
def MAP()   : return map(int,input().split())
def LIST()  : return list(MAP())

k = INT()
x = 0
for i in range(6):
    x += 7*10**i
    if x % k == 0:
        print(i+1)
        exit()
print(-1)

Fixed code:
from math import ceil,floor,factorial,gcd,sqrt,log2,cos,sin,tan,acos,asin,atan,degrees,radians,pi,inf,comb
from itertools import accumulate,groupby,permutations,combinations,product,combinations_with_replacement
from collections import deque,defaultdict,Counter
from bisect import bisect_left,bisect_right
from operator import itemgetter
from heapq import heapify,heappop,heappush
from queue import Queue,LifoQueue,PriorityQueue
from copy import deepcopy
from time import time
from functools import reduce
import string
import sys
sys.setrecursionlimit(10 ** 7)
def input() : return sys.stdin.readline().strip()
def INT()   : return int(input())
def MAP()   : return map(int,input().split())
def LIST()  : return list(MAP())

k = INT()
x = 0
for i in range(k):
    x = ( x * 10 + 7 ) % k
    if x % k == 0:
        print(i+1)
        exit()
print(-1)
Buggy code:
k = int(input())
a = 0
for i in range(k):
  a = (a*10+7)/k
  if a == 0:
    print(i+1)
    quit()
print(-1)

Fixed code:
k = int(input())
a = 0
for i in range(k):
  a = (a*10+7)%k
  if a == 0:
    print(i+1)
    quit()
print(-1)
Buggy code:
n = int(input())
if n % 2 == 0:
  print(-1)
else:
  a = 7
  for i in range(1000000)
    if a % n == 0:
      print(i+1)
      break
    a = a * 10 + 7


Fixed code:
n = int(input())
if n % 2 == 0:
  print(-1)
else:
  a = 7
  b = 0
  for i in range(1000000):
    if a % n == 0:
      print(i+1)
      b = 1
      break
    a = (a%n) * 10 + 7
  if b == 0:
    print(-1)
Buggy code:
k = int(input())

if k % 2 == 0 or k % 5 == 0:
    print(-1)
    exit()

if k == 1:
    print(1)
    exit()

tmp = 7
for i in range(1, 10**7):
    tmp = (10 * tmp) % (9*k)
    print(tmp)
    if tmp == 7:
        print(i)
        exit()

print(-1)


Fixed code:
k = int(input())

if k % 2 == 0 or k % 5 == 0:
    print(-1)
    exit()

if k == 1:
    print(1)
    exit()

tmp = 7
for i in range(1, 10**7):
    tmp = (10 * tmp) % (9*k)
    if tmp == 7:
        print(i)
        exit()

print(-1)
Buggy code:
K = int(input())

first_mod = 7 % K
"""
cnt = 1
if first_mod == 0:
    print(1)
else:
    flg = True
    for i in range(2,K):
        seven = old * 10 + 7
        mod = seven % K
        cnt += 1
        old = seven
        if mod == 0:
            break
        if mod == first_mod:
            flg = False
            break
    if flg:
        print(cnt)
    else:
        print(-1)
"""
old_mod = now_mod = first_mod

cnt = 1
if first_mod == 0:
    print(1)
else:
    flg = True
    for i in range(2,K):
        now_mod = ((old_mod * 10) + 7) % K
        cnt += 1
        old_mod = now_mod
        if now_mod == 0:
            break
        if now_mod == first_mod:
            flg = False
            break
    if flg:
        print(cnt)
    else:
        print(-1)
        


Fixed code:
K = int(input())

first_mod = 7 % K
"""
cnt = 1
if first_mod == 0:
    print(1)
else:
    flg = True
    for i in range(2,K):
        seven = old * 10 + 7
        mod = seven % K
        cnt += 1
        old = seven
        if mod == 0:
            break
        if mod == first_mod:
            flg = False
            break
    if flg:
        print(cnt)
    else:
        print(-1)
"""
old_mod = now_mod = first_mod

cnt = 1
if first_mod == 0:
    print(1)
else:
    flg = False
    for i in range(2,K+1):
        now_mod = ((old_mod * 10) + 7) % K
        cnt += 1
        old_mod = now_mod
        if now_mod == 0:
            flg = True
            break
        if now_mod == first_mod:
            break
    if flg:
        print(cnt)
    else:
        print(-1)
Buggy code:
K = int(input())
used = set()
pos = 1
v = 0

while 1:
    v += 10*v+7
    v %= K
    if v==0:
        print(pos)
        break
    if v in used:
        print(-1)
        break
    used.add(v)
    pos += 1

Fixed code:
K = int(input())
used = set()
pos = 1
v = 0

while 1:
    v += 7*pow(10, pos-1, K)
    v %= K
    if v==0:
        print(pos)
        break
    if v in used:
        print(-1)
        break
    used.add(v)
    pos += 1
Buggy code:
K = int(input())

sevens = 0
count = 0
repeat = True

if {K%10} & {0,2,4,5,6,8}:
    count = -1
    repeat = False

while repeat:
    sevens = sevens * 10 + 7
    count += 1
    if sevens % K == 0:
        repeat = False

print(count)

Fixed code:
K = int(input())

sevens = 0
count = 0
repeat = True

if {K%10} & {0,2,4,5,6,8}:
    count = -1
    repeat = False

while repeat:
    sevens = sevens % K * 10 + 7
    count += 1
    if sevens % K == 0:
        repeat = False

print(count)
Buggy code:
import sys
k = int(input())
for i in range(k+1):
  d = 7
  d = (10*d) + 7
  d %= k
  if d == 0:
    print(i+1)
    sys.exit()
print(-1)

Fixed code:
import sys
k = int(input())
d = 0
for i in range(k+1):
  d = (10*d) + 7
  d %= k
  if d == 0:
    print(i+1)
    sys.exit()
print(-1)
Buggy code:
import sys
import bisect
from functools import lru_cache
from collections import defaultdict
inf = float('inf')
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10**6)
def input(): return sys.stdin.readline().rstrip()
def read():
  return int(readline())
def reads():
  return map(int, readline().split())
K=reads()
mod=7//K
index=1
dic=defaultdict(int)
while(True):
    if mod==0:
        print(index)
        exit
    if dic[mod]==1:
        print(-1)
        exit
    dic[mod]=1
    mod=mod*10+7
    i+=1
    

Fixed code:
import sys
import bisect
from functools import lru_cache
from collections import defaultdict
inf = float('inf')
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10**6)
def input(): return sys.stdin.readline().rstrip()
def read():
  return int(readline())
def reads():
  return map(int, readline().split())
K=read()
mod=7%K
index=1
dic=defaultdict(int)
while(True):
    if mod==0:
        print(index)
        exit()
    if dic[mod]==1:
        print(-1)
        exit()
    dic[mod]=1
    mod=mod*10+7
    mod%=K
    index+=1
Buggy code:
k = int(input())
if k % 2 == 0:
    print(-1)

amari = [7]
tmp = 7
for i in range(k):
    tmp = (tmp * 10) % k
    if tmp != 7:
        amari.append(tmp%k)
    else:
        break
amari = amari * ((k//len(amari)) +1)

ans = amari[0]
for i in range(1, k):
    ans += amari[i]
    if ans % k == 0:
        print(i+1)
        break
else:
  print(-1)

Fixed code:
k = int(input())
if k % 2 == 0:
    print(-1)
elif k in [1,7]:
  	print(1)
else:
  amari = [7]
  tmp = 7
  for i in range(k):
      tmp = (tmp * 10) % k
      if tmp != 7:
          amari.append(tmp%k)
      else:
          break
  amari = amari * ((k//len(amari)) +1)

  ans = amari[0]
  for i in range(1, k+1):
      ans += amari[i]
      if ans % k == 0:
          print(i+1)
          break
  else:
    print(-1)
Buggy code:
k=int(input())
l=[]
x=7%k
if x == 0:
  print(1)
  break
for i in range(2,k+1):
  x=7%k
  num=(x*10+7)%k
  x=num
  l.append(num)
  if num==0:
    print(i)
    break
if 0 not in l:
  print(-1)

Fixed code:
import sys
k=int(input())
l=[]
x=7%k
if x == 0:
  print(1)
  sys.exit()
for i in range(2,k+1):
  num=(x*10+7)%k
  x=num
  l.append(num)
  if num==0:
    print(i)
    break
if 0 not in l:
  print(-1)
Buggy code:
def main():
    K = int(input())
    l = [False] * K
    ans = 1
    now = 0
    while True:
        now = now * 10 + 7
        now %= 7
        if now == 0:
            print(ans)
            break

        if l[now]:
            print(-1)
            break
        
        l[now] = True
        ans += 1

if __name__ == '__main__':
    main()

Fixed code:
def main():
    K = int(input())
    l = [False] * K
    ans = 1
    now = 0
    while True:
        now = now * 10 + 7
        now %= K
        if now == 0:
            print(ans)
            break

        if l[now]:
            print(-1)
            break
        
        l[now] = True
        ans += 1

if __name__ == '__main__':
    main()
Buggy code:
def main():
    K = int(input())

    if K % 2 == 0:
        v = 7
        for i in range(1, 1000000):
            if v % K == 0:
                print(i)
                return

            v = (v * 10 + 7) % K
        
    print(-1)

main()


Fixed code:
def main():
    K = int(input())

    v = 7
    for i in range(1, 1000000):
        if v % K == 0:
            print(i)
            return

        v = (v * 10 + 7) % K
        
    print(-1)

main()
Buggy code:
K=int(input())
m=7
count=1
flag=0
for i in range(K):
  if m%K==0:
    flag=1
    break
  else:
    m*=10
    m+=7
    m%=K
    count+=1
if flag:
  print("-1")
else:
  print(count)

Fixed code:
K=int(input())
m=7
count=1
flag=0
for i in range(K):
  if m%K==0:
    flag=1
    break
  else:
    m*=10
    m+=7
    m%=K
    count+=1
if not flag:
  print("-1")
else:
  print(count)
Buggy code:
K=int(input())
i=0
if K%2==0 or K%5==0:
    print('-1')
else:
    for d in range(K):
        i=(10*i+7)%K
        if i==0:
            print(i+1)
            break


Fixed code:

K=int(input())
i=0
if K%2==0 or K%5==0:
    print('-1')

else:
    for d in range(K):
        i=(10*i+7)%K
        if i==0:
            print(d+1)
            break
Buggy code:
K = int(input())
count = 0
an = 0

if K%2 == 0 or K%2 ==0:
    print("-1")
    exit(0)
while True:
  an = 10*an + 7
  count +=1
  if an % K == 0:
    print(count)
    break


Fixed code:
K = int(input())

if K%2 == 0 or K%5 == 0:
    print(-1)
    exit(0)

count = 0
an = 0
while True:
  an = (10*an + 7) % K
  count +=1
  if an == 0:
    break
print(count)
Buggy code:
import sys
import math
import itertools
import bisect
from copy import copy,deepcopy
from collections import deque,Counter
from decimal import Decimal
def s(): return input()
def i(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def L(): return list(map(int,input().split()))
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 9)
INF = 10**9
mod = 10**9+7

K = i()
if K%2 == 0 or K%5 == 0:
    print(-1)
    exit()
for i in range(1,7000):
    if int('7'*i)%K == 0:
        print(i)
        exit()
print(K-1)

Fixed code:
import sys
import math
import itertools
import bisect
from copy import copy,deepcopy
from collections import deque,Counter
from decimal import Decimal
def s(): return input()
def i(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def L(): return list(map(int,input().split()))
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 9)
INF = 10**9
mod = 10**9+7

K = i()
if K%2 == 0 or K%5 == 0:
    print(-1)
    exit()
m = 7
for i in range(1,10000000):
    if m%K == 0:
        print(i)
        exit()
    m = (m*10+7)%K
print(K-1)
Buggy code:
k = int(input())
if k == 2 or k == 5:
  print(-1)
else:
  a = 7
  cnt = 1
  while True:
    if a % k == 0:
      print(cnt)
      break
    a = a * 10 + 7
    cnt += 1

Fixed code:
k = int(input())
if k % 2 == 0 or k % 5 == 0:
  print(-1)
else:
  state = 7
  state %= k
  cnt = 1
  while True:
    if state == 0:
      print(cnt)
      break
    state = state * 10 + 7
    state %= k
    cnt += 1
Buggy code:
K = int(input())

a = 7

for i in range(K):
    if(a % K == 0):
        print(i + 1)
        break
    a = a * 10 + 7

else:
    print(-1)

Fixed code:
K = int(input())

x = 7 % K
for i in range(K):
    if x == 0:
        print(i + 1)
        break
    x = x * 10 + 7
    x = x % K
else:
    print(-1)
Buggy code:
import sys, bisect, math, itertools, string, queue, copy
# import numpy as np
# import scipy
# from collections import Counter,defaultdict,deque
# from itertools import permutations, combinations
# from heapq import heappop, heappush
# from fractions import gcd
# input = sys.stdin.readline
# sys.setrecursionlimit(10**8)
# mod = 10**9+7
def inp(): return int(input())
def inpm(): return map(int,input().split())
def inpl(): return list(map(int, input().split()))
def inpls(): return list(input().split())
def inplm(n): return list(int(input()) for _ in range(n))
def inplL(n): return [list(input()) for _ in range(n)]
def inplT(n): return [tuple(input()) for _ in range(n)]
def inpll(n): return [list(map(int, input().split())) for _ in range(n)]
def inplls(n): return sorted([list(map(int, input().split())) for _ in range(n)])

k = inp()

ans = -1
tmp = 7
for i in range(1000001):
  tmp = (tmp * 10 + 7)
  if tmp % k == 0:
    ans = i+1
    break

print(ans)


Fixed code:
import sys, bisect, math, itertools, string, queue, copy
# import numpy as np
# import scipy
# from collections import Counter,defaultdict,deque
# from itertools import permutations, combinations
# from heapq import heappop, heappush
# from fractions import gcd
# input = sys.stdin.readline
# sys.setrecursionlimit(10**8)
# mod = 10**9+7
def inp(): return int(input())
def inpm(): return map(int,input().split())
def inpl(): return list(map(int, input().split()))
def inpls(): return list(input().split())
def inplm(n): return list(int(input()) for _ in range(n))
def inplL(n): return [list(input()) for _ in range(n)]
def inplT(n): return [tuple(input()) for _ in range(n)]
def inpll(n): return [list(map(int, input().split())) for _ in range(n)]
def inplls(n): return sorted([list(map(int, input().split())) for _ in range(n)])

k = inp()

keta = len(str(k))
ans = -1
tmp = 0
for i in range(1000001):
    tmp = ((tmp + (7 * pow(10,i,k)) % k)) % k
    if tmp == 0:
        ans = i+1
        break

print(ans)
Buggy code:
limit = pow(10, 7)
K = int(input())
num = "7"
if K % 2 == 0 or K % 5 == 0:
    print (-1)
else:
    total = 0
    flag = False
    for i in range(limit + 1):
        total = (total * 10 + 7) % K
        if total == 0:
            flag = True
            break
    if flag:
        print (i)
    else:
        print(-1)

Fixed code:
limit = pow(10, 7)
K = int(input())
num = "7"
if K % 2 == 0 or K % 5 == 0:
    print (-1)
else:
    total = 0
    flag = False
    for i in range(1, limit + 1):
        total = (total * 10 + 7) % K
        if total == 0:
            flag = True
            break
    if flag:
        print (i)
    else:
        print(-1)
Buggy code:
k = int(input())
i = int(str(k)[-1])
if(i % 2 == 0 | i % 5 == 0 ):
    print(-1)
else:
    numl = [0]*k
    num = 7
    for i in range(k):
        numl[i] = num
        num = 7+ num*10
        
    for i in range(k):
        if(numl[i] % k == 0):
            break
        else:
            result=i+1
    else:
        result = -1
    print(result)

Fixed code:
k = int(input())
i = int(str(k)[-1])
if(i % 2 == 0 | i % 5 == 0 ):
    print(-1)
else:
    num = 7
    result=1
    for i in range(k):
        if(num % k == 0):
            break
        else:
            num = (7+ num*10)%k
            result+=1
    else:
        result = -1
    print(result)
Buggy code:
K = int(input())

t = 7
for i in range(K):
  print(t)
  if t % K == 0:
      print(i + 1)
      break
  t = (t * 10 + 7) % K
else:
  print(-1)

Fixed code:
K = int(input())

t = 7
for i in range(K):
    if t % K == 0:
        print(i + 1)
        break
    t = (t * 10 + 7) % K
else:
    print(-1)
Buggy code:
k = int(input())



if k % 2 != 0 and k % 5 != 0:
    if k % 7 == 0:
        l = 9 * k // 7
    else:
        l = 9 * k
    for i in range(1,k + 3):
        if (10 ** i) % l == 1:
            print(i)
            break

else:
    print(-1)

Fixed code:
k = int(input())

if k == 1 or k == 7:
    print(1)

elif k % 2 != 0 and k % 5 != 0:
    if k % 7 == 0:
        l = 9 * k // 7
    else:
        l = 9 * k

    m = 10 % l
    for i in range(1,k + 3):
        if m * 10 % l == 1:
            print(i + 1)
            break
        else:
            m = m * 10 % l

else:
    print(-1)
Buggy code:
import sys
k=int(input())
n=7
if k%2==0:
    print(-1)
for i in range(1,k+1):
    if n%k==0:
        print(i)
        sys.exit()
    else:
        n=(10*(n%k)+7)%k
print(-1)

Fixed code:
import sys
k=int(input())
n=7
if k%2==0:
    print(-1)
    sys.exit()
for i in range(1,k+1):
    if n%k==0:
        print(i)
        sys.exit()
    else:
        n=(10*(n%k)+7)%k
print(-1)
Buggy code:
K = int(input())

N = 7
count = -1

for i in range(K):
    amari = N%K
    if amari == 0:
        count = i+1
        break
    N = N*10 + 7
print(count)

Fixed code:
K = int(input())

N = 0
count = -1

for i in range(K):
    N = (N*10+7)%K
    if N == 0:
        count = i+1
        break
    
print(count)
Buggy code:
k = int(input())
if k % 2 == 0 or k % 5 == 0:
    print(-1)
    exit()

i = 7
cnt = 1
while i != 0:
    i = i * 10 + 7
    i %= 7
    cnt += 1
print(cnt)


Fixed code:
k = int(input())
if k % 2 == 0 or k % 5 == 0:
    print(-1)
    exit()

i = 7 % k
cnt = 1
while i != 0:
    i = i * 10 + 7
    i %= k
    cnt += 1
print(cnt)
Buggy code:

def s(): return input()
def i(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def X(): return list(input())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
count = 0
ans = -1

K = i()
N = 1
s = 10
if K == 7:
    print(1)
    exit()
if K % 2 == 0:
    print(-1)
    exit()

for i in range(1,10**7):
    N += s
    s *= 10
    if N % K == 0:
        print(i+1)
        exit()
print(-1)


Fixed code:

def s(): return input()
def i(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def X(): return list(input())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
count = 0
ans = -1

K = i()
N = "7"
s = 10
if K == 7 or K == 1:
    print(1)
    exit()
if K % 2 == 0:
    print(-1)
    exit()
mod = 7 % K

for i in range(10**7):
    if mod == 0:
        print(i+1)
        exit()
    else:
        mod *= 10
        mod += 7
        mod %= K
print(-1)
Buggy code:
#!python3.8
# -*- coding: utf-8 -*-
# abc174/abc174_c
import sys

s2nn = lambda s: [int(c) for c in s.split(' ')]
ss2nn = lambda ss: [int(s) for s in list(ss)]
ss2nnn = lambda ss: [s2nn(s) for s in list(ss)]
i2s = lambda: sys.stdin.readline().rstrip()
i2n = lambda: int(i2s())
i2nn = lambda: s2nn(i2s())
ii2ss = lambda n: [i2s() for _ in range(n)]
ii2nn = lambda n: ss2nn(ii2ss(n))
ii2nnn = lambda n: ss2nnn(ii2ss(n))

def main():
    K = i2n()

    #while K % 7 == 0:
    #    K = K // 7
    x = 10 % K
    a = 0
    for i in range(1, K + 10):
        a = a * 10 + 7
        if a % K == 0:
            print(i)
            return
    else:
        print('-1')
    return

main()


Fixed code:
#!python3.8
# -*- coding: utf-8 -*-
# abc174/abc174_c
import sys

s2nn = lambda s: [int(c) for c in s.split(' ')]
ss2nn = lambda ss: [int(s) for s in list(ss)]
ss2nnn = lambda ss: [s2nn(s) for s in list(ss)]
i2s = lambda: sys.stdin.readline().rstrip()
i2n = lambda: int(i2s())
i2nn = lambda: s2nn(i2s())
ii2ss = lambda n: [i2s() for _ in range(n)]
ii2nn = lambda n: ss2nn(ii2ss(n))
ii2nnn = lambda n: ss2nnn(ii2ss(n))

def main():
    K = i2n()
    a = 0
    if K % 7:
        L = 9 * K
    else:
        L = 9 * K // 7
    a = 1
    for i in range(1, K + 10):
        a = (a * 10) % L
        if a == 1:
            print(i)
            return
    print('-1')
    return
 
main()
Buggy code:
import sys, math, itertools, collections, bisect 
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8') 
inf = float('inf') ;mod = 10**9+7 
mans = inf ;ans = 0 ;count = 0 ;pro = 1

k = int(input())
d = 7 % k
for i in range(1, k+10):
    if d == 0:
        ans = i
        break
    d = (10*d + 7) % k
print(ans)

Fixed code:
import sys, math, itertools, collections, bisect 
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8') 
inf = float('inf') ;mod = 10**9+7 
mans = inf ;ans = 0 ;count = 0 ;pro = 1

k = int(input())
ans = -1
d = 7 % k
for i in range(1, k+10):
    if d == 0:
        ans = i
        break
    d = (10*d + 7) % k
print(ans)
Buggy code:
K = int(input())
ans = 7%K
A = 1
C = [0]*K
if K == 1 or K == 7:
  print(1)
  exit()
for i in range(K):
  A = (A*10)%K
  ans += (A*7)
  ans %= K
  if ans == 0:
    break
  if C[ans] == 0:
    C[ans] += 1
  else:
    break
if i == K:
  print(-1)
else:
  print(i+2)

Fixed code:
K = int(input())
ans = 7%K
A = 1
C = [0]*K
if K == 1 or K == 7:
  print(1)
  exit()
for i in range(K):
  A = (A*10)%K
  ans += (A*7)
  ans %= K
  if ans == 0:
    break
  if C[ans] == 0:
    C[ans] += 1
  else:
    print(-1)
    exit()
print(i+2)
Buggy code:
import sys
input = lambda: sys.stdin.readline().rstrip()

def main():
    k = int(input())
    ans = 0

    if k % 2 == 0 or k % 5 == 0:
        print(-1)
    else:
        a = 7
        while 1:
            if a % k == 0:
                print(len(str(a)))
                break
            else:
                a = a * 10 + 7

if __name__ == '__main__':
    main()


Fixed code:
import sys
input = lambda: sys.stdin.readline().rstrip()

def main():
    k = int(input())
    ans = 1

    if k % 2 == 0 or k % 5 == 0:
        print(-1)
    else:
        a = 7
        while 1:
            if a % k == 0:
                print(ans)
                break
            else:
                a = (a % k) * 10 + 7
                ans += 1
if __name__ == '__main__':
    main()