Harryxun/stf_run huggingface dataset:
import fractions
mod=10**9+7
n=int(input())
a=list(map(int,input().split()))

count=a[0]
for i in range(n-1):
    count=count*a[i+1]//fraction.gcd(count, a[i+1])
ans=0
for i in range(n):
    ansa=count//a[i]
    ans+=ansa
    ans%=mod
print(ans)

### FIXED CODE ###

import fractions
mod=10**9+7
n=int(input())
a=list(map(int,input().split()))

def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)

count=a[0]
for i in range(n-1):
    count=lcm(count,a[i+1])
ans=0
for i in range(n):
    ansa=count//a[i]
    ans+=ansa
    
print(ans%mod)
X = int(input())
Y = int(input())
Z = int(input())

print(Z,X,Y)

### FIXED CODE ###

X, Y, Z = map(int, input().split())
print(Z, X, Y)
n, m, x = map(int, input().split())
a = list(map(int, input().split()))

cost_left = 0
for i in range(x-1,0,-1):
    if i in a:
        cost_left+= 1
cost_right = 0
for i in range(x+1, N):
    if i in a:
        cost_right+= 1
    
print(min(cost_left, cost_right))

### FIXED CODE ###

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

#leftto0
cost_left = 0
for i in range(x-1,0,-1):
    if i in a:
        cost_left+= 1
    
#right_to_N
cost_right = 0
for i in range(x+1, n):
    if i in a:
        cost_right+= 1
    
print(min(cost_left, cost_right))
A = []
for i in range(3):
    A.append(list(input().split()))
N = int(input())
B = set()
for i in range(N):
    B.append(input())
if {A[0]} <= B or {A[1]} <= B or {A[2]} <= B or {A[0][0], A[1][0], A[2][0]} <= B or {A[0][1], A[1][1], A[2][1]} <= B or {A[0][2], A[1][2], A[2][2]} <= B or {A[0][0], A[1][1], A[2][2]} <= B or {A[2][2], A[1][1], A[2][0]} <= B:
    print("Yes")
else:
    print("No")

### FIXED CODE ###

A = []
for i in range(3):
    A.append(list(input().split()))
N = int(input())
B = []
for i in range(N):
    B.append(input())
B=set(B)
if set(A[0]) <= B or set(A[1]) <= B or set(A[2]) <= B or {A[0][0], A[1][0], A[2][0]} <= B or\
{A[0][1], A[1][1], A[2][1]} <= B or {A[0][2], A[1][2], A[2][2]} <= B \
or {A[0][0], A[1][1], A[2][2]} <= B or {A[0][2], A[1][1], A[2][0]} <= B:
    print("Yes")
else:
    print("No")
from collections import deque


def solvemaze(y, x, num):
    maps.append([])
    dx, dy = (-1, 0, 1, 0), (0, -1, 0, 1)
    maze[y][x] = num
    que = deque()
    que.append((y, x))
    while que:
        y_, x_ = que.popleft()
        maps[num].append((y_, x_))
        for i in range(4):
            y2 = y_ + dy[i]
            x2 = x_ + dx[i]
            if 0 <= y2 < h and 0 <= x2 < w and maze[y2][x2] == '.':
                maze[y2][x2] = num
                que.append((y2, x2))

def makeroute(s_maps, num):
    for y, x in s_maps:
        for i in range(-2, 3):
            for j in range(-2, 3):
                y2 = y + i
                x2 = x + j
                if 0 <= y2 < h and 0 <= x2 < w:
                    num2 = maze[y2][x2]
                    if not  num2 in [0, '#'] + E[num]:
                        E[num].append(num2)
                        E[num2].append(num)
    

h, w = map(int, input().split())
Ch, Cw = map(int, input().split())
Dh, Dw = map(int, input().split())
maze = [[x for x in input()] for _ in range(h)]
maps = []

num = 0
for i in range(h):
    for j in range(w):
        if maze[i][j] == '.':
            solvemaze(i, j, num)
            num += 1

E = [[] for _ in range(num)]
for i in range(num):
    makeroute(maps[i], i)

s = maze[Ch-1][Cw-1]
g = maze[Dh-1][Dw-1]
used = [False] * num
used[s] = True
que = deque()
que.append((0, s))
cost = [float('inf')] * num
cost[s] = 0
while que:
    c, v = que.popleft()
    for e in E[v]:
        if not used[e]:
            que.append((c+1, e))
            cost[e] = c+1
            used[e] = True

if not used[g]:
    print(-1)
else:
    print(cost[g])

### FIXED CODE ###

import math


n, x, t = map(int, input().split())
print(math.ceil(n / x) * t)
K = int(input())
A = int(input())
B = int(input())
""" K=4
A=5
B=7 """


if A==B:
    if A%K==0:
        print("OK")
    else:
        print("NG")

num=A
while num <= B:
    num += 1
    if num%K == 0:
        print("OK") 
        exit()
    if num==B:
        print("NG")
        exit()



### FIXED CODE ###

k=int(input())
a,b= map(int, input().split())
q=0
 
for i in range(1,1000):
  if a<=k*i and k*i<=b:
    print('OK')
    q=1
    break
 
if q==0:
  print('NG')
n = int(input())

ans = ""

al = ['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']

while n > 0:
    tmp = n % 26
    if tmp > 0:
        ans += al[tmp-1]
    else:
        ans += 'z'
        n -= 1
    n /= 26
    if n == 0:
        break

print(ans[::-1])


### FIXED CODE ###

n = int(input())

ans = ""

al = ['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']

while n > 0:
    tmp = n % 26
    if tmp > 0:
        ans += al[tmp-1]
    else:
        ans += 'z'
        n = n - 1
    n = n // 26

print(ans[::-1])
from collections import deque


def main():
    N, M = map(int, input().split())
    edges = [[] for _ in range(N)]

    for _ in range(M):
        u, v = map(int, input().split())
        edges[u - 1].append(v - 1)

    converted_edges = [[] for _ in range(N)]
    for v, v_edge in enumerate(edges):
        three_steps_nodes = []
        for w in edges[v]:
            for x in edges[w]:
                for y in edges[x]:
                    three_steps_nodes.append(y)
        converted_edges[v] = three_steps_nodes.copy()

    S, T = map(lambda x: int(x) - 1, input().split())
    q = deque([(S, 0)])

    nodes = [-1] * N

    while q:
        cv, count = q.popleft()
        if cv == T:
            if nodes[cv] == -1:
                nodes[cv] = count
            else:
                nodes[cv] = min(nodes[cv], count)
        else:
            if nodes[cv] == -1 or count < nodes[cv]:
                nodes[cv] = count
                for u in converted_edges[cv]:
                    q.append((u, count + 1))

    print(nodes[T])


if __name__ == '__main__':
    main()


### FIXED CODE ###

from collections import deque


def main():
    N, M = map(int, input().split())
    edges = [[] for _ in range(3 * N)]

    for _ in range(M):
        u, v = map(lambda x: int(x) - 1, input().split())
        edges[3 * u].append(3 * v + 1)
        edges[3 * u + 1].append(3 * v + 2)
        edges[3 * u + 2].append(3 * v)

    S, T = map(lambda x: (int(x) - 1) * 3, input().split())
    q = deque([(S, 0)])
    nodes = [-1] * (3 * N)

    while q:
        cv, count = q.popleft()

        if cv == T:
            nodes[cv] = count if nodes[cv] == -1 else min(nodes[cv], count)
        else:
            if nodes[cv] == -1 or count < nodes[cv]:
                nodes[cv] = count
                for u in edges[cv]:
                    q.append((u, count + 1))

    print(nodes[T] // 3 if nodes[cv] != -1 else -1)


if __name__ == '__main__':
    main()
n = input()
 
A = {}
A = map(int, raw_input().split())
  
q = input()
  
M = map(int, raw_input().split())
 
def solve(i, m):
  if m == 0:
    return True
  if i >= n:
    return False
  res = solve(i, m) or solve(i, m - A[i])
  return res
 
 
for m in M:
  if solve(0,m):
    print "yes"
  else:
    print "no"

### FIXED CODE ###

n = input()

A = map(int, raw_input().split())
   
q = input()
   
M = map(int, raw_input().split())
  
def solve(i, m):
  if m == 0:
    return True
  if i >= n or m > sum(A):
    return False
  res = solve(i+1, m) or solve(i+1, m - A[i])
  return res
  
  
for m in M:
  if solve(0,m):
    print "yes"
  else:
    print "no"
a = int(input())
b = int(input())
print(a*b)
print(2*a+2*b)


### FIXED CODE ###

a,b = map(int, input().split())
print(a*b,2*a+2*b)
n = int(input())
nums = list(map(int,input().split()))
dp = [[0,0,0] for _ in range(n)]
dp[0][0] = nums[0]
dp[1][0],dp[1][1],dp[1][2] = nums[1],nums[0],-float("inf")
dp[2][0],dp[2][1],dp[2][2] = nums[2],nums[1],nums[0]
for i in range(3,n):
    if i%2 == 0:
        dp[i][0] = max(dp[i-2]) + nums[i]
        dp[i][1] = max(dp[i-3]) + nums[i-1]
        dp[i][2] = sum(nums[0:i-1:2])
    else:
        dp[i][0] = max(dp[i-2]) + nums[i]
        dp[i][1] = sum(nums[0:i-2:2]) + nums[i-1]
        dp[i][2] = -float("inf")
print(max(dp[n-1]))

### FIXED CODE ###

n = int(input())
nums = list(map(int,input().split()))
if n == 2:
    print(max(nums[0],nums[1]))
else:
    temp =[0]
    for i in range(n):
        if i%2 == 0:
            temp += [temp[-1]+nums[i]]
    dp = [[0,0,0] for _ in range(n)]
    dp[0][0] = nums[0]
    dp[1][0],dp[1][1],dp[1][2] = nums[1],nums[0],-float("inf")
    dp[2][0],dp[2][1],dp[2][2] = nums[2],nums[1],nums[0]
    for i in range(3,n):
        if i%2 == 0:
            dp[i][0] = max(dp[i-2]) + nums[i]
            dp[i][1] = max(dp[i-3]) + nums[i-1]
            dp[i][2] = temp[i//2]
        else:
            dp[i][0] = max(dp[i-2]) + nums[i]
            dp[i][1] = temp[(i-1)//2] + nums[i-1]
            dp[i][2] = -float("inf")
    print(max(dp[n-1]))
S = list(input())
for key in S: 
    if key == "B":
      final_str = final_str[:-1]
    else:
      final_str.append(key)
print(''.join(final_str)

### FIXED CODE ###

S = list(input())
final_str = []
for key in S: 
    if key == "B":
      final_str = final_str[:-1]
    else:
      final_str.append(key)
print(''.join(final_str))
n = 0
while 2**n <= (int(input())):
  n += 1
print(2**(n-1))
  

### FIXED CODE ###

a = int(input())
n = 0
while 2**n <= a:
  n += 1
print(2**(n-1))
N, K = map(int, input().split())
p = [0] + list(map(int, input().split()))
c = [0] + list(map(int, input().split()))

max = -10000000000

for i in range(1,N+1):
    naw = i
    S = 0
    l = 0
    lmax = -10000000000
    kl = K

    while 1:
        naw = p[naw]
        S += c[naw]
        l += 1
        kl -= 17
        if S > lmax:
            lmax = S
            max_l = l
        if kl == 0 or naw == i:
            break
    
    if kl == 0:
        imax = lmax
    else:
        if S <= 0:
            imax = lmax
        else:
            imax = lmax + S * ( (K - max_l) // l)
    
    if (imax > max):
        max = imax

print(max)

### FIXED CODE ###

s = input()

if "RRR" in s:
    ans = 3
elif "RR" in s:
    ans = 2;
elif "R" in s:
    ans = 1;
else:
    ans = 0;

print(ans)
c = 0
result = 0
while True:
    st = raw_input()
    if c == 0:
        s_str = st
    elif 'END_OF_TEXT' in st:
        break
    else:
        c = c+1
        if s_str in st:
            result = result + st.split(' ').count(s_str)
        else:
            pass
print result

### FIXED CODE ###

c = 0
result = 0
while True:
    st = raw_input()
    if c == 0:
        s_str = st
    elif 'END_OF_TEXT' == st:
        break
    elif c > 0:
        if s_str.lower() in st.lower():
            result = result + st.lower().split(' ').count(s_str.lower())
        else:
            pass
    c = c+1
print result
from math import gcd


def eratosthenes(n):
    prime = []
    data = [i for i in range(n - 1)]
    while True:
        p = data[0]
        if n <= p ** 2:
            return prime + data
        prime.append(p)
        data = [e for e in data if e % p != 0]
    return data


def factorize(N):  # 素因数分解
    prime = set()
    for p in prime_list:
        if p * p > N:
            break
        while N % p == 0:
            N //= p
            prime.add(p)
    if N > 1:
        prime.add(N)
    return prime


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

ans = 0
for ai in a:
    ans = gcd(ans, ai)
if ans != 1:
    print('not coprime')
    exit()

prime_list = eratosthenes(10 ** 6)
num = set()
for ai in a:
    prime = factorize(ai)
    if len(prime & num) > 0:
        print('setwise coprime')
        break
    num |= prime
else:
    print('pairwise coprime')


### FIXED CODE ###

from math import gcd


def eratosthenes(n):
    prime = []
    data = [i + 1 for i in range(1, n)]
    while True:
        p = data[0]
        if n <= p ** 2:
            return prime + data
        prime.append(p)
        data = [e for e in data if e % p != 0]
    return data


def factorize(N):  # 素因数分解
    for p in prime_list:
        if p * p > N:
            break
        if N % p == 0 and (p in num):
            print('setwise coprime')
            exit()
        while N % p == 0:
            N //= p
            num.add(p)
    if N > 1:
        if N in num:
            print('setwise coprime')
            exit()
        num.add(N)


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

ans = 0
for ai in a:
    ans = gcd(ans, ai)
if ans != 1:
    print('not coprime')
    exit()

prime_list = eratosthenes(10 ** 6)
num = set()
for ai in a:
    factorize(ai)
else:
    print('pairwise coprime')
# https://atcoder.jp/contests/abc079/tasks/abc079_c
# C - Train Ticket

a, b, c, d = list(input().split()[0])
a, b, c, d = [int(x) for x in [a, b, c, d]]

# 2 ** 3通りなので全探索でいけそう
is_ok = False

for op1 in [True, False]:
    work_1 = a + b if op1 else a - b
    for op2 in [True, False]:
        work_2 = work_1 + c if op2 else work_1 - c
        for op3 in [True, False]:
            work_3 = work_2 + d if op3 else work_2 - c
            if work_3 == 7:
                is_ok = True
                op_list = [op1, op2, op3]
                break
        if is_ok:
            break
    if is_ok:
        break

op_list = ['+' if op else '-' for op in op_list]
ans = str(a) + op_list[0] + str(b) + op_list[1] + str(c) + op_list[2] + str(d) + '=7'
print(ans)


### FIXED CODE ###

# https://atcoder.jp/contests/abc079/tasks/abc079_c
# C - Train Ticket

a, b, c, d = list(input().split()[0])
a, b, c, d = [int(x) for x in [a, b, c, d]]

# 2 ** 3通りなので全探索でいけそう
is_ok = False

for op1 in [True, False]:
    work_1 = a + b if op1 else a - b
    for op2 in [True, False]:
        work_2 = work_1 + c if op2 else work_1 - c
        for op3 in [True, False]:
            work_3 = work_2 + d if op3 else work_2 - d
            if work_3 == 7:
                is_ok = True
                op_list = [op1, op2, op3]
                break
        if is_ok:
            break
    if is_ok:
        break

op_list = ['+' if op else '-' for op in op_list]
ans = str(a) + op_list[0] + str(b) + op_list[1] + str(c) + op_list[2] + str(d) + '=7'
print(ans)
n,k,x,y=map(int,input().split())

if n>k:
  print(round(k*x+(n-k)*y))

else:
  print(round(k*x))
      

### FIXED CODE ###

n = int(input())
k = int(input())
x= int(input())
y= int(input())

if n>k:
  print(k*x+(n-k)*y)

else:
  print(n*x)
def resolve():
    # 整数 1 つ
    # n = int(input())
    # 整数複数個
    h, w = map(int, input().split())
    # 整数 N 個 (改行区切り)
    S = [list(input()) for i in range(h)]
    # 整数 N 個 (スペース区切り)
    # N = list(map(int, input().split()))
    # 整数 (縦 H 横 W の行列)
    # A = [list(map(int, input().split())) for i in range(H)]

    flag = True
    for i in range(h):
        for j in range(w):
            if S[i][j] == ".":
                continue
            else:
                if S[i][j-1] == "." and S[i][j+1] == "." and S[i-1][j] == "." and S[i+1][j] == ".":
                    flag = False
                    break
        if flag == False
            break

    if flag == False:
        print("No")
    else:
        print("Yes")


resolve()

### FIXED CODE ###

def resolve():
    # 整数 1 つ
    # n = int(input())
    # 整数複数個
    h, w = map(int, input().split())
    # 整数 N 個 (改行区切り)
    S = [list(input()) for i in range(h)]
    # 整数 N 個 (スペース区切り)
    # N = list(map(int, input().split()))
    # 整数 (縦 H 横 W の行列)
    # A = [list(map(int, input().split())) for i in range(H)]

    flag = True
    for i in range(h):
        for j in range(w):
            if S[i][j] == ".":
                continue
            else:
                neighbor = False
                N = [[i-1, j], [i+1, j], [i, j-1], [i, j+1]]
                for s in N:
                    if s[0] >= 0 and s[0] <= h-1 and s[1] >= 0 and s[1] <= w-1:
                        if S[s[0]][s[1]] == "#":
                            neighbor = True
                            break
#                print(neighbor)
                if neighbor == False:
                    flag = False
                    break
        if flag == False:
            break

    if flag == False:
        print("No")
    else:
        print("Yes")


resolve()
N ,M = map(int,input().split())
cnt = [0]*M
C = [0]*M
for i in range(M):
    s, c = map(int,input().split())
    if c == C[s-1]:
        pass
    else:
        C[s-1] += c
        cnt[s-1] += 1

if max(cnt)>=2 or C[0] == 0   :
    print(-1)
else:
    print("".join(map(str,C)))

### FIXED CODE ###

N ,M = map(int,input().split())
cnt = [0]*N
C = [0]*N
C[0] = 1
for i in range(M):
    s, c = map(int,input().split())
    if cnt == 1 and C[s-1] != c:
        cnt[s-1] += 1
    elif cnt[s-1] == 1 and C[s-1] == c:
        pass
    else:
        cnt[s-1] += 1
        C[s-1] = c
if N ==1 and C[0] == 0:
    print(0)
elif N ==1 and M == 0:
    print(0)
elif max(cnt)>=2 or C[0] == 0 :
    print(-1)
else:
    print("".join(map(str,C)))
# AC を 1回以上出した各問題において、初めて AC を出すまでに出した WA の数
n,m = map(int, input().split())
p = []
s = []
wacounter = 0
walist = []
for i in range(0, n):
  walist.append(0)
point = 0
point_to_num = [] #acをとった問題
for i in range(0, m):
  list = input().split()
  p.append(int(list[0]))
  s.append(list[1])
 
for i in range(0, m):
  if s[i] == "AC" and not p[i] in point_to_num: #もし正解で、今までにその問題に正解していなかったら
    point_to_num.append(p[i]) #正解リストにその問題を追加
    #point = point + 1 正解ポイントをあげる
  elif s[i] == "WA" and not p[i] in point_to_num: #不正解かつ今まで正解を出したことがない
      wacounter += 1
      walist[p[i]-1] += 1
for i in range(0, n):
  if not i + 1 in point_to_num:#もし正解してない番号があったら、walistからwacounterをとってきてひく
    wacounter = wacounter - walist[i]
print(len(point_to_num), wacounter)
    


### FIXED CODE ###

s = input()
n = ord(s)

print(chr(n+1))
ABC=iuput()
if ABC.count('5')==2 and ABC.count('7')==1:
  print('YES')
else:
  print('NO')

### FIXED CODE ###

ABC=input()
if ABC.count('5')==2 and ABC.count('7')==1:
  print('YES')
else:
  print('NO')
s = input()
a, b, c = [int(x) for x in s.split(' ')]
if a+b < c:
    echo('No')
else:
    echo('Yes')

### FIXED CODE ###

s = input()
a, b, c = [int(x) for x in s.split(' ')]
if a+b < c:
    print('No')
else:
    print('Yes')
a=input()
b=input()
c=a.split()
n=int(c[0])
d=b.split()
d=[int(i) for i in d]
d.sort(reverse=True)
count=0
ll=list()
for i in d:
    if count!=0:
        ll.append(c-i)
    c=i
    count+=1
ll.sort()
for i in range(n-1):
    del ll[-1]
print(sum(ll))


### FIXED CODE ###

a=input()
b=input()
c=a.split()
n=int(c[0])
d=b.split()
d=[int(i) for i in d]
d.sort(reverse=True)
count=0
ll=list()
for i in d:
    if count!=0:
        ll.append(c-i)
    c=i
    count+=1
ll.sort()
for i in range(n-1):
    ccc=len(ll)
    if ccc>=1:
        del ll[-1]
print(sum(ll))
# cadidates of no shortest paths
n, m = map(int, input().split())

d = [[float("inf") for i in range(n + 1)] for i in range(n + 1)]
edge_data=[]
connect={i:[] for i in range(1,n+1)}
for i in range(m):
    x, y, z = map(int, input().split())
    # 有向グラフか無向グラフかによってここで場合わけが生じる
    d[x][y] = z
    d[y][x] = z
    connect[x].append(y)
    connect[y].append(x)    
    edge_data.append((x,y,z))
for i in range(n + 1):
    d[i][i] = 0  # 自身のところに行くコストは０


def warshall_floyd(d):
    # d[i][j]=i番目の頂点からj番目の頂点までの最短距離
    for k in range(1, n + 1):
        for i in range(1, n + 1):
            for j in range(1, n + 1):
                d[i][j] = min(d[i][j], d[i][k] + d[k][j])
    return d

warshall_floyd(d)

#最短距離を求めた
cnt=0
for some in edge_data:
    x,y,zsome[0],some[1],some[2]
    if d[x][y]<z:
        cnt+=1
print(cnt)


### FIXED CODE ###

# cadidates of no shortest paths
n, m = map(int, input().split())

d = [[float("inf") for i in range(n + 1)] for i in range(n + 1)]
edge_data=[]
connect={i:[] for i in range(1,n+1)}
for i in range(m):
    x, y, z = map(int, input().split())
    # 有向グラフか無向グラフかによってここで場合わけが生じる
    d[x][y] = z
    d[y][x] = z
    connect[x].append(y)
    connect[y].append(x)    
    edge_data.append((x,y,z))
for i in range(n + 1):
    d[i][i] = 0  # 自身のところに行くコストは０


def warshall_floyd(d):
    # d[i][j]=i番目の頂点からj番目の頂点までの最短距離
    for k in range(1, n + 1):
        for i in range(1, n + 1):
            for j in range(1, n + 1):
                d[i][j] = min(d[i][j], d[i][k] + d[k][j])
    return d

warshall_floyd(d)

#最短距離を求めた
cnt=0
for some in edge_data:
    x,y,z=some[0],some[1],some[2]
    if d[x][y]<z:
        cnt+=1
print(cnt)
a,b = map(int, input().split())

d = (a * b)
e = d % 2

if e = 0:
    print("Even")
else e = 1:
    print("Odd")

### FIXED CODE ###

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

c = (a * b) % 2

if c == 0:
    print("Even")
elif c == 1:
    print("Odd")
N = int(input())
memo = []
for i in range(N):
    if i == 0:
        memo.append(2)
    elif i == 1:
        memo.append(1)
    else:
        memo.append(memo[i-1] + memo[i-2])
if N == 0:
    print(memo[0])
elif N == 1:
    print(memo[1])
else: 
    print(memo[N-1] + memo[N - 2])

### FIXED CODE ###

N = int(input())
memo = []
for i in range(N):
    if i == 0:
        memo.append(2)
    elif i == 1:
        memo.append(1)
    else:
        memo.append(memo[i-1] + memo[i-2])
if N == 1:
    print(1)
else:
    print(memo[N - 1] + memo[N - 2])
I=lambda:[int(i)for i in input().split()]
n,m=I()
P=I()
D={i:i for i in range(n)}
def U(x):
  if D[x]!=x:
    D[x]=U(D[x])
  return D[x]
for _ in [0]*m:
  x,y=I();D[U(x)]=U(y)
print(sum(U(i)==U(p-1)for i,p in enumerate(P)))




### FIXED CODE ###

a,b,c,d=map(int,input().split())
print("Yes" if abs(a-c)<=d or abs(a-b)<=d and abs(c-b)<=d else "No")
import sys
def line():return sys.stdin.readline().strip()

import re

while True:
    e = re.findall(r"[0-9X]+",line())

    ans = -1
    for i in range(10):
        a,b,c = [int(_.replace("X",str(i))) for _ in e]
        if a + b == c :
            ans = i
            break

    if ans == -1:
        print("NA")
    else:
        print(ans)

### FIXED CODE ###

import sys
import re
def line():return sys.stdin.readline().strip()

while True:
    try:
        e = re.findall(r"[0-9X]+",line())

        ans = -1
        for i in range(10):
            a,b,c = [_.replace("X",str(i)) for _ in e]
            if i == 0 \
                and (\
                (a[0] == "0" and len(a) != 1)\
                or (b[0] == "0" and len(b) != 1)\
                or (c[0] == "0" and len(c) != 1)\
                ):
                continue 
            if int(a) + int(b) == int(c) :
                ans = i
                break

        if ans == -1:
            print("NA")
        else:
            print(ans)
    except:
        break
m=2019
l,r=map(int,input().split())

if l%m>r%m or m*(r%m)==r:
  print(0)
  exit()

import numpy as np
lr=m
for ii in np.arange(l,r):
  for jj in np.arange(ii+1,r+1):
    t=(ii*jj)%m
    if t==0:
        print(0)
        exit()
    if t<lr:
      lr=t
print(lr)

### FIXED CODE ###

m=2019
l,r=map(int,input().split())

if l==0 or l//m<r//m or l%m==0:
  print(0)
  exit()

import numpy as np
lr=m
for ii in np.arange(l,r):
  for jj in np.arange(ii+1,r+1):
    t=((ii%m)*(jj%m))%m
    if t==0:
        print(0)
        exit()
    if t<lr:
      lr=t
print(lr)
f = list(map(int, input().split()))
s = list(map(int, input().split()))
t = list(map(int, input().split()))
n = int(input())
k = []
for i in range(n):
    k.append(int(input()))

lis = []

lis.append(f)
lis.append(s)
lis.append(t)

ans = 0

for i in lis:
    c =0
    for n in range(len(i)):
        if i[n] in k:
            i[n] = 'X'
            c += 1
            if c == 3:
                ans +=1
                break

if f[0] == 'X' and s[0] == 'X' and t[0] == 'X':
    ans +=1
elif f[1] == 'X' and s[1] == 'X' and t[1] == 'X':
    ans += 1
elif f[2] == 'X' and s[2] == 'X' and t[2] == 'X':
    ans += 1
elif f[0] == 'X' and s[1] == 'X' and t[3] == 'X':
    ans += 1
elif f[3] == 'X' and s[2] == 'X' and t[1] == 'X':
    ans += 1
    
if ans >= 1:
    print('Yes')
else:
    print('No')
        

### FIXED CODE ###

n = int(input())

p = n//2 + n%2
print(p)