Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
n = input()
op_cnt = len(n) - 1  # すき間の個数
for i in range(2 ** op_cnt):
    op = ["-"] * op_cnt  # あらかじめ ["-", "-", "-"] というリストを作っておく
    for j in range(op_cnt):
        if ((i >> j) & 1):
            op[op_cnt - 1 - j] = "+"  # フラグが立っていた箇所を "+" で上書き

    formula = ""
    for p_n, p_o in zip(n, op + [""]):  # 少々モヤッとする
        formula += (p_n + p_o)
    if eval(formula) == 7:
        print(formula + "=7")
        break

Fixed submission:
n = list(raw_input())
operators = ["+", "-"]
total = None
for op1 in operators:
    for op2 in operators:
        for op3 in operators:
            total = n[0] + op1 + n[1] + op2 + n[2] + op3 + n[3]
            if eval(total) == 7:
                total = total + "=7"
                print(total)
                exit(0)
Buggy python submission (verdict: Runtime Error):
strings = raw_input().split()
cand = [5, 7, 5]

for i in range(len(cand)):
    for j in range(len(strings)):
        if cand[i] == int(strings[j]):
            cand.pop(i)
print(len(cand)==0)

Fixed submission:
from collections import defaultdict
strings = raw_input().split()
# a, b, c = int(strings[0]), int(strings[1]), int(strings[2])
cand = {
    '5': 2,
    '7': 1
}
source = defaultdict(int)
for i in range(len(strings)):
    if strings[i] == '5':
        if source[strings[i]]:
            source[strings[i]] += 1
        else:
            source[strings[i]] = 1
    elif strings[i] == '7':
        if source[strings[i]]:
            source[strings[i]] += 1
        else:
            source[strings[i]] = 1
if source == cand:
    print "YES"
else:
    print "NO"
Buggy python submission (verdict: Time Limit Exceeded):
from fractions import gcd

MOD = 1000000007

def LCM(a, b):
    return a * b // gcd(a, b)

N = int(input())
A = list(map(int, input().split()))

lcm = 1
for i in A: lcm = LCM(lcm, i)

ans = 0
for i in A:
    ans += lcm // i
    ans %= MOD

print(ans)

Fixed submission:
from fractions import gcd

MOD = 1000000007

N = int(input())
A = list(map(int, input().split()))

lcm = 1
for i in A: lcm = lcm * i // gcd(lcm, i)

ans = 0
for i in A: ans += lcm // i

print(ans % MOD)

Buggy python submission (verdict: Time Limit Exceeded):
import fractions

MOD = 1000000007

def LCM(a, b):
    gcd = fractions.gcd(a, b)
    return a * b // gcd

N = int(input())
A = list(map(int, input().split()))

lcm = 1
for i in A: lcm = LCM(lcm, i)

ans = 0
for i in A:
    ans += lcm // i
    ans %= MOD

print(ans)

Fixed submission:
from fractions import gcd

MOD = 1000000007

N = int(input())
A = list(map(int, input().split()))

lcm = 1
for i in A: lcm = lcm * i // gcd(lcm, i)

ans = 0
for i in A: ans += lcm // i

print(ans % MOD)

Buggy python submission (verdict: Time Limit Exceeded):
import fractions

MOD = 1000000007
inv = [1] * 1001001

def LCM(a, b):
    gcd = fractions.gcd(a, b)
    return a * b // gcd

N = int(input())
A = list(map(int, input().split()))

for i in range(2, 1001001):
    inv[i] = MOD - inv[MOD % i] * (MOD // i) % MOD

lcm = 1
for i in A:
    lcm = LCM(lcm, i)

ans = 0
for i in A:
    ans += lcm // i
    ans %= MOD

print(ans)

Fixed submission:
from fractions import gcd

MOD = 1000000007

N = int(input())
A = list(map(int, input().split()))

lcm = 1
for i in A: lcm = lcm * i // gcd(lcm, i)

ans = 0
for i in A: ans += lcm // i

print(ans % MOD)

Buggy python submission (verdict: Runtime Error):
import math

MOD = 1000000007
inv = [1] * 1001001

def LCM(a, b):
    gcd = math.gcd(a, b)
    return a * b // gcd

N = int(input())
A = list(map(int, input().split()))

for i in range(2, 1001001):
    inv[i] = MOD - inv[MOD % i] * (MOD // i) % MOD

lcm = 1
for i in A:
    lcm = LCM(lcm, i)

ans = 0
for i in A:
    ans += lcm // i
    ans %= MOD

print(ans)

Fixed submission:
from fractions import gcd

MOD = 1000000007

N = int(input())
A = list(map(int, input().split()))

lcm = 1
for i in A: lcm = lcm * i // gcd(lcm, i)

ans = 0
for i in A: ans += lcm // i

print(ans % MOD)
Buggy python submission (verdict: Runtime Error):
N = int(input())
if N % 2: print(0)
else:
  ans = 0
  N //= 2
  while n > 0:
    ans += N // 5
    N //= 5
	print(ans)

Fixed submission:
N = int(input())
if N % 2:
  print(0)
else:
  ans = 0
  N //= 2
  while N > 0:
    ans += N // 5
    N //= 5
  print(ans)
Buggy python submission (verdict: Runtime Error):
N = int(input())
A = list(map(int, input().split()))
ans = 0
while 1:
  if A.all(0): break
  for i in A: i //= 2
print(ans)

Fixed submission:
N = int(input())
A = list(map(int, input().split()))

ans = 0

while True:
	for i in range(N):
		if A[i] % 2 != 0:
			print(ans)
			exit()
		A[i] //= 2
	ans += 1
Buggy python submission (verdict: Runtime Error):
N = int(input())
S = int(input())

def f(B, N):
    X, res = N, 0
    while 0 < X:
        res += X % B
        X //= B
    return res


if N == S:
    print(N + 1)
    exit()

for i in range(2, N):
    if N < i * i: break
    if f(i, N) == S:
        print(i)
        exit()

for i in range(1, N):
    if N < i * i: break
    b = (N - S) // i + 1
    if f(b, N) == S:
        print(b)
        exit()

print(-1)

Fixed submission:
import math

N = int(input())
S = int(input())

def f(B, N):
    X, res = N, 0
    while 0 < X:
        res += X % B
        X //= B
    return res


if N == S:
    print(N + 1)
    exit()

i = 2
while i * i <= N:
    if f(i, N) == S:
        print(i)
        exit()
    i += 1

sqrtN = math.floor(math.sqrt(N))
i = 1
ans = []
while i * i < N:
    if (N - S) % i != 0:
        i += 1
        continue
    b = (N - S) // i + 1
    if sqrtN < b and f(b, N) == S:
        ans.append(b)
    i += 1

print(-1 if len(ans) == 0 else min(ans))
Buggy python submission (verdict: Runtime Error):
import math

a = int(input())
b = float(input())

print(math.floor(a*b))

Fixed submission:
li = input().split()
a = int(li[0])
b = str(li[1])
b = int(b.replace('.',''))

print(a*b//100)
Buggy python submission (verdict: Time Limit Exceeded):
H, N = map(int, input().split())
magic = []
for _ in range(N):
    A, B = map(int, input().split())
    magic.append((A,B))

dp = [10**10] * (H+1)
dp[0] = 0
for i in range(1,H+1):
    for m in magic:
        if m[0] > i:
            dp[i] = min(dp[i], m[1])
        else:
            dp[i] = min(dp[i], dp[i-m[0]]+m[1])

print(dp[H])

Fixed submission:
H, N = map(int, input().split())
magic = []
for _ in range(N):
    A, B = map(int, input().split())
    magic.append((A,B))

dp = [10**10] * (H+1)
dp[0] = 0
for i in range(1,H+1):
    for m in magic:
        if m[0] > i:
            dp[i] = min(dp[i], m[1])
        else:
            dp[i] = min(dp[i], dp[i-m[0]]+m[1])

print(dp[H])
Buggy python submission (verdict: Runtime Error):
N = int(input())

pos = []
for _ in range(N):
    tmp = tuple(map(int, input().split()))
    pos.append(tmp)

pos.sort()

dic = dict()
for i in range(N):
    for j in range(i+1,N):
        distance = (pos[j][0]-pos[i][0], pos[j][1]-pos[i][1])
        #print(f'{distance=}')
        if distance in dic:
            dic[distance] += 1
        else:
            dic[distance] = 1

max_frenquency = max(dic.values())

print(N-max_frenquency)

Fixed submission:
N = int(input())

pos = []
for _ in range(N):
    tmp = tuple(map(int, input().split()))
    pos.append(tmp)

pos.sort()

dic = dict()
for i in range(N):
    for j in range(i+1,N):
        distance = (pos[j][0]-pos[i][0], pos[j][1]-pos[i][1])
        #print(f'{distance=}')
        if distance in dic:
            dic[distance] += 1
        else:
            dic[distance] = 1
if dic :
    max_frenquency = max(dic.values())

    print(N-max_frenquency)
else:
    print(N)
Buggy python submission (verdict: Runtime Error):

def solve(index: int, dp: list, footing: list) -> int:
    if dp[index] != -1:
        return dp[index]

    if index == 0:
        return 0
    elif index == 1:
        return abs(footing[1]-footing[0])

    tmp = min(solve(index-1, dp, footing)+abs(footing[index]-footing[index-1]), solve(index-2, dp, footing)+abs(footing[index]-footing[index-2]))
    #print(f'{tmp=}')
    dp[index] = tmp
    return tmp

N = int(input())
footing = list(map(int, input().split()))

dp = [-1] * N

ans = solve(N-1, dp, footing)

print(ans)

Fixed submission:
import sys
sys.setrecursionlimit(10 ** 7)

def solve(index: int, dp: list, footing: list) -> int:
    if dp[index] != -1:
        return dp[index]

    if index == 0:
        return 0
    elif index == 1:
        return abs(footing[1]-footing[0])

    tmp = min(solve(index-1, dp, footing)+abs(footing[index]-footing[index-1]), solve(index-2, dp, footing)+abs(footing[index]-footing[index-2]))
    #print(f'{tmp=}')
    dp[index] = tmp
    return tmp

N = int(input())
footing = list(map(int, input().split()))

dp = [-1] * N

ans = solve(N-1, dp, footing)

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N, W = map(int, input().split())

items = [list(map(int, input().split())) for _ in range(N)]

dp = [[0] * (W+1) for _ in range(N+1)]

for i in range(1,N+1):
    for j in range(W+1):
        dp[i][j] = dp[i-1][j]
        if items[i-1][0] <= j:
            dp[i][j] = max(dp[i][j], dp[i-1][j-items[i-1][0]] + items[i-1][1])

print(dp[N][W])


Fixed submission:
N, W = map(int, input().split())

items = [list(map(int, input().split())) for _ in range(N)]

dp = [[0] * (W+1) for _ in range(N+1)]

for i in range(1,N+1):
    for j in range(W+1):
        dp[i][j] = dp[i-1][j]
        if items[i-1][0] <= j:
            dp[i][j] = max(dp[i][j], dp[i-1][j-items[i-1][0]] + items[i-1][1])

print(dp[N][W])
Buggy python submission (verdict: Runtime Error):

def search(index: int, dp: list, graph: list) -> int:
    if dp[index] != -1:
        return dp[index]+1

    tmp = 0
    for d in graph[index]:
        tmp = max(tmp, search(d, dp, graph))

    dp[index] = tmp
    return tmp+1


N, M = map(int, input().split())

graph = [ [] for _ in range(N)]
dp = [-1 for _ in range(N)]

for _ in range(M):
    x, y = map(int, input().split())
    graph[x-1].append(y-1)

ans = 0
for i in range(N):
    ans = max(ans, search(i, dp, graph))

print(ans-1)

Fixed submission:
import sys
sys.setrecursionlimit(10 ** 7)

def search(index: int, dp: list, graph: list) -> int:
    if dp[index] != -1:
        return dp[index]+1

    tmp = 0
    for d in graph[index]:
        tmp = max(tmp, search(d, dp, graph))

    dp[index] = tmp
    return tmp+1


N, M = map(int, input().split())

graph = [ [] for _ in range(N)]
dp = [-1 for _ in range(N)]

for _ in range(M):
    x, y = map(int, input().split())
    graph[x-1].append(y-1)

ans = 0
for i in range(N):
    ans = max(ans, search(i, dp, graph))

print(ans-1)
Buggy python submission (verdict: Time Limit Exceeded):
N, M = map(int, input().split())

upper = M // N

ans = None
for i in reversed(range(1,upper+1)):
    if M % i == 0:
        ans = i
        break

print(ans)

Fixed submission:
import bisect

N, M = map(int, input().split())

vector = []

i = 1
while i * i <= M:
    if M%i == 0:
        vector.append(i)
        vector.append(M//i)
    i+=1

vector.sort()

bottom = M//N
index = bisect.bisect_right(vector, bottom)

ans = vector[index-1]
print(ans)
Buggy python submission (verdict: Runtime Error):

def search(start: int, visited: list, power: list, min_power: int, min_powers: int) -> int:
    minimum = 10**4
    if min_powers[start] != -1:
        return min_powers[start] + min_power
    if visited[1] == True:
        #print(f'{min_power=}')
        return min_power
    for i, v in enumerate(visited):
        if not v:
            visited[i] = True
            min_power += power[start][i]

            #min_powers[i] = search(i,visited,power,min_power,min_powers)
            minimum = min(minimum, search(i,visited,power,min_power,min_powers))

            visited[i] = False
            min_power -= power[start][i]
            #print(f'{minimum=}')
    return minimum


H, W = map(int, input().split())

power = [[] for _ in range(10)]

for i in range(10):
    power[i] = list(map(int, input().split()))

world = [[] for _ in range(H)]

for i in range(H):
    world[i] = list(map(int, input().split()))

min_powers = [-1] * 10
visited = [False] * 10

#print(f'{power[8][4]=}')
for i in range(10):
    min_power = 0
    visited[i] = True
    min_powers[i] = search(i,visited,power,min_power,min_powers)
    visited[i] = False
    #visited = [False] * 10
for i in range(10):
    #pass
    print(f'{i=}, {min_powers[i]=}')
ans = 0
for wor in world:
    for w in wor:
        if w != -1:
            ans += min_powers[w]

print(ans)


Fixed submission:

def search(start: int, visited: list, power: list, min_power: int, min_powers: int) -> int:
    minimum = 10**4
    if min_powers[start] != -1:
        return min_powers[start] + min_power
    if visited[1] == True:
        #print(f'{min_power=}')
        return min_power
    for i, v in enumerate(visited):
        if not v:
            visited[i] = True
            min_power += power[start][i]

            #min_powers[i] = search(i,visited,power,min_power,min_powers)
            minimum = min(minimum, search(i,visited,power,min_power,min_powers))

            visited[i] = False
            min_power -= power[start][i]
            #print(f'{minimum=}')
    return minimum


H, W = map(int, input().split())

power = [[] for _ in range(10)]

for i in range(10):
    power[i] = list(map(int, input().split()))

world = [[] for _ in range(H)]

for i in range(H):
    world[i] = list(map(int, input().split()))

min_powers = [-1] * 10
visited = [False] * 10

#print(f'{power[8][4]=}')
for i in range(10):
    min_power = 0
    visited[i] = True
    min_powers[i] = search(i,visited,power,min_power,min_powers)
    visited[i] = False
    #visited = [False] * 10
for i in range(10):
    pass
    #print(f'{i=}, {min_powers[i]=}')
ans = 0
for wor in world:
    for w in wor:
        if w != -1:
            ans += min_powers[w]

print(ans)
Buggy python submission (verdict: Runtime Error):
import sympy

def count_divisor(num: int) -> int:
    i =1 
    count = 0
    while i * i < num:
        if num % i == 0:
            count += 2
        i += 1
    if num % i == 0:
        count += 1
    return count

M = 10**9+7
N = int(input())

data = [0] * (N+1)
i = N
while i > 0:
    dic = sympy.factorint(i)
    for k, v in dic.items():
        data[k] += v
    i -= 1

ans = 1
for d in data:
    if d != 0:
        ans = ans * (d+1) % M
        ans %= M

print(ans)


Fixed submission:
#import sympy

def count_divisor(num: int) -> int:
    i =1 
    count = 0
    while i * i < num:
        if num % i == 0:
            count += 2
        i += 1
    if num % i == 0:
        count += 1
    return count

def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

M = 10**9+7
N = int(input())

data = [0] * (N+1)
i = N
while i > 0:
    #dic = sympy.factorint(i)
    lis = factorization(i)
    #for k, v in dic.items():
    #    data[k] += v
    for li in lis:
        k, v = li
        data[k] += v 
    i -= 1

ans = 1
data[1] = 0
for d in data:
    if d != 0:
        ans = ans * (d+1) % M
        ans %= M

print(ans)
#print(factorization(1))
#print(sympy.factorint(1))
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = [int(i) for i in input().split()]

for i in range(1, N):
    print(A.count(i))
print(0)

Fixed submission:
N = int(input())
A = [int(i) for i in input().split()]

P = [0]*N
for i in range(N-1):
    P[A[i]-1] += 1

for i in range(N):
    print(P[i])

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = [int(i) for i in input().split()]
B = sorted(A)
for i in range(N-1):
    print(B.count(i+1))
print(0)

Fixed submission:
N = int(input())
A = [int(i) for i in input().split()]

P = [0]*N
for i in range(N-1):
    P[A[i]-1] += 1

for i in range(N):
    print(P[i])

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = [int(i) for i in input().split()]

for i in range(N-1):
    print(A.count(i+1))
print(0)

Fixed submission:
N = int(input())
A = [int(i) for i in input().split()]

P = [0]*N
for i in range(N-1):
    P[A[i]-1] += 1

for i in range(N):
    print(P[i])
Buggy python submission (verdict: Time Limit Exceeded):
import math
K = int(input())
ans = 0
num = range(1, K+1)
for a in num:
    for b in num:
        for c in num:
            ans += math.gcd(math.gcd(a, b), c)

print(ans)

Fixed submission:
import math
K = int(input())
ans = 0

for a in range(1, K+1):
    for b in range(a, K+1):
        for c in range(b, K+1):
            s = math.gcd(a, b)
            t = math.gcd(s, c)
            if a == c:
                ans += t
            elif (a == b or b == c) and a != c:
                ans += 3*t
            else:
                ans += 6*t
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import math
K = int(input())
ans = 0
for a in range(1, K+1):
    for b in range(1, K+1):
        for c in range(1, K+1):
            s = math.gcd(a, b)
            ans += math.gcd(s, c)

print(ans)

Fixed submission:
import math
K = int(input())
ans = 0

for a in range(1, K+1):
    for b in range(a, K+1):
        for c in range(b, K+1):
            s = math.gcd(a, b)
            t = math.gcd(s, c)
            if a == c:
                ans += t
            elif (a == b or b == c) and a != c:
                ans += 3*t
            else:
                ans += 6*t
print(ans)

Buggy python submission (verdict: Runtime Error):
[N, K] = [int(i) for i in input().split()]
print(min(N%K, -N%K))

Fixed submission:
import math
K = int(input())
ans = 0

for a in range(1, K+1):
    for b in range(a, K+1):
        for c in range(b, K+1):
            s = math.gcd(a, b)
            t = math.gcd(s, c)
            if a == c:
                ans += t
            elif (a == b or b == c) and a != c:
                ans += 3*t
            else:
                ans += 6*t
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
S = [input() for _ in range(N)]

T = list(set(S))
t = 1
U = []
for i in range(len(T)):
    x = S.count(T[i])
    if t < x:
        t = x
        U = [T[i]]
    elif t == x:
        U.append(T[i])

U_ = list(sorted(U))
for i in range(len(U_)):
    print(U_[i])

Fixed submission:
N = int(input())
dic = {}
for i in range(N):
    s = str(input())
    if s in dic:
        dic[s] += 1
    else:
        dic[s] = 1

S = sorted(dic.values())
t = S[-1]

X = []
for key in dic:
    if dic[key] == t:
        X.append(key)
x = sorted(X)

for i in range(len(X)):
    print(x[i])

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
S = []
for i in range(N):
    s = str(input())
    S.append(s)

T = list(set(S))
t = 1
U = []
for i in range(len(T)):
    x = S.count(T[i])
    if t < x:
        t = x
        U = [T[i]]
    elif t == x:
        U.append(T[i])

U_ = list(sorted(U))
for i in range(len(U_)):
    print(U_[i])

Fixed submission:
N = int(input())
dic = {}
for i in range(N):
    s = str(input())
    if s in dic:
        dic[s] += 1
    else:
        dic[s] = 1

S = sorted(dic.values())
t = S[-1]

X = []
for key in dic:
    if dic[key] == t:
        X.append(key)
x = sorted(X)

for i in range(len(X)):
    print(x[i])

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
S = []
for i in range(N):
    s = str(input())
    S.append(s)

T = list(set(S))
t = 1
U = []
for i in range(len(T)):
    if t < S.count(T[i]):
        t = S.count(T[i])
        U = [T[i]]
    elif t == S.count(T[i]):
        U.append(T[i])

U_ = list(sorted(U))
for i in range(len(U_)):
    print(U_[i])

Fixed submission:
N = int(input())
dic = {}
for i in range(N):
    s = str(input())
    if s in dic:
        dic[s] += 1
    else:
        dic[s] = 1

S = sorted(dic.values())
t = S[-1]

X = []
for key in dic:
    if dic[key] == t:
        X.append(key)
x = sorted(X)

for i in range(len(X)):
    print(x[i])
Buggy python submission (verdict: Runtime Error):
[H, A] = [int(i) for i in input().split()]
t = 0
if H/A != int(H/A):
    t = 1
print(int(H/A) + t)

Fixed submission:
[S, T] = [str(i) for i in input().split()]
[A, B] = [int(i) for i in input().split()]
U = str(input())

if S == U:
    print(A-1, B)
else:
    print(A, B-1)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
P = [int(i) for i in input().split()]

t = 0
for i in range(N):
    s = 0
    for j in range(i):
        if P[i] > P[j]:
            s += 1
            break
    if s == 0:
        t += 1

print(t)

Fixed submission:
N = int(input())
P = [int(i) for i in input().split()]

p = N
ans = 0
for i in range(N):
    if p >= P[i]:
        ans += 1
        p = P[i]

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n , k = map(int , input().split())
arr = list(map(int , input().split()))
tot=1
for i in range(0 , k):
	tot = tot*arr[i]
j = 0
for i in range(k , n):
	now = tot*arr[i]
	now = now//arr[j]
	j=j+1
	if now>tot:
		print("Yes")
	else:
		print("No")


Fixed submission:
import math
n , k = map(int , input().split())
arr = list(map(int , input().split()))
tot=0
for i in range(0 , k):
	tot = tot + (math.log2(arr[i]))
j = 0
for i in range(k , n):
	now = tot + math.log2(arr[i])
	now = now-math.log2(arr[j])
	j=j+1
	if now>tot:
		print("Yes")
	else:
		print("No")
Buggy python submission (verdict: Time Limit Exceeded):
n=map(int , input())
arr=list(map(int , input().split()))
p=1000000000000000000
f=0
res=1
for i in arr:
	res=res*i
	if res>p:
		f=1
if res==0:
	print(res)
elif f:
	print(-1)
else:
	print(res)	

Fixed submission:
n=map(int , input())
arr=list(map(int , input().split()))
p=1000000000000000000
f=0
res=1
arr.sort()
for i in arr:
	res=res*i
	if res==0:
		break
	if res>p:
		f=1
		break
if res==0:
	print(res)
elif f:
	print(-1)
else:
	print(res)
Buggy python submission (verdict: Time Limit Exceeded):
def solve(k):
    a_mod = 0
    for i in range(1000000):
        a_mod += 7 * pow(10, i, k)
        a_mod %= k
        if a_mod == 0:
            return i + 1
    return -1


def main():
    k = int(input())
    res = solve(k)
    print(res)


def test():
    assert solve(101) == 4
    assert solve(2) == -1
    assert solve(999983) == 999982


if __name__ == "__main__":
    test()
    main()


Fixed submission:
def solve(k):
    a_mod = 0
    for i in range(1000000):
        a_mod += 7 * pow(10, i, k)
        a_mod %= k
        if a_mod == 0:
            return i + 1
    return -1


def main():
    k = int(input())
    res = solve(k)
    print(res)


def test():
    assert solve(101) == 4
    assert solve(2) == -1
    assert solve(999983) == 999982


if __name__ == "__main__":
    test()
    main()