Harryxun/stf_run huggingface dataset:
n,a,b,c,d = ( int(i) for i in input().split())
s = input()

a_to_c = s[a:(c-1)-1]
b_to_d = s[b-1:d-1]

possibility = True

if c>d:
    b_to_d = s[(b-1)-1:(d-1)+1]
    if "##" in a_to_c or "..." not in b_to_d
        possibility = False
else:
    b_to_d = s[(b-1)+1:(d-1)-1]
    if "##" in a_to_c or "##" in b_to_d:
        possibility = False

if possibility:
    print("Yes")
else:
    print("No")

### FIXED CODE ###

n,a,b,c,d = ( int(i) for i in input().split())
s = input()

a_to_c = s[(a-1)+1:(c-1)-1 +1]

possibility = True

if c>d:
    b_to_d = s[(b-1)-1:(d-1)+1 +1]
    if "##" in a_to_c or "..." not in b_to_d:
        possibility = False
else:
    b_to_d = s[(b-1)+1:(d-1)-1 +1]
    if "##" in a_to_c or "##" in b_to_d:
        possibility = False

if possibility:
    print("Yes")
else:
    print("No")
import math

x = int(input())

n = x // 105
for i in range(1, 1000):
  ave = x // i
  if 100 <= ave <= 105:
    if x % 105 >= 5*n:
      print('1')
    else:
      print('0')
    exit()
print('0')

### FIXED CODE ###

m1, d1 = map(int, input().split())
m2, d2 = map(int, input().split())

if m1 ==1 and d1 == 31:
  print('1')
elif m1==2 and d1 == 28:
  print('1')
elif m1==3 and d1 == 31:
  print('1')
elif m1==4 and d1 == 30:
  print('1')
elif m1==5 and d1 == 31:
  print('1')
elif m1==6 and d1 == 30:
  print('1')
elif m1==7 and d1 == 31:
  print('1')
elif m1==8 and d1 == 31:
  print('1')
elif m1==9 and d1 == 30:
  print('1')
elif m1==10 and d1 == 31:
  print('1')
elif m1==11 and d1 == 30:
  print('1')
else:
  print('0')
while True:
    n=input()
    m=input()
    if n==m==0:break
    S,L=set(),[]
    for i in range(m):
        a,b=map(int,raw_input().split())
        if a==1:
            S.add(b)
        elif b==1:
            S.add(a)
        else:
            L.append((a,b))
    for i in S:
        for s in L:
            if i in s:
                S=S.union(s)
    print len(S)

### FIXED CODE ###

while True:
    n=raw_input()
    if n in "0":break
    try:
        m=input()
    except SyntaxError:
        break
    S,L=set(),[]
    for i in range(m):
        a,b=map(int,raw_input().split())
        if a==1:
            S.add(b)
        elif b==1:
            S.add(a)
        else:
            L.append((a,b))
    for i in S:
        for s in L:
            if i in s:
                S=S.union(s)
    print len(S)
#b
a,b,c,k=map(int, input().split())
test = []
test += [1]*a
test += [0]*b
test += [-1]*c
print(sum(test[0:k]))

### FIXED CODE ###

a,b,c,k=map(int, input().split())
if a > k:
    print(k)
elif a + b > k:
    print(a)
else:
    print(a-(k-(a+b)))
from collections import Counter
from collections import defaultdict
import math

def combination(n, r):
    return math.factorial(n) // (math.factorial(n-r) * math.factorial(r))

N = int(input())
L = defaultdict(int)
ans = 0
for _ in range(N):
    s = sorted(list(input()))
    L[s] += 1

for c in L.items():
    ans += combination(c)
print(ans)

### FIXED CODE ###

from collections import Counter
from collections import defaultdict
import math

def combination(n, r):
    return math.factorial(n) // (math.factorial(n-r) * math.factorial(r))

N = int(input())
L = defaultdict(int)
ans = 0
for _ in range(N):
    s = sorted(list(input()))
    L[str(s)] += 1

for c in L.values():
    if c > 1:
        ans += combination(c, 2)
print(ans)
import sys

n = int(input())
s = str(input())

if n == 1:
    if s[0] == s[1]:
        print(2)
    else:
        print(1)
    sys.exit()

count = 0
i = 0
while i < n - 1:
    if s[i] == s[i + 1]:
        count = count + 1
    i = i + 1

ans = n - count
print(ans)

### FIXED CODE ###

n = int(input())
s = str(input())
count = 0

for i in range(n - 1):
    if s[i] == s[i + 1]:
        count = count + 1

print(n - count)
n, k = [int(item) for item in input().split()]
a = sorted([int(item) for item in input().split()], reverse=True)
max_k = min(sum(a), 5000)

def check_needed(index):
    memo = [[0] * (max_k + 1) for _ in range(n+1)]
    memo[0][0] = 1
    for i in range(n):
        for j in range(max_k + 1):
            if memo[i][j] == 1: 
                memo[i+1][j] = 1 
                if i != index:
                    memo[i+1][j+a[i]] = 1 
    return (1 in memo[n][max(k-a[index], 0):k])

l = -1
r = n
while r-l > 1:
    mid = (l+r) // 2
    if not check_needed(mid):
        r = mid
    else:
        l = mid
if sum(a) < k:
    print(n)
else:
    print(n - r)

### FIXED CODE ###

n, k = [int(item) for item in input().split()]
a = sorted([int(item) for item in input().split()], reverse=True)

count = 0
asum = 0
for item in a:
    if asum + item < k:
        asum += item
        count += 1
    else:
        count = 0

print(count)
n=int(input())
ans = []
for i in range(int(n**0.5),0,-1):
    if n%i==0:
        ans += n//i+i-2
print(min(ans))

### FIXED CODE ###

n=int(input())
ans=n
for i in range(int(n**0.5),0,-1):
    if n%i==0:
        ans=n//i+i-2
        break
print(ans)
li = list(input())
counter = int(li[0) + int(li[1]) + int(li[2])
print(counter)

### FIXED CODE ###

num = input()
counter = 0
li = list(num)
if li[0] == "1":
    counter += 1
if li[1] == "1":
    counter += 1
if li[2] == "1":
    counter += 1
print(counter)
def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

A=10**4
mod = 10**9+7
g1 = [1, 1]
g2 = [1, 1]
inverse = [0, 1]

for i in range( 2, A + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )

N,M,K=map(int,input().split())
keisuu=cmb(N*M-2,K-2,mod)

sum_=0
for i in range(N):
    a=min(abs(i),abs(N-i-1))
    b=max(abs(i),abs(N-i-1))
    sum_+=(M**2)*((a*(a+1)//2)+(b*(b+1)//2))
for i in range(M):
    a=min(abs(i),abs(M-i-1))
    b=max(abs(i),abs(M-i-1))
    sum_+=(N**2)*((a*(a+1)//2)+(b*(b+1)//2))
print(keisuu * (sum_//2))

### FIXED CODE ###

def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

A=2*10**5
mod = 10**9+7
g1 = [1, 1]
g2 = [1, 1]
inverse = [0, 1]

for i in range( 2, A + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )

N,M,K=map(int,input().split())
keisuu=cmb(N*M-2,K-2,mod)

sum_=0
for i in range(N):
    a=min(abs(i),abs(N-i-1))
    b=max(abs(i),abs(N-i-1))
    sum_+=(M**2)*((a*(a+1)//2)+(b*(b+1)//2))
for i in range(M):
    a=min(abs(i),abs(M-i-1))
    b=max(abs(i),abs(M-i-1))
    sum_+=(N**2)*((a*(a+1)//2)+(b*(b+1)//2))
print((keisuu * (sum_//2))%mod)
s=[int(0) for i in range(26)]
for s in input():
    x=input()
    for i in range(len(list(x))):
        if 97<=ord(list(x)[i].lower())<=122:
            s[ord(list(x)[i].lower())-97]=s[ord(list(x)[i].lower())-97]+1
for i in range(26):
    print(chr(97+i),":",s[i])

### FIXED CODE ###

s=[int(0) for i in range(26)]
while True:
    try:
        x=input()
        for i in range(len(list(x))):
            if 97<=ord(list(x)[i].lower())<=122:
                s[ord(list(x)[i].lower())-97]=s[ord(list(x)[i].lower())-97]+1
    except EOFError:
        break
for i in range(26):
    print(chr(97+i),":",s[i])
a = (int)input()
print(a*a)

### FIXED CODE ###

n = int(input())
print(n*n)
s,w = map(int,input().split(' '))
if w >= s:
  print(unsafe)
else:
  print(safe)


### FIXED CODE ###

s,w = map(int,input().split(' '))
if w >= s:
  print('unsafe')
else:
  print('safe')
a, b, k = map(int, input())
print(max(a-k, 0), max(min(a+b-k, b), 0)) 

### FIXED CODE ###

a, b, k = map(int, input().split())
print(max(a-k, 0), max(min(a+b-k, b), 0))
A = int(input())
B=int(input())

print((A-1)*(B-1))

### FIXED CODE ###


A,B =  [int(x) for x in input().split()]


print((A-1)*(B-1))
n=int(input())
l = list(map(int, input().split()))
print(sum(l) = n)

### FIXED CODE ###

n=int(input())
l = list(map(int, input().split()))
print(sum(l) - n)
import sys
from collections import deque
sys.setrecursionlimit(10 ** 6)
def input():
    return sys.stdin.readline()[:-1]

def dfs(v,prev = -1):
    for u in graph[v]:
        if u == prev:
            continue
        sign[u] = v
        dfs(u,v)

def bfs(v):
    que = deque([])
    que.append(v)
    while que:
        p = que.popleft()
        if visited[p] == 0:
            visited[p] = 1
            for u in graph[v]:
                que.append(u)

import heapq

def dijkstra(s):
    hq = [(0, s)]
    heapq.heapify(hq) # リストを優先度付きキューに変換
    cost = [float('inf')] * (M+1) # 行ったことのないところはinf
    cost[s] = 0 # 開始地点は0
    while hq:
        c, v = heapq.heappop(hq)
        if c > cost[v]: # コストが現在のコストよりも高ければスルー
            continue
        for u in graph[v]:
            tmp = 1 + cost[v]
            if tmp < cost[u]:
                cost[u] = tmp
                path[u] = v
                heapq.heappush(hq, (tmp, u))
    return path

N,M = map(int,input().split())
graph = [[] for i in range(M+1)]
for i in range(M):
    a,b = map(int,input().split())
    graph[a].append(b)
    graph[b].append(a)
path = [0]*(N+1)
c = dijkstra(1)
print("Yes")
for i in range(2,N+1):
    print(c[i])


### FIXED CODE ###

import sys
from collections import deque
sys.setrecursionlimit(10 ** 6)
def input():
    return sys.stdin.readline()[:-1]

def dfs(v,prev = -1):
    for u in graph[v]:
        if u == prev:
            continue
        sign[u] = v
        dfs(u,v)

def bfs(v):
    que = deque([])
    que.append(v)
    while que:
        p = que.popleft()
        if visited[p] == 0:
            visited[p] = 1
            for u in graph[v]:
                que.append(u)

import heapq

def dijkstra(s):
    hq = [(0, s)]
    heapq.heapify(hq) # リストを優先度付きキューに変換
    cost = [float('inf')] * (N+1) # 行ったことのないところはinf
    cost[s] = 0 # 開始地点は0
    while hq:
        c, v = heapq.heappop(hq)
        if c > cost[v]: # コストが現在のコストよりも高ければスルー
            continue
        for u in graph[v]:
            tmp = 1 + cost[v]
            if tmp < cost[u]:
                cost[u] = tmp
                path[u] = v
                heapq.heappush(hq, (tmp, u))
    return path

N,M = map(int,input().split())
graph = [[] for i in range(N+1)]
for i in range(M):
    a,b = map(int,input().split())
    graph[a].append(b)
    graph[b].append(a)
path = [0]*(N+1)
c = dijkstra(1)
print("Yes")
for i in range(2,N+1):
    print(c[i])
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# FileName: 	C
# CreatedDate:  2020-09-26 20:52:24 +0900
# LastModified: 2020-09-26 21:18:10 +0900
#


import os
import sys
# import numpy as np
# import pandas as pd


def BFS(cnt, color, path, u):
    color[u] = cnt
    for v in path[u]:
        if color[v] == -1:
            BFS(cnt, color, path, v)


def main():
    N, M = map(int, input().split())
    path = [[] for _ in range(N+1)]
    for _ in range(M):
        A, B = map(int, input().split())
        path[A].append(B)
        path[B].append(A)
    color = [-1] * (N+1)
    cnt = 0
    for i in range(1, N+1):
        if color[i] == -1:
            BFS(cnt, color, path, i)
            cnt += 1
    print(max(color))


if __name__ == "__main__":
    main()


### FIXED CODE ###

#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# FileName: 	C
# CreatedDate:  2020-09-26 20:52:24 +0900
# LastModified: 2020-09-26 21:19:33 +0900
#


import os
import sys
sys.setrecursionlimit(2000000)
# import numpy as np
# import pandas as pd


def BFS(cnt, color, path, u):
    color[u] = cnt
    for v in path[u]:
        if color[v] == -1:
            BFS(cnt, color, path, v)


def main():
    N, M = map(int, input().split())
    path = [[] for _ in range(N+1)]
    for _ in range(M):
        A, B = map(int, input().split())
        path[A].append(B)
        path[B].append(A)
    color = [-1] * (N+1)
    cnt = 0
    for i in range(1, N+1):
        if color[i] == -1:
            BFS(cnt, color, path, i)
            cnt += 1
    print(max(color))


if __name__ == "__main__":
    main()
A,B = map(int, input().split())
count = 0
for i in range(A, B+1):
  s = str(i)
  if s[0] == s[4] and s[1] == i[3]:
    count += 1
print(count)

### FIXED CODE ###

a = input()
b = input()
c = input()

print(a[0]+b[1]+c[2])
N, K, q=map(int, input().split())
score=[0]*N

for i in range(q):
    score[q-1]+=1

for i in range(N):
    if score[i]-K<=0:
        print("No")
    else:
        print("Yes")

### FIXED CODE ###

N, K, q=map(int, input().split())
score=[0]*N

for i in range(q):
    tmp=int(input())
    score[tmp-1]+=1

for i in range(N):
    if K-(q-score[i])>0:
        print("Yes")
    else:
        print("No")
import math
a, b, c = map(int, input().split())
c = c / 180.0 * math.pi

s = 0.5 * a * b * math.sin(c))
l = a + b + math.sqrt(a ** 2 + b ** 2 - 2 * a * b * math.sin(c))
h = b * math.sin(c)

print ("%f" % s)
print ("%f" % l)
print ("%f" % h)

### FIXED CODE ###

import math
a, b, c = map(float, raw_input().split())
c = (c * math.pi) / 180.0

print "%f" %(a * b * math.sin(c) / 2.0)
print "%f" %(a + b + math.sqrt(a ** 2 + b ** 2 - 2 * a * b * math.cos(c)))
print "%f" %((b * math.sin(c)))
a = list(map(int, input().split()))
b = a.pop(max(a))
print(b*10+sum(a))

### FIXED CODE ###

a = list(map(int, input().split()))
b = a.pop(a.index(max(a)))
print(b*10+sum(a))
# coding: utf-8
import sys

def main(argv=sys.argv):
  
  dict = {input().split()}
  print(dict)
  
  return 0


if __name__ == '__main__':
  sys.exit(main())

### FIXED CODE ###

# coding: utf-8
import sys
 
def main(argv=sys.argv):
  
  set1 = set(input().split())
  print(len(set1))
  
  return 0
 
 
if __name__ == '__main__':
  sys.exit(main())
class add():
    def __init__(self,a,b):
        self.a = a
        self.b = b

    def add(self):
        return self.a+self.b

def main():
    data_set = []
    ds_max = 200

    for i in range(0,ds_max):
        n = input().split()

        a = int(n[0])
        b = int(n[1])

        data_set.append(add(a,b))

    for i in range(0,ds_max):
        ans = data_set[i].add()
        print(ans)


if __name__ == "__main__":
    main()

### FIXED CODE ###

import math

def main():
    data = []
    while 1:
        try:
            n = input().split()
            a = int(n[0])
            b = int(n[1])
            ans = int(math.log10(a+b)+1)
            data.append(ans)
        except EOFError:
            break

    for i in data:
        print(i)

if __name__ == "__main__":
    main()
k=int(input())

now=7
for i in range(k+10):
	if now==0:
		print(i+1)
		exit()
	now*=10
	now+=7
    now%=k
print(-1)
    

### FIXED CODE ###

k=int(input())

now=7%k
for i in range(k+10):
	if now==0:
		print(i+1)
		exit()
	now*=10
	now+=7
	now%=k
print(-1)
h,w = map(int, input().split())
if h == 0 and w == 0:
    break
else:
    for i in range(h):
        print("#"*w)
    print()


### FIXED CODE ###

#
# 5a
#

def main():
    while True:
        H, W = map(int, input().split())
        if H == W == 0:
            break
        for i in range(H):
            print("#"*W)
        print()


if __name__ == '__main__':
    main()
import sys
l = sys.stdin.readline().strip()
N = int(l)
l = sys.stdin.readline().strip()
nums = map(int, l.split())
a = sum(nums) / len(nums)
a1 = int(a)
a2 = int(a) + 1
def count(p):
    d = 0
    for n in nums:
        d += (n-p)**2
    return d
print(min(count(a1), count(a2)))


### FIXED CODE ###

import sys
l = sys.stdin.readline().strip()
N = int(l)
l = sys.stdin.readline().strip()
nums = map(int, l.split())
nums = sorted(nums)
start = nums[0]
end = nums[-1] + 1
mi = float("INF")
def compute_dist(p):
  dist = 0
  for n in nums:
    dist += (n-p) ** 2
  return dist
for i in range(start, end):
  d = compute_dist(i)
  if d < mi:
    mi = d
print(mi)
import numpy as np
N = int(input())
x = [0]*N
u = [0]*N
for i in range(N):
    x[i], u[i]= map(input().split())
    
x_int = [float(j) for j in x]

### FIXED CODE ###

import numpy as np
N = int(input())
x = [0]*N
u = [0]*N
for i in range(N):
    x[i], u[i]= map(str, input().split())
    
x_int = [float(j) for j in x]
u_replace = [1 if k =="JPY" else 380000.0 for k in u]

x_arr = np.array(x_int)
u_arr = np.array(u_replace).reshape(N, 1)

ans = np.dot(x_arr, u_arr)
print(ans[0])
x , y = map(iint,input().split())
A = [1,3,5,7,8,10,12]
B = [4,6,9,11]
C = [2]
if x in A and y in A:
  print("Yes")
elif  x in B and y in B:
  print("Yes")
else:
  print("No")

### FIXED CODE ###

x , y = map(int,input().split())
A = [1,3,5,7,8,10,12]
B = [4,6,9,11]
C = [2]
if x in A and y in A:
  print("Yes")
elif  x in B and y in B:
  print("Yes")  
else:
  print("No")
H, W = list(map(int, input().split()))
S = []
for _ in range(H):
    S.append(list(input()))
    
for w in range(W):
    if S[0][w] == ".":
        S[0][w] = str(S[0][max(0,w-1):min(W, w+2)].count("#")
                    +S[1][max(0,w-1):min(W, w+2)].count("#"))

for h in range(1, H-1):
    for w in range(W):
        if S[h][w] == ".":
            S[h][w] = str(S[h-1][max(0,w-1):min(W, w+2)].count("#")
                        +S[h][max(0,w-1):min(W, w+2)].count("#")
                        +S[h+1][max(0,w-1):min(W, w+2)].count("#"))
            
for w in range(W):
        if S[H-1][w] == ".":
            S[H-1][w] = str(S[H-2][max(0,w-1):min(W, w+2)].count("#")
                        +S[H-1][max(0,w-1):min(W, w+2)].count("#"))
            
for h in range(H):
    print("".join(S[h]))

### FIXED CODE ###

H, W = list(map(int, input().split()))
S = []
for _ in range(H):
    S.append(list(input()))

if H > 1:
    for w in range(W):
        if S[0][w] == ".":
            S[0][w] = str(S[0][max(0,w-1):min(W, w+2)].count("#")
                        +S[1][max(0,w-1):min(W, w+2)].count("#"))

    for h in range(1, H-1):
        for w in range(W):
            if S[h][w] == ".":
                S[h][w] = str(S[h-1][max(0,w-1):min(W, w+2)].count("#")
                            +S[h][max(0,w-1):min(W, w+2)].count("#")
                            +S[h+1][max(0,w-1):min(W, w+2)].count("#"))

    for w in range(W):
            if S[H-1][w] == ".":
                S[H-1][w] = str(S[H-2][max(0,w-1):min(W, w+2)].count("#")
                            +S[H-1][max(0,w-1):min(W, w+2)].count("#"))

else:
    for w in range(W):
        if S[0][w] == ".":
            S[0][w] = str(S[0][max(0,w-1):min(W, w+2)].count("#"))
for h in range(H):
    print("".join(S[h]))
A = list(map(str,input().split()))
stack = []
number = [str(i) for i in range(101)]
for item in A:
    if item in number:
        stack.append(str(item))
    elif item == '+':
        v = int(stack[-2]) + int(stack[-1])
        del stack[-2]
        del stack[-1]
        stack.append(str(v))
    elif item == '-':
        v = int(stack[-2]) - int(stack[-1])
        del stack[-2]
        del stack[-1]
        stack.append(str(v))
    elif item == '*':
        v = int(stack[-2]) * int(stack[-1])
        del stack[-2]
        del stack[-1]
        stack.append(str(v))

print(stack[-1])


### FIXED CODE ###

A = list(map(str,input().split()))
stack = []
for item in A:
    if item != '+' and item != '-' and item != '*':
        stack.append(str(item))
    elif item == '+':
        v = int(stack[-2]) + int(stack[-1])
        del stack[-2]
        del stack[-1]
        stack.append(str(v))
    elif item == '-':
        v = int(stack[-2]) - int(stack[-1])
        del stack[-2]
        del stack[-1]
        stack.append(str(v))
    elif item == '*':
        v = int(stack[-2]) * int(stack[-1])
        del stack[-2]
        del stack[-1]
        stack.append(str(v))

print(stack[-1])
a,b=2,1
for i in range(n):
    a,b=b,a+b
print(a)

### FIXED CODE ###

n=int(input())
a,b=2,1
for i in range(n):
    a,b=b,a+b
print(a)
import sys
input=sys.stdin.readline
import math

n=int(input())
s=list(input())
ls=[0 if i=='W' else 1 for i in s]
a=sum(ls)
#print(a)
l=[math.inf]
for i in range(n):
    if ls[i]==1:
        a-=1
        l.append(a)
    elif ls[i]==0:
        a+=1
        l.append(a-1)
print(min(l))

### FIXED CODE ###

N=int(input())
S=input()
 
count=S[1:].count("E")
mincount=count
 
for i in range(1,N):
    if S[i]=="E":
        count-=1
    if S[i-1]=="W":
        count+=1
 
 
    mincount=min(count,mincount)
print(mincount)
N,Q = map(int,input().split())

par = [i for i in range(N+1)]
rank = [1 for i in range(N+1)]

# 木の根を求める
def root(x):
    if par[x] == x:
        return x
    else:
        par[x] = root(par[x])
        return par[x]

# xとyが同じ集合に属するか否か
def bool_same(x,y):
    return root(x) == root(y)

# xとyの属する集合を併合(ランク有)
def unite(x,y):
    x = root(x)
    y = root(y)
    if x != y:
        if rank[x] < rank[y]:
            par[x] = y
            rank[y] += rank[x]
        else:
            par[y] = x
            rank[x] += rank[y]

for i in range(Q):
    p,a,b = map(int,input().split())
    if p == 0:
        unite(a,b)
    else:
        print('Yes' if bool_same(a,b) else 'No')

### FIXED CODE ###

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

par = [i for i in range(N+1)]

# 木の根を求める
def root(x):
    if par[x] == x:
        return x
    else:
        par[x] = root(par[x])
        return par[x]

# xとyが同じ集合に属するか否か
def bool_same(x,y):
    return root(x) == root(y)

# xとyの属する集合を併合
def unite(x,y):
    x = root(x)
    y = root(y)
    if x != y:
        par[x] = y

p = [0] + list(map(int,input().split()))

for i in range(M):
    a,b = map(int,input().split())
    unite(a,b)

ans = 0
for i in range(1,N+1):
    if bool_same(i,p[i]):
        ans += 1

print(ans)
def Sumofnum(K,S):
    A = min(K,S) + 1
    a = max(S - 2*K, 0)
    c = 0
    for x in range (a,A):
        B = min(S - x,K) + 1
        b = max(S - x - K,0)
        for y in range (b,B):
            c = c + 1
    print(c)
    
s = list(map(int,input().split()))
Sumofnum(K,S)

### FIXED CODE ###

def Sumofnum(K,S):
    A = min(K,S) + 1
    a = max(S - 2*K, 0)
    c = 0
    for x in range (a,A):
        B = min(S - x,K) + 1
        b = max(S - x - K,0)
        for y in range (b,B):
            c = c + 1
    print(c)
    
s = list(map(int,input().split()))
K = s[0]
S = s[1]
Sumofnum(K,S)
c = input()

txt = 'abcdefghijklmnopqrstuvwxyz'

for i in range(27):
    if txt[i] == c:
        print(txt[i + 1])


### FIXED CODE ###

c = input()

txt = 'abcdefghijklmnopqrstuvwxyz'
for i in range(26):
    if txt[i] == c:
        print(txt[i + 1])
r,g,b=map(str,input().split())
l=('r'+'g'+'b')
if 0 == (int(l)%4):
  print('YES')
else:
  print('NO')


### FIXED CODE ###

r,g,b=map(int,input().split())
l=(str(r)+str(g)+str(b))
if 0 == (int(l)%4):
  print('YES')
else:
  print('NO')
import.math
h=int(input())
i=int(math.log(2,h))
print(2**(i+1)-1)

### FIXED CODE ###

import math
h=int(input())
i=int(math.log(h,2))
print((2**(i+1))-1)
import math

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

if A==1:
    A=14
if B==1:
    B=14
    
if A>B:
    print('Alice')
elif A<B:
    if b=='H':
        print('Bob')
    else:
        print('Draw')

### FIXED CODE ###

import math

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

if A==1:
    A=14
if B==1:
    B=14
    
if A>B:
    print('Alice')
elif A<B:
    print('Bob')
else:
    print('Draw')
a = list(map(int,input().split()))
sort(a)
print(str(a[0])+" "+str(a[1])+" "+str(a[2]))

### FIXED CODE ###

a = list(map(int,input().split()))
a.sort()
print(str(a[0])+" "+str(a[1])+" "+str(a[2]))
s=input("")
t=input("")
print(str(s)+str(t))


### FIXED CODE ###

S,T=map(str,input().split(" "))
print(T+S)
a = input()
b = input()

c = a*b

if c%2==1:
  print("Odd")
else:
  print("Even")

### FIXED CODE ###

x = input()
x = x.split(" ")

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

c = a*b

if c%2==0:
    print("Even")
else:
    print("Odd")
A = list(map(math.floor, A))

### FIXED CODE ###

import math
import bisect

N, M = map(int, input().split())
A = list(map(int, input().split()))
A.sort(reverse = True)

def XX(A, M):
  if M <= 0 or A[0]<1:
    return
  A[0] = A[0]/2
  M -= 1
  for i in range(1, len(A)):
    if A[i] > A[0] and M > 0:
      A[i] = A[i]/2
      M -= 1
    else:
      break
  A.sort(reverse = True)
  XX(A, M)
  
XX(A, M)
A = list(map(math.floor, A))
print(sum(A))