qyliang/CodeNanoFix huggingface dataset:
Buggy code:
K = int(input())

t = 7
ans = 1

for _ in range(K):
    if t % K == 0:
        print(ans)
        exit(0)
    else:
        t = t * 10 + 7
        ans += 1

print(-1)

Fixed code:
K = int(input())

t = 7
ans = 1

for _ in range(K):
    if t % K == 0:
        print(ans)
        exit(0)
    else:
        t = (t * 10 + 7) % K
        ans += 1

print(-1)
Buggy code:
k = int(input())
cnt = 0
mod = [0]
while cnt<k:
    cnt+=1
    n = mod[-1]*10+7
    mod.append(n%k)
    if n % k == 0:
        print(cnt)

Fixed code:
k = int(input())
cnt = 0
mod = [0]
not_found = 1
while cnt<k+1:
    cnt+=1
    n = mod[-1]*10+7
    mod.append(n%k)
    if n % k == 0:
        not_found = 0
        print(cnt)
        break
if(not_found):
    print(-1)
Buggy code:
K = int(input())
#a1= 7 mod K
#a2= a1*10+7 mod K
#a3= a2*10+7 mod K
a = 0
count = -1
for i in range(K):
    a = (7 + a*10)
    if a % K== 0:
        count=i+1
        break
print(count)

Fixed code:
K = int(input())
#a1= 7 mod K
#a2= a1*10+7 mod K
#a3= a2*10+7 mod K
a = 0
count = -1
for i in range(K):
    a = (7 + a*10) % K
    if a  == 0:
        count=i+1
        break
print(count)
Buggy code:
K = int(input())

num = 7

if(7 % K == 0):
    print(1)
    exit()

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

print(-1)
    


Fixed code:
K = int(input())

num = 0

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

    num %= K

print(-1)
Buggy code:
from sys import stdin
k = int(stdin.readline().rstrip())
num = 7
flag = 0
for i in range(1, k + 1):
    if num % k == 0:
        flag = 1
        break
    num = num * 10 + 7
if flag == 1:
    print(i)
else:
    print(-1)

Fixed code:
from sys import stdin
k = int(stdin.readline().rstrip())
num = 7
flag = 0
for i in range(1, k + 1):
    if num % k == 0:
        flag = 1
        break
    num = (num * 10 + 7) % k
if flag == 1:
    print(i)
else:
    print(-1)
Buggy code:
ma = lambda :map(int,input().split())
ni = lambda:int(input())
yn = lambda fl:print("Yes") if fl else print("No")
import collections
import math
import itertools
import heapq as hq
k = ni()

if k%2==0 or k%5==0:
    print(-1)
if k%7==0:
    L=9*k//7
else:
    L=9*k
tmp=1
for i in range(1,10**6):
    tmp = tmp*10 %L
    if tmp==1:
        print(i)
        break
else:
    print(-1)


Fixed code:
ma = lambda :map(int,input().split())
ni = lambda:int(input())
yn = lambda fl:print("Yes") if fl else print("No")
import collections
import math
import itertools
import heapq as hq
k = ni()

if k%2==0 or k%5==0:
    print(-1)
    exit()
if k%7==0:
    L=9*k//7
else:
    L=9*k
tmp=1
for i in range(1,10**6):
    tmp = tmp*10 %L
    if tmp==1:
        print(i)
        break
else:
    print(-1)
Buggy code:
ma = lambda :map(int,input().split())
ni = lambda:int(input())
yn = lambda fl:print("Yes") if fl else print("No")
import collections
import math
import itertools
import heapq as hq
k = ni()
a = 0
for i in range(10**7):
    a=(a+7*pow(10,i,k))%k
    if a== 0:
        print(i+1)
        exit()


Fixed code:
ma = lambda :map(int,input().split())
ni = lambda:int(input())
yn = lambda fl:print("Yes") if fl else print("No")
import collections
import math
import itertools
import heapq as hq
k = ni()
a = 0
for i in range(10**6):
    a=(a+7*pow(10,i,k))%k
    if a== 0:
        print(i+1)
        break
else:
    print(-1)
Buggy code:
K = int(input())
a = 7
ans = -1
for i in range(1,10^6+1):
  if a%K==0:
    ans = i
    break
  a = a*10+7
print(ans)

Fixed code:
K = int(input())
a = 7%K
ans = -1
for i in range(1,10**6+1):
  if a==0:
    ans = i
    break
  a = (a*10+7)%K
print(ans)
Buggy code:
k = int(input())
num = 7 
s = set()
cnt = 1
while(1):
    m = num%k
    if m == 0:
        print(cnt)
        break
    elif m in s:
        print(-1)
        break
    else:
        s.add(m)
    num = num*10+7
    cnt += 1

Fixed code:
k = int(input())
m = 7 % k 
s = set()
cnt = 1
while(1):
    if m == 0:
        print(cnt)
        break
    elif m in s:
        print(-1)
        break
    else:
        s.add(m)
    m = ((m * (10 % k)) % k + 7 % k) % k
    cnt += 1
Buggy code:
K=int(input())
a=7
for i in range(1,K+1):
    if a%7==0:
        print(i)
        exit()
    a=a*10+7
print(-1)

Fixed code:
K = int(input())

a = 7 % K

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

print(-1)
Buggy code:
K = int(input())
ans = 1
X = 7
cnt = K
while(cnt > 0):
#     print('rem={}'.format(X%K))
    rem = X % K
    if rem == 0:
        print(ans)
        break
    else:
        remlst.append(rem)
        ans += 1
        X = rem*10 + 7 
        cnt -= 1

if cnt == 0:
    print(-1)

Fixed code:
K = int(input())
ans = 1
X = 7
cnt = K
while(cnt > 0):
#     print('rem={}'.format(X%K))
    rem = X % K
    if rem == 0:
        print(ans)
        break
    else:
        ans += 1
        X = rem*10 + 7 
        cnt -= 1

if rem != 0:
    print(-1)
Buggy code:
# coding: utf-8

# k = int(input())
k = 999983
befo = 0

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


Fixed code:
# coding: utf-8

k = int(input())
n = 7 % k

for i in range(k+1):
    if n % k == 0:
        print(i+1)
        exit(0)
    n = (((n % k) * (10 % k)) + 7 % k) % k
print(-1)
Buggy code:
k=int(input())
a=7%k
sm=7
for i in range(k):
  if sm%k==0:
    print(i+1)
    break
  a=(10*a)%k
  sm+=a

Fixed code:
k=int(input())
a=7%k
sm=7
for i in range(k):
  if sm%k==0:
    print(i+1)
    break
  a=(10*a)%k
  sm+=a
else:
  print(-1)
Buggy code:
from sys import stdin
input = stdin.readline
ri = lambda : int(input())
ril = lambda : list(map(int, input().split()))

def main():
  K = ri()
  m = 0
  ans = -1
  for i in range(K):
    m = (10 * m + 7) % K
    if m == 0:
      ans = i
      break
  print(ans)

if __name__ == '__main__':
  main()


Fixed code:
from sys import stdin
input = stdin.readline
ri = lambda : int(input())
ril = lambda : list(map(int, input().split()))

def main():
  K = ri()
  m = 0
  ans = -1
  for i in range(K):
    m = (10 * m + 7) % K
    if m == 0:
      ans = i + 1
      break
  print(ans)

if __name__ == '__main__':
  main()
Buggy code:
k = int(input())
start = 7 % k
ans = start
con = 1

if k % 2 == 0 or k % 5 == 0:
  print("No")
  exit()
while True:
  if ans == 0:
    print(con)
    break
  else:
    con += 1
    ans = ans * 10 + 7
    ans = ans % k
    if ans == start:
      print("-1")
      break


Fixed code:
k = int(input())
start = 7 % k
ans = start
con = 1

if k % 2 == 0 or k % 5 == 0:
  print("-1")
  exit()
while True:
  if ans == 0:
    print(con)
    break
  else:
    con += 1
    ans = ans * 10 + 7
    ans = ans % k
    if ans == start:
      print("-1")
      break
Buggy code:
num=int(input())
a=7
flag=0
for i in range(num):
    a=(a*10+7)
    if a%num==0:
        print(i)
        flag=1
        break
    
if flag==0:
    print("-1")

Fixed code:
num=int(input())
a=7
flag=0
for i in range(num):
    if a%num==0:
        print(i+1)
        flag=1
        break
    a=(a*10+7)%num
if flag==0:
    print(-1)
Buggy code:
import sys
input = sys.stdin.readline
def I(): return int(input())


def main():
    K = I()
    if K % 2 == 0 or K %  5 == 0:
        print(-1)
        exit()
    if K % 7 == 0:
        K = 9*K//7
    else:
        K = 9*K
    amari = 1
    num = 1
    for i in range(10**6):
        num *= 10
        amari = amari*10 % K        
        if amari == 1:
            print(i+1)
            exit()
    print(-1)

main()

Fixed code:
import sys
input = sys.stdin.readline
def I(): return int(input())


def main():
    K = I()
    if K % 2 == 0 or K %  5 == 0:
        print(-1)
        exit()
    if K % 7 == 0:
        K = 9*K//7
    else:
        K = 9*K
    amari = 1
    for i in range(10**6):
        amari = amari*10 % K
        if amari == 1:
            print(i+1)
            exit()
    print(-1)

if __name__ == "__main__":
    main()
Buggy code:
k = int(input())
mod = 0
for i in range(1, k):
    mod = ((mod * 10) + 7) % 7
    if mod == 0:
        print(i)
        exit()
print(-1)        

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

k = int(input())

a = 0

for i in range(1, k+1):
  a = a*10+7
  if a%k == 0:
      print(i)
      sys.exit()
print(-1)


Fixed code:
import sys

k = int(input())

a = 0

for i in range(1, k+1):
  a = (a*10+7)%k
  if a == 0:
      print(i)
      sys.exit()

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

Fixed code:
a=int(input())
b=7
for i in range(a):
  if b%a==0:
    print(i+1)
    break
  b=10*b%a+7
  if i==a-1:
    print(-1)
    break
Buggy code:
#C-respect
K = int(input())
count = 1
a = 7 % K

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

Fixed code:
#C-respect
K = int(input())
count = 1
a = 7 % K

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

print (-1)
Buggy code:
k=int(input())
ans=1
judge=0
remainder=7%k

while ans<=k:
    if remainder==0:
        judge=1
        break
    else:
        remainder=remainder*10+7
        ans+=1
        
if judge==1:
    print(ans)
else:
    print(-1)

Fixed code:
k=int(input())
ans=1
judge=0
s=7%k
while ans<=k:
    if s==0:
        judge=1
        break
    else:
        s=s*10+7
        s%=k
        ans+=1
if judge==1:
    print(ans)
else:
    print(-1)
Buggy code:
def main():
    k = int(input())
    num = 1
    n = 7

    if (k % 2) == 0:
        print(-1)
        return
    
    for i in range(100000):
        if (n % k == 0):
            print(num)
            return
        else:
            n = (n*10 + 7) %k
            num += 1
    print(-1)

if __name__ == '__main__':
    main() 

Fixed code:
def main():
    k = int(input())
    num = 1
    n = 7

    if (k % 2 == 0):
        print(-1)
        return
    
    for i in range(1000000):
        if (n % k == 0):
            print(num)
            return
        else:
            n = (n*10 + 7) %k
            num += 1
    print(-1)

if __name__ == '__main__':
    main()
Buggy code:
import sys
K=int(input())
L=9*K
if L%7==0:
  L = L//7
for i in range(1,K+1):
  if 10 ** i % L == 1:
    print(i)
    sys.exit()
print(-1)


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

if k % 7 == 0:
  k = k/7

if k % 2 == 0 or k % 5 == 0:
  print(-1)
else:
  ans = 1
  cnt = 1
  while 1:
    if ans % k == 0:
      break
    else:
      cnt += 1
      ans *= 10
      ans += 1

  print(cnt)      

Fixed code:
k=int(input())

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

flg = True
for i in range(1,10**12):
  x = x%k
  if x ==0:
    break
  else:
    x = x*10+7
    
if k%2==0:
  flg = False
    
print(i if flg else '-1')


Fixed code:
k = int(input())
x = 7%k

flg = False
for i in range(1,k+1):
  x = x%k
  if x ==0:
    flg = True
    break
  else:
    x = x*10+7
  
print(i if flg else '-1')
Buggy code:
n = int(input())

k = 7
m = k%n
if m == 0:
    print(1)
    exit()
cnt = 1

for i in range(1,n+1):
    k = 7*10**i + k
    #print(k)
    m = k%n
    #print(m)
    if m == 0:
        print(i+1)
        exit()
print(-1)

Fixed code:
n = int(input())

k = 7
m = k%n
if m == 0:
    print(1)
    exit()
cnt = 1

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

maxV = (10**6)**2

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

print(-1)

Fixed code:
k = int(input())

maxV = (10**6)**2

i = 0
sevens = 0
while i < 10**6+1:
    sevens = sevens * 10 + 7
    sevens = sevens % k
    i+=1
    if sevens % k == 0:
        print(i)
        exit()

print(-1)
Buggy code:
import sys
read = sys.stdin.read
readline = sys.stdin.buffer.readline

sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7


def main():
    K = int(readline())
    if K%2==0:
        print(-1)
    else:
        seven = 7
        amari = [7]
        ans = 1
        while True:
            seven = seven%K
            if seven==0:
                print(ans)
                break
            else:
                seven = seven*10+7

                if seven in amari:
                    print(-1)
                    break
                ans += 1
                amari.append(seven)


if __name__ == '__main__':
    main()


Fixed code:
import sys
read = sys.stdin.read
readline = sys.stdin.buffer.readline

sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7


def main():
    K = int(readline())
    if K%2==0:
        print(-1)
    else:
        seven = 7
        amari = set([7])
        ans = 1
        while True:
            seven = seven%K
            if seven==0:
                print(ans)
                break
            else:
                seven = seven*10+7
                if seven in amari:
                    print(-1)
                    break
                ans += 1
                amari.add(seven)


if __name__ == '__main__':
    main()
Buggy code:
count = 0
before = 0
if k%2 == 0 or k%5==0:
    print(-1)
    exit()

ai=0
i=0
while True:
    ai = (ai*10+7)%k
    i += 1
    if ai == 0:
        print(i)
        break

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

ai = 0
i = 0
while True:
    ai = (ai*10+7) % k
    i += 1
    if ai == 0:
        print(i)
        break
Buggy code:
import sys
import math
import itertools
import collections
import heapq
import re
import numpy as np
from functools import reduce

rr = lambda: sys.stdin.readline().rstrip()
rs = lambda: sys.stdin.readline().split()
ri = lambda: int(sys.stdin.readline())
rm = lambda: map(int, sys.stdin.readline().split())
rl = lambda: list(map(int, sys.stdin.readline().split()))
inf = float('inf')
mod = 10**9 + 7

k = ri()
a = k%10
if a in [1, 3, 7, 9]:
    s = 7
    while s%k:
        s = s*10 + 7
    print(math.ceil(math.log10(s)))
else:
    print(-1)




Fixed code:
import sys
import math
import itertools
import collections
import heapq
import re
import numpy as np
from functools import reduce

rr = lambda: sys.stdin.readline().rstrip()
rs = lambda: sys.stdin.readline().split()
ri = lambda: int(sys.stdin.readline())
rm = lambda: map(int, sys.stdin.readline().split())
rl = lambda: list(map(int, sys.stdin.readline().split()))
inf = float('inf')
mod = 10**9 + 7

k = ri()
a = k%10
if a in [1, 3, 7, 9]:
    s = 7
    cnt = 1
    while s%k:
        s = s*10 + 7
        s %= k
        cnt += 1
    print(cnt)
else:
    print(-1)
Buggy code:
k=int(input())
x=7
cnt=1
if k%2==0:
    print(-1)
else:
    while True:
        if x % k ==0:
            print(cnt)
            break
        elif cnt<10000000:
            x=(x+7*(10**cnt)%k)%k
            cnt+=1
        else:
            print(-1)
            break

Fixed code:
k=int(input())
x=7
cnt=1
if k%2==0:
    print(-1)
else:
    while True:
        if x%k ==0:
            print(cnt)
            break
        elif cnt<10000000:
            x=(x*10+7)%k
            cnt+=1
        else:
            print(-1)
            break
Buggy code:
K = int(input())

i, a = 0, 0
l = []
for i in range(K):
  a = 10*a + 7
  l.append(a % K)
  
j, ans = 0, 0
for j in range(K):
  if l[j] == 0:
    ans = j
    break
  else: 
    ans = -1

print(ans)

Fixed code:
K = int(input())
 
i, a = 0, 0
l = []
for i in range(K):
  a = (10*a + 7) % K
  l.append(a)

j, ans = 0, -1
for j in range(K):
  if l[j] == 0:
    ans = j + 1
    break

print(ans)
Buggy code:
#!/usr/bin/env python3

def main():
    K = int(input())
    if K % 7 == 0:
        L = 9 * K / 7
    else:
        L = 9 * K
    if L == 2 or L == 5:
        ans = -1
    else:
        i = 1
        tmp = 10
        while True:
            tmp %= L
            if tmp == 1:
                ans = i
                break
            i += 1
            tmp *= 10

    print(ans)


if __name__ == "__main__":
    main()


Fixed code:
#!/usr/bin/env python3

def main():
    K = int(input())
    if K % 7 == 0:
        L = 9 * K / 7
    else:
        L = 9 * K
    if L % 2 == 0 or L % 5 == 0:
        ans = -1
    else:
        i = 1
        tmp = 10
        while True:
            tmp %= L
            if tmp == 1:
                ans = i
                break
            i += 1
            tmp *= 10

    print(ans)


if __name__ == "__main__":
    main()
Buggy code:
k=int(input())

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

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

tmpNum = 7
count = 1
keisuu = 10

tmp = tmpNum%K
aa = tmp
while tmp !=0 and count<=K:
    aa = (aa*10)%K
    tmp = (tmp+aa)%K
    count+=1

if count==K:
    count=-1

print(count)

Fixed code:
K = int(input())

tmpNum = 7
count = 1
keisuu = 10

tmp = tmpNum%K
aa = tmp
while tmp !=0 and count<=K:
    aa = (aa*10)%K
    tmp = (tmp+aa)%K
    count+=1

if count>K:
    count=-1

print(count)
Buggy code:
def resolve():
    '''
    code here
    '''
    K = int(input())

    is_not_found = True
    memo = [0 for _ in range(K)]

    i=7%K
    memo[i] += 1
    res = 1
    while is_not_found and memo[i] == 1:
        i = (i * 10 + 7) % K
        memo[i] += 1
        res += 1
        if i == 0:
            is_not_found = False

    print(res)


if __name__ == "__main__":
    resolve()


Fixed code:
def resolve():
    '''
    code here
    '''
    K = int(input())

    is_not_found = True
    memo = [0 for _ in range(K)]

    i=7%K
    res = 1
    if i == 0:
        is_not_found = False

    while is_not_found and memo[i] == 0:
        memo[i] += 1
        if i == 0:
            is_not_found = False
        else:
            res += 1
            i = (i * 10 + 7) % K

    print(res) if is_not_found == False else print(-1)


if __name__ == "__main__":
    resolve()
Buggy code:
K = int(input())
i = 0
y = 0
if K%2 == 0 or K%5 == 0:
  print(-1)
elif K%3 == 0:
  print(3)
else:
  if K%7 == 0:
    K = K//7
  while True:
    i += 1
    y += 10**(i-1)
    if y%K== 0:
      break
  print(i)

Fixed code:
K = int(input())
i = 1
y = 1
if K== 1:
  print(1)
elif K%2 == 0 or K%5 == 0:
  print(-1)
#elif K%3 == 0:
#  print(3)
elif K== 7:
  print(1)
else:
  if K%7 == 0:
    K = K//7
  while True:
    i += 1
    y = ((y*10)%K) + 1
    y = y%K
    if y == 0:
      break
  print(i)
Buggy code:
K = int(input())

tmp1 = 0
for i in range(1, 2 * K + 1):
    tmp1 += 7 * pow(10, i, K)
    if tmp1 % K == 0:
        print(i)
        exit()

print(-1)

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

tmp1 = 0
for i in range(1, 2 * K + 1):
    tmp1 += 7 * pow(10, i, K)
    if tmp1 % K == 0:
        print(i)
        exit()

print(-1)
Buggy code:
cnt = 1
mod = 7
k = int(input())

for i in range(k):
  if mod % k == 0:
    break
  cnt += 1
  mod = (mod * 10 * 7) % k

if mod % k == 0:
  print(cnt)
else:
  print(-1)


Fixed code:
cnt = 1
mod = 7
k = int(input())
for i in range(k):
    if mod % k == 0:
        break
    cnt += 1
    mod = (mod * 10 + 7) % k

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

Fixed code:
K = int(input())
like = 7
ans = -1
for i in range(K):
    if like % K == 0:
        ans = i+1
        break
    like = (like*10+7) % K
print(ans)
Buggy code:
K=int(input())
temp=0
for i in range(1,10**6+1):
  t="7"*K
  r=int(t)%K
  if(r%K==0):
    print(i)
    temp=1
    break
if(temp==0):
  print(-1)

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

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

num=7
num%=k
ans=1

while k!=0:
  num=(10*num+7)%k+7

print(ans)

Fixed code:
k=int(input())

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

num=7
num%=k
ans=1

while num!=0:
  num=10*num+7
  num%=k
  ans+=1

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

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

if str(k)[-1] not in ["1","3","7","9"]:
    print(-1)
    exit()

tmp = "7"*(len(str(k))-1)
while True:
    tmp += "7"
    if int(tmp)%k == 0:
        print(len(tmp))
        exit()

Fixed code:
k = int(input())

if str(k)[-1] not in ["1","3","7","9"]:
    print(-1)
    exit()

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

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

Fixed code:
K = int(input())
tmp = 7
for i in range(1,K+1):
    if tmp%K == 0:
        print(i)
        exit()
    tmp = (tmp*10 + 7)%K
    tmp %= K
print(-1)
Buggy code:
K = int(input())

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

elif K%7 ==0:
    x = -1
    b = 9*K/7
    c = 10%b

    for i in range(1,K+1):
        if c ==1:
            x = i
            break
        c = (c*10)%b

    print(x)

else:
    x = -1
    b = 9*K
    c = 10%b
    for i in range(1,K+1):
        if c ==1:
            x = i
            break
        #c = (c*10)%b
        print(c)
    print(x)


Fixed code:
K = int(input())

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

elif K%7 == 0:
    x = -1
    b = 9*K/7
    c = 10%b

    for i in range(1,K+1):
        if c ==1:
            x = i
            break
        c = (c*10)%b

    print(x)

else:
    x = -1
    b = 9*K
    c = 10%b
    for i in range(1,K+1):
        if c ==1:
            x = i
            break
        c = (c*10)%b
        #print(c)
    print(x)
Buggy code:
K = int(input())

n = 0
for i in range(1,K+1):
    n = (n*10 + 7)%K
    if n == 0:
        print("%d",i)
        break

else:
    print(-1)

Fixed code:
K = int(input())

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

else:
    print(-1)
Buggy code:
import sys
K=int(input())
if K%2==0 or K%5==0:
    print('-1')
    sys.exit()
i=1
K=9*K

while(1):
    if 7*(10**i-1)%K==0:
        print(i)
        sys.exit()
    i+=1

Fixed code:
import sys
K=int(input())
if K%2==0 or K%5==0:
    print('-1')
    sys.exit()
i=1
K=9*K
ans=10-K

while(1):
    if 7*(ans-1)%K==0:
        print(i)
        sys.exit()
    i+=1
    ans=ans*10%K
Buggy code:
#https://atcoder.jp/contests/abc174/tasks/abc174_c

K= int(input(" "))

B= 7

if K%2==0 or K%5==0:
    print(-1)
elif K==1 or K==7:
    print(1)
else:
    i = 1
    while 1:
        i= i+1
        B = 10*B + 7
        if B%K==0:
            print(i)
            break

Fixed code:
#https://atcoder.jp/contests/abc174/tasks/abc174_c
K= int(input())

if K%2==0 or K%5==0:
    print(-1)
elif K==1 or K==7:
    print(1)
else:
    B = 7
    i = 1
    while 1:
        if B==0:
            print(i)
            break
        else:
            B = (10 * B + 7) % K
            i = i + 1