Buggy python submission (verdict: Time Limit Exceeded):
K = int(input())
res = '-1'
a = 0
for n in range(K):
  a += 7*(10**n)
  if a%K==0:
    res = n+1
    break
print(res)


Fixed submission:
K = int(input())
ans = '-1'
mod = 7%K
path = [mod]
for i in range(1,K+1):
  if mod == 0:
    ans = i
    break
  mod = (mod*10 + 7)%K
  path.append(mod)
  if mod == path[0]:
    ans = '-1'
    break
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
K = int(input())
res = '-1'
a = 0
for n in range(K):
  a += 7*(10**n)
  if a%K==0:
    res = n+1
    break
print(res)


Fixed submission:
K = int(input())
ans = '-1'
mod = 7%K
path = [mod]
for i in range(1,K+1):
  if mod == 0:
    ans = i
    break
  mod = (mod*10 + 7)%K
  path.append(mod)
  if mod == path[0]:
    ans = '-1'
    break
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
K = int(input())
a = 0
out = '-1'
for n in range(K):
  a += 7 * (10 ** n)
  if a % K == 0:
    out = n + 1
    break
print(out)


Fixed submission:
K = int(input())
ans = '-1'
mod = 7%K
path = [mod]
for i in range(1,K+1):
  if mod == 0:
    ans = i
    break
  mod = (mod*10 + 7)%K
  path.append(mod)
  if mod == path[0]:
    ans = '-1'
    break
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
K = int(input())
a = 0
out = '-1'
for n in range(K):
  a += 7 * (10 ** n)
  if a % K == 0:
    out = n + 1
    break
print(out)

Fixed submission:
K = int(input())
ans = '-1'
mod = 7%K
path = [mod]
for i in range(1,K+1):
  if mod == 0:
    ans = i
    break
  mod = (mod*10 + 7)%K
  path.append(mod)
  if mod == path[0]:
    ans = '-1'
    break
print(ans)

Buggy python submission (verdict: Runtime Error):
K = int(input())
a = [0]
out = '-1'
for n in range(1, K):
  a.append((a[n-1] + 7 * (10 ** (n-1)))%K)
for i in range(1, K):
  if a[i] == 0:
    out = i
  	break
print(out)

Fixed submission:
K = int(input())
ans = '-1'
mod = 7%K
path = [mod]
for i in range(1,K+1):
  if mod == 0:
    ans = i
    break
  mod = (mod*10 + 7)%K
  path.append(mod)
  if mod == path[0]:
    ans = '-1'
    break
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
K = int(input())
a = 0
out = '-1'
for n in range(K):
  a += 7 * (10 ** n)
  if a % K == 0:
    out = n + 1
    break
print(out)

Fixed submission:
K = int(input())
ans = '-1'
mod = 7%K
path = [mod]
for i in range(1,K+1):
  if mod == 0:
    ans = i
    break
  mod = (mod*10 + 7)%K
  path.append(mod)
  if mod == path[0]:
    ans = '-1'
    break
print(ans)

Buggy python submission (verdict: Runtime Error):
K = int(input())
a = 0
n = 0
out = -1
for _ in range(K):
  a += 7 * (10 ** n)
  if a % K == 0:
    out = n + 1
    break
return print(out)


Fixed submission:
K = int(input())
ans = '-1'
mod = 7%K
path = [mod]
for i in range(1,K+1):
  if mod == 0:
    ans = i
    break
  mod = (mod*10 + 7)%K
  path.append(mod)
  if mod == path[0]:
    ans = '-1'
    break
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
K = int(input())
a = 0
n = 0
out = -1
while True:
  a += 7 * (10 ** n)
  if a % K == 0:
    out = n + 1
    print(out)
    break
  n += 1

Fixed submission:
K = int(input())
ans = '-1'
mod = 7%K
path = [mod]
for i in range(1,K+1):
  if mod == 0:
    ans = i
    break
  mod = (mod*10 + 7)%K
  path.append(mod)
  if mod == path[0]:
    ans = '-1'
    break
print(ans)