Harryxun/stf_run huggingface dataset:
# Setup
import sys
sys.setrecursionlimit(4100000)
n = int(input())
a = [int(input()) for i in range(n)]
heap = []
for i in range(n):
    heapq.heappush(heap,-a[i])
for i in range(n):
    temp = heapq.heappop(heap)
    if -a[i] == temp:
        temp2 = heapq.heappop(heap)
        print(-temp2)
        heapq.heappush(heap,temp)
        heapq.heappush(heap,temp2)
    else:
        print(-temp)
        heapq.heappush(heap,temp)

### FIXED CODE ###

# Setup
import sys
import heapq
sys.setrecursionlimit(4100000)
n = int(input())
a = [int(input()) for i in range(n)]
heap = []
for i in range(n):
    heapq.heappush(heap,-a[i])
for i in range(n):
    temp = heapq.heappop(heap)
    if -a[i] == temp:
        temp2 = heapq.heappop(heap)
        print(-temp2)
        heapq.heappush(heap,temp)
        heapq.heappush(heap,temp2)
    else:
        print(-temp)
        heapq.heappush(heap,temp)
N=int(input())
A=list(map(int,input().split()))

sum=0
for i in range(N-1):
    for j in range(i+1,N):
        sum+=(A[i]*A[j])%(10**9+7)

print(sum%(10**9+7))


### FIXED CODE ###

d,t,s=map(int,input().split())

if d <= t*s:
    print("Yes")
else:
    print("No")
n = int(input())
cnt=0
for i in range(1,n+1):
	if len(str(i))%2==1:
		cnt+=1
print(cnt)

### FIXED CODE ###

a,b,c=map(int,input().split())
y1=a-b
y2=c-y1
if y2<0:
	print("0")
else:
	print(y2)
while True:
  cards = str(input())
  if cards == '-':
    break
  
  n = int(input())
  for i in range(n):
    p = str(input())
    cards = cards[p:] + cards[:p]
  print(cards)


### FIXED CODE ###

while True:
  cards = str(input())
  if cards == '-':
    break
  
  n = int(input())
  for i in range(n):
    p = int(input())
    cards = cards[p:] + cards[:p]
  print(cards)
n,x,m = map(int,input().split())
a = list(map(int,input().split()))
lcnt = 0
rcnt = 0
for i in range(m):
  if a[i] < x:
    lcnt += 1
  else:
    rcnt += 1
print(min(lcnt,rcnt))
    

### FIXED CODE ###

n,m,x = map(int,input().split())
a = list(map(int,input().split()))
lcnt = 0
rcnt = 0
for i in range(m):
  if a[i] < x:
    lcnt += 1
  else:
    rcnt += 1
print(min(lcnt,rcnt))
import math


def main():
    a = list(input())
    b = list(input())
    dica = {}
    dicb = {}
    dif = 0
    alpha = list("abcdefghijklmnopqrstuvwxyz")
    for aa,bb in zip(a,b):
        if aa != bb:
            if bb not in dica:  
                dica[bb] = aa
            if aa not in dicb:
                dicb[aa] =bb
        
            if dica[bb] != aa or dicb[aa] != bb:            
                print("No")
                return 0
        
            # if aa not in dica:
            #     dica[aa] = bb
            # if bb not in dicb:
            #     dicb[bb] = aa
            
    if dica[b[-1]] != a[-1] or dicb[a[-1]] != b[-1]:            
        print("No")
        return 0
    
    print("Yes")
    
    # for c in alpha:
    #     dica[c] = 0
    #     dicb[c] = 0
    # for temp in a:
    #     dica[temp] +=1
    # for temp in b:
    #     dicb[temp] +=1
    # for c in alpha:
    #     dif += (dica[c]-dicb[c])
    
    

if __name__ == '__main__':
    main()


### FIXED CODE ###

s1 = input()
s2 = input()
di1 = {} #s1 → s2 の対応表
di2 = {} #s2 → s1 の対応表

ans = "Yes"
for c1,c2 in zip(s1,s2):
    if c1 not in di1:
        di1[c1] = c2
    else:
        if di1[c1] != c2:
            ans = "No"

    if c2 not in di2:
        di2[c2] = c1
    else:
        if di2[c2] != c1:
            ans = "No"

print(ans)
n, k= map(int, input().split())
s=input()
s[k], lower()
print(s)

### FIXED CODE ###

n,k=map(int,input().split())
s=input()
print(s[:k-1]+s[k-1].lower()+s[k:])
from fractions import gcd
n=int(input())
a=list(map(int,input().split()))
print(gcd(a))

### FIXED CODE ###

from fractions import gcd
n=int(input())
a=list(map(int,input().split()))
b=a[0]
for x in a[1:]:
  b=gcd(b,x)
print(b)
from math import atan, degrees
a,b,x = map(int, input().split())

if x >= a*b/2:
  print(round(degrees(atan((b-x/(a**2))*2/a),7)))
else:
  print(round(degrees(atan(a*(b**2)/(2*x))),7))

### FIXED CODE ###

from math import atan, degrees
a,b,x = map(int, input().split())

if x/a >= a*b/2:
  print(degrees(atan((b-x/(a**2))*2/a)))
else:
  print(90 - degrees(atan(2*x/(a*(b**2)))))
n=input()
a=int(n[-2]+n[-1])
b=int(n)//100
if b*5<a:
    print(0)
else:
    print(1)

### FIXED CODE ###

n=input()
if len(n)==1:
  a=10
else:
  a=n[-2]+n[-1]
if a=="00":
  c=0
else:
  c=int(a)
b=int(n)//100
if b*5<c:
    print(0)
else:
    print(1)
X,t=map(int,input().split())
print("0" if x-t<0 else x-t)

### FIXED CODE ###

x,t=map(int,input().split())
print("0" if x-t<0 else x-t)
import sys
s = sys.argv
weathers = ['Sunny', 'Cloudy', 'Rainy']
for i, weather in enumerate(weathers):
    if s == weather:
        return weathers[i+1]

### FIXED CODE ###

s = input()
weathers = ['Sunny', 'Cloudy', 'Rainy']
print(weathers[(weathers.index(s)+1)%3])
N = int(input())
X_2 = input()
X_10 = int(X_2, 2)

y=sum(map(int, X_2))+1
z=y-2

a = X_10%y
b = X_10%z

for i in range(N):
    if X_2[i]=='0':
        c = (2**(N-1-i))%y
        x = (a+c)%y
    elif sum(map(int, X_2[0:i]+X_2[i+1:]))==0:
        print(0)
        continue
    else:
        c = (2**(N-1-i))%z
        x = (b-c)%z
    
    count = 1
    while x != 0:
        x = x%sum(map(int, bin(x)[2:]))
        count+=1
    print(count)

### FIXED CODE ###

N = int(input())
X_2 = input()
X_10 = int(X_2, 2)

y = X_2.count('1')

a = X_10%(y+1)
if y==1:
    b = 0
else:
    b = X_10%(y-1)

for i in range(N):
    if X_2[i] == '1' and y == 1:
        print(0)
        continue
    elif X_2[i] == '1':
        x = (b-pow(2, N-1-i, y-1))%(y-1)
    else:
        x = (a+pow(2, N-1-i, y+1))%(y+1)
    count = 1
    while x!=0:
        x %= bin(x)[2:].count('1')
        count += 1
    print(count)
n,q = map(int,input().split())
a=[[] for i in range(n)]
p=[]
l=[0]*n

def plus(tl,ta,t2):
    # print(tl)
    for i in ta:
        tl[i-1]+=t2
        # print(ta[t1-1],t1)
        plus(tl,a[i-1],t2)

for i in range(n-1):
    t1,t2 = map(int,input().split())
    a[t1-1].append(t2)
# print(a)
for i in range(q):
    t1,t2 = map(int,input().split())
    # print(a[t1-1],t1)
    l[t1-1]+=t2
    plus(l,a[t1-1],t2)
    
print(" ".join(map(str,l)))

### FIXED CODE ###

import sys
sys.setrecursionlimit(10**6)

readline = sys.stdin.readline

n,q = map(int,readline().split())
a=[[] for i in range(n)]
l=[0 for _ in range(n)]
ans=[0 for _ in range(n)]

def dfs(parent,current,value):
    value += l[current]
    ans[current] = value
    for i in a[current]:
        if i == parent:
            continue
        dfs(current,i,value)


for i in range(n-1):
    t1,t2 = map(int,readline().split())
    a[t1-1].append(t2-1)
    a[t2-1].append(t1-1)
    
for i in range(q):
    t1,t2 = map(int,readline().split())
    l[t1-1]+=t2
dfs(-1,0,0)

print(" ".join(map(str,ans)))
n=int(input())
s=[]
t=[]
for i in range(n):
  s.append(input())
m=int(input())
for i in range(m):
  t.append(input())
max=0
for i in range(len(s)):
  get=0
  for j in range(len(s[i:n])):
    if s[i]==s[j]:
      get+=1
  for k in range(len(t)):
    if s[i]==s[k]:
      get-=1
  if get>max:
    max=get
print(max) 

### FIXED CODE ###

N = int(input())
worddict = {}
for i in range(N):
  s = input()
  if s in worddict:
    worddict[s] += 1
  else:
    worddict[s] = 1
    
M = int(input())
for i in range(M):
  t = input()
  if t in worddict:
    worddict[t] -= 1
    
maxyen = 0
for i in worddict:
  maxyen = max(maxyen, worddict[i])
print(maxyen)
from collections import defaultdict
import queue

def getlist():
	return list(map(int, input().split()))

class Graph(object):
    def __init__(self):
        self.graph = defaultdict(list)

    def __len__(self):
        return len(self.graph)

    def add_edge(self, a, b, w):
        self.graph[a].append([b, w])

    def get_nodes(self):
        return self.graph.keys()

class BFS(object):
    def __init__(self, graph, N):
        self.g = graph.graph
        self.dist = [0] * (N + 1)
        self.visit = [0] * (N + 1)
        self.Q = queue.Queue()
        self.Q.put(1)

        while not self.Q.empty():
            v = self.Q.get()
            for i, w in self.g[v]:
            	if self.visit[i] == 0:
            		self.dist[i] = self.dist[v] + w

            	self.Q.put(i)
            	self.visit[i] = 1

    def weight(self):
        return self.dist

N = int(input())
G = Graph()
for i in range(N - 1):
	u, v, w = getlist()
	G.add_edge(u, v, w)
XX = BFS(G, W, N)
ans = XX.weight()

for i in range(1, N + 1):
	if ans[i] % 2 == 0:
		print(0)
	else:
		print(1)

### FIXED CODE ###

from collections import defaultdict
import queue

def getlist():
	return list(map(int, input().split()))

class Graph(object):
    def __init__(self):
        self.graph = defaultdict(list)

    def __len__(self):
        return len(self.graph)

    def add_edge(self, a, b, w):
        self.graph[a].append([b, w])

    def get_nodes(self):
        return self.graph.keys()

class BFS(object):
    def __init__(self, graph, N):
        self.g = graph.graph
        self.dist = [0] * (N + 1)
        self.visit = [0] * (N + 1)
        self.Q = queue.Queue()
        self.Q.put(1)

        while not self.Q.empty():
            v = self.Q.get()
            for i, w in self.g[v]:
            	if self.visit[i] == 0:
            		self.dist[i] = self.dist[v] + w
            		self.Q.put(i)
            		self.visit[i] = 1

    def weight(self):
        return self.dist

N = int(input())
G = Graph()
for i in range(N - 1):
    u, v, w = getlist()
    G.add_edge(u, v, w)
    G.add_edge(v, u, w)

XX = BFS(G, N)
ans = XX.weight()
for i in range(1, N + 1):
	if ans[i] % 2 == 0:
		print(0)
	else:
		print(1)
from collections import deque
import numpy as np
H,W = map(int,input().split())
A = [list(input()) for _ in range(H)]
table = [[float('inf')]*(W) for _ in range(H)]
visited = [[False]*(W) for _ in range(H)]
start = []
for i in range(H):
    for j in range(W):
        if A[i][j] == '#':
            table[i][j] = 0
            start.append((i,j))
for (sy, sx) in start:
    visited[sy][sx] = True
    que = deque([(sx,sy)])
    while que:
        y,x = que.popleft()
        for dy, dx in ((1,0),(-1,0),(0,1),(0,-1)):
            ny,nx = y+dy, x+dx
            if 0<=ny<H and 0<=nx<W:
                if table[ny][nx] == float('inf'):
                    table[ny][nx] = table[y][x]+1
                    que.append((ny, nx))
print(np.array(table).max())

### FIXED CODE ###

from scipy.ndimage import distance_transform_cdt
H,W = map(int,input().split())
S = list(list(input()) for h in range(H))
for h in range(H):
    for w in range(W):
        if S[h][w] == '#':
            S[h][w] = 0
        else:
            S[h][w] = 1
print(distance_transform_cdt(S, metric='taxicab').max())
N,M = map(int,input().split())
AC = 0
WA = 0
lis = [0] * N
for i in range(M):
  a,b = map(input().split())
  if lis[int(a)-1] < 0:
    pass
  elif b == 'AC':
    WA += lis[int(a)-1]
    AC += 1
    lis[int(a)-1] = -1
  else:
    lis[int(a)-1] += 1
print(AC, WA)


### FIXED CODE ###

N,M = map(int,input().split())
AC = 0
WA = 0
lis = [0] * N
for i in range(M):
  a,b = input().split()
  if lis[int(a)-1] < 0:
    pass
  elif b == 'AC':
    WA += lis[int(a)-1]
    AC += 1
    lis[int(a)-1] = -1
  else:
    lis[int(a)-1] += 1
print(AC, WA)
from math import log2

def prob(num, dice, K):
	times = int(log2(K/num) + 1)
	base  = 1/dice
	if times < 0:
		times = 0
	p = base * pow(0.5,times)
	return p

def sum_prob(dice, K):
	probabilty = 0
	for i in range(1,dice+1):
		probabilty += prob(i, dice, K)
	return probabilty


inputs = list(map(float,input().split(' ')))[:2]
dice = inputs[0]
K = inputs[1]
probabilty = sum_prob(dice, K)
print(probabilty)

### FIXED CODE ###

length_and_index = list(map(int,input().split(' ')))
input_str = list(input()[:length_and_index[0]])
input_str[length_and_index[1]-1] = chr(ord(input_str[length_and_index[1]-1])+32)
out = "".join(str(x) for x in input_str)
print(out)
[a, b] = map(int(input().split()))
print(a * b,(a + b) * 2)

### FIXED CODE ###

[a, b] = map(int, input().split())
print(a*b, (a+b)*2)
N = int(input())
nlist = [int(i) for i in input().split()]
nlist.sort(reverse = True)
a = 0
b = 0
for j in range(N):
    if j % 2 == 0:
        a += nlist[j]
    else:
        b += nlist[j]

print(a-b)

### FIXED CODE ###

N = int(input())
A = int(input())

a = N % 500
if a <= A:
    print("Yes")
else:
    print("No")
from collections import deque

N, M, K = list(map(int, input().split()))
A = list(map(int, input().split()))
B = list(map(int, input().split()))
# print(N, M, K)
# print(A)
# print(B)


consumptions_A = [0]
for Ai in A:
    consumptions_A.append(consumptions_A + Ai)

consumptions_B = []
for Bi in B:
    consumptions_B.append(sum(B[:i]))

answer = 0
j = M
for i in range(len(consumptions_A)):
    if (consumptions_A[i] > K): break

    remaining_time = K - consumptions_A[i]
    while consumptions_B[j] > remaining_time:
        j -= 1
    
    num_books = i + j
    answer = max(answer, num_books)

print(answer)


### FIXED CODE ###

from collections import deque

N, M, K = list(map(int, input().split()))
A = list(map(int, input().split()))
B = list(map(int, input().split()))
# print(N, M, K)
# print(A)
# print(B)


consumptions_A = [0]
for i in range(len(A)):
    consumptions_A.append(consumptions_A[i] + A[i])

consumptions_B = [0]
for i in range(len(B)):
    consumptions_B.append(consumptions_B[i] + B[i])

answer = 0
j = M
for i in range(len(consumptions_A)):
    if (consumptions_A[i] > K): break

    remaining_time = K - consumptions_A[i]
    while consumptions_B[j] > remaining_time:
        j -= 1
    
    num_books = i + j
    answer = max(answer, num_books)

print(answer)
import pandas as pd

k, x = map(int, input().split())

axis = list(range(-10, 11, 1))
df = pd.DataFrame(axis)
df = df.rename(columns = {0 : 'var'})

res = []

if k == 1:
    print(x)
else:
    for i in range(1, k):

        a = df[df['var'] == x + i]
        a = list(a['var'])
        res.append(a)
        
        a = df[df['var'] == x - i]
        a = list(a['var'])
        res.append(a)
    res.append([x])
    res = sum(res, []) #リスト一段解除
    res = sorted(res) #並び替え
    print(*res)


### FIXED CODE ###

k, x = map(int, input().split())

res = []
if k == 1:
    print(x)
else:
    for i in range(1, k):
        res.append(x + i)
    for i in range(1, k):
        res.append(x - i)
    res.append(x)
    res = sorted(res)
    print(*res)
from decimal import Decimal
a, b, c = map(int, input().split())
if Decimal(a).sqrt() + Decimal(b).sqrt(b) < Decimal(c).sqrt():
    print('Yes')
else:
    print('No')

### FIXED CODE ###


from decimal import Decimal
a, b, c = map(int, input().split())
if Decimal(a).sqrt() + Decimal(b).sqrt() < Decimal(c).sqrt():
    print('Yes')
else:
    print('No')
A = map(int, input().split())
A=A[0]
B=A[1]
C=A[2]
D=C-(A-B)
print(D)

### FIXED CODE ###

A,B,C = map(int, input().split())
D=C-(A-B)
if D > 0:
    print(D)
else:
    print(0)
s = [int(x) for x in int(input())]

sum = 0
for i in s:
  if i == 1:
    sum += 1

print(sum)

### FIXED CODE ###

s = int(input())
l = [int(x) for x in list(str(s))]

sum = 0
for i in l:
  if i == 1:
    sum += 1

print(sum)
s=map(int,input().split())

s.sort()

print((s[0])+(s[1]))

### FIXED CODE ###

s=list(map(int,input().split()))
 
s.sort()
 
print(s[0]+s[1])
from collections import defaultdict
import math


def main():
    n = int(input())
    mod = 1000000007
    zeroes = 0
    counter = defaultdict(lambda: defaultdict(int))
    for _ in range(n):
        a, b = [int(x) for x in input().split()]
        denominator = math.gcd(a, b)
        x, y = a // denominator, b // denominator

        if x == y == 0:
            zeroes += 1
            continue
        if y < 0:
            # quadrant III, IV -> I, II
            x, y = -x, -y

        if x <= 0:
            # round 90° from quadrant II to I
            x, y = y, -x
            counter[(x, y)][1] += 1
        else:
            counter[(x, y)][0] += 1

    ans = 1
    for v in counter.values():
        now = 1
        now += pow(2, v[0], mod) - 1
        now += pow(2, v[1], mod) - 1
        ans = ans * now % mod
    ans += zeroes
    ans -= 1  # choose no fish
    return ans % mod


if __name__ == '__main__':
    print(main())


### FIXED CODE ###

from collections import defaultdict
import math


def ggg(a, b):
    """規約分数を作る。n/0, 0/n は n=1,-1 にして返す。"""
    if a == b == 0:
        return 0, 0

    denominator = math.gcd(a, b)
    x, y = a // denominator, b // denominator
    return x, y


def main():
    n = int(input())
    mod = 1000000007
    zeroes = 0
    counter = defaultdict(lambda: defaultdict(int))
    for _ in range(n):
        a, b = [int(x) for x in input().split()]
        x, y = ggg(a, b)

        if x == y == 0:
            zeroes += 1
            continue
        if y < 0:
            # quadrant III, IV -> I, II
            x, y = -x, -y

        if x <= 0:
            # round 90° from quadrant II to I
            x, y = y, -x
            counter[(x, y)][1] += 1
        else:
            counter[(x, y)][0] += 1

    ans = 1
    for v in counter.values():
        now = 1
        now += pow(2, v[0], mod) - 1
        now += pow(2, v[1], mod) - 1
        ans = ans * now % mod
    ans += zeroes
    ans -= 1  # choose no fish
    return ans % mod


if __name__ == '__main__':
    print(main())
N,A,B = map(int, input().split())

count = N//(A+B)
amari = N%(A+B)

if amari < A:
  c = amari
else:
  c = A
  
ans = A * x + c
print(ans)

### FIXED CODE ###

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

count = N//(A+B)
amari = N%(A+B)

if amari < A:
  c = amari
else:
  c = A
  
ans = A * count + c
print(ans)
#include <stdio.h>

int main(void){
  int a;
  int p;
  
  scanf("%d",a); scanf("%d",a);
  print("%d", (a*3+p)/2);

  return 0;
}

### FIXED CODE ###

a,p = map(int,input().split())
print((a*3+p)//2)
N, M = map(int, input().split())

like = list(map(int, input().split()))
all_like = set()
for l in like:
	all_like.add(l)
    
for i in range(N-1):
  like = list(map(int, input().split()))
  for l in like:
    if l not in all_like:
      all_like.remove(l);
print(len(all_like))

### FIXED CODE ###

import copy

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

like = list(map(int, input().split()))
like.pop(0)
all_like = set()
for l in like:
	all_like.add(l)
    
for i in range(N-1):
  like = list(map(int, input().split()))
  like.pop(0)
  tmp = copy.deepcopy(all_like)
  for l in all_like:
    if l not in like:
      tmp.remove(l);
  all_like = tmp
print(len(all_like))
dishes = [int(input()) for _ in range(5)]
print(sum(map(lambda num: num + 10 * (num % 10 != 0) - (num % 10), dishes)) + min(n for n in map(lambda num: num % 10, dishes) if n) - 10)


### FIXED CODE ###

dishes = [int(input()) for _ in range(5)]
tuple_ = tuple(n for n in map(lambda num: num % 10, dishes) if n)
print(sum(map(lambda num: num + 10 * (num % 10 != 0) - (num % 10), dishes)) + min(tuple_ if tuple_ else (10,)) - 10)
human_num, train_value, taxi_num = tuple(int(i) for i in input().split(""))
print(min(train_value * human_num, taxi_num))

### FIXED CODE ###

human_num, train_value, taxi_num = tuple(int(i) for i in input().split(" "))
print(min(train_value * human_num, taxi_num))
import copy
n = int(input())
x = [int(y) for y in input().split()]
z = copy.deepcopy(x)
for i in range(n):
  x.pop(i)
  x.sort()
  print(x[(n - 2) / 2])
  x = z

### FIXED CODE ###

import copy
import statistics
n = int(input())
x = [int(y) for y in input().split()]
z = copy.deepcopy(x)
z.sort()
t = (z[int(n / 2) - 1] + z[int(n / 2)]) / 2

for i in range(n):
  if x[i] < t:
    print(z[int(n / 2)])
  else:
    print(z[int(n / 2) - 1])
r, d, x = map(int,input().split())
print((x = x * r - k ) for _ in range(10))

### FIXED CODE ###

r, d, x = map(int,input().split())
for _ in range(10):
    x = x * r - d
    print(x)
import sys
sys.setrecursionlimit(10**8)
def ii(): return int(sys.stdin.readline())
def mi(): return map(int, sys.stdin.readline().split())
def li(): return list(map(int, sys.stdin.readline().split()))
def li2(N): return [list(map(int, sys.stdin.readline().split())) for _ in range(N)]
def dp2(ini, i, j): return [[ini]*i for _ in range(j)]
def dp3(ini, i, j, k): return [[[ini]*i for _ in range(j)] for _ in range(k)]
#import bisect #bisect.bisect_left(B, a)
#from collections import defaultdict #d = defaultdict(int) d[key] += value
#from itertools import accumulate #list(accumulate(A))

def pow_r_mod(x, n, mod=10**9+7):
    # 計算量 : log N
    if n == 0:
        return 1
    K = 1
    while n > 1:
        if n % 2 != 0:
            K *= x
        x *= x
        x %= mod
        n //= 2
    return (K * x) % mod

def  mod_pow(a:int, b:int, mod:int)->int:
    if b % 2 == 0:
        return (mod_pow(a, b//2, mod) ** 2) % mod
    elif b == 1:
        return a % mod
    else:
        return ((mod_pow(a, b//2, mod) ** 2) * a) % mod

m, a, b = mi()

P = 10**9+7
N = 2*(10**5)+1
inv_t = [0]+[1]
for i in range(2, N):
  inv_t += [inv_t[P % i] * (P - int(P / i)) % P]

mca = mcb = 1

for i in range(1, a+1):
    mca *= (m-i+1) * inv_t[i]
    mca %= P

for i in range(1, b+1):
    mcb *= (m-i+1) * inv_t[i]
    mcb %= P

#print((pow_r_mod(2, m)-1-mca-mcb) % P)
print((mod_pow(2, m, P)-1-mca-mcb) % P)

### FIXED CODE ###

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

if N < 10:
    print(K+100*(10-N))
else:
    print(K)
val = input()

if val>=30:
    print('Yes')
else:
    print('No')

### FIXED CODE ###

val = int(input())
if val>=30:
    print('Yes')
else:
    print('No')
import sys
input = sys.stdin.readline

S=input()
K=int(input())

n = 0
m = 0
for c in S:
    if c != '1':
        m = int(c)
        break
    n += 1
if K <= n:
    print(1)
else:
    print(m)



### FIXED CODE ###

import sys
input = sys.stdin.readline

S=input().strip()
K=int(input().strip())

n = 0
m = 0
for c in S:
    if c != '1':
        m = int(c)
        break
    n += 1
if K <= n:
    print(1)
else:
    print(m)
import sys
import math
import collections

def set_debug(debug_mode=False):
    if debug_mode:
        fin = open('input.txt', 'r')
        sys.stdin = fin


def int_input():
    return list(map(int, input().split()))


if __name__ == '__main__':
    # set_debug(True)

    t = input()
    
    if t.is_upper():
        print('A')
    else:
        print('a')

    

### FIXED CODE ###

import sys
import math
import collections
 
def set_debug(debug_mode=False):
    if debug_mode:
        fin = open('input.txt', 'r')
        sys.stdin = fin
 
 
def int_input():
    return list(map(int, input().split()))
 
 
if __name__ == '__main__':
    # set_debug(True)
 
    t = input()
    
    if 'A' <= t <= 'Z':
        print('A')
    else:
        print('a')
N, M = map(int,input().split())

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

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


Swap=[None]*M
for i in range(M):
    Swap[i]=sorted(map(int,input().split()))
 
Swap.sort(key=lambda x:x[0])

for i in range(M):
    if (Group[Swap[i][1]],Group[Swap[i][0]])!=(min(Group[Swap[i][0]], Group[Swap[i][1]]),min(Group[Swap[i][0]], Group[Swap[i][1]])):
        Group[Swap[i][1]],Group[Swap[i][0]]=min(Group[Swap[i][0]], Group[Swap[i][1]]),min(Group[Swap[i][0]], Group[Swap[i][1]])
        print(Group)

Swap.reverse()

for i in range(M):
    if (Group[Swap[i][1]],Group[Swap[i][0]])!=(min(Group[Swap[i][0]], Group[Swap[i][1]]),min(Group[Swap[i][0]], Group[Swap[i][1]])):
        Group[Swap[i][1]],Group[Swap[i][0]]=min(Group[Swap[i][0]], Group[Swap[i][1]]),min(Group[Swap[i][0]], Group[Swap[i][1]])
        print(Group)


count=0

for i in range(N):
    if Group[P[i]]==Group[i+1]:
        count+=1


print(count)

### FIXED CODE ###

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

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


Swap=[None]*M
for i in range(M):
    Swap[i]=sorted(map(int,input().split()))

def find(x):
    while Group[x] != x:
        x=Group[x]
    return x

for i in range(M):
    if find(Swap[i][1]) != find(Swap[i][0]):
        Group[find(Swap[i][1])]=min(find(Swap[i][1]),find(Swap[i][0]))
        Group[find(Swap[i][0])]=min(find(Swap[i][1]),find(Swap[i][0]))
        Group[Swap[i][1]]=min(find(Swap[i][1]),find(Swap[i][0]))
        Group[Swap[i][1]]=min(find(Swap[i][1]),find(Swap[i][0]))

count=0

for i in range(N):
    if find(P[i])==find(i+1):
        count+=1


print(count)