Harryxun/sft_time huggingface dataset:
### BUGGY CODE ###

import numpy
s=list(input())
t=list(input())
dp=[["" for _ in range(len(t)+1)] for _ in range(len(s)+1)]
for i in range(len(s)):
    for j in range(len(t)):
        if s[i]==t[j]:
            list=[dp[i][j]+s[i],dp[i+1][j],dp[i][j+1]]
            index=numpy.argmax([len(item) for item in list])
            dp[i+1][j+1]=list[index]
        else:
            list=[dp[i][j],dp[i+1][j],dp[i][j+1]]
            index=numpy.argmax([len(item) for item in list])
            dp[i+1][j+1]=list[index]
print(dp[len(s)][len(t)])

### FIXED CODE ###

s=list(input())
t=list(input())
dp=[[0 for _ in range(len(t)+1)] for _ in range(len(s)+1)]

for i in range(len(s)):
    for j in range(len(t)):
        if s[i]==t[j]:
            dp[i+1][j+1]=max(dp[i][j]+1,dp[i+1][j],dp[i][j+1])
        else:
            dp[i+1][j+1]=max(dp[i+1][j],dp[i][j+1])

path=[]

lens=len(s)
lent=len(t)
while lens>-1 and lent>-1 :
    if dp[lens][lent]==dp[lens-1][lent]:
        lens-=1
    elif dp[lens][lent]==dp[lens][lent-1]:
        lent-=1
    else:
        path.append(lens)
        lens-=1
        lent-=1

path.sort()
if path==[]:
    print("")
else:
    for i in path:
    	print(s[i-1],end="")
### BUGGY CODE ###

import math
def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
N = int(input())
A = [int(a) for a in input().split()]
a = [0] * N
for i in range(N):
    a[A[i]-1] += 1
for k in range(N):
    sum = 0
    a[A[k]-1] -= 1
    for i in range(N):
        if a[i] >= 2:
            sum += combinations_count(a[i], 2)
    print(sum)
    a[A[k]-1] += 1


### FIXED CODE ###

N = int(input())
A = [int(a) for a in input().split()]
a = [0] * N
for i in A:
    a[i-1] += 1
cnt = 0
cnt += sum([i*(i-1)//2 for i in a])
for i in A:
    print(cnt - (a[i-1]-1))
### BUGGY CODE ###

N = int(input())
array=[int(n) for n in input().split()]
lst=[]
for i in range(N+1):
    left_array=array[:N+i]
    l = sorted(left_array)[-N:]
    right_array=array[N+i:]
    r = sorted(right_array)[:N]
    ans = sum(l)-sum(r)
    if lst ==[] or ans>lst:
        lst=ans
print(lst)

### FIXED CODE ###

N = int(input())
array = [int(n) for n in input().split()]
import copy
import heapq
lst = [None for i in range(N + 1)]
left_lst = copy.deepcopy(lst)
right_lst = copy.deepcopy(lst)
left_array = array[:N]
right_array= [-n for n in array[-N:]]
l_sum = sum(left_array)
r_sum = sum(right_array)
heapq.heapify(left_array)
heapq.heapify(right_array)
left_lst[0] = l_sum
right_lst[0] = r_sum

for k in range(N, 2 * N):
    new_a, new_b = array[k], array[-k - 1]*-1
    heapq.heappush(left_array,new_a)
    heapq.heappush(right_array,new_b)
    old_a = heapq.heappop(left_array)
    l_sum += (new_a - old_a)
    left_lst[k - N + 1] = l_sum
    old_b = heapq.heappop(right_array)
    r_sum += (new_b - old_b)
    right_lst[k - N + 1] = r_sum
lst = [ a + b for a, b in zip(left_lst, list(reversed(right_lst)))]
print(max(lst))
### BUGGY CODE ###

import array;R=range;L=input;T=[0]*28;N=int(L());S=[[ord(C)-95 for C in L()]for _ in[0]*N];U=N*26**2*array.array('i',[0]);V=N*[0];Q=int(L())
for X in S:
	P=0
	for C in X:
		if T[P+C]==0:T[P+C]=len(T);T+=[0]*28
		T[P]+=1;P=T[P+C]
	T[P]+=1;T[P+1]=1
while N:
	N-=1;P=0
	for C in S[N]:
		for A in R(26):X=T[P+A+2];U[676*N+26*A+C-2]+=T[X]*(X and A!=C-2)
		V[N]+=T[P+1];P=T[P+C]
while Q:
	K,P=L().split();K=int(K)-1;P=[ord(C)-97 for C in P];X=1+V[K]
	for A in R(26):
		for B in R(A+1,26):X+=U[676*K+26*P[A]+P[B]]
	print(X);Q-=1

### FIXED CODE ###

from array import*;R=range;T=[0]*28;N=int(input());S=[[ord(C)-95 for C in input()]for _ in[0]*N];U=N*26**2*array('i',[0]);V=N*[0];Q=int(input())
for X in S:
	P=0
	for C in X:
		if T[P+C]==0:T[P+C]=len(T);T+=[0]*28
		T[P]+=1;P=T[P+C]
	T[P]+=1;T[P+1]=1
for I in R(N):
	P=0
	for C in S[I]:
		for A in R(26):
			X=T[P+A+2]
			if(A!=C-2)*X:U[676*I+26*A+C-2]+=T[X]
		V[I]+=T[P+1]
		P=T[P+C]
while Q:
	K,P=input().split();K=int(K)-1;P=[ord(C)-97 for C in P];X=1+V[K]
	for A in R(26):
		for B in R(A+1,26):
			X+=U[676*K+26*P[A]+P[B]]
	print(X);Q-=1
### BUGGY CODE ###

n, k = map(int, input().split())
h = []

for i in range(n):
  h.append(int(input()))
h.sort()

ans = []
for i in range(0,len(h)-k+1):
  ans.append(max(h[i: i+k]) - min(h[i: i+k]))

print(min(ans))
  

### FIXED CODE ###

n, k = map(int, input().split())
h = []

for i in range(n):
  h.append(int(input()))
h.sort()

ans = []
for i in range(0,len(h)-k+1):
  ans.append(h[i+k-1] - h[i])

print(min(ans))
### BUGGY CODE ###

s = input()
Q = int(input())
for i in range(Q):
    t = input()
    if len(t) == 1:
        s = s[::-1]
    else:
        if t[2] == '1':
            s = t[4] + s
        else:
            s += t[4]
print(s)

### FIXED CODE ###

s = input()
Q = int(input())
r = -1
head = ''
tail = ''
for i in range(Q):
    t = input()
    if t[0] == '1':
        r *= -1
    else:
        if t[2] == '1':
            if r == 1:
                tail += t[4]
            else:
                head = t[4] + head
        else:
            if r == 1:
                head = t[4] + head
            else:
                tail += t[4]
if r == 1:
    print(tail[::-1] + s[::-1] + head[::-1])
else:
    print(head + s + tail)
### BUGGY CODE ###

n = int(input())
s = [tuple(map(int, input().split())) for _ in range(n-1)]
s.append((0, 0, 0))

for i in range(n):
    sec = s[i][0] + s[i][1]
    for j in range(i+1, n-1):
        c = s[j][1]
        while True:
            if c >= sec:
                sec = c
                break
            c += s[j][2]
        sec += s[j][0]
    print(sec)


### FIXED CODE ###

from math import ceil

n = int(input())
s = [tuple(map(int, input().split())) for _ in range(n-1)]
s.append((0, 0, 0))

for i in range(n):
    sec = s[i][0] + s[i][1]
    for j in range(i+1, n-1):
        if sec < s[j][1]: sec = s[j][1]
        else: sec = s[j][2] * ceil(sec / s[j][2])
        sec += s[j][0]
    print(sec)
### BUGGY CODE ###

N = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

na, nb = 0, 0

suma = sum(a)
sumb = sum(b)
jdg = False

for i in range(N):
    while a[i]!= b[i]:
        if suma + na >= sumb + nb:
            jdg = True
            break
        if a[i] > b[i]:
            b[i] += 1
            if nb > 0: nb -= 1
            na += 2
        else:
            a[i] += 2
            if na >= 2: na -= 2
            nb += 1
    if jdg: break
print('No' if jdg else 'Yes')

### FIXED CODE ###

N = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

na, nb = 0, 0

suma = sum(a)
sumb = sum(b)
jdg = False

for i in range(N):
    while a[i]!= b[i]:
        if suma + na > sumb + nb:
            jdg = True
            break
        if i == N - 1:
            a[i] += na
            b[i] += nb
            if a[i] > b[i]:
                jdg = True
            break
        if a[i] > b[i]:
            ab = a[i] - b[i]
            if nb < ab:
                na += 2 * (ab - nb)
                nb = 0
            else: nb -= ab
            sumb += ab
            b[i] += ab
        else:
            ba = b[i] - a[i]
            if na < ba:
                nb += (ba - na + 1) // 2
                na = 0
            else: na -= ((ba+1)//2)*2
            if nb > 0: nb -= ba%2
            else: na += 2 * (ba%2)
            suma += ((ba+1)//2)*2
            sumb += ba%2
            a[i] += ((ba+1)//2)*2
            b[i] += ba%2
    if jdg: break
print('No' if jdg else 'Yes')
### BUGGY CODE ###

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

ab_list = []
tree_dict = {}
for i in range(N-1):
    a, b = map(int, input().split())
    ab_list.append(a)
    ab_list.append(b)

    if a not in tree_dict:
        tree_dict[a] = [b]
    else:
        tree_dict[a].append(b)

value_dict = {k:0 for k in list(set(ab_list))}

for i in range(Q):
    p, x = map(int, input().split())

    kk_list = [p]
    while(1):
        if len(kk_list) == 0:
            break
        k = kk_list[0]
        value_dict[k] += x
        if k in tree_dict:
            kk_list += tree_dict[k]
        kk_list.pop(0)

print(' '.join([str(v) for k, v in value_dict.items()]))

### FIXED CODE ###

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

ab_list = []
tree_dict = {}
for i in range(N-1):
    a, b = map(int, input().split())
    ab_list.append(a)
    ab_list.append(b)

    if a not in tree_dict:
        tree_dict[a] = [b]
    else:
        tree_dict[a].append(b)

value_list = list(set(ab_list))

px_dict = {}
for i in range(Q):
    p, x = map(int, input().split())
    if p in px_dict:
        px_dict[p] += x
    else:
        px_dict[p] = x

out = ""
for v in value_list:
    if v in px_dict:
        x = px_dict[v]
        if v in tree_dict:
            tree_list = tree_dict[v]
            for t in tree_list:
                if t in px_dict:
                    px_dict[t] += x
                else:
                    px_dict[t] = x
        o = str(px_dict[v])
    else:
        o = str(0)
    out += o + " "

print(out[:-1])
### BUGGY CODE ###

from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,copy,time
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())


N = inp()
AA = inpl()
BB = inpl()

# In[]:
# N = 3
# AA = [3, 4, 3]
# BB = [3, 2, 3]

cards = []
for i,(a,b) in enumerate(zip(AA,BB)):
    if i%2 == 0:
        cards.append((a, b, i))
    else:
        cards.append((b, a, i))


n = (N+1)//2

# In[]:
def solve(ii):
    tmp = 0
    # print(ii)
    for _ in range(N):
        next = []
        for k, i in enumerate(ii):
            if i == 0:
                tmp += k
            else:
                next.append(i-1)
        ii = next[:]
    # print(tmp)
    return tmp



# In[]:
ans = INF
for Acards in itertools.combinations(cards, n):
    Ais = sorted([(Acard[0], Acard[2]) for Acard in Acards])

    ii = set([i for A,i in Ais])
    Bis = []
    for a,b,i in cards:
        if i not in ii:
            Bis.append((b,i))
    Bis.sort()

    nums = []
    ii = []
    for i in range(N):
        if i%2 == 0:
            n,i = Ais[i//2]
        else:
            n,i = Bis[i//2]
        nums.append(n)
        ii.append(i)

    # print(nums,ii)
    if nums != sorted(nums):
        continue
    else:
        ans = min(ans,solve(ii))


if ans == INF:
    print(-1)
else:
    print(ans)


### FIXED CODE ###

from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,copy,time
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())


N = inp()
AA = inpl()
BB = inpl()

# In[]:
# N = 3
# AA = [3, 4, 3]
# BB = [3, 2, 3]

cards = []
for i,(a,b) in enumerate(zip(AA,BB)):
    if i%2 == 0:
        cards.append((a, b, i))
    else:
        cards.append((b, a, i))


n = (N+1)//2

# In[]:
def solve(ii):
    tmp = 0
    # print(ii)
    for _ in range(N):
        next = []
        for k, i in enumerate(ii):
            if i == 0:
                tmp += k
            else:
                next.append(i-1)
        ii = next[:]
    # print(tmp)
    return tmp



# In[]:
ans = INF
for Acards in itertools.combinations(cards, n):
    Ais = sorted([(Acard[0], Acard[2]) for Acard in Acards])

    ii = set([i for A,i in Ais])
    Bis = []
    for a,b,i in cards:
        if i not in ii:
            Bis.append((b,i))
    Bis.sort()

    nums = []
    ii = []
    for i in range(N):
        if i%2 == 0:
            n,i = Ais[i//2]
        else:
            n,i = Bis[i//2]
        nums.append(n)
        ii.append(i)

    # print(nums,ii)
    if nums != sorted(nums):
        continue
    else:
        ans = min(ans,solve(ii))


if ans == INF:
    print(-1)
else:
    print(ans)
### BUGGY CODE ###

def c_many_medians(N, X):
    x = [[0, 0] for _ in range(N)]
    for i, e in enumerate(X):
        x[i] = [i, e]
    x.sort(key=lambda k: k[1])
    mid = N // 2 - 1
    a, b = [0] * N, [0] * N
    for i, (k, v) in enumerate(x):
        a[i] = k
        b[i] = v
    ans = ''
    for i in range(N):
        idx = a.index(i)
        value = b[idx]
        b.remove(value)
        ans += '{}\n'.format(b[mid])
        b.insert(idx, value)
    ans = ans[:-1]
    return ans

N = int(input())
X = [int(i) for i in input().split()]
print(c_many_medians(N, X))

### FIXED CODE ###

def c_many_medians(N, X):
    # 解説どおり
    Y = sorted(X)
    ans = ['' for _ in range(N)]
    pos = N // 2
    for k, xi in enumerate(X):
        if xi < Y[pos]:
            ans[k] = str(Y[pos])
        else:
            ans[k] = str(Y[pos - 1])
    return '\n'.join(ans)

N = int(input())
X = [int(i) for i in input().split()]
print(c_many_medians(N, X))
### BUGGY CODE ###

import sys
def input():
    return sys.stdin.readline()[:-1]

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

if S[0]!='B' or S[-1]!='B':
    print(0)
    exit()

mod = 10**9 + 7
cnt_l = 1
cnt_r = 0
pre_s = 'B'
pre_d = 1 #1がleft
ans = 1

for i in range(1,N*2):
    s = S[i]

    if pre_s==s:
        if pre_d:
            pre_d = 0
            ans *= cnt_l - cnt_r #ここまでに出てきたLeftの総数 - ここまでに出てきたrightの総数
            cnt_r += 1
        else:
            pre_d = 1
            cnt_l += 1
    else:
        if pre_d:
            cnt_l += 1
        else:
            ans *= cnt_l - cnt_r #ここまでに出てきたLeftの総数 - ここまでに出てきたrightの総数
            cnt_r += 1
    pre_s = s

for i in range(1,N+1):
    ans *= i
    ans %= mod
if cnt_l!=N:
    print(0)
    exit()

print(ans)

### FIXED CODE ###

import math
n = int(input())
S = input()
 
RL = [None]*2*n
 
for i in range(2*n):
    if i % 2 == 0:
        if S[i] == 'B':
            RL[i] = 'L'
        else:
            RL[i] = 'R'
 
    else:
        if S[i] == 'B':
            RL[i] = 'R'
        else:
            RL[i] = 'L'
 
if S[0] == 'W' or S[-1] == 'W':
    print(0)
    exit()
 
left = 0
count = 1
mod = 10**9 + 7
 
for check in RL:
    if check == 'L':
        left += 1
    else:
        count = count * left % mod
        left -= 1
 
    if left < 0:
        print(0)
        exit()
 
count = count * math.factorial(n) % mod
 
if left != 0:
    print(0)
else:
    print(count)
### BUGGY CODE ###

k = int(input())
mod = 7

if k % 2 == 0:
  print('-1')
else:
  for i in range(10**7):
    if mod % k == 0:
      print(i+1)
      break
    else:
      mod = mod*10 + 7
  else:
    print('-1')

### FIXED CODE ###

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

for i in range(1, 10**6 + 1):
  if ans%k == 0:
    print(i)
    exit()
  else:
    ans = (ans*10 + 7)%k
print(-1)
### BUGGY CODE ###

N=int(input())
a=list(map(int,input().split()))
A=[0]*N
B=[]
count=0
for i in range(N//2,N):
    if a[i]==1:
        A[i]=1
        count=count+1
        B.append(i+1)
for i in range(N//2)[::-1]:
    asum=0 
    x=i+1
    for j in range(i,N,x):
        asum=asum+A[j]
    if asum%2!=a[i]:
        A[i]=1
        B.insert(0,i+1)
        count=count+1
print(count)
if count!=0:
    print(*B)

### FIXED CODE ###

N=int(input())
a=list(map(int,input().split()))
A=[0]*N
B=[]
for i in range(N//2,N):
    if a[i]==1:
        A[i]=1
        B.append(i+1)
for i in range(N//2)[::-1]:
    asum=0 
    x=i+1
    for j in range(i,N,x):
        asum=asum+A[j]
    if asum%2!=a[i]:
        A[i]=1
        B.append(i+1)
count=sum(A)
print(count)
if count!=0:
    print(*B)
### BUGGY CODE ###

N, K = map(int, input().split())
D = 60
to = [None] * D
to[0] = [None] * N
for i, a in enumerate(map(int, input().split())):
    to[0][i] = a - 1
for t in range(1, D):
    to[t] = [None] * N
    for i in range(N):
        to[t][i] = to[t-1][to[t-1][i]]
v = 0
for i in reversed(range(D)):
    l = 1<<i
    if l <= K:
        v = to[i][v]
        K -= l
        if K <= 0:
            print(v + 1)
            exit()

### FIXED CODE ###

N, K = map(int, input().split())
A = list(map(int, input().split()))
r = [None] * N
i = 0
cur = 0
m = None
while True:
    if m is None and r[cur] is not None:
        m = i - r[cur]
        K = i + (K-i)%m
    else:
        r[cur] = i
    if i == K:
        print(cur+1)
        exit()
    i += 1
    cur = A[cur] - 1
### BUGGY CODE ###

import sys
import copy
import math
import itertools
import numpy as np
N = int(input())
print(sum(range(N)))

### FIXED CODE ###

N = int(input())
print(N*(N-1)//2)
### BUGGY CODE ###

n=int(input())
a=list(map(int, input().split()))

l = sorted(a)
dp = [True] * (max(l) + 1)
ans = 0

for i,num in enumerate(l):
    if dp[num-1]:
        j= 2 * num
        while j <= max(l):
            dp[j-1] = False
            j += num
        if not i+1==len(l):
            if l[i]==l[i+1]:
                dp[num-1] = False

for k in l:
    if dp[k-1]:
        ans += 1

#print(dp)
print(ans)

### FIXED CODE ###

n=int(input())
a=list(map(int, input().split()))

a.sort()
dp = [True] * a[-1]
ans = 0

for i,num in enumerate(a):
    if dp[num-1]:
        j= 2 * num
        while j <= a[-1]:
            dp[j-1] = False
            j += num
        if not i+1==len(a):
            if a[i]==a[i+1]:
                dp[num-1] = False

for k in a:
    if dp[k-1]:
        ans += 1

#print(dp)
print(ans)
### BUGGY CODE ###

#!/usr/bin/env pypy
import sys

input = sys.stdin.readline


def main():
    n, m = map(int, input().split())
    a = [int(input()) for _ in range(m)]
    diff_a = [a[i+1] - a[i] for i in range(m - 1)]
    if 1 in diff_a:
        print(0)
        return
    method = [0] * (n + 1)
    method[0] = 1
    if 1 not in a:
        method[1] = 1

    for i in range(2, n + 1):
        if i in a:
            continue
        else:
            method[i] = method[i-1] + method[i-2]
            method[i] %= 1000000007

    print(method[n])


if __name__ == '__main__':
    main()


### FIXED CODE ###

#!/usr/bin/env python3
import sys

sys.setrecursionlimit(10 ** 8)
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N, M = map(int, readline().split())
A = list(map(int, readlines()))
assert len(A) == M

MOD = 10 ** 9 + 7


def solve():
    broken = [False] * (N + 1)
    for a in A:
        broken[a] = True
    p1, p2 = 1, 0
    for i in range(1, N + 1):
        if broken[i]:
            p1, p2 = 0, p1
        elif i == 1:
            p1, p2 = p1, p1
        else:
            p1, p2 = (p1 + p2) % MOD, p1
    return p1


if __name__ == "__main__":
    print(solve())
### BUGGY CODE ###

n = int(input())
x = input()

def popcount(n):
    n_b = str(bin(n))
    return n_b.count("1")

x_i = int(x, 2)
solve = 0
for i in range(n):
    if x[i] == "0":
        solve = x_i+2**(n-i-1)
    else:
        solve = x_i-2**(n-i-1)
    count = 0
    while solve > 0:
        solve = solve % popcount(solve)
        count+=1
    print(count)

### FIXED CODE ###


n = int(input())
x = input()

def popcount(ni):
    n_b = str(bin(ni))
    return n_b.count("1")

def ans(n,x):
    x_i = int(x, 2)
    x_orig = popcount(x_i)
    x_i_t = x_i % (x_orig+1)
    if x_orig != 1:
        x_i_b = x_i % (x_orig-1)
    else:
        x_i_b = x_i
    solve = 0
    for i in range(n):
        x_count = x_orig
        if x[i] == "0":
            x_count += 1
            solve = x_i_t + pow(2,n-1-i,x_count)
        else:
            x_count -= 1
            if x_count != 0:
                solve = x_i_b - pow(2,n-1-i,x_count)
            else:
                print(0)
                continue
        count = 0

        if x_count != 0 :
            solve = solve % x_count
            count+=1

        while solve > 0:
            solve = solve % popcount(solve)
            count+=1

        print(count)

    
ans(n,x)
### BUGGY CODE ###

s = input()
s = s[::-1]
mod = 10 ** 9 + 7
table = [[0] * 13 for _ in range(len(s) + 2)]
d = 0
table[0][0] = 1
dd = 1
for c in range(len(s)):
    dd = (10 ** d) % 13
    if s[c] == "?":
        for n in range(10):
            for i in range(13):
                table[d + 1][(i + n * dd) % 13] += table[d][i]
    else:
        num = int(s[c])
        for i in range(13):
            table[d + 1][(i + num * dd) % 13] += table[d][i]
    d += 1
print(table[d][5] % mod)

### FIXED CODE ###

s = input()
s = s[::-1]
mod = 10 ** 9 + 7
table = [[0] * 13 for _ in range(len(s) + 2)]
table[0][0] = 1
dd = 1
for c in range(len(s)):
    if s[c] == "?":
        for n in range(10):
            for i in range(13):
                table[c + 1][(i + n * dd) % 13] += table[c][i]
                table[c + 1][(i + n * dd) % 13] %= mod
    else:
        num = int(s[c])
        for i in range(13):
            table[c + 1][(i + num * dd) % 13] += table[c][i]
            table[c + 1][(i + num * dd) % 13] %= mod
    dd = (dd * 10) % 13
print(table[c + 1][5])
### BUGGY 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
  count +=1
  if an%K == 0:
    break
print(count)

### FIXED CODE ###

def calc(k):
    cur = 0
    for i in range(1, 10 ** 7):
        cur *= 10
        cur += 7
        cur %= k
        if cur == 0:
            return i

    return -1


k = int(input())
print(calc(k))
### BUGGY CODE ###

n = int(input())
aaa = list(map(int, input().split()))

result = 0
for i in range(n - 1):
  for j in range(i + 1, n):
    result += aaa[i] * aaa[j]
    
mode = 10 ** 9 + 7
print(result % mode)

### FIXED CODE ###

n = int(input())
aaa = list(map(int, input().split()))

sum_a = 0
sum_aa = 0
for a in aaa:
  sum_a += a
  sum_aa += a ** 2
  
print(((sum_a ** 2 - sum_aa) // 2) % (10 ** 9 + 7))
### BUGGY CODE ###

N, K = map(int, input().split())
counter = 0

for i in range(1, N+1):
    j = K - i
    while j <= 0:
        j += K
    while j <= N:
        k = K - i
        while k <= 0:
            k += K
        while k <= N:
            if (j+k) % K == 0 and (j+k) != 0:
                counter += 1
            k += K
        j += K

print(counter)


### FIXED CODE ###

N, K = map(int, input().split())
result = (N//K)**3
if K % 2 == 0:
    if N-K*(N//K) < K/2:
        result += (N//K)**3
    else:
        result += ((N//K)+1)**3

print(result)
### BUGGY CODE ###

a, b, c = map(int, input().split())
k = int(input())
flag = False
if a < b < c:
    flag = True
count = 0
while count < k and not (a < b < c):
    if a > b:
        count += 1
        b = 2*b
    if b > c:
        count += 1
        c = 2*c

if count <= k:
    if a < b < c:
        print("Yes")
    else:
        print("No")
else:
    print("No")

### FIXED CODE ###

a, b, c = map(int, input().split())
k = int(input())

count = 0
while count < k and not (a < b < c):
    if a >= b:
        count += 1
        b = 2*b
    if b >= c:
        count += 1
        c = 2*c

if count <= k:
    if a < b < c:
        print("Yes")
    else:
        print("No")
else:
    print("No")