Harryxun/stf_run huggingface dataset:
import functools

def multiply(x, y):
  mod = pow(10,9) + 7
  ans = x * y
  if ans >= mod or ans < 0:
    ans %= mod
  return ans

n, k = map(int, input().split())
num = list(map(int, input().split()))
sort_num = sorted(num, reverse=True)
abssort_num = sorted(num, key = abs, reverse=True)
minusNum = 0
cnt = 0
answer = 1
mod = pow(10,9) + 7
flg = -1
minusCnt = 0
delFlg = 0
if (sort_num[0] < 0) and (k % 2 == 1):
  combi = abssort_num[-k:]
  answer = functools.reduce(multiply, combi)
elif k == n:
  answer = functools.reduce(multiply, num)
else:
  for i in range(n):
    if abssort_num[i] < 0:
      minusCnt += 1
      flg = i
  if minusCnt != 0:
    if (minusCnt % 2) == 1:
      del abssort_num[flg]
      n -= 1
  for i in range(n):
    if cnt == k:
      break
    if cnt == k - 1:
      if minusNum % 2 == 0:
        if abssort_num[i] > 0:
          answer *= abssort_num[i]
          answer %= mod
          break
        else:
          continue
      else:
        if abssort_num[i] < 0:
          answer *= abssort_num[i]
          answer %= mod
          break
        else:
          continue
    else:
      answer *= abssort_num[i]
      answer %= mod
      cnt += 1
      if abssort_num[i] < 0:
        minusNum += 1
  delNum = []
  for i in range(n):
      if abssort_num[i] < 0:
          delNum.append(i)
          n -= 1
  for i in delNum:
      del abssort_num[i]
  if n >= k:
      combi = abssort_num[:k]
      if functools.reduce(multiply, combi) > answer:
          answer = functools.reduce(multiply, combi)
print(answer)


### FIXED CODE ###

import functools

def sign(x):
    if x>0:
        return 1
    elif x==0:
        return 0
    else:
        return -1

def multiply(x,y):
    ans = x*y
    if ans>=10**9+7 or ans<0:
        ans %= (10**9+7)
    return ans

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

if (A[-1]<0 and K%2==1):
    combi = A[-K:]
    if K >1:
        answer =  functools.reduce(multiply,combi)

elif K == N:
    answer = functools.reduce(multiply,A)

else:
    signs = 1
    i,j = 0,0
    for _ in range(K):
        if abs(A[i]) > abs(A[N-j-1]):
            signs *= sign(A[i])
            i += 1

        else:
            signs *= sign(A[N-j-1])
            j += 1
    combi = A[N-j:] + A[:i]
    del A[N-j:]
    del A[:i]
    combi = combi[::-1]

    if signs == -1:
        if A:
            if combi[-1]<0:
                del combi[0]
                combi.append(A[-1])
            elif A[0]>=0:
                del combi[0]
                combi.append(A[-1])
            elif A[0]<0 and A[-1] >0:
                if combi[0]*A[0] > combi[-1]*A[-1]:
                    del combi[-1]
                    combi.insert(0,A[0])
                else:
                    del combi[0]
                    combi.append(A[-1])
            elif A[-1] <= 0:
                del combi[-1]
                combi.insert(0,A[0])

    answer =  functools.reduce(multiply,combi)
print(answer)
N,X=map(int,input().split())
L=sorted(map(int,input().split()),reverse=True)
mod=10**9+7

D=[[0]*(X+1) for i in range(N//2+1)]
D[1][L[0]]=1

for l in L[1:]:
    ND=[[0]*(X+1) for i in range(N//2+1)]

    for c in range(1,N//2+1):
        for s in range(X+1):
            if D[c][s]==0:
                continue
            
            k=D[c][s]

            if s+l+c<=X and c+1<=N//2:
                ND[c+1][s+l]=(ND[c+1][s+l]+k*(c+1))%mod
            ND[c][s]=(ND[c][s]+k*(s-c*(l-1)))%mod

            for i in range(1,min(X-s-c+2,l+1)):
                ND[c][s+i]=(ND[c][s+i]+k*2*c)%mod

            if c==1:
                continue

            for i in range(1,min(X-s-c+3,l+1)):
                ND[c-1][s+i]=(ND[c-1][s+i]+k*(c-1)*(l-i+1))%mod
    D=ND

print(D[1][X])

### FIXED CODE ###

N,X=map(int,input().split())
L=sorted(map(int,input().split()),reverse=True)
mod=10**9+7

D=[[0]*(X+1) for i in range(N//2+2)]
D[1][L[0]]=1

for l in L[1:]:
    ND=[[0]*(X+1) for i in range(N//2+1)]

    for c in range(1,N//2+1):
        for s in range(X+1):
            if D[c][s]==0:
                continue
            
            k=D[c][s]

            if s+l+c<=X and c+1<=N//2:
                ND[c+1][s+l]=(ND[c+1][s+l]+k*(c+1))%mod
            ND[c][s]=(ND[c][s]+k*(s-c*(l-1)))%mod

            for i in range(1,min(X-s-c+2,l+1)):
                ND[c][s+i]=(ND[c][s+i]+k*2*c)%mod

            if c==1:
                continue

            for i in range(1,min(X-s-c+3,l+1)):
                ND[c-1][s+i]=(ND[c-1][s+i]+k*(c-1)*(l-i+1))%mod
    D=ND

print(D[1][X])
x = list(map(int,input().split()))
 
for i in range(len(x)):
	if x[i] == 0:
    	print(i+1)
    	break


### FIXED CODE ###

x = list(map(int,input().split()))
 
for i in range(len(x)):
  if x[i] == 0:
    print(i+1)
    break
n,m = map(int,input().split())
ll = []
rl = []

for i in range(m):
  l,r = list(map(int,input().split()))
  ll.append(l)
  rl.append(r)
  
if min(rr)<max(ll):
  print("0")

else:
  print(abs(max(rr)-min(ll)+1))

### FIXED CODE ###

n,m = map(int,input().split())
ll = []
rl = []
 
for i in range(m):
  l,r = list(map(int,input().split()))
  ll.append(l)
  rl.append(r)
  
if min(rl)<max(ll):
  print("0")
 
else:
  print(abs(min(rl)-max(ll)+1))
y,x = [int(x) for x in input().split()]
if(not y*x  == 0):
    for i in range(y):
        print('#'*x)    print('#'*x)

### FIXED CODE ###

y,x = [int(x) for x in input().split()]
while(x > 0 or y > 0):
    for i in range(y):
        print('#'*x)
    print()
    y,x = [int(x) for x in input().split()]
N, u, v = list(map(int, input().split()))
graph = [[] for _ in range(N+1)]
for i in range(N-1):
  A, B = list(map(int, input().split()))
  graph[A].append(B)
  graph[B].append(A)
#print(graph)

def dfs(v):
  dist = [-1] * (N+1)
  dist[v] = 0
  stack = [v
 # print(dist)
  while stack:
    now = stack.pop()
    dw = dist[now] + 1
#graph[]は隣接している要素
    for ne in graph[now]:
      if dist[ne] >= 0:
        continue
      dist[ne] = dw
      stack.append(ne)
      #print(ne)
  return dist

Taka = dfs(u)
Ao = dfs(v)

ans = 0
for t, a in zip(Takahashi[1:], Aoki[1:]):
  if t < a:
    ans = max(ans, a-1)

print(ans)


### FIXED CODE ###

A = int(input())
B = int(input())

print(6-A-B)
N,M=map(int,input().split())
n1=min(N,M//2)
N-=n1
M-=2*n1
print(ans+(M-2*n1)//4)


### FIXED CODE ###

N,M=map(int,input().split())
n1=min(N,M//2)
print(n1+(M-2*n1)//4)
#２つでの再酥油公倍数
def lcm_base(x, y):
    import math
    return (x * y) // math.gcd(x, y)

def lcm_list(numbers):
    from functools import reduce
    return reduce(lcm_base, numbers, 1)


def main():
    n = int(input())
    array = list(map(int, input().split()))
    lcm = lcm_list(array)

    total = 0
    for i,num in enumerate(array):
        total += lcm / num
    print(int(total%(10**9+7)))

if __name__ == '__main__':
    main()

### FIXED CODE ###

def main():
    import fractions
    n = int(input())
    array = list(map(int, input().split()))
    lcm = array[0]
    for i in range(1, n):
        lcm = lcm * array[i] // fractions.gcd(lcm, array[i])

    total = 0
    for i,num in enumerate(array):
        total += lcm // num
    print(int(total%(10**9+7)))

if __name__ == '__main__':
    main()
r=[float(x) for x in input().split()]
print(float(r**2*3.1412),float(2*r*3.1412))


### FIXED CODE ###

from math import pi
r = float(input())
print("{:.010f} {:.010f}".format(r * r * pi, 2 * pi * r))
n = int(input())
a = list(map(int, input().split())
print(sum(a)-n)

### FIXED CODE ###

n = int(input())
a = list(map(int, input().split()))
ans = sum(a) - n
print(ans)
x, a = map(int, input().split()
if x < a:
    print(0)
else:
    print(10)

### FIXED CODE ###

x, a = map(int, input().split())
if x < a:
    print(0)
else:
    print(10)
N = int(input())
x = 1
alphabet = {i-96:chr(i) for i in range(97, 97+26)}
if int(N) > 26:
    ans = ''
    while x != 0:
        x = N // 26
        mod = N%26
        #print(x, mod, alphabet[mod])
        ans += alphabet[mod]
        N = x
else:
    ans = alphabet[int(N)]
print(ans[::-1])

### FIXED CODE ###

N = int(input())
x = 1
alphabet = {i-96:chr(i) for i in range(97, 97+26)}
if int(N) > 26:
    ans = ''
    while x != 0:
        x = N // 26
        mod = N%26
        #print(x, mod)
        if mod == 0:
            ans += 'z'
            #x -= x%26
            x -= 1
        else:
        #print(x, mod, alphabet[mod])
            ans += alphabet[mod]
        N = x
else:
    ans = alphabet[int(N)]
print(ans[::-1])
n = int(input())
a_list = []
for i in range(n):
    a, b = map(int, input().split())
    a_list.append([a,b])

a_list.sort(key = sortSecond)

def detect(alist):
  time = 0
  for item in a_list:
    if time >= item[1]:
      return "No"
    else:
      time += item[0]
  return "Yes"

print(detect(a_list))

### FIXED CODE ###

n = int(input())
a_list = []
for i in range(n):
    a, b = map(int, input().split())
    a_list.append([a,b])

new_list = sorted(a_list, key = lambda x: x[1])

def detect(alist):
  time = 0
  for item in alist:
      time += item[0]
      if time > item[1]:
        return "No"
  return "Yes"

print(detect(new_list))
admission = []
n = int(input())
admission.append(map(int,input().split()))

for i in range(n):
    if admission[n+1] % 2 == 0:
        if admission[n+1] % 3 == 0 or admission[n+1] % 5 == 0:
            print("APPROVED")
        else:
            print("DENIED")


### FIXED CODE ###

n = int(input())
a = map(int,input().split())
for l in a:
    if l % 2 ==0:
        if l % 3 == 0 or l % 5 == 0:
            continue
        else:
            print("DENIED")
            quit()
print("APPROVED")
n,m = map(int,input().split())
for x in range(n+1):
  for y in range(n+1):
    z = n - x - y
    if (10000*x + 5000*y + 1000*z == m and \
        x + y + z = m and \
        0 <= z <= n:
        print(x,y,z)
print('-1 -1 -1')
        

### FIXED CODE ###

n,m = map(int,input().split())
for x in range(n+1):
  for y in range(n+1):
    z = n - x - y
    if (10000*x + 5000*y + 1000*z == m and x + y + z == n and 0 <= z <=n):
        print(x,y,z)
        exit()
print('-1 -1 -1')
H, N = map(int, input().split())
A = list(map(int, input().split()))

s=0

for i in range(N):
    s+=A[i]
if(s>=H):
    print(Yes)
else:
    print(No)


### FIXED CODE ###

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

s=0

for i in range(N):
    s+=A[i]
if(s>=H):
    print("Yes")
else:
    print("No")
X,Y = map(int,input().split())
# 何回移動するか
r = (X+Y)//3
# 移動の可能性 rC(x-r)
from functools import reduce
mod = 10**9+7
if (X+Y)%3==0:
    r = (X+Y)//3
    if r != X and r != Y:
        try:
            num = reduce(lambda x,y:x*y%mod,[k+1 for k in range(r)])
            p = reduce(lambda x,y:x*y%mod,[k+1 for k in range(X-r)])
            q = reduce(lambda x,y:x*y%mod,[k+1 for k in range(2*r-X)])
            ans = num*pow(p,mod-2,mod)*pow(q,mod-2,mod)%mod
            print(ans%mod)  
        except:
            num = reduce(lambda x,y:x*y%mod,[k+1 for k in range(r)])
            p = reduce(lambda x,y:x*y%mod,[k+1 for k in range(X-r)])
            ans = num*pow(p,mod-2,mod)%mod
            print(ans%mod)  
    else:
        print(1)
else:
    print(0)

### FIXED CODE ###

X,Y = map(int,input().split())
# 何回移動するか
r = (X+Y)//3
# 移動の可能性 rC(x-r)
from functools import reduce
mod = 10**9+7

if (X+Y)%3==0 and X<= 2*Y and Y<= 2*X :
    r = (X+Y)//3
    l = min
    if r != X and r != Y:
        num = reduce(lambda x,y:x*y%mod,[k+1 for k in range(r)])
        p = reduce(lambda x,y:x*y%mod,[k+1 for k in range(X-r)])
        q = reduce(lambda x,y:x*y%mod,[k+1 for k in range(2*r-X)])
        ans = num*pow(p,mod-2,mod)*pow(q,mod-2,mod)%mod
        print(ans%mod)   
    else:
        print(1)
else:
    print(0)
c = input()
print chr(ord(c) + 1)

### FIXED CODE ###

c = str(input())

print(chr(ord(c)+1))
n = int(input())

s = []
for i in range(n):
  s.append(input())
  
s.sort()

print(s)
t =[]
count = 1
for i in range(1,n):
  if s[i-1] == s[i] and i != n-1:
    count+=1
  elif s[i-1] == s[i] and i == n-1:
    count += 1
    t.append([s[i-1],count])
  elif i == n-1:
    t.append([s[i-1],1])
  else:
    t.append([s[i-1],count])
    count = 1

t.sort(key=lambda x:x[1])

for j in range(len(t)-1,0,-1):
  if t[j][1] != t[j-1][1]:
    k = j
    break
for b in range(k,len(t)):
  print(t[b][0])

### FIXED CODE ###

n = int(input())

s = []
for i in range(n):
  s.append(input())
  
s.sort()
t =[]
count = 1
for i in range(1,n):
  if s[i-1] == s[i] and i != n-1:
    count+=1
  elif s[i-1] == s[i] and i == n-1:
    count += 1
    t.append([s[i-1],count])
  elif i == n-1:
    t.append([s[i-1],1])
    t.append([s[i],1])
    
  else:
    t.append([s[i-1],count])
    count = 1

t.sort(key=lambda x:x[1])
ma = t[len(t)-1][1]

for i in range(len(t)):
  if t[i][1] == ma:
    print(t[i][0])
X = input()
A = input()

x = int(X)
a = int(A)

if x < a:
    print(0)

elif a > x:
    print(10)

### FIXED CODE ###

c = input()
l = c.split()

x = int(l[0])
a = int(l[1])

if x < a:
    print(0)

elif a <= x:
    print(10)
import math
a,b,c = map(int,input(),split())
n = math.pow((c-a-b),2)
m = 4*a*b
if(a+b >= c)
    print("No")
else
    if(n > m)
        print("Yes")
    else
        print("No")

### FIXED CODE ###

import math
a,b,c = map(int,input().split())
l = 4*a*b
r = (c-a-b)**2
if (a+b >= c):
    print("No")
else:
    if(l < r):
        print("Yes")
    else:
        print("No")
['SAT', 'FRI', 'THU', 'WED', 'TUE', 'MON', 'SUN']
s = input()
for num, i in enumerate(w):
  if i == s:
    print(num+1)

### FIXED CODE ###

w = ['SAT', 'FRI', 'THU', 'WED', 'TUE', 'MON', 'SUN']
s = input()
for num, i in enumerate(w):
  if i == s:
    print(num+1)
import sys
input = sys.stdin.readline
from collections import *

N, K = map(int, input().split())
A = list(map(int, input().split()))
MOD = 10**9+7
p, n = [], []
flag = False

for Ai in A:
    if Ai==0:
        flag = True
    elif Ai>0:
        p.append(Ai)
    else:
        n.append(Ai)

if len(p)==0 and K%2==1:
    if 0 in A:
        print(0)
    else:
        n.sort(reverse=True)
        ans = 1
        
        for ni in n[:K]:
            ans *= ni
            ans %= MOD
        
        print(ans)
    exit()
    
if K==N:
    ans = 1
    
    for Ai in A:
        ans *= Ai
        ans %= MOD
    
    print(ans)
    exit()

p.sort(reverse=True)
n.sort()

if K%2==0:
    l = []
    
    for i in range(len(p)//2):
        l.append(p[2*i]*p[2*i+1])
    
    for i in range(len(n)//2):
        l.append(n[2*i]*n[2*i+1])

    l.sort(key=lambda x: abs(x), reverse=True)
    ans = 1
    
    for i in range(K//2):
        ans *= l[i]
        ans %= MOD
else:
    ans = p[0]
    l = []
    
    for i in range(len(p)//2):
        l.append(p[2*i]*p[2*i+1])
    
    for i in range(len(n)//2):
        l.append(n[2*i]*n[2*i+1])
    
    l.sort(key=lambda x: abs(x), reverse=True)
    
    for i in range((K-1)//2):
        ans *= l[i]
        ans %= MOD

print(ans)


### FIXED CODE ###

import sys
input = sys.stdin.readline

N, K = map(int, input().split())
A = list(map(int, input().split()))
MOD = 10**9+7
p, n = [], []

for i in range(N):
    if A[i]>=0:
        p.append(A[i])
    else:
        n.append(A[i])

ok = False

if len(p)>0:
    if N==K:
        if len(n)%2==0:
            ok = True
    else:
        ok = True
else:
    if K%2==0:
        ok = True

if not ok:
    A.sort(key=lambda x: abs(x))
    ans = 1
    
    for Ai in A[:K]:
        ans *= Ai
        ans %= MOD

    print(ans)
    exit()

p.sort(reverse=True)
n.sort()

if K%2==1:
    ans = p[0]
    p = p[1:]
else:
    ans = 1
    
l = []
    
for i in range(len(p)//2):
    l.append(p[2*i]*p[2*i+1])
    
for i in range(len(n)//2):
    l.append(n[2*i]*n[2*i+1])

l.sort(key=lambda x: abs(x), reverse=True)

for li in l[:K//2]:
    ans *= li
    ans %= MOD
    
print(ans)
N, L = map(int, input().split())
S = []
for i in range(N):
    line = input()
    S.append(line)
S.sort()
print("".join(S))

### FIXED CODE ###

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

arr = [A, B, C]
fives = 0
sevens = 0

for num in arr:
    if num == 5:
        fives += 1
    if num == 7:
        sevens += 1

if fives == 2 and sevens == 1:
    print("YES")
else:
    print("NO")
n = int(inpur())
s = input()
half = n//2

if s == (s[0:half] + s[0:half]:
         print("Yes")
else:
         print("No")

### FIXED CODE ###

n = int(input())
s = input()
half = n//2

if half == 0:
  				print("No")

elif s == (s[0:half] + s[0:half]):
                 print("Yes")
else:
                 print("No")
import math 
a, b, c = map(int, input().split())
if math.sqrt(a) + math.sqrt(b) - math.sqrt(c) < 0
  print('Yes')
else:
  print('No')

### FIXED CODE ###

import math 
a, b, c = map(int, input().split())
if (a * b * 4 < (c - a - b) * (c - a - b)) and (c - a - b) > 0:
  print('Yes')
else:
  print('No')
height,width=map(int,input().split())
graph = [[s for s in input()] for i in range(height)]

for r in range(width):
    for c in range(height):
        if graph[r][c]==".":
            continue

        if r>1 and graph[r-1][c]=="#":
            continue

        if r<width-1 and graph[r+1][c]=="#":
            continue

        if c>1 and graph[r][c-1]=="#":
            continue

        if c<height-1 and graph[r][c+1]=="#":
            continue

        print("No")
        exit()
print("Yes")



### FIXED CODE ###

height,width=map(int,input().split())
graph = [[s for s in input()] for i in range(height)]

for r in range(height):
    for c in range(width):
        if graph[r][c]==".":
            continue

        if r>0 and graph[r-1][c]=="#":
            continue

        if r<width-1 and graph[r+1][c]=="#":
            continue

        if c>0 and graph[r][c-1]=="#":
            continue

        if c<height-1 and graph[r][c+1]=="#":
            continue

        print("No")
        exit()
print("Yes")
import time
from bisect import bisect_left
t = time.time()
H,W,m = map(int,input().split())
h = [0]*(H+1)
w = [0]*(W+1)
c = [[-1] for i in range(H+1)]
for i in range(m):
    a,b = map(int,input().split())
    h[a] += 1
    w[b] += 1
    c[a].append(b)
mh = max(h)
mw = max(w)
hkouho = []
wkouho = []
for i in range(H+1):
    if h[i] == mh:
        hkouho.append(i)
for i in range(W+1):
    if w[i] == mw:
        wkouho.append(i)
for i in range(H+1):
    c[i].sort()
# print(hkouho)
# print(wkouho)
for i in hkouho:
    for j in wkouho:
        # print(i,j,bisect_left(c[i],j))
        if c[i][bisect_left(c[i],j)] != j:
        # if j not in c[i]:
            print(mh+mw)
            exit()
        if time.time()-t > 2.7:
            print(mh+mw-1)
            exit()
print(mh+mw-1)

### FIXED CODE ###

import time
from bisect import bisect_left
t = time.time()
H,W,m = map(int,input().split())
h = [0]*(H+1)
w = [0]*(W+1)
c = [[-1,10**6] for i in range(H+1)]
for i in range(m):
    a,b = map(int,input().split())
    h[a] += 1
    w[b] += 1
    c[a].append(b)
mh = max(h)
mw = max(w)
hkouho = []
wkouho = []
for i in range(H+1):
    if h[i] == mh:
        hkouho.append(i)
for i in range(W+1):
    if w[i] == mw:
        wkouho.append(i)
for i in range(H+1):
    c[i].sort()
# print(hkouho)
# print(wkouho)
for i in hkouho:
    for j in wkouho:
        # print(c[i],i,j,bisect_left(c[i],j))
        if c[i][bisect_left(c[i],j)] != j:
            print(mh+mw)
            exit()
        if time.time()-t > 2.7:
            print(mh+mw-1)
            exit()
print(mh+mw-1)
N, M = map(int,input().split())
List_A = list(map(int,input().split()))
List_BC = [list(map(int,input().split())) for i in range(M)]

List_A.sort()
List_BC.sort(key=lambda x:x[1], reverse=True)
flag = 0
k = 0

for i in range(M):
    for j in range(List_BC[i][0]):
        if List_BC[i][1] > List_A[k] and k < N:
            List_A[k] = List_BC[i][1]
            k += 1
        else:
            flag = 1
            break
    if flag == 1:
        break

tmp = 0
for i in range(N):
    tmp += List_A[i]
    
print("{}".format(tmp))

### FIXED CODE ###

N, M = map(int,input().split())
List_A = list(map(int,input().split()))
List_BC = [list(map(int,input().split())) for i in range(M)]

List_A.sort()
List_BC.sort(key=lambda x:x[1], reverse=True)
flag = 0
k = 0

for i in range(M):
    for j in range(List_BC[i][0]):
        if k >= N:
            flag = 1
            break
        elif List_BC[i][1] > List_A[k]:
            List_A[k] = List_BC[i][1]
            k += 1
        else:
            flag = 1
            break
    if flag == 1:
        break

tmp = 0
for i in range(N):
    tmp += List_A[i]
    
print("{}".format(tmp))
n,m = map(int, input().split())
p = list(map(int, input().split()))
par = list(range(n))
rank = [0 for x in range(n)]

def root(x):
	if par[x] == x:
		return x
	else:
		return root(par[x])
def merge(x, y):
	x = root(x)
	y = root(y)
	if x == y:
		pass
	else:
		if rank[x] > rank[y]:
			par[y] = x
			rank[y] += rank[x]
		else:
			par[x] = y
			rank[x] += rank[y]
	pass

for i in range(m):
	x, y = map(int, input().split())
	merge(x-1, y-1)

ans = 0

for i in range(n):
	if p[i]-1 == i:
		ans += 1
	elif root(p[i]-1) == root(i):
		ans += 1

print(ans)

### FIXED CODE ###

n,m = map(int, input().split())
p = list(map(int, input().split()))
par = [i for i in range(n)]
rank = [0 for x in range(n)]

def root(x):
	tmp = par[x]
	if tmp == x:
		return x
	else:
		a = root(tmp)
		par[x] = a
		return a

def merge(x, y):
	x = root(x)
	y = root(y)
	if x == y:
		return
	else:
		if rank[x] > rank[y]:
			par[y] = x
			rank[y] += rank[x]
		else:
			par[x] = y
			rank[x] += rank[y]
		return

for i in range(m):
	x, y = map(int, input().split())
	merge(x-1, y-1)

ans = 0

for i in range(n):
	if p[i]-1 == i:
		ans += 1
	elif root(p[i]-1) == root(i):
		ans += 1

print(ans)
import math
a,b,x=map(int,input().split())
if a**2*b>=2*x:
  ans=math.degrees(math.atan(2*x/(a*b**2)))
  print(90-ans)
else:
  ans=math.degrees(math.atan(a**2/(2*a*b-2*x/a)))
  print(90-ans)

### FIXED CODE ###

a,b=map(int,input().split())
if a<=9 and b<=9:
  print(a*b)
else:
  print(-1)
n = int(input())
a = [int(_) for _ in input().split()]

sub_num = [0]*(2*10**5)

for i in range(1, n+1):
#    print(abs(int(a[i-1]-i)))
    sub_num[abs(int(a[i-1]-i))] += 1

b = -sub_num.index(max(sub_num))
#print(b)

result = 0
for i in range(1, n+1):
    result += abs(a[i-1] - (b + i))

print(result)

### FIXED CODE ###

import numpy as np

n = int(input())
a = [int(_) for _ in input().split()]

sub_num = []

for i in range(1, n+1):
#    print(abs(int(a[i-1]-i)))
    sub_num.append(int(a[i-1]-i))


b = np.median(sub_num)
#print(b)

result = 0
for i in range(n):
    result += abs(sub_num[i] - b)

print(int(result))
n = int(input())
a = [int(input()) for i in range(n)]
l = [0 for i in range(n)]
for i in range(len(a)):
    while a[i] % 2 == 0:
        a[i] /= 2
        l[i] += 1
print(min(l))

### FIXED CODE ###

n = int(input())
a = list(map(int, input().split()))
l = [0 for i in range(n)]
for i in range(len(a)):
    while a[i] % 2 == 0:
        a[i] /= 2
        l[i] += 1
print(min(l))
n, k = map(int, input().split())
a = [int(t) - 1 for t in input().split()]

loc = 0
visited_bkt = [-1 for _ in range(2 * 10 ** 5 + 1)]
count = 0
loop_len = -1
while True:
    visited_bkt[loc + 1] = count
    loc = a[loc]
    if visited_bkt[loc + 1] > 0:
        loop_len = count - visited_bkt[loc + 1] + 1
        break
    count += 1
start_len = count - loop_len
# print(visited_bkt)
# print(start_len, loop_len)
# print(start_len + (k - start_len) % loop_len if k >= count else k)
print(visited_bkt.index(start_len + (k - start_len) % loop_len) if k >= count else visited_bkt.index(k))


### FIXED CODE ###

n, k = map(int, input().split())
a = [int(t) - 1 for t in input().split()]

loc = 0
visited_bkt = [-1 for _ in range(2 * 10 ** 5 + 1)]
count = 0
loop_len = -1
while True:
    visited_bkt[loc + 1] = count
    loc = a[loc]
    count += 1
    if visited_bkt[loc + 1] >= 0:
        loop_len = count - visited_bkt[loc + 1]
        break
start_len = count - loop_len
print(visited_bkt.index(start_len + (k - start_len) % loop_len) if k >= count else visited_bkt.index(k))
a,b,c = map(int, raw_input().split)

count=0
for x in range(a,b+1):
    if  c%x == 0:
       count += 1
print  ('x')     
       
  

### FIXED CODE ###

a,b,c = map(int, raw_input().split())

count=0
for x in range(a,b+1):
    if  c%x == 0:
       count += 1
print(count)