Harryxun/stf_run huggingface dataset:
nv,ne = [int(i) for i in input().split()]

g = [[] for i in range(nv)]

for i in range(ne):
    s,t = [int(j) for j in input().split()]
    g[s].append(t)

done = []
f = 0

def put_forword(index):
    global f

    if index in done:
        return

    done.append(index)

    for i in g[index]:

        if i == 0　and done.count() == nv:
            f = 1
            return
        put_forword(i)

put_forword(0)

print(f)



### FIXED CODE ###


nv,ne = [int(i) for i in input().split()]

g = [[] for i in range(nv)]

for i in range(ne):
    s,t = [int(j) for j in input().split()]
    g[s].append(t)

visited = []
f = 0

def pursue_from(index, origin):

    if visited[index]:
        return

    visited[index] = True

    for next_index in g[index]:

        if next_index == origin:
            global f
            f = 1
            return
        pursue_from(next_index, origin)

for i in range(nv):
    visited = [False for i in range(nv)]

    pursue_from(i, i)

    if f == 1:
         break

print(f)
X, N = map(int, input().split())
p = list(map(int, input().split()))

if N == 0:
        print(X)
        exit()

p.sort()
tmp = [i for i in range(1, 101)]
for i in p:
        tmp.remove(i)

ans_num = float("Inf")
ans_i = 0
for i in range(len(tmp)):
        if abs(X - tmp[i]) < ans_num:
                ans_num = abs(X - tmp[i])
                ans_i = i


print(tmp[ans_i])


### FIXED CODE ###

X, N = map(int, input().split())
p = list(map(int, input().split()))

if N == 0:
        print(X)
        exit()

p.sort()
tmp = [i for i in range(-111, 111)]
for i in p:
        tmp.remove(i)

ans_num = float("Inf")
ans_i = 0
for i in range(len(tmp)):
        if abs(X - tmp[i]) < ans_num:
                ans_num = abs(X - tmp[i])
                ans_i = i


print(tmp[ans_i])
n=int(input())
li = list(map(int,input().split()))
a=0
for i in range(n-1):
  for j in range(n):
    a += li[i]*li[j+1]
print(a)

### FIXED CODE ###

n=int(input())
li = list(map(int,input().split()))
a=0
for i in range(n):
  for j in range(n):
    a += li[i]*li[j]
b=0
for i in range(n):
    b+= li[i]*li[i]
print((a-b)//2)
n = input()
n = int(n)
num = []*n
numint = []
num = input().split(' ')
for i in range(len(num)):
    numint.append(int(num[i]))
i = 0
x, y = int, int
word = []

numint = sorted(numint)
x = numint[0]
y = numint[1]
word.append(str(x) + " " + str(y))
numint.append(x - y)
numint.pop(0)
numint.pop(0)
while len(numint) > 1:
    numint = sorted(numint)
    x = numint[0]
    y = numint[1]
    if x < y:
        a, b = x, y
        x, y = b,a
    word.append(str(x) + " " + str(y))
    numint.append(x - y)
    numint.pop(0)
    numint.pop(0)
print(numint[0])
for i in range(len(word)):
    print(word[i])

### FIXED CODE ###

n, k = input().split(' ')
n, k = int(n), int(k)
maxval = 1
if k == 1:
    print(0)
else:
    while n - maxval - k + 1 != 0:
        maxval += 1
    print(maxval - 1)
a,b = map(int,input().split())
print(b if a>=13 else b//2 if 6<=a<=12 else 0 if a<=5)

### FIXED CODE ###

a,b = map(int,input().split())
print(b if a>=13 else b//2 if 6<=a<=12 else 0)
import sys
from collections import deque
sys.setrecursionlimit(10 ** 5)
input = sys.stdin.readline
n = int(input())
m = {}
np = [deque([]) for _ in range(n)]
for _ in range(n-1):
    a, b, c = [int(x) for x in input().strip().split()]
    m[(a, b)] = c
    m[(b, a)] = c
    np[a-1].append(b)
    np[b-1].append(a)

q, k = [int(x) for x in input().strip().split()]
master = [-1 for _ in range(n)]
master[k-1] = 0

def dfs(cur, pre, master):
    #print('cur = {}, pre = {}'.format(cur, pre))
    for p in np[cur-1]:
        if p == pre:
            continue
        master[p-1] = master[cur-1] + m[(cur, p)]
        dfs(p, cur, master)

dfs(k, -1, master)

for _ in range(q):
    x, y = [int(x) for x in input().strip().split()]
    print(master[x-1] + master[y-1])

### FIXED CODE ###

import sys
from collections import deque
sys.setrecursionlimit(10 ** 6)
input = sys.stdin.readline
n = int(input())
m = {}
np = [deque([]) for _ in range(n)]
for _ in range(n-1):
    a, b, c = [int(x) for x in input().strip().split()]
    m[(a, b)] = c
    m[(b, a)] = c
    np[a-1].append(b)
    np[b-1].append(a)

q, k = [int(x) for x in input().strip().split()]
master = [-1 for _ in range(n)]
master[k-1] = 0

def dfs(cur, pre, master):
    #print('cur = {}, pre = {}'.format(cur, pre))
    for p in np[cur-1]:
        if p == pre:
            continue
        master[p-1] = master[cur-1] + m[(cur, p)]
        dfs(p, cur, master)

dfs(k, -1, master)

for _ in range(q):
    x, y = [int(x) for x in input().strip().split()]
    print(master[x-1] + master[y-1])
a, b, t = list(input(''))
total = 0
for i in range(a, t+1, a):
  total += b
print(total)

### FIXED CODE ###

a, b, t = map(int, input().split())
total = 0
for i in range(a, t+1, a):
  total += b
print(total)
import numpy as np
N,T = map(int, input().split())

c_list = []
t_list=[]
for i in range(N):
	c,t=map(int, input().split())
	c_list.append(c)
	t_list.append(t)

c_list = np.array(c_list)
t_list = np.array(t_list)	

if t_list[t_list<=T]:
	print('TLE')
else:
	print(min(c_list[t_list<=T]))

### FIXED CODE ###

import numpy as np
N,T = map(int, input().split())

c_list = []
t_list=[]
for i in range(N):
	c,t=map(int, input().split())
	c_list.append(c)
	t_list.append(t)

c_list = np.array(c_list)
t_list = np.array(t_list)	

if not np.any(t_list[t_list<=T]):
	print('TLE')
else:
	print(min(c_list[t_list<=T]))
import sys

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


def main():
    H, W, M = map(int, readline().split())
    row = [0] * H
    column = [0] * W
    grid = [[0] * W for _ in range(H)]

    for _ in range(M):
        h, w = map(int, readline().split())
        row[h-1] += 1
        column[w-1] += 1
        grid[h-1][w-1] += 1

    max_row = [i for i,x in enumerate(row) if x == max(row)]
    max_column = [i for i,x in enumerate(column) if x == max(column)]
    ans = 0
    for h in max_row:
        for w in max_column:
            tmp = row[h] + column[w] - grid[h][w]
            ans = max(tmp,ans)
    print(tmp)

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():
    H, W, M = map(int, readline().split())
    row = [0] * H
    column = [0] * W
    grid = set()

    for _ in range(M):
        h, w = map(int, readline().split())
        row[h-1] += 1
        column[w-1] += 1
        grid.add((h-1,w-1))

    max_row = max(row)
    max_column = max(column)

    idx_row = [i for i,x in enumerate(row) if x == max_row]
    idx_column = [i for i,x in enumerate(column) if x == max_column]

    ans = max_row+max_column
    flag = False

    for h in idx_row:
        for w in idx_column:
            if not (h,w) in grid:
                flag = True
                break

    if flag:
        print(ans)
    else:
        print(ans-1)


if __name__ == '__main__':
    main()
import math
import sys
input = sys.stdin.readline
N = int(input())
A = list(map(int,input().split()))
L = [0]*(N-3)
for i in range(N-1,-1,-1):
    L.append(math.gcd(A[i],A[i-1]))
if L.count(min(L)) == 2 and len(L) > 2:
    L.sort()
    ans = L[2]
else:
    ans = L[0]
print(ans)

### FIXED CODE ###

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

def gcd(a,b):
    if b == 0:
        return a
    return gcd(b,a%b)

L,R = [A[0]],[A[-1]]
Lg = A[0]
Rg = A[-1]
for i in range(N-1):
    Lg = gcd(Lg,A[i+1])
    L.append(Lg)
for i in range(N-1,0,-1):
    Rg = gcd(Rg,A[i-1])
    R.append(Rg)
L.append(A[-1])
R.append(A[0])

res = 0
for i in range(N):
    if i == 0:
        res = max(res,R[-3])
    elif i == N-1:
        res = max(res,L[-3])
    else:
        res = max(res,gcd(L[i-1],R[-i-3]))
        
print(res)
import sys
x,n=map(int,input().split())
p=list(map(int,input().split()))
c=0
if n==0:
  print(x)
  sys.exit()
for i in range(x,-200,-1):
  
  if not i in p:
    print(i)
    sys.exit()
  if not (x+c) in p:
    print(x+c)
    sys.exit()
　c+=1

### FIXED CODE ###

import sys
x,n=map(int,input().split())
p=list(map(int,input().split()))
c=0
if n==0:
  print(x)
  sys.exit()
for i in range(x,-200,-1):
  
  if not i in p:
    print(i)
    sys.exit()
  if not (x+c) in p:
    print(x+c)
    sys.exit()
  c+=1
n,k=map(int,input().split())
a=list(map(int,input().split()))

l=[]
for i in range(n-k+1):
    total=1
    for j in range(0+i,k+i):
        total*=a[j]
    l.append(total)

for i in range(n-k):
    if l[i]<l[i+1]:
        print('Yes')
    else:
        print('No')   

### FIXED CODE ###

x=int(input())

if 400<=x<=599:
    print(8)
elif 600<=x<=799:
    print(7)
elif 800<=x<=999:
    print(6)
elif 1000<=x<=1199:
    print(5)
elif 1200<=x<=1399:
    print(4)
elif 1400<=x<=1599:
    print(3)
elif 1600<=x<=1799:
    print(2)
else:
    print(1)
def a(t,i):
    if i==l-1:
        print(sum(map(int,t.split('+'))))
        exit()
    return a(t+s[i+1],i+1)+a(t+'+'+s(i+1),i+1)

s=input()
a(s[0],0)
l = s.len()

### FIXED CODE ###

def dfs(i,s):
    if i==n-1:
        return sum(map(int,s.split('+')))
    return dfs(i+1,s+S[i+1])+dfs(i+1,s+'+'+S[i+1])

S=input()
n=len(S)
ans=dfs(0,S[0])
print(ans)
n, k, q = map(int, input().split())
a = list(map(int, [input() for i in range(q)]))
p = [k-q] * n
for i in range(q):
  p[a[i]] += 1
for i in range(n):
  print('Yes' if p[i] > 0 else 'No')

### FIXED CODE ###

n, k, q = map(int, input().split())
a = list(map(int, [input() for i in range(q)]))
p = [k-q] * n
for i in range(q):
  p[a[i]-1] += 1
for i in range(n):
  print('Yes' if p[i] > 0 else 'No')
*A=map(int,input().split());print(sum(A)-max(A))

### FIXED CODE ###

*A,=map(int,input().split());print(sum(A)-max(A))
a, b = map(int, input().split())
n = int(input())
print(a * (n // (a + b))+ min(n % (a + b), a))

### FIXED CODE ###

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

result = 0
result += N // (A + B) * A
result += min(N % (A + B), A)
print(result)
N = int(input())
A = [int(i) for i in input().split()]
B = [int(i) for i in input().split()]
C = [int(i) for i in input().split()]
A2=sorted(A)
B2=sorted(B)
C2=sorted(C)
ans = 0
sum = 0
t =0
b = 0
for i in range(N):
    a = A2[i]
    low = 0
    high = N-1
    while True:
        t = (low + high) // 2
        if B2[t] <= a:
            if t == N-1:
                b = False
                break
            elif B2[t] <= a <B2[t+1]:

                b = B2[t+1]
                t = t + 1
                break
            else:
                low = t+1
                continue
        elif B2[t] > a:
            if t == 0:
                b = B2[0]
                break
            elif B2[t] > a >= B2[t-1]:
                b = B2[t]
                break
            else:
                high = t - 1
                continue
    if b != False:
        for j in range(t,N):
            b = B2[j]
            low = 0
            high = N - 1
            while True:
                print(a, b)
                t = (low + high) // 2
                if C2[t] <= b:
                    if C2[t] <= b < C2[t + 1]:
                        c = C2[t + 1]
                        ans = N - t - 1
                        break
                    else:
                        low = t + 1
                        continue
                elif C2[t] > b:
                    if t == 0:
                        if C2[t] > b:
                            ans = N
                            break
                        else:
                            ans = 0
                            break
                    elif C2[t] > b >= C2[t - 1]:
                        c = C2[t]
                        ans = N - t
                        break
                    else:
                        high = t - 1
                        continue
                print("ans={}".format(ans))
            sum += ans

print(sum)


### FIXED CODE ###

N = int(input())
A = list(int(i) for i in input().split())
B = list(int(i) for i in input().split())
C = list(int(i) for i in input().split())
A.sort()
B.sort()
C.sort()
sum = 0
for j in range(N):
    low = low2 = 0
    high = high2 = N
    b = B[j]
    mid = mid2 = 0
    #print(b)
    while(high>low):
        mid = (high + low)//2
        if b > A[mid]:
            low = mid +1
        else:
            high = mid
    acount = low
    while (high2>low2):
        mid2 = (high2 + low2)//2
        if b < C[mid2]:
            high2 = mid2
        else:
            low2 = mid2 + 1
    ccount=N-low2
    sum += acount*ccount
print(sum)
import math
l1=input().split(" ")
t80=int(l1[0])
t100=int(l1[1])
t80_min=math.ceil(t80/0.08)
t80_max=math.ceil((t80+1)/0.08)
t100_min=math.ceil(t100/0.1)
t100_max=math.ceil((t100+1)/0.1)
f=0
for i  in range(min(t80_min,t100_min),max(t80_max,t100_max)):
    if int(i*0.08)==a and int(i*0.1)==b:
        print(i)
        sys.exit()
print(-1)

### FIXED CODE ###

import sys
 
a,b = map(int,input().split())
low = int(min(a//0.08,b//0.1))
high = int(max((a+1)//0.08,(b+1)//0.1))
for i in range(low,high+1):
  if int(i*0.08)==a and int(i*0.1)==b:
    print(i)
    sys.exit()
print(-1)
n = int(input())

game = [0]

for _ in range(n):
    comp = list(map(int, input().split()))
    game.append(comp[::-1])

count = 0
final = n*(n-1)//2
for day in range(1, 1000000):
    finish = set()
    possible = False
    for me in range(1, n+1):
        if me in finish or game[me] == []:
            continue

        you = game[me][-1]
        if you in finish:
            continue
        else:
            if game[you][-1] == me:
                finish.add(game[you].pop())
                finish.add(game[me].pop())
                possible = True
                count += 1
            else:
                contin
    if not possible:
        print(-1)
        exit()

    if count == final:
        print(day)
        exit()


### FIXED CODE ###

from collections import deque
import sys
input = sys.stdin.readline

n = int(input())
game = {}

for i in range(1, n+1):
    game[i] = deque((map(int, input().split())))

count = 0
final = n*(n-1)//2
done = []

finish = [0] * (n + 1)
for me in range(1, n + 1):
    if finish[me] == 1 or game[me] == deque([]):
        continue

    you = game[me][0]
    if finish[you] == 1:
        continue
    else:
        if game[you][0] == me:
            done.append(you)
            done.append(me)
            finish[game[you].popleft()] = 1
            finish[game[me].popleft()] = 1
            possible = True
            count += 1
        else:
            continue

for day in range(2, 1000000):
    finish = [0]*(n+1)
    possible = False
    new_done = []
    for me in done:
        if finish[me] == 1 or game[me] == deque([]):
            continue

        you = game[me][0]
        if finish[you] == 1:
            continue
        else:
            if game[you][0] == me:
                finish[game[you].popleft()] = 1
                finish[game[me].popleft()] = 1
                new_done.append(me)
                new_done.append(you)
                possible = True
                count += 1
            else:
                continue
    done = new_done
    if not possible:
        print(-1)
        exit()

    if count == final:
        print(day)
        exit()
from bisect import *
n, k = map(int, input().split())
a = list(map(int, input().split()))

posi = 0
nega = 0
zero = 0
p = []
m = []

for i in range(n):
    if a[i] > 0:
        p.append(a[i])
        posi += 1
    elif a[i] < 0:
        nega += 1
        m.append(-a[i])
    else:
        zero += 1

p.sort()
m.sort()

if k <= posi*nega:
    l = 0
    r = 10**18
    while r - l > 1:
        mid = l+(r-l)//2
        count = k
        for i in range(len(p)-1, -1, -1):
            count -= posi-bisect_left(m, (mid-1)//p[i]+1)
            if count <= 0:
                break
        if count <= 0:
            l = mid
        else:
            r = mid
        #print(r, l)

    print(-l)

elif k <= posi*nega+zero*(zero-1)//2+zero*(posi+nega):
    print(0)

else:
	print("aa")
    k -= posi*nega+zero*(zero-1)//2+zero*(posi+nega)
    l = 0
    r = 10**18
    while r - l > 1:
        mid = l+(r-l)//2
        count = k
        for i in range(len(p)):
            count -= max(bisect_right(p, (mid)//p[i])-i-1, 0)
            if count < 0:
                #continue
                break
        for i in range(len(m)):
            count -= max(bisect_right(m, (mid)//m[i])-i-1, 0)
            if count < 0:
                #continue
                break

        if count > 0:
            l = mid
        else:
            r = mid
    print(r)


### FIXED CODE ###

from bisect import *
n, k = map(int, input().split())
a = list(map(int, input().split()))

posi = 0
nega = 0
zero = 0
p = []
m = []

for i in range(n):
    if a[i] > 0:
        p.append(a[i])
        posi += 1
    elif a[i] < 0:
        nega += 1
        m.append(-a[i])
    else:
        zero += 1

p.sort()
m.sort()

if k <= posi*nega:
    l = 0
    r = 10**18
    while r - l > 1:
        mid = l+(r-l)//2
        count = k
        for i in range(len(p)-1, -1, -1):
            count -= nega-bisect_left(m, (mid-1)//p[i]+1)
            if count <= 0:
                break
        if count <= 0:
            l = mid
        else:
            r = mid
        #print(r, l)

    print(-l)

elif k <= posi*nega+zero*(zero-1)//2+zero*(posi+nega):
    print(0)

else:
    k -= posi*nega+zero*(zero-1)//2+zero*(posi+nega)
    l = 0
    r = 10**18
    while r - l > 1:
        mid = l+(r-l)//2
        count = k
        for i in range(len(p)):
            count -= max(bisect_right(p, (mid)//p[i])-i-1, 0)
            if count < 0:
                #continue
                break
        for i in range(len(m)):
            count -= max(bisect_right(m, (mid)//m[i])-i-1, 0)
            if count < 0:
                #continue
                break

        if count > 0:
            l = mid
        else:
            r = mid
    print(r)
import itertools
N = int(input())
V = list(map(int, input().split()))
C = list(map(int, input().split()))

M = [[V[i], C[i]]for i in range(N)]
# print(M)

com_M = list(itertools.combinations(M, 2))
m_M = []
for i in range(N):
    X = com_M[i][0][0] + com_M[i][1][0]
    Y = com_M[i][0][1] + com_M[i][1][1]
    # print(X)
    # print(Y)
    m_M.append(X - Y)

print(max(m_M))


### FIXED CODE ###

import itertools
N = int(input())
V = list(map(int, input().split()))
C = list(map(int, input().split()))

M = [[V[i], C[i]]for i in range(N)]
#print(M)


tx = 0
R = 0
for i in range(N):
    tx = V[i] - C[i]
    if (tx > 0):
        R += tx

print(R)
N,M = map(int,input().split())
value = []
ans = [0]*M
for i in range(M):
    a,b = map(int,input().split())
    value.append([a,b])
    ans[a-1] += 1
    ans[b-1] += 1

for i in ans:
    print(i)



### FIXED CODE ###

N,M = map(int,input().split())
ans = [0]*N
for i in range(M):
    a,b = map(int,input().split())
    ans[a-1] += 1
    ans[b-1] += 1

for i in ans:
    print(i)
N,M = map(int,input().split())
A = ['a']*N
dic = {} 
for _ in range(M):
  s,c = map(int,input().split())
  if s in dic and dic[s] != c:
    print(-1)
    exit()
  elif s==1 and c == 0:
    print(-1)
    exit()
  else:
    dic[s] = c
  ans = ''
  for i in range(N):
    if i+1 in dic:
      ans += str(dic[i+1])
    elif i+1 == 1:
      ans += '1'
    else:
      ans += '0'
print(ans)

### FIXED CODE ###

N,M = map(int,input().split())
ret = ['a']*N
for _ in range(M):
  s,c = map(int,input().split())
  if ret[s-1] not in ['a', c]:
    print(-1)
    exit()
  ret[s-1] = c
if ret[0] == 0:
  if N != 1:
    print(-1)
    exit()
ans = ''
for i in range(N):
  if ret[i] != 'a':
    ans += str(ret[i])
  else:
    if i == 0 and N > 1:
      ans += '1'
    else:
      ans += '0'
print(int(ans))
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a


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


N = int(input())
T = [int(input()) for _ in range(N)]
LCM = lcm(T[0], T[1])

for i in range(1, N-1):
    LCM = lcm(LCM, T[i+1])

print(LCM)

### FIXED CODE ###

import sys
input = sys.stdin.readline


def gcd(a, b):
    while b:
        a, b = b, a % b
    return a


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


N = int(input())
T = [int(input()) for _ in range(N)]

if N == 1:
    print(T[0])

else:
    LCM = lcm(T[0], T[1])
    
    for i in range(1, N-1):
        LCM = lcm(LCM, T[i+1])
    
    print(LCM)
# key not available ""
n = int(input())
matrix = []
for _ in range(n):
    matrix.append([int(i) for i in input().split()])
dp = [[0 for i in range(3)] for j in range(n+1)]


def go(i, j):
    if i < 0:
        return 0
    ans = 0
    if dp[i][j] > 0:
        return dp[i][j]
    dp[i][j] = max(ans, go(i-1, (j+1) % 3)+matrix[i][j], go(i-1, (j+2) % 3)+matrix[i][j])
    return dp[i][j]


print(max(go(n-1, 2),go(n-1,1),go(n-1,0)))



### FIXED CODE ###

# key not available ""
n = int(input())
matrix = []
for _ in range(n):
    matrix.append([int(i) for i in input().split()])
dp = [[0 for i in range(3)] for j in range(n)]
for i in range(3):
    dp[0][i] = matrix[0][i]
for i in range(1,n):
    for j in range(3):
        if j == 0:
            dp[i][j] = max(dp[i-1][j+1],dp[i-1][j+2])+matrix[i][j]
        elif j == 1:
            dp[i][j] = max(dp[i-1][j+1],dp[i-1][j-1])+matrix[i][j]
        else:
            dp[i][j] = max(dp[i-1][j-1], dp[i-1][j-2]) + matrix[i][j]
print(max(dp[-1]))
import math
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a


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

g = gcd(a,b)


ans = 1
for i in range(2,int(math.sqrt(g))):
    while g%i == 0:
        g=g//i
        isdevided = True
    if isdevided:
        ans += 1
        isdevided = False
    if g == 1:
        break

print(ans)

### FIXED CODE ###

import math
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a


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

g = gcd(a,b)


arr = []
temp = g
for i in range(2, int(-(-g**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])

print(len(arr)+1)
import math

class Circle:
    def output(self, r):
        print "%.6f %.6f" % (math.pi * r * r, 2.0 * math.pi * r)

if __name__ == "__main__":
    cir = Circle()
    r = int(raw_input())
    cir.output(r)

### FIXED CODE ###

import math

class Circle:
    def output(self, r):
        print "%.6f %.6f" % (math.pi * r * r, 2.0 * math.pi * r)

if __name__ == "__main__":
    cir = Circle()
    r = float(raw_input())
    cir.output(r)
#

import itertools
from collections import Counter
from collections import defaultdict
from collections import deque
import bisect
from heapq import heappush, heappop

def solve(positions, s, t):
    # print('{}, s = {}, t = {}'.format(positions, s, t))
    if len(t) == 0:
        return 0
    if len(positions[t[0]]) == 0:
        return -1

    i = 0
    j = 0
    while i < len(s) and j < len(t):
        candidates = positions[t[j]]
        pos = bisect.bisect_left(candidates, i)
        if pos == len(candidates):
            break
        # print('pos = {} t = {}, i = {}'.format(candidates[pos], t[j], i))
        i = candidates[pos] + 1
        j += 1

    if j == len(t):
        return i
    else:
        rest = solve(positions, s, t[j:])
        return len(s) + rest if rest != -1 else -1


def main():
    s = input()
    t = input()

    positions = defaultdict(list)
    for i in range(len(s)):
        positions[s[i]].append(i)

    # check can or cannot
    print(solve(positions, s, t))


if __name__ == '__main__':
    main()


### FIXED CODE ###

#

import itertools
from collections import Counter
from collections import defaultdict
from collections import deque
import bisect
from heapq import heappush, heappop


def solve(positions, s, t):

    if not set(t) <= set(s):
        return -1

    loop = 0
    prev = -1

    for tchar in t:
        candidates = positions[tchar]
        pos = bisect.bisect_right(candidates, prev)

        if pos == len(candidates):
            loop += 1
            pos = 0
        prev = candidates[pos]

    return loop * len(s) + prev + 1


def main():
    s = input()
    t = input()

    positions = defaultdict(list)
    for i in range(len(s)):
        positions[s[i]].append(i)

    print(solve(positions, s, t))


if __name__ == '__main__':
    main()