Harryxun/stf_run huggingface dataset:
from math import *
from cmath import rect

def dft(f,x):
  if len(f)==1:
    return
  f0,f1=f[0::2],f[1::2]
  dft(f0,x)
  dft(f1,x)
  z=rect(1,x*2*acos(-1)/len(f))
  n=1+0j
  for i in range(len(f)):
    f[i]=f0[i%len(f0)]+n*f1[i%len(f1)]
    n=n*z

def pm(p,q):
  siz=1
  while len(p)+len(q)>siz:
    siz*=2
  np=[]
  nq=[]
  for i in range(len(p)):
    np.append(rect(p[i],0))
  for i in range(len(q)):
    nq.append(rect(q[i],0))
  while len(np)<siz:
    np.append(0+0j)
  while len(nq)<siz:
    nq.append(0+0j)
  dft(np,1)
  dft(nq,1)
  for i in range(siz):
    np[i]=np[i]*nq[i]
  dft(np,-1)
  EPS=0.1
  for i in range(siz):
    np[i]=int(np[i].real/siz+EPS)
  return np

H,W,K=map(int,input().split())
C=[input() for i in range(H)]
DP=0
X=[]
P=0

def poly(x):
  r=[0]*x
  r.append(1)
  r[0]+=1
  return r

def knapsack(L):
  if len(L)==1:
    return poly(L[0])
  a=knapsack(L[:len(L)//2])
  b=knapsack(L[len(L)//2:])
  return pm(a,b)[:K+1]

for i in range(1,1<<H):
  X=[0]*W
  for j in range(H):
    if i&(1<<j):
      for k in range(W):
        if C[j][k]=='#':
          X[k]+=1
  DP=knapsack(X)[K]
  if len(DP)>K:
    P+=DP[K]
print(P)

### FIXED CODE ###

H,W,K=map(int,input().split())
S=[input() for i in range(H)]
P=0
Q=0
for i in range(1<<H):
  for j in range(1<<W):
    Q=0
    for k in range(H):
      for l in range(W):
        if S[k][l]=='#' and i&(1<<k)!=0 and j&(1<<l)!=0:
          Q+=1
    if Q==K:
      P+=1
print(P)
def inputlist():
	n=int(input())
	A=list()
	for i in range(n):
		Ai = int(input())
		s=list()
		for i in range(Ai):
			s += input().split()
		s = [int(i) for i in s]
		A.append(s)
	return A

A=inputlist()
n=len(A)
ans=0
for i in range(2**n):
	bit_str = str(format(i,'015b'))
	p = 0
	for j in range(n):
		if ((i >> j) & 1):
			for k in range(0,len(A[j]),2):
				if (int(bit_str[(-1*A[j][k])-1]) == A[j][k+1]):
					p = 1
					continue
				else:
					p=0
					break
	if (p):
		ans+=1
print(ans)

### FIXED CODE ###

def inputlist():
	n=int(input())
	A=list()
	for i in range(n):
		Ai = int(input())
		s=list()
		for i in range(Ai):
			s += input().split()
		s = [int(i) for i in s]
		A.append(s)
	return A
A=inputlist()
n=len(A)
ans=0
for i in range(2**n):
	p = 1
	bit_str = str(format(i,'015b'))
	for j in range(n):
		if ((i >> j) & 1):
			for k in range(0,len(A[j]),2):
				if not(A[j][k+1] == int(bit_str[-1*A[j][k]])):
					p = 0
	if (p):
		ans = max(ans,bit_str.count('1'))
print(ans)
import math
r=int(input())
print("%.6f"%(r**2*math.pi),"%.6f"%(r*2*math.pi))

### FIXED CODE ###

# encoding:utf-8
import math

r = float(input())

area = r**2*math.pi
circumference = r * 2 * math.pi

area = ('%03.6f' % area)
circumference = ('%03.6f' % circumference)

print(area),
print(circumference)
def s(n,p):
  while n>0:yield n%p;n//=p
c=lambda*a:sum(s(*a));print(min(c(i,6)+c(n-i,9)for i in range(int(input())+1)))

### FIXED CODE ###

def s(n,c):
  if n<6:return c+n
  a=b=1
  while a*6<=n:a*=6
  while b*9<=n:b*=9
  return min(s(n-a,c+1),s(n-b,c+1))
print(s(int(input()),0))
r = input()
print(3*r*r)

### FIXED CODE ###

r = int(input())
print(3*r*r)
#!/usr/bin/env python
# -*- coding: utf-8 -*-

var = raw_input()
sum = var*var*var

print sum

### FIXED CODE ###

#!/usr/bin/env python
# -*- coding: utf-8 -*-

var = int(raw_input())
sum = var*var*var

print sum
n, m = map(int, input().split())
adj_matrix = [[0] * n for _ in range(N)]

for i in range(m):
  a, b = map(int, input().split())
  adj_matrix[a-1][b-1] = 1
  adj_matrix[b-1][a-1] = 1
  
def dfs(v, used):
  if not False in used:
    return 1
  
  ans = 0
  for i in range(n):
    if not adj_matrix[v][i]:
      continue
    if used[i]:
      continue
    
    used[i] = True
    ans += dfs(i, used)
    used[i] = False
    
  return ans

used = [False] * n
used[0] = True

print(dfs(0, used))

### FIXED CODE ###

N, M = map(int, input().split())
adj_matrix = [[0]* N for _ in range(N)]

for i in range(M):
    a, b = map(int, input().split())
    adj_matrix[a-1][b-1] = 1
    adj_matrix[b-1][a-1] = 1

def dfs(v, used):
    if not False in used:
        return 1
    
    ans = 0
    for i in range(N):
        if not adj_matrix[v][i]:
            continue
        if used[i]:
            continue
        
        used[i] = True
        ans += dfs(i, used)
        used[i] = False
    
    return ans

used = [False] * N
used[0] = True

print(dfs(0, used))
import math
s = int(input())
if s < 6:
    print("0")
else:
    bar = (s // 3) - 1
    ans = 0
    for i in range(bar+1):
        if i == 0:
            ans += 1
        else:
            val = s - 3 * (i+1)
            count = math.factorial(val+i) // (math.factorial(val) * math.factorial(i))
            ans += count % (10**9+7)
print(ans%(10**9+7))

### FIXED CODE ###

import math
s = int(input())
if s < 3:
    print("0")
else:
    bar = (s // 3) - 1
    ans = 0
    for i in range(bar+1):
        if i == 0:
            ans += 1
        else:
            val = s - 3 * (i+1)
            count = math.factorial(val+i) // (math.factorial(val) * math.factorial(i))
            ans += count % (10**9+7)
    print(ans%(10**9+7))
R, G = map(int, input().split())
print(2 * G - R)

### FIXED CODE ###

R = int(input())
G = int(input())
print(2 * G - R)
if a==1 :
    if b==2:
        print(3)
    elif b==3:
        print(2)
elif a ==2 :
    if b==1:
        print(3)
    elif b==3:
        print(1)
else:
    if b==1:
        print(2)
    elif b==2:
        print(1)

### FIXED CODE ###

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

if a==1 :
    if b==2:
        print(3)
    elif b==3:
        print(2)
elif a ==2 :
    if b==1:
        print(3)
    elif b==3:
        print(1)
else:
    if b==1:
        print(2)
    elif b==2:
        print(1)
A,B,C,D = map(int,input().split())
while A>0 && C>0:
    C=C-B
    A=A-D

if C<0:
    print("Yes")
else:
    print("No")


### FIXED CODE ###

A,B,C,D = map(int,input().split())
while True:
    C=C-B
    if C<=0:
        print("Yes")
        break

    A=A-D
    if A<=0:
        print("No")
        break
import numpy as np

a,b,x = input().split()
a = int(a)
b = int(b)
x = int(x)
ans = 0.000000000
if 2*x/(a**2) < b:
  l = 2*x/(a*b)
  ans = np.arctan(l/b)
else:
  l = 2 * (b - x/(a**2))
  ans = np.arctan(a/l)

ans = 90 - np.rad2deg(ans)
print('{:.10f}'.format(ans))

### FIXED CODE ###

import numpy as np

a,b,x = input().split()
a = int(a)
b = int(b)
x = int(x)
ans = 0
if 2*x/(a**2) < b:
  l = 2*x/(a*b)
  ans = np.arctan(l/b)
else:
  l = 2 * (b - x/(a**2))
  if l == 0:
    ans = np.pi/2
  else:
    ans = np.arctan(a/l)

ans = 90 - np.rad2deg(ans)
print('{:.10f}'.format(ans))
import sys

input = sys.stdin.readline
n,k = map(int,input().split())
a = list(map(int,input().split()))

if k ==1:
    print(a[a[0]-1])
    sys.exit()

z = 1
p = [1]
for _ in range(k):
    z = a[z-1]
    if z in p:
        p.append(z)
        break
    p.append(z)

# 周期の来る前の回数
num = p.index(p[-1])

p = p[num:]

# 周期
pn = len(p)-1

k -= num

# 回数/周期のあまり
anum = k%pn
print(p[anum])

### FIXED CODE ###

import sys

input = sys.stdin.readline
n,k = map(int,input().split())
a = list(map(int,input().split()))

p = [1]
for i in range(n):
    p.append(a[p[i]-1])

if k <= n:
    print(p[k])
else:
    # 周期の来る前の回数
    num = p.index(p[-1])
    p = p[num:]

    # 周期
    pn = len(p)-1
    k -= num

    # 回数/周期のあまり
    ans = k%pn
    print(p[ans])
import collections

def getls():
    return [ipt for ipt in input().split()]
def getlsi():
    return [int(ipt) for ipt in input().split()]
#Topological sort Gは辞書として渡す Lは空のリスト
def tsort(N,G,dic):
    res = 0
    #Topological Sort
    if dic[N] != -1:
        return dic[N]
    for node in G[N]:
        res = max(res,tsort(node,G,dic)+1)
    dic[N] = res
    return dic[N]

[n,m] = getlsi()
dic_next = collections.defaultdict(list)
dp = [-1] * n
for i in range(m):
    [x,y] = getlsi()
    dic_next[x-1].append(y-1)
ans = 0
for i in range(n):
    ans = max(ans,tsort(i,dic_next,dp))
print(ans)


### FIXED CODE ###

import collections
import sys
sys.setrecursionlimit(10**6)

def getls():
    return [ipt for ipt in input().split()]
def getlsi():
    return [int(ipt) for ipt in input().split()]
#Topological sort Gは辞書として渡す
def tsort(N,G,dic):
    res = 0
    #Topological Sort
    if dic[N] != -1:
        return dic[N]
    for node in G[N]:
        res = max(res,tsort(node,G,dic)+1)
    dic[N] = res
    return dic[N]

[n,m] = getlsi()
dic_next = collections.defaultdict(list)
dp = [-1] * n
for i in range(m):
    [x,y] = getlsi()
    dic_next[x-1].append(y-1)
ans = 0
for i in range(n):
    ans = max(ans,tsort(i,dic_next,dp))
print(ans)
N,K = map(int,input().split())
A = list(map(int,input().split()))
town = [[] for _ in range(N)]
visited = [0]

for i in range(N):
  town[i] = [i,A[i] - 1]

def teleport(i,con):
  goal = town[i][1]
  if goal in visited or con == N:
    return goal
  else:
    visited.append(goal)
    return teleport(goal,con + 1)

l = teleport(visited[0],0)

if K < len(visited):
  print(visited[K] + 1)
else:
  cs = visited.index(l)
  cycle = visited[cs:]
  K = K - len(visited) + len(cycle)
  print(cycle[K % len(cycle)] + 1)

### FIXED CODE ###

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

A = list(map(int,input().split()))
town = [[] for _ in range(N)]
visited = [0]
flag = [-1] * N

for i in range(N):
  town[i] = [i,A[i] - 1]

f = 0

while flag[f] == -1:
  t = town[f][1]
  flag[f] = t
  f = town[t][0]
  visited.append(t)
  
l = visited[-1]
lv = len(visited)

if K <= lv:
  print(visited[K] + 1)
else:
  cs = visited.index(l)
  cycle = visited[cs:-1]
  lc = len(cycle)
  print(cycle[(K - lv + 1) % lc] + 1)
##i
n,k =map(int,input().split())
a=[int(x ) for x in input().split()]
for i in range(k,n):
    if a[i-k]>a[i-1]:
        print("Yes")
    else:
        print("No")


### FIXED CODE ###

x=int(input())
if x in range(400,600):
    p=8
elif x in range(600,800):
    p=7
elif x in range(800,1000):
    p=6
elif x in range(1000,1200):
    p=5
elif x in range(1200,1400):
    p=4
elif x in range(1400,1600):
    p=3
elif x in range(1600,1800):
    p=2
elif x in range(1800,2000):
    p=1
print(p)
n,m=map(int,input().split())
step=list(range(n+1))
mod=10**9+7
for i in range(m):
    step.remove(int(input()))
dp=[0]*n+1
dp[0]=1
dp[1]=1
step.remove(0)
for i in range(2,n):
    dp[i]=(dp[i-1]+dp[i-2])
print(dp[n]%mod)

### FIXED CODE ###

N, M = list(map(int, input().split()))
A = {i: 0 for i in range(N+1)}
mod = 10 ** 9 + 7
for _ in range(M):
    A[int(input())] = 1
 
dp = [0 for _ in range(N+1)]
dp[0] = 1
 
for i in range(N+1):
    if A.get(i+1) == 0:
        dp[i + 1] += dp[i]
    if A.get(i+2) == 0:
        dp[i + 2] += dp[i]
 
print(dp[N]%mod)
a,b,c,d = map(int, input().split())
i = 0
for x in range(a, b+1):
  for y in range(c, c+1):
    x * y = z
    if z >= i:
      i = z
print(i)
    


### FIXED CODE ###

a, b, c, d = map(int, input().split())
ans = a * c
if a * d > ans:
    ans = a * d
if b * c > ans:
    ans = b * c
if b * d > ans:
    ans = b * d
print(ans)
sum_num = []
card_num = [1,0,-1]
for i,card in enumerate(a[0:3]):
  if card > a[3]:
    sum_num.append(a[3] * card_num[i])
    a[3] -= a[3]
  else:
    sum_num.append(card * card_num[i])
    a[3] -= card
print(sum(sum_num))

### FIXED CODE ###

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

#K枚の優先順位を選ぶ
#＋１の枚数分だけ選択、KからAを引く、総和のリストにA枚分の+1を追加
# K<Aのとき、K枚分だけリストにAを追加、KからKを引く
#0の枚数分だけ選択、KからBを引く、総和のリストにB枚分の0を追加

#・・・総和のリストないの総和を計算する
sum_num = []
card_num = [1,0,-1]
for i,card in enumerate(a[0:3]):
  if card > a[3]:
    sum_num.append(a[3] * card_num[i])
    a[3] -= a[3]
  else:
    sum_num.append(card * card_num[i])
    a[3] -= card
print(sum(sum_num))
N = int(input())
# N = 4n+7m 
if (N % 4 == 0) or (N % 7 == 0) or (N % 7 == 4):
  print("Yes")
else:
  print("No")

### FIXED CODE ###

N,K = map(int,input().split())
if N%K == 0:
  print(0)
else :
  print(1)
N, K = [int(_) for _ in stdin.readline().rstrip().split()]
L = sorted([int(_) for _ in stdin.readline().rstrip().split()], reverse=True)
print(sum(L[:k]))

### FIXED CODE ###

from sys import stdin
N, K = [int(_) for _ in stdin.readline().rstrip().split()]
L = sorted([int(_) for _ in stdin.readline().rstrip().split()], reverse=True)
print(sum(L[:K]))
R, G, B, N = map(int, input().split())
R, G, B = sorted([R, G, B], reverse=True)
maxR = N // R
ans = 0
if R == 1:
    ans += (N+2)(N+1) // 2
    print()
    quit()

for r in range(maxR+1):
    if r * R == N:
        ans += 1
        continue
    n = N - r * R
    maxG = n // G
    for g in range(maxG+1):
        if g * G == n:
            ans += 1
            continue
        nn = n - g * G
        maxB = nn // B
        for b in range(maxB+1):
            if b * B == nn:
                ans += 1

print(ans)

### FIXED CODE ###

R, G, B, N = map(int, input().split())
R, G, B = sorted([R, G, B], reverse=True)
maxR = N // R
ans = 0
if R == 1:
    ans = (N+2)*(N+1) // 2
    print(ans)
    quit()

for r in range(maxR+1):
    if r * R == N:
        ans += 1
        continue
    n = N - r * R
    maxG = n // G
    for g in range(maxG+1):
        if g * G == n:
            ans += 1
            continue
        nn = n - g * G
        maxB = nn // B
        for b in range(maxB+1):
            if b * B == nn:
                ans += 1

print(ans)
S = list(input().strip())
n = len(S)
def Remove(binList,lenList):
    for i in range(0,lenList-1):
        if (binList[i] == "0" and binList[i+1] == "1") or (binList[i] == "1" and binList[i+1] == "0"):
            del binList[i:i+2]
            return Remove(binList,lenList - 2)
    return binList
S = Remove(S,n)
print(n-len(S))

### FIXED CODE ###

S = list(input())
obj = min(S.count("0"),S.count("1"))
print(obj*2)
time=int(input())
sec=time%60
min=(time/60)%60
hour=time/3600
print(hour+":"+min+":"+sec)

### FIXED CODE ###

time=int(input())
sec=time%60
min=(time//60)%60
hour=time//3600
print(hour,min,sec,sep=':')
from collections import defaultdict
n,m = map(int,input().split())
city = [list(map(int,input().split())) for _ in range(m)]
d = defaultdict(list)
for k,v in city:
    d[k].append(v)
lis = [[] for _ in range(10**5+1)]
for i in d.keys():
    d[i].sort()
for i in d.keys():
    for j in range(len(d[i])):
        lis[d[i][j]].append(i)
        lis[d[i][j]].append(j+1)
for i in range(m):
    upper,lower = lis[city[i][1]][0], lis[city[i][1]][1]
    uplen,lolen = len(str(upper)),len(str(lower))
    if uplen<6:
        upper = '0'*(6-uplen)+str(upper)
    else:
        upper = str(upper)
    if lolen<6:
        lower = '0'*(6-lolen) + str(lower)
    else:
        lower = str(lower)
    print(upper+lower)

### FIXED CODE ###

n,m = map(int,input().split())
py = []
for i in range(m):
    num = i+1
    p,y = map(int,input().split())
    py.append([num,p,y])
py = sorted(py, key = lambda x:x[1]*10**10+x[2])
x = 0
b = '000000'
ans = []
for pyi in py:
    if pyi[1] != x:
        x = pyi[1]
        cnt = 1
    else:
        cnt += 1
    ans.append([pyi[0], (b+str(pyi[1]))[-6:], (b+str(cnt))[-6:]])
ans = sorted(ans, key = lambda x: x[0])
for ansi in ans:
    print(ansi[1]+ansi[2])
import sys
input = sys.stdin.readline

n, k = map(int, input().split())
*a, = map(int, input().split())

s = [0]*(n+1)
for i in range(len(a)):
    s[i+1] = s[i] + a[i]
for i in range(len(s)):
    s[i] = (s[i] - i)%k

cnt = [0]*k
left = 0
right = k-1
if right >= n:
    right = n-1

for i in range(right+1):
    cnt[s[i]] += 1

ans = 0
while left < right:
    ans += cnt[s[left]]-1
    if right == n:
        cnt[s[left]] -= 1
        left += 1
    else:
        cnt[s[left]] -= 1 
        left += 1
        right += 1
        cnt[s[right]] += 1 

print(ans)


### FIXED CODE ###

import sys
input = sys.stdin.readline

n, k = map(int, input().split())
*a, = map(int, input().split())

s = [0]*(n+1)
for i in range(len(a)):
    s[i+1] = s[i] + a[i]
for i in range(len(s)):
    s[i] = (s[i] - i)%k

from collections import defaultdict
cnt = defaultdict(int)

left = 0
right = k-1
if right > n:
    right = n

for i in range(right+1):
    cnt[s[i]] += 1

ans = 0
while left < right:
    ans += cnt[s[left]]-1
    if right == n:
        cnt[s[left]] -= 1
        left += 1
    else:
        cnt[s[left]] -= 1 
        left += 1
        right += 1
        cnt[s[right]] += 1 

print(ans)
import math
a,b = map(int, input().split())

print((a * b) // math.gcd(a,b))

### FIXED CODE ###

from fractions import gcd
a,b = map(int, input().split())

print((a * b) // gcd(a,b))
k,x=map(int, input().split())
print(" ".join([i for i in range(x-(k-1), x+(k-1)+1)]))

### FIXED CODE ###

k,x=map(int, input().split())
print(" ".join([str(i) for i in range(x-(k-1), x+(k-1)+1)]))
#a,b=map(int, input().split()) 

for i in range(a):
    if (a-i)*2+(i)*4 == b:
        print('Yes')
        break
  
 print('No')

### FIXED CODE ###

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

for i in range(a+1):
    if (a-i)*2+(i)*4 == b:
        print('Yes')
        break
    if i==a:
        print('No')
a,b=map(int,input().split())
c=input()
c[b]=c[b].lower()
print(c)

### FIXED CODE ###

a,b=map(int,input().split())
c=list(input())
c[b-1]=c[b-1].lower()
print(*c,sep="")
N, Q, *D = map(int, open(0).read().split())
val = [0 for _ in range(N+1)]
child = [[] for _ in range(N+1)]
for i in range(N-1):
  l, r = D[2*i], D[2*i+1]
  child[l].append(r)
D = D[-2*Q:]
for i in range(Q):
  l, r = D[2*i], D[2*i+1]
  val[l] += r
def dfs(c):
  for ch in child[c]:
    val[ch] += val[c]
    dfs(ch)
dfs(1)
print(' '.join(map(str, val[1:])))

### FIXED CODE ###

import sys
sys.setrecursionlimit(500000)
N, Q, *D = map(int, open(0).read().split())
val = [0 for _ in range(N+1)]
E = [[] for _ in range(N+1)]
D = list(zip(*[iter(D)]*2))
assert(len(D) == N+Q-1)
for i in range(N+Q-1):
  l, r = D[i][0], D[i][1]
  if i < N - 1:
  	E[l].append(r)
  	E[r].append(l)
  else:
    val[l] += r
visited = [False for _ in range(N+1)]
def dfs(c):
  visited[c] = True
  for ch in E[c]:
    if not visited[ch]:
      val[ch] += val[c]
      dfs(ch)
dfs(1)
print(' '.join(map(str, val[1:N+1])))
n=int(input())
t,a=map(int,input().split())
x=list(map(int,input().split()))
ans=0
cnt=10**3
for i in range(x):
  s=t-x[i]*0.006
  if abs(s-a)<cnt:
    cnt=abs(s-a)
    ans=i+1
print(ans)

### FIXED CODE ###

n=int(input())
t,a=map(int,input().split())
x=list(map(int,input().split()))
ans=0
cnt=10**3
for i in range(len(x)):
  s=t-x[i]*0.006
  if abs(s-a)<cnt:
    cnt=abs(s-a)
    ans=i+1
print(ans)
S = input()
if S[-1] = 's':
  return S + 'es'
else:
  return S + 's'


### FIXED CODE ###

def solution():
  S = input()
  if S[-1] == 's':
    return S + 'es'
  else:
    return S + 's'

print (solution())
N=int(input())
arr=[int(a) for a in input().split()]
ans=0
for i in range(i):
   c=0
   while arr[i]%2 ==0:
      arr[i]=arr[i]//2
      c=c+1
   ans=ans+c

print(ans)


### FIXED CODE ###

N=int(input())
arr=[int(a) for a in input().split()]
ans=0
for i in range(N):
   c=0
   while arr[i]%2 ==0:
      arr[i]=arr[i]//2
      c=c+1
   ans=ans+c

print(ans)
S = input()
k = []
ans = []
alphabet = ["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"]
for i in range(len(S)):
  k.append(S[i])
k = sorted(k)
for i in range(26):
  if k[i] not in alphabet:
    ans.append(k[i])
print(ans[0])


### FIXED CODE ###

S = input()
ls= ["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"]
ls2=["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"]
for i in range(len(S)):
  for j in range(len(ls)):
    if S[i] == ls[j]:
      if ls[j] in ls2:
        ls2.remove(ls[j])
      break
if len(ls2) == 0:
  print("None")
else:
  print(ls2[0])
print("reference: yaketate08")

from collections import deque

N, M = map(int, input().split())
UV = [list(map(int, input().split())) for _ in range(M)]
S, T = map(int, input().split())

graph = [[] for i in range(N + 1)]
for U, V in UV:
    graph[U].append(V)

INF = 10 ** 9

U = [[INF for _ in range(N)] for i in range(3)]
U[0][S] = 0 # S != T なのでこの表記はOK

#そうか、余りの数で最小のものを都度探す。
que = deque([(S, 0)])
while que:
    v, t = que.popleft()
    u = (t + 1) % 3
    d = U[t][v]
    if t == 2:
        d += 1
    Uu = U[u]
    for w in G[v]:
        if Uu[w] != INF:
            continue
        que.append((w, u))
        Uu[w] = d
print(U[0][T] if U[0][T] < INF else -1)

### FIXED CODE ###

import sys
readline = sys.stdin.buffer.readline

from collections import deque

N, M = map(int, input().split())
UV = [list(map(int, input().split())) for _ in range(M)]
S, T = map(int, input().split())
INF = 10 ** 15

if M == 0:
  print(-1)
  exit()

graph = [[] for _ in range(3 * M + 1)]
for u, v in UV:
  graph[u].append(v + M)
  graph[u + M].append(v + 2 * M)
  graph[u + 2 * M].append(v)

queue = deque([S])
dist = [INF] * (3 * M + 1)
dist[S] = 0

while queue:
  q = queue.popleft()
  for g in graph[q]:
    if dist[g] > dist[q] + 1:
      dist[g] = dist[q] + 1
      queue.append(g)
print(dist[T] // 3 if dist[T] != INF else -1)
from math import sqrt
from sys import stdin

def pm(n):
    l = list(range(3,n+1)[0::2])
    p = 3
    i = 0
    p = l[i]
    m = sqrt(n)+1
    while p <= m:
        l = l[:i+1] + [n for n in l[i+1:] if n%p != 0]
        i += 1
        p = l[i]
    return len(l) + 1

for n in stdin:
    print (pm(int(n)))

### FIXED CODE ###

from math import sqrt,floor
from sys import stdin

def cntPrime(n):
    mx = sqrt(n)
    if n % 2 == 0:
      l = [0, 1] + [1, 0] * (int(n/2) - 1)
    else:
      l = [0, 1] + [1, 0] * (int(n/2) - 1) + [1]
    c = 3
    while c < mx:
        for k in range(c*2, n+1, c):
            l[k-1] = 0
        c = l[(c+1):].index(1) + c +2
        while c % 2 == 0:
            c = l[(c+1):].index(1) + c +2
    return l
t = cntPrime(1000000)
for n in stdin:
    n = int(n)
    print(sum(t[:n]))
n=int(input())
A=[[int(i)] for i in input().split()]

for i in range(n):
  A[i].append(i)
A=sorted(A, key=lambda x:x[0])
B=[A[i][1]+1 for i in range(n)]

print(*B)

### FIXED CODE ###

n=int(input())
ans=(n/2+(n%2)*0.5)/n
print(ans)
import numpy as np
n=int(input())
mod=10**9+7
def searchPrimeNum(N):
    max = int(np.sqrt(N))
    searchList = [i for i in range(2,N+1)]
    primeNum = []
    while searchList[0] <= max:
        primeNum.append(searchList[0])
        tmp = searchList[0]
        searchList = [i for i in searchList if i % tmp != 0]
    primeNum.extend(searchList)
    return primeNum
l=len(searchPrimeNum(n))
plist=searchPrimeNum(n)
cnt=[0]*l
for i in range(l):
  k=1 
  while plist[i]**k<n:
    cnt[i]+=n//(plist[i]**k)
    k+=1
ans=1
for i in cnt:
  ans=(ans*i)%mod
print(ans)

### FIXED CODE ###

import sys
import numpy as np
n=int(input())
mod=10**9+7
if n==1:print(1);sys.exit()
def searchPrimeNum(N):
    max = int(np.sqrt(N))
    searchList = [i for i in range(2,N+1)]
    primeNum = []
    while searchList[0] <= max:
        primeNum.append(searchList[0])
        tmp = searchList[0]
        searchList = [i for i in searchList if i % tmp != 0]
    primeNum.extend(searchList)
    return primeNum
l=len(searchPrimeNum(n))
plist=searchPrimeNum(n)
cnt=[0]*l
for i in range(l):
  k=1 
  while plist[i]**k<=n:
    cnt[i]+=n//(plist[i]**k)
    k+=1
ans=1
for i in cnt:
  ans=(ans*(i+1))%mod
print(ans)
from collections import deque

n = int(input())
A = deque(map(int, input().split()))
num = list(sorted(A, reverse=True))

count = 0
for i in range(n - 1):
    count += len(A) - 1 - A.index(num[i])
    A.remove(num[i])

print(count)

### FIXED CODE ###

def merge(A, left, mid, right):
    global count
    banpei = 1000000001
    L = A[left:mid]
    l = len(L)
    L += [banpei]
    R = A[mid:right] + [banpei]

    i, j = 0, 0
    for k in range(left, right):
        if L[i] <= R[j]:
            A[k] = L[i]
            i += 1
        else:
            A[k] = R[j]
            j += 1
            count += l - i
    return count


def merge_Sort(A, left, right):
    if 1 < right - left:
        mid = (left + right) // 2
        merge_Sort(A, left, mid)
        merge_Sort(A, mid, right)
        merge(A, left, mid, right)

n = int(input())
A = list(map(int, input().split()))
count = 0
merge_Sort(A, 0, n)
print(count)