Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
n = int(input())
numbers = list(map(int,input().split()))
p = numbers[0]
a, b = 0, 0
if p > 0:
    q = -1
    b = p + 1
elif p < 0:
    q = 1
    b = -p + 1
    
for i in range(1, n):
    if p > 0:
        p += numbers[i]
        if p >= 0:
            a += (p + 1)
            p -= (p + 1)
    else:
        p += numbers[i]
        if p <= 0:
            a -= (p - 1)
            p -= (p - 1)

for j in range(1, n):
    if q > 0:
        q += numbers[j]
        if q >= 0:
            b += (q + 1)
            q -= (q + 1)
    else:
        q += numbers[j]
        if q <= 0:
            b -= (q - 1)
            q -= (q - 1)


print(min(a, b))

Fixed submission:
n = int(input())
numbers = list(map(int,input().split()))
p = numbers[0]
a, b = 0, 0
if p > 0:
    q = -1
    b = p + 1
elif p < 0:
    q = 1
    b = -p + 1
else:
    p, q = 1, -1
    a, b = 1, 1
    
for i in range(1, n):
    if p > 0:
        p += numbers[i]
        if p >= 0:
            a += (p + 1)
            p -= (p + 1)
    else:
        p += numbers[i]
        if p <= 0:
            a -= (p - 1)
            p -= (p - 1)

for j in range(1, n):
    if q > 0:
        q += numbers[j]
        if q >= 0:
            b += (q + 1)
            q -= (q + 1)
    else:
        q += numbers[j]
        if q <= 0:
            b -= (q - 1)
            q -= (q - 1)


print(min(a, b))
Buggy python submission (verdict: Runtime Error):
n = int(input())
nums = list(map(int,input().split()))
ans = 1

if nums[1] >= nums[0]:
    flag = 1
else:
    flag = 2

i = 1
while i < n:
    if flag == 0:
        if nums[i] > nums[i-1]:
            flag = 1
            ans += 1
        else:
            flag = 2
            ans += 1

    elif flag == 1:
        if nums[i] < nums[i-1]:
            flag = 0
            if i == n-1:
                ans += 1
    elif flag == 2:
        if nums[i] > nums[i-1]:
            flag = 0
            if i == n-1:
                ans += 1

    i += 1

print(ans)

Fixed submission:
n = int(input())
nums = list(map(int,input().split()))
ans = 0
i = 0

while i < n:
    j, k = i, i
    while j < n - 1 and nums[j] <= nums[j+1]:
        j += 1
    while k < n - 1 and nums[k] >= nums[k+1]:
        k += 1
    i = max(j , k) + 1
    ans += 1
print(ans)
Buggy python submission (verdict: Runtime Error):
N = int(input())
p = N // 15
print(N*800 - P*200)

Fixed submission:
N = int(input())
p = N // 15
print(N*800 - p*200)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
p = 1
for i in range(1,N+1):
    p *= i
print(p % 1000000007)

Fixed submission:
import math
N = int(input())
p = math.factorial(N)
print(p % 1000000007)
Buggy python submission (verdict: Runtime Error):
import sympy


Fixed submission:
n = int(input())
ans = 1
r = [1] * (n + 1)
s = n


for i in range(1, n + 1):
    p = i
    while p % 2 == 0:
        p = p // 2
        r[1] += 1

    for j in range(3, i + 1, 2):
        while p % j == 0:
            p = p // j
            r[j-1] += 1

for k in range(n+1):
    ans *= r[k]

ans = ans % (10 ** 9 + 7)
print(ans)

Buggy python submission (verdict: Runtime Error):
import sympy
N = int(input())
p = 1
for i in range(1, N+1):
    p *= i
ans = sympy.divisor_count(p)
print(ans % (10**9+7))

Fixed submission:
n = int(input())
ans = 1
r = [1] * (n + 1)
s = n


for i in range(1, n + 1):
    p = i
    while p % 2 == 0:
        p = p // 2
        r[1] += 1

    for j in range(3, i + 1, 2):
        while p % j == 0:
            p = p // j
            r[j-1] += 1

for k in range(n+1):
    ans *= r[k]

ans = ans % (10 ** 9 + 7)
print(ans)
Buggy python submission (verdict: Runtime Error):
K, S = map(int,input())
print(S//K)

Fixed submission:
K, S = map(int,input().split())
ans = 0
for i in range(K+1):
    for j in range(K+1):
            if 0 <= S - i - j <= K:
                ans += 1
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
from fractions import Fraction
n = int(input())
nums = [list(map(int,input().split())) for _ in range(n)]
a, b = nums[0][0], nums[0][1]
for i in range(1, n):
    if a / nums[i][0] != b / nums[i][1]:
        p, q = nums[i][0], nums[i][1]
        if a > p or b > q:
            j = 2
            while p < a or q < b:
                p = nums[i][0] * j
                q = nums[i][1] * j
                j += 1
        a, b = p, q
        
print(a + b)

Fixed submission:
from math import ceil
from fractions import Fraction
n = int(input())
nums = [list(map(int,input().split())) for _ in range(n)]
a, b = 1, 1
p = 1
for i in range(n):
    x, y = nums[i][0], nums[i][1]
    p = ceil(max(Fraction(a, x), Fraction(b, y)))
    a, b = p * x, p * y
        
print(a + b)

Buggy python submission (verdict: Time Limit Exceeded):
from fractions import Fraction
n = int(input())
nums = [list(map(int,input().split())) for _ in range(n)]
a, b = nums[0][0], nums[0][1]
for i in range(1, n):
    if a / nums[i][0] != b / nums[i][1]:
        p, q = nums[i][0], nums[i][1]
        while p < a or q < b:
            p += nums[i][0]
            q += nums[i][1]
        a, b = p, q
        
print(a + b)

Fixed submission:
from math import ceil
from fractions import Fraction
n = int(input())
nums = [list(map(int,input().split())) for _ in range(n)]
a, b = 1, 1
p = 1
for i in range(n):
    x, y = nums[i][0], nums[i][1]
    p = ceil(max(Fraction(a, x), Fraction(b, y)))
    a, b = p * x, p * y
        
print(a + b)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
nums = [int(input()) for _ in range(n)]
standard = nums[:]
standard.sort()
ans = 0

for i in range(n):
    p = nums[i]
    x = standard.index(p)
    if abs(x - i) % 2 == 1:
        ans += 1

print(ans // 2)

Fixed submission:
n = int(input())
nums = [[int(input()), i] for i in range(n)]
nums.sort()
ans = 0

for i in range(n):
    if abs (i - nums[i][1]) % 2 == 1:
        ans += 1

print(ans // 2)
Buggy python submission (verdict: Time Limit Exceeded):
from sys import stdin, stdout
import heapq
import cProfile
from collections import Counter, defaultdict, deque
from functools import reduce
import math
import string

def get_int():
    return int(stdin.readline().strip())


def get_tuple():
    return map(int, stdin.readline().split())


def get_list():
    return list(map(int, stdin.readline().split()))

n,k = get_tuple()
ls = get_list()
i = 0
prod = 1
j = 0
start = ls[j]
while i<k:
    prod *= ls[i]
    i += 1

while i<n:
    oldprod = prod
    prod = int(prod/ls[j])
    prod *= ls[i]
    if oldprod>=prod:
        print("No")
    else:
        print("Yes")

    i += 1
    j += 1



Fixed submission:
from sys import stdin, stdout
import heapq
import cProfile
from collections import Counter, defaultdict, deque
from functools import reduce
import math
import string

def get_int():
    return int(stdin.readline().strip())


def get_tuple():
    return map(int, stdin.readline().split())


def get_list():
    return list(map(int, stdin.readline().split()))

n,k = get_tuple()
ls = get_list()
j = 0
i = k
while i<n:
    if ls[j]>=ls[i]:
        print("No")
    else:
        print("Yes")
    i += 1
    j += 1
Buggy python submission (verdict: Time Limit Exceeded):
from collections import defaultdict
import math
k= int(input())
ans = 0
dic = defaultdict(int)
for a in range(1,k+1):
    for b in range(1,k+1):
        for c in range(1,k+1):
            if (a,b) not in dic:
                x = math.gcd(a,b)
                dic[(a,b)] = x
            x = dic[(a,b)]
            if (x,c) not in dic:
                x = math.gcd(x,c)
                dic[(x,c)] = x
            ans += dic[(x,c)]
print(ans)


Fixed submission:
import math
k= int(input())
ans = 0
for a in range(1,k+1):
    for b in range(1,k+1):
        x = math.gcd(a,b)
        for c in range(1,k+1):
            ans += math.gcd(x,c)
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):
            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(1,k+1):
        x = math.gcd(a,b)
        for c in range(1,k+1):
            ans += math.gcd(x,c)
print(ans)
Buggy python submission (verdict: Runtime Error):
import math
n,k = map(int,input().strip().split())
x = min(math.gcd(n,k),n,k)
f = 1
while f:
    if abs(x-k)<x:
        x = abs(x-k)
        f = 1
    else:
        f = 0
print(x)


Fixed submission:
import math
n,k = map(int,input().strip().split())
f = 1
x = n
while True:
    if x>k:
        poss = x//k
        x = x-poss*k
    if abs(x-k)<x:
        x = abs(x-k)
        f = 1
    else:
        break
print(x)
Buggy python submission (verdict: Runtime Error):
import math
a,b,c = map(int,input().strip().split())
l = math.log(4)+math.log(a)+math.log(b)
r = 2*math.log(c-(a+b))
if l<r:
    print("Yes")
else:
    print("No")


Fixed submission:
a,b,c = map(int,input().strip().split())
if c-(a+b)<=0:
    print("No")
else:
    l = 4*a*b
    r = (c**2+(a+b)**2-2*c*(a+b))
    if l<r:
        print("Yes")
    else:
        print("No")
Buggy python submission (verdict: Runtime Error):
import sys
list_a = []
S = input()
T = input()
if T in S:
    print(0)
    sys.exit()
for i in range(len(S) - len(T)):
    cnt = 0
    for j in range(len(T)):
        if T[j] != S[i + j]:
            cnt += 1
    list_a.append(cnt)
print(min(list_a))

Fixed submission:
S = input()
T = input()
list_a = []
if len(S) - len(T) ==0:
    cnt = 0
    for j in range(len(T)):
        if T[j] != S[j]:
            cnt += 1
    list_a.append(cnt)
else:
    for i in range(len(S) - len(T)):
        cnt = 0
        for j in range(len(T)):
            if T[j] != S[i + j]:
                cnt += 1
        list_a.append(cnt)
print(min(list_a))

Buggy python submission (verdict: Runtime Error):
list_ = []
S = input()
T = input()
for i in range(len(S) - len(T)):
    cnt = 0
    for j in range(len(T)):
        if T[j] != S[i + j]:
            cnt += 1
    list_.append(cnt)
print(min(list_))


Fixed submission:
S = input()
T = input()
list_a = []
if len(S) - len(T) ==0:
    cnt = 0
    for j in range(len(T)):
        if T[j] != S[j]:
            cnt += 1
    list_a.append(cnt)
else:
    for i in range(len(S) - len(T)):
        cnt = 0
        for j in range(len(T)):
            if T[j] != S[i + j]:
                cnt += 1
        list_a.append(cnt)
print(min(list_a))
Buggy python submission (verdict: Runtime Error):
    N, X, T = map(int, input().split())
    if N % X == 0:
        ans = N / X * T
    else:
        ans = (N // X + 1) * T
    print(int(ans))

Fixed submission:
N, X, T = map(int, input().split())
if N % X == 0:
    ans = N / X * T
else:
    ans = (N // X + 1) * T
print(int(ans))
Buggy python submission (verdict: Time Limit Exceeded):
K = int(input())
i = 1

if K % 5 == 0 or K % 2 == 0:
    i = -1

while True:
    if i == -1:
        break
    N = "7" * i
    N = int(N)
    if N % K != 0:
        i += 1
        continue
    else:
        break
print(i)

Fixed submission:
K = int(input())
i = 1

if K % 5 == 0 or K % 2 == 0:
    i = -1
N = 0
while True:
    if i == -1:
        break
    N = (N * 10 + 7)  %K 
    if N % K != 0:
        i += 1
    else:
        break
print(i)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A_list = list(map(int, input().split()))
ans = 1
for i in range(N):
    ans *= A_list[i]
if ans > 10**18:
    ans=-1

print(ans)

Fixed submission:
N = int(input())
A_list = list(map(int, input().split()))
ans = 1
if 0 in A_list:
    ans = 0
else:
    for A in A_list:
        ans *= A
        if ans > 10**18:
            ans=-1
            break

print(ans)
Buggy python submission (verdict: Runtime Error):
import itertools as it

N, M, X = map(int, input().split())
book = [[int(_) for _ in input().split()] for i in range(N)]

combs = it.product([0, 1], repeat=N)
prices = []
for comb in combs:
    # print(comb)
    bag = [0] * M+1
    for i in range(N):
        if comb[i] == 0:
            continue
        else:
            for j in range(M+1):
                bag[j] += book[i][j]

    if min(bag[1:]) < X:
        continue
    else:
        prices.append(bag[0])

if len(prices) == 0:
    print(-1)
else:
    print(min(prices))

Fixed submission:
import itertools as it

N, M, X = map(int, input().split())
book = [[int(_) for _ in input().split()] for i in range(N)]

combs = it.product([0, 1], repeat=N)
prices = []
for comb in combs:
    # print(comb)
    bag = [0] * (M+1)
    for i in range(N):
        if comb[i] == 0:
            continue
        else:
            for j in range(M+1):
                bag[j] += book[i][j]

    if min(bag[1:]) < X:
        continue
    else:
        prices.append(bag[0])

if len(prices) == 0:
    print(-1)
else:
    print(min(prices))

Buggy python submission (verdict: Runtime Error):
import itertools as it
N, M, X = map(int,input().split())
book = [[int(_) for _ in input().split()] for i in range(N)]

combs = it.product([0,1], repeat=N)
prices = []
for comb in combs:
    # print(comb)
    bag = [0]*M
    for i in range(N):
        if comb[i] == 0:
            continue
        else:
            for j in range(M):
                bag[j] += book[i][j]
    
    if min(bag[1:]) < X:
        continue
    else:
        prices.append(bag[0])

if len(prices) == 0:
    print(-1)
else:
    print(min(prices))


Fixed submission:
import itertools as it

N, M, X = map(int, input().split())
book = [[int(_) for _ in input().split()] for i in range(N)]

combs = it.product([0, 1], repeat=N)
prices = []
for comb in combs:
    # print(comb)
    bag = [0] * (M+1)
    for i in range(N):
        if comb[i] == 0:
            continue
        else:
            for j in range(M+1):
                bag[j] += book[i][j]

    if min(bag[1:]) < X:
        continue
    else:
        prices.append(bag[0])

if len(prices) == 0:
    print(-1)
else:
    print(min(prices))
Buggy python submission (verdict: Runtime Error):
S = str(input())
if S=="ABC":
    print("ARC")
elif
    print("ABC")

Fixed submission:
S = str(input())
if S=="ABC":
    print("ARC")
else:
    print("ABC")
Buggy python submission (verdict: Runtime Error):
def main():
    X = int(input())
    Y = int(X**(1/5))+1
    for A in range(-Y,Y):
        for B in range(-Y,Y):
            if A**5 - B**5==X:
                return A,B

if __name__ == "__main__":
    A,B=main()
    print("{} {}".format(A,B))

Fixed submission:
def main():
    X = int(input())
    Y = 2*int(X**(1/5))+1
    for A in range(-Y,Y):
        for B in range(-Y,Y):
            if A**5 - B**5==X:
                return A,B

if __name__ == "__main__":
    A,B=main()
    print("{} {}".format(A,B))
Buggy python submission (verdict: Runtime Error):
N = int(input())
S = []
for j in range(N):
    S[j]= input()
print(len(set(S)))

Fixed submission:
N = int(input())
S = []
for j in range(N):
    S.append(input())
print(len(set(S)))
Buggy python submission (verdict: Time Limit Exceeded):
import math
from functools import reduce

def gcd(*numbers):
    return reduce(math.gcd, numbers)
sum = 0
K = int(input())
for i in range(1,K+1):
  for j in range(1,K+1):
    gcd_0 = gcd(i,j)
    for k in range(1,K+1):
      sum += gcd(gcd_0,k)

print(sum)

Fixed submission:
import math
from functools import reduce

def gcd(*numbers):
    return reduce(math.gcd, numbers)
sum = 0
K = int(input())
for i in range(1,K+1):
  for j in range(1,K+1):
    gcd_0 = gcd(i,j)
    for k in range(1,K+1):
      sum += gcd(gcd_0,k)

print(sum)

Buggy python submission (verdict: Time Limit Exceeded):
import math
from functools import reduce

def gcd(*numbers):
    return reduce(math.gcd, numbers)
sum = 0
K = int(input())
for i in range(1,K+1):
  for j in range(1,K+1):
      for k in range(1,K+1):
        sum += gcd(i,j,k)

print(sum)

Fixed submission:
import math
from functools import reduce

def gcd(*numbers):
    return reduce(math.gcd, numbers)
sum = 0
K = int(input())
for i in range(1,K+1):
  for j in range(1,K+1):
    gcd_0 = gcd(i,j)
    for k in range(1,K+1):
      sum += gcd(gcd_0,k)

print(sum)
Buggy python submission (verdict: Runtime Error):
N = int(input())
S_list = []
for _ in range(N):
    S_list.append(input())

S_dict = {}
for s in S_list:
    S_dict[s]=0
for s in S_list:
    S_dict[s]+=1

max_kv = max(S_dict.values())

max_k_list = [kv[0] for kv in S_dict.items() if kv[1] == max_kv]
max_k_list.sort()
for k in max_k_list:
    print(k)


Fixed submission:
# https://atcoder.jp/contests/abc155/tasks/abc155_a

A,B,C = map(int,input().split())

S = set([A,B,C])

if len(S) == 2:
    print("Yes")
else:
    print("No")
Buggy python submission (verdict: Time Limit Exceeded):
import itertools

N = int(input())
L_list = list(map(int, input().split()))
ans = 0
for (i, j, k) in itertools.combinations(range(N), 3):
    if (
        L_list[i] < L_list[j] + L_list[k]
        and L_list[j] < L_list[k] + L_list[i]
        and L_list[k] < L_list[i] + L_list[j]
    ):
        ans += 1
print(ans)

Fixed submission:
from bisect import bisect_left
N = int(input())
L_list = list(map(int, input().split()))
L_list.sort()

ans = 0
for i in range(N):
    for j in range(i + 1, N):
        a, b = L_list[i], L_list[j]
        r = bisect_left(L_list, a+b)
        ans += max(0,r-j-1)
print(ans)
Buggy python submission (verdict: Runtime Error):
n = int(input())
a = int(input()).split()
a.sort()
if a[0] == 0:
  print(0)
  return
ans = 1
for i in range(n):
  ans *= a[i]
  if ans > 10**18:
    print(-1)
    return
print(ans)

Fixed submission:
import sys
n = int(input())
a = list(map(int,input().split()))
a.sort()
if a[0] == 0:
  print(0)
  sys.exit()
ans = 1
for i in range(n):
  ans *= a[i]
  if ans > 10**18:
    print(-1)
    sys.exit()
print(ans)
Buggy python submission (verdict: Runtime Error):
mod = 998244353
N,K = map(int,input().split())

D = [list(map(int,input().split())) for _ in range(K)]
D.sort()

dp = [0]*N
dp[0] = 1
dp[D[0][0]] = 1

for n in range(D[0][0],N-1):
    dp[n+1] = dp[n]
    for i in range(K):
        L,R = D[i]
        if n-L+1>=0:
            dp[n+1] += dp[n-L+1]
        if n-R+1>0:
            dp[n+1] -= dp[n-R]
        dp[n+1] %= mod
print(dp[N-1])

Fixed submission:
mod = 998244353
N,K = map(int,input().split())

D = [list(map(int,input().split())) for _ in range(K)]
D.sort()

dp = [0]*N
dp[0] = 1
if D[0][0]<N:
    dp[D[0][0]] = 1

    for n in range(D[0][0],N-1):
        dp[n+1] = dp[n]
        for i in range(K):
            L,R = D[i]
            if n-L+1>=0:
                dp[n+1] += dp[n-L+1]
            if n-R+1>0:
                dp[n+1] -= dp[n-R]
            dp[n+1] %= mod
print(dp[N-1])
Buggy python submission (verdict: Runtime Error):
from collections import defaultdict
N,X,M = map(int,input().split())
ans = 0
d = defaultdict(lambda:-1)
x = X%M
for n in range(M):
    if x in d:
        T = n-d[x]
        break
    else:
        d[x] = n
    x *= x
    x %= M
p = 0
y = x
for m in range(d[x],n):
    p += y
    y *= y
    y %= M

ans = 0
n = N
z = X%M
while n:
    ans += z
    n -= 1
    z *= z
    z %= M
    if z==x:
        ans += n//T*p
        n %= T
print(ans)

Fixed submission:
from collections import defaultdict
N,X,M = map(int,input().split())
ans = 0
d = defaultdict(lambda:-1)
x = X%M
for n in range(M+100):
    if x in d:
        T = n-d[x]
        break
    else:
        d[x] = n
    x *= x
    x %= M
p = 0
y = x
for m in range(d[x],n):
    p += y
    y *= y
    y %= M

ans = 0
n = N
z = X%M
while n:
    ans += z
    n -= 1
    z *= z
    z %= M
    if z==x:
        ans += n//T*p
        n %= T
print(ans)
Buggy python submission (verdict: Runtime Error):
N,K = map(int,input().split())
P = list(map(lambda x: int(x) - 1, input().split()))
C = list(map(int,input().split()))

ans = max(C)
for i in range(N):
    s = i
    l = [C[i]]
    while True:
        s = P[s]
        if s == i:
            break
        l.append(C[s])
        

    if sum(l) > 0:
        c = K//len(l)*sum(l)
        n = K%len(l)
        ans = max(ans,c)
        s = i
        for j in range(n):
            c += C[s]
            s = P[s]
            ans = max(ans,c)

    n = min(N*2,K)
    s = i
    c = 0
    for j in range(n):
        c += C[s]
        s = P[s]
        ans = max(ans,c)
            
print(ans)

Fixed submission:
s = input()
if s == 'RRR':
    ans = 3
elif s == 'SRR' or s == 'RRS':
    ans = 2
elif s == 'SSS':
    ans = 0
else:
    ans = 1
print(ans)
Buggy python submission (verdict: Runtime Error):
import numpy as np
from numpy.fft import rfft,irfft

p = 200003
N = int(input())
A = list(map(int,input().split()))
a = np.zeros(p-1)

g = 1
d = {}
p2 = [1]*p
for i in range(p):
    d[g] = i
    p2[i] = g
    g *= 2
    g %= p

for i in range(N):
    if A[i]==0:
        continue
    a[d[A[i]]] += 1

b = rfft(a,2*p-2)
b = irfft(b*b,2*p-2)
b = np.rint(b).astype(np.int64)

ans = 0
for i in range(p-1):
    ans += (b[i]+b[i+p-1])*p2[i]

for i in range(N):
    ans -= A[i]**2%p
ans //= 2
print(ans)

Fixed submission:
import numpy as np
from numpy.fft import rfft,irfft

p = 200003
N = int(input())
A = list(map(int,input().split()))
a = np.zeros(p-1)

g = 1
d = {}
p2 = [1]*(p-1)
for i in range(p-1):
    d[g] = i
    p2[i] = g
    g *= 2
    g %= p

for i in range(N):
    if A[i]==0:
        continue
    a[d[A[i]]] += 1

b = rfft(a,2*p-2)
b = irfft(b*b,2*p-2)
b = np.rint(b).astype(np.int64)

ans = 0
for i in range(p-1):
    ans += (b[i]+b[i+p-1])*p2[i]

for i in range(N):
    ans -= A[i]**2%p
ans //= 2
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
K = int(input())

n = 7
ans = 0
i = 1
if K%2==0:
    ans = -1
else:
    while True:
        if n%K==0:
            ans = i
            break
        n *= 10
        n += 7
        n %= K
        i += 1
print(ans)

Fixed submission:
K = int(input())

n = 7
ans = -1
i = 1
if K%2==0:
    ans = -1
else:
    for i in range(K*2+10):
        if n%K==0:
            ans = i+1
            break
        n *= 10
        n += 7
        n %= K
print(ans)
Buggy python submission (verdict: Runtime Error):
from math import ceil
N,K = map(int,input().split())
A = list(map(int,input().split()))

def possible(l):
    c = 0
    for i in range(N):
        n = A[i]//l
        c += n
    return c<=K

l = 0
r = max(A)
m = (l+r)/2
for i in range(32):
    pos = possible(m)
    if pos:
        r = m
    else:
        l = m
    m = (l+r)/2

ans = ceil(m)
if possible(ans-1):
    ans -= 1
print(ans)

Fixed submission:
from math import ceil
N,K = map(int,input().split())
A = list(map(int,input().split()))

def possible(l):
    if l==0:
        return False
    c = 0
    for i in range(N):
        if A[i]%l==0:
            n = A[i]//l-1
        else:
            n = A[i]//l
        c += n
    return c<=K

l = 0
r = max(A)
m = (l+r)/2
for i in range(32):
    pos = possible(m)
    if pos:
        r = m
    else:
        l = m
    m = (l+r)/2

if possible(int(m)):
    print(int(m))
else:
    print(ceil(m))