Harryxun/stf_run huggingface dataset:
a,b = int(),input().split()
if a < b:
    print("a < b")
elif a > b:
    print("a > b")
else a == b:
    print("a == b")


### FIXED CODE ###

a,b = input().split()
a = int(a)
b = int(b)
if a < b:
    print("a < b")
elif a > b:
    print("a > b")
else:
    print("a == b")
N, K = map(int, input().split())
S = input()

L = []
before = ''
cnt = 0
len_l = 0
for i in range(N):
  if before == '0' and S[i] == '0':
  	cnt += 1
  elif before == '0' and S[i] == '1':
  	before = '1'
    L.append(cnt)
    len_l += 1
    cnt = 0
  elif before == '1' and S[i] == '0':
    before == '0'
    cnt += 1
if cnt != 0:
  L.append(cnt)
  len_l += 1

L.sort(reverse=True)

if len_l > K:
  print(sum(L[:K])
else:
  print(sum(L))


### FIXED CODE ###

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

before = S[0]
cnt = 0
same_nums = []
if S[0] == '0':
  same_nums.append(0)
for i in range(N):
  if S[i] == before:
    cnt += 1
  else:
    same_nums.append(cnt)
    before = S[i]
    cnt = 1
same_nums.append(cnt)
if S[-1] == '0':
  same_nums.append(0)
  
sum_nums = sum(same_nums[:2*K+1])
ans = sum_nums
for i in range(0, len(same_nums)-2*K, 2):
  sum_nums = sum_nums - sum(same_nums[i:i+2]) + sum(same_nums[i+2*K+1:i+2*K+3])
  ans = max(ans, sum_nums)
print(ans)
a=int(input())
if 9 in a:
  print('Yes')
else:
  print('No')

### FIXED CODE ###

a=input()
if '9' in a:
  print('Yes')
else:
  print('No')
n = input()
l = list(map(int,input().split(" ")))
 
count = 0
 
while True:
  for i in range(n):
    if l[i]%2 == 0:
      l[i] = l[i]//2
    else:
      print(count)
      exit()
  count += 1
 

### FIXED CODE ###

n = int(input())
l=list(map(int,input().split()))
count=0
while True:
    for i in range(n):
        if l[i]%2==0:
            l[i]=l[i]//2
        else:
            print(count)
            exit()
    count+=1
from sys import exit
class Fib:
  def __init__(self):
    self.memo = {}
  def calc(self, n):
    if n == 1 or n == 2:
      self.memo[n] = 1
      return 1
    if n <= 0:
      self.memo[n] = 0
      return 0
    if n in self.memo.keys():
      return self.memo[n]
    self.memo[n] = self.calc(n - 1) + self.calc(n - 2)
    return self.memo[n]

N, M = map(int, input().split())
ans = 1
mod = 10 ** 9 + 7
pre = -1
for i in range(M):
  a = int(input())
  if a == 1:
    pre = a
    continue
  if a == pre + 1 and pre != 0:
    print(0)
    exit()
  ans *= Fib().calc(a - pre - 1) % mod
  pre = a
ans *= Fib().calc(N - pre) % mod
print(ans % mod)

### FIXED CODE ###

import sys
class Fib:
  def __init__(self):
    self.memo = {}
  def calc(self, n):
    if n == 1 or n == 2:
      self.memo[n] = 1
      return 1
    if n <= 0:
      self.memo[n] = 0
      return 0
    if n in self.memo.keys():
      return self.memo[n]
    self.memo[n] = self.calc(n - 1) + self.calc(n - 2)
    return self.memo[n]
sys.setrecursionlimit(200000)
N, M = map(int, input().split())
ans = 1
mod = 10 ** 9 + 7
pre = -1
for i in range(M):
  a = int(input())
  if a == 1:
    pre = a
    continue
  if a == pre + 1 and pre != 0:
    print(0)
    sys.exit()
  ans *= Fib().calc(a - pre - 1) % mod
  pre = a
ans *= Fib().calc(N - pre) % mod
print(ans % mod)
l1 = list(map(int, input().split()))
l2 = list(map(int, input().split()))

H  int(l1[0])
N = int(l1[1])
A = int(sum(l2))
result = H - A
if result <= 0:
    print("Yes")
else:
    print("No")


### FIXED CODE ###

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

def attack(l):
    H = l[0]
    A = l[1]
    cnt = 0
    while H > 0:
        H -= A
        cnt += 1
    return cnt

print(attack(l))
s=int(input())
for i in range(s):
    p= list(map(int, input().split()))
    if p[0]==p[1]:
        z+=1
        if z==3:
            print("Yes")
            exit()
    else:
        z=0

print("No")

### FIXED CODE ###

s=int(input())
flag=0
z=0
for i in range(s):
    p= list(map(int, input().split()))
    if p[0]==p[1]:
        z+=1
        if z==3:
            flag=1
    else:
        z=0
if flag:
    print("Yes")
else:
    print("No")
a = list(map(int,input().split()))
b = []

for i in range((a[1]-a[0])%2019):
  for j in range(i):
    c = ((i+a[0])%2019)*((j+a[0])%2019)
    b.append(c)
else:
  print(min(b))

### FIXED CODE ###

a = list(map(int,input().split()))
b = []

if a[1]-a[0]>=2019:
  print(0)
else:
  for i in range(a[0],a[1]+1):
    for j in range(a[0],i):
      c = (i*j)%2019
      b.append(c)
  else:
    print(min(b))
S = input()
l = []
a = ["A", "C", "G", "T"]
n = 0
for i in S:
  if i in a:
    n += 1
  else:
    l.append(n)
    n = 0
print(max(l))

### FIXED CODE ###

S = input()
a = ["A", "C", "G", "T"]
ans = 0
count = 0
for i in S:
  if i in a:
    count += 1
  elif ans < count:
    ans = count
    count = 0

if count != 0:
  if ans < count:
    ans = count

print(ans)
x = input().split()
a,op,b = int(x[0]),x[1],int(x[2])
if x[1] == "+":
    print a+b
elif x[1] == "-":
    print a-b
elif x[1] == "*":
    print a*b
elif x[1] == "/":
    print a/b
else:
    break
    
    
    
    

### FIXED CODE ###

while True:
    x = raw_input().split()
    a,op,b = int(x[0]),x[1],int(x[2])
    if op == "+":
        print a+b
    elif op == "-":
        print a-b
    elif op == "*":
        print a*b
    elif op == "/":
        print a/b
    else:
        break
N, K = map(int, input().split())
S = input()
S[K-1] += 32
print(S)

### FIXED CODE ###

N, K = list(map(int, input().split()))
S = input()
print(S[:K-1]+S[K-1].lower()+S[K:])
import copy
from operator import itemgetter
from operator import attrgetter
N = int(input())
li = []

for i in range(N):
    li.append(list(map(str, input().split())))
    li[i][1]  = int (li[i][1])


copyli = li.copy()
ans = []
##copyli.sort()
a = sorted(copyli, key = itemgetter(1),  reverse=True)
c = sorted(a, key = itemgetter(0))


##copyli.sort(key=attrgetter(1), reverse=True)

for i in range(N):
    for j in range(N):
        if (li[j][0] == c[i][0]) and (li[j][1] == c[i][1]):
            ans.append(j+1)

for i in range(N):
    print(ans[i])

### FIXED CODE ###


N = int(input())
li = []

for i in range(N):
    li.append(list(map(str, input().split())))
    li[i][1]  = int (li[i][1])


copyli = li.copy()
ans = []
##copyli.sort()
a = sorted(copyli, key = lambda copyli: copyli[1],  reverse=True)
c = sorted(a, key = lambda a: a[0])


##copyli.sort(key=attrgetter(1), reverse=True)

for i in range(N):
    for j in range(N):
        if (li[j][0] == c[i][0]) and (li[j][1] == c[i][1]):
            ans.append(j+1)

for i in range(N):
    print(ans[i])
# -*- coding: utf-8 -*-
import sys
import copy
import collections
from bisect import bisect_left
from bisect import bisect_right
from collections import defaultdict
from heapq import heappop, heappush
import math

# NO, PAY-PAY
#import numpy as np
#import statistics
#from statistics import mean, median,variance,stdev

def main():
	N, W = map(int, input().split())
	wv = []
	for i in range(N):
		w, v = map(int, input().split())
		if w <= W:
			wv.append((w,v))
		
	DP = [[0 for _ in range(100000)] for _ in range(N)]
	
	for i, val in enumerate(wv):
		w, v = val
		if i == 0:
			DP[i][w] = v
			continue
			
		for j in range(W):
			DP[i][j] = max(DP[i-1][j], DP[i][j])
			
			if j+w <= W:
				DP[i][j+w] = max(DP[i-1][j] + v, DP[i][j+w])
			
	print(max(DP[N-1]))
	
if __name__ == "__main__":
	main()


### FIXED CODE ###

# -*- coding: utf-8 -*-
import sys
import copy
import collections
from bisect import bisect_left
from bisect import bisect_right
from collections import defaultdict
from heapq import heappop, heappush
import math

# NO, PAY-PAY
#import numpy as np
#import statistics
#from statistics import mean, median,variance,stdev

def main():
	N, W = map(int, input().split())
	wv = []
	for i in range(N):
		w, v = map(int, input().split())
		if w <= W:
			wv.append((w,v))
		
	DP = [[0 for _ in range(100001)] for _ in range(N)]
	
	for i, val in enumerate(wv):
		w, v = val
		if i == 0:
			DP[i][w] = v
			continue
			
		for j in range(W):
			DP[i][j] = max(DP[i-1][j], DP[i][j])
			
			if j+w <= W:
				DP[i][j+w] = max(DP[i-1][j] + v, DP[i][j+w])
			
	print(max(DP[N-1]))
	
if __name__ == "__main__":
	main()
N = input()
if(N%sum(list(map(int,N))) == 0):
  print("Yes")
else:
  print("No")

### FIXED CODE ###

N = input()
cnt = 0
for n in N:
  cnt += int(n)
if(int(N)%cnt == 0):
  print("Yes")
else:
  print("No")
import re
import sys

s = sys.stdin.buffer.readline().rstrip().decode()
ans = 0

for i in range(len(s) - 3):
    for j in range(i, len(s)):
        if int(s[i: j+i])%2019 == 0:
            ans += 1
print(ans)


### FIXED CODE ###

import sys

s = sys.stdin.buffer.readline().rstrip().decode()
MOD = 2019
ans = [1] + [0 for i in range(MOD)]
t = 1
r = 0
for i in reversed(s):
    r = (r + int(i)*t) % MOD
    t = t*10%2019
    ans[r] += 1
print(sum([m*(m-1)//2 for m in ans]))
from collections import deque

n, m = map(int, input().split())
g = [[] for _ in range(m)]

for _ in range(m):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    g[a].append(b)
    g[b].append(a)

start = -1
for v in range(n):
    if len(g[v]) == 0:
        continue
    start = v
    break

memo = [0] * n
memo[start] = 1
count = 0
q1 = []
q2 = []
for v in g[start]:
    if memo[v] == 1:
        continue
    memo[v] = 1
    count += 1
    if count > 2:
        break
    if count == 1:
        q1.append(v)
    elif count == 2:
        q2.append(v)

ans1 = [start]
while q1:
    node = q1.pop()
    ans1.append(node)
    flag = 0
    for nv in g[node]:
        if memo[nv] == 1:
            continue
        memo[nv] = 1
        q1.append(nv)
        flag = 1
        break
    if flag == 0:
        break

ans2 = [start]
while q2:
    node = q2.pop()
    ans2.append(node)
    flag = 0
    for nv in g[node]:
        if memo[nv] == 1:
            continue
        memo[nv] = 1
        q1.append(nv)
        flag = 1
        break
    if flag == 0:
        break

ans1 = ans1[::-1]
for l, r in zip(ans1, ans1[1:]):
    print(l+1, r+1)
for l, r in zip(ans2, ans2[1:]):
    print(l+1, r+1)


### FIXED CODE ###

from collections import deque

n, m = map(int, input().split())
g = [[] for _ in range(n)]

for _ in range(m):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    g[a].append(b)
    g[b].append(a)

start = -1
for v in range(n):
    if len(g[v]) == 0:
        continue
    start = v
    break

memo = [0] * n
memo[start] = 1
count = 0
q1 = deque([])
q2 = deque([])
for v in g[start]:
    if memo[v] == 1:
        continue
    count += 1
    if count > 2:
        break
    memo[v] = 1
    if count == 1:
        q1.append(v)
    elif count == 2:
        q2.append(v)

ans1 = [start]
while q1:
    node = q1.popleft()
    ans1.append(node)
    flag = 0
    for nv in g[node]:
        if memo[nv] == 1:
            continue
        memo[nv] = 1
        q1.append(nv)
        flag = 1
        break
    if flag == 0:
        break

ans2 = []
while q2:
    node = q2.popleft()
    ans2.append(node)
    flag = 0
    for nv in g[node]:
        if memo[nv] == 1:
            continue
        memo[nv] = 1
        q2.append(nv)
        flag = 1
        break
    if flag == 0:
        break

ans1 = ans1[::-1]


ans = []
for i in ans1:
    ans.append(i+1)
for i in ans2:
    ans.append(i+1)
print(len(ans))
print(*ans)
import sys
readline = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7

def main():
    N, L, T = map(int, readline().split())
    position = []
    #0をL-1からーに時計回りに超える場合は+1
    #0からL-1に反時計回りに超える場合は-1
    count = 0
    for i in range(N):
        x,w = map(int, readline().split())
        if w==1:
            count += (x+T)//L
            position.append((x+T)%L)
        else:
            if x-T<0:
                count += (x-T+1)//L
            position.append((x-T)%L)
    position.sort()
    if count>=0:
        ans = position[count:] + position[:count]
    for i in range(N):
        print(ans[i])


if __name__ == '__main__':
    main()

### FIXED CODE ###

import sys
readline = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7

def main():
    N, L, T = map(int, readline().split())
    position = []
    #0をL-1からーに時計回りに超える場合は+1
    #0からL-1に反時計回りに超える場合は-1
    count = 0
    for i in range(N):
        x,w = map(int, readline().split())
        if w==1:
            count += (x+T)//L
            position.append((x+T)%L)
        else:
            if x-T<0:
                count += (x-T)//L
            position.append((x-T)%L)
    position.sort()
    count %= N
    ans = position[count:] + position[:count]
    for i in range(N):
        print(ans[i])


if __name__ == '__main__':
    main()
from sys import stdin
from math import pi
from bisect import bisect
from itertools import repeat
def main():
    x1, y1, x2, y2 = map(int, stdin.readline().split())
    sx = 1
    if x1 > x2:
        x1, x2 = -x1, -x2
        sx = -1
    sy = 1
    if y1 > y2:
        y1, y2 = -y1, -y2
        sy = -1
    n = int(stdin.readline())
    dat = map(int, stdin.read().split(), repeat(10, 2 * n))
    a = []
    for i in xrange(n):
        x, y = dat[i*2:i*2+2]
        x *= sx
        y *= sy
        if x1 <= x <= x2 and y1 <= y <= y2:
            a.append((x, y))
    a.sort()
    c = pi * 5 - 10
    if x1 == x2 or y1 == y2:
        if a:
            print "%.12f" % ((x2 - x1 + y2 - y1) * 100 + 2 * c)
        else:
            print "%.12f" % ((x2 - x1 + y2 - y1) * 100)
        return
    b = [-10 ** 9] + [10 ** 9] * 200010
    m = 1
    for x, y in a:
        p = bisect(b, y, lo=0, hi=m)
        b[p] = y
        if p == m:
            m += 1
    c = pi * 5 - 20
    print "%.12f" % ((x2 - x1 + y2 - y1) * 100 + (m - 1) * c)
main()
from sys import stdin
from math import pi
from bisect import bisect
from itertools import repeat
def main():
    x1, y1, x2, y2 = map(int, stdin.readline().split())
    sx = 1
    if x1 > x2:
        x1, x2 = -x1, -x2
        sx = -1
    sy = 1
    if y1 > y2:
        y1, y2 = -y1, -y2
        sy = -1
    n = int(stdin.readline())
    dat = map(int, stdin.read().split(), repeat(10, 2 * n))
    a = []
    for i in xrange(n):
        x, y = dat[i*2:i*2+2]
        x *= sx
        y *= sy
        if x1 <= x <= x2 and y1 <= y <= y2:
            a.append((x, y))
    a.sort()
    c = pi * 5 - 10
    if x1 == x2 or y1 == y2:
        if a:
            print "%.12f" % ((x2 - x1 + y2 - y1) * 100 + 2 * c)
        else:
            print "%.12f" % ((x2 - x1 + y2 - y1) * 100)
        return
    b = [-10 ** 9] + [10 ** 9] * 200010
    m = 1
    for x, y in a:
        p = bisect(b, y, lo=0, hi=m)
        b[p] = y
        if p == m:
            m += 1
    c = pi * 5 - 20
    print "%.12f" % ((x2 - x1 + y2 - y1) * 100 + (m - 1) * c)
main()


### FIXED CODE ###

from sys import stdin
from math import pi
from bisect import bisect
from itertools import repeat
def main():
    x1, y1, x2, y2 = map(int, stdin.readline().split())
    sx = 1
    if x1 > x2:
        x1, x2 = -x1, -x2
        sx = -1
    sy = 1
    if y1 > y2:
        y1, y2 = -y1, -y2
        sy = -1
    n = int(stdin.readline())
    dat = map(int, stdin.read().split(), repeat(10, 2 * n))
    a = []
    for i in xrange(n):
        x, y = dat[i*2:i*2+2]
        x *= sx
        y *= sy
        if x1 <= x <= x2 and y1 <= y <= y2:
            a.append((x, y))
    a.sort()
    c = pi * 10 - 20
    b = [-10 ** 9] + [10 ** 9] * 200010
    m = 1
    for x, y in a:
        p = bisect(b, y, lo=0, hi=m)
        b[p] = y
        if p == m:
            m += 1
    d = pi * 5 - 20
    if m <= min(x2 - x1 + 1, y2 - y1 + 1):
        c = d
    print "%.12f" % ((x2 - x1 + y2 - y1) * 100 + (m - 2) * d + c)
main()
N,Y=map(int,input().split())
for i in range(N+1):
  for k range(N+1-i):
    int m = N-i-k
    if 10000*i + 5000*k + 1000*m == Y:
      print(i k m)
      exit()
print('-1' '-1' '-1')

### FIXED CODE ###

N,Y=map(int,input().split())
for i in range(N+1):
  for k in range(N+1-i):
    m = N-i-k
    if 10000*i + 5000*k + 1000*m == Y:
      print(i,k,m)
      exit()
print(-1,-1,-1)
N, A, B = map(int, input().split())
num
for i in range(N+1):
  if A <= sum(list(map(int, list(str(i))))) <= B:
    num += i
print(num)    


### FIXED CODE ###

N, A, B = map(int, input().split())
num = 0
for i in range(N+1):
  if A <= sum(list(map(int, list(str(i))))) <= B:
    num += i
print(num)
S = input()
T = "ACGT"
ans = 0

i = 0
while i < len(S):
    if S[i] in T:
        temp = 1
        for j in range(i+1, len(S)):
            if S[j] in T:
                temp += 1
            else:
                break
        ans = max(ans, temp)
        i = max(i+1, j+1)
    else:
        i += 1

print(ans)


### FIXED CODE ###

S = input()
T = "ACGT"
ans = 0

i = 0
while i < len(S):
    if S[i] in T:
        temp = 1
        for j in range(i+1, len(S)):
            if S[j] in T:
                temp += 1
            else:
                break
        ans = max(ans, temp)
        i += 1
    else:
        i += 1

print(ans)
a, b, c = map(int, nput().split())
if b - a == c - b:
    print('YES')
else:
    print('NO')

### FIXED CODE ###

a, b, c = map(int, input().split())
if b - a == c - b:
    print('YES')
else:
    print('NO')
x, y = map(int,input().split())
z=-2
if x %2 == 0:
    for i in range(x):
        if i % 2 == 0:
            z +=4
        else:
            z +=2
    if z == y :
            print("Yes")
    elif z!=y :
            print("No")
elif x%2 != 0
    for i in range(x):
        if i % 2 == 0:
            z +=4
        else:
            z +=2
    if z == y or z == (y-2):
            print("Yes")
    elif z!=y :
            print("No")

### FIXED CODE ###

x1,x2,x3,x4,x5,=map(int,input().split())
if 0 == x1:
    print("1")
elif 0 == x2:
    print("2")
elif 0 ==x3:
    print("3")
elif 0 == x4:
    print("4")
else:
    print("5")
a,v =map(int, input().split())
b,w =map(int, input().split())
t=int(input())
if a == b:
    print("YES")
    c+=1
if a*b<0:
    d = a+b
else:
    d = a-b
if d < 0:
    d = -d
if v > w:
    d2 = v-w
else:
    d2 = w-v
if  (v > w) and (d2*t < d) and c==0:
    print("NO")
elif v <= w and c==0:
    print("NO")
elif c==0:
    print("YES")

### FIXED CODE ###

a,v =map(int, input().split())
b,w =map(int, input().split())
t=int(input())

if a*b<0:
    if a > 0:
        d = a-b
    else:
        d = b-a
else:
    d = a-b
if d < 0:
    d = -d
if v > w:
    d2 = v-w
else:
    d2 = w-v
if  (v > w) and (d2*t < d):
    print("NO")
elif v <= w:
    print("NO")
else:
    print("YES")
import math

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

n = math.gcd(a,b)
m = n
x = 2
ans = 1

while m!=1:
    if m%x !=0:
        if x==2:
            x += 1
        else:
            x += 2
        continue
    ans += 1
    while m%x == 0:
        m /= x
    if x==2:
        x += 1
    else:
        x += 2

print(ans)
    


### FIXED CODE ###

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

def gcd(a,b):
    if a>b:
        a,b = b,a
    if b%a == 0:
        return a
    return gcd(a,b%a)

n = gcd(a,b)
m = n
ans = 1

if m%2==0:
    ans += 1
    while m%2==0:
        m //= 2
f = 3

while f*f <= n:
    if m%f==0:
        ans += 1
        while m%f==0:
            m //= f
    f+=2

if m!=1:
    ans += 1

print(ans)
a,b = map(int, input())
if a%3 and b%3 and (a+b)%3:
  print("Impossible")
else:
  print("Possible")

### FIXED CODE ###

a,b = map(int, input().split())
if a%3 and b%3 and (a+b)%3:
  print("Impossible")
else:
  print("Possible")
def solve_knapsack(profits, weights, capacity):
    # basic checks
    n = len(profits)

    dp = [[0 for x in range(capacity+1)] for y in range(n)]
    # populate the capacity = 0 columns, with '0' capacity we have '0' profit
    for i in range(0, n):
        dp[i][0] = 0
    for c in range(0, capacity+1):
        if weights[0] <= c: dp[0][c] = profits[0]
    for i in range(1, n):
        for c in range(1, capacity+1):
            if weights[i] <= c:
                dp[i][c] = max(profits[i] + dp[i - 1][c - weights[i]], dp[i - 1][c])
            else: dp[i][c]  = dp[i - 1][c]

    # maximum profit will be at the bottom-right corner.
    return dp[n - 1][capacity]
  
def main():

    for i in range(N):
        weights[i],profits[i] = map(int,input().split())
    res = solve_knapsack(profits, weights, capacity)
 
    print(res)
if __name__ == "__main__":
	main()

### FIXED CODE ###

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

INF = 10 ** 20

dp = [INF]*(n)
dp[0] = 0
dp[1] = abs(h[1]-h[0])
 
for i in range(2,n):
    dp[i] = min(dp[i-1]+abs(h[i]-h[i-1]), dp[i-2]+abs(h[i]-h[i-2]))
 
print(dp[n-1])
a = int(input())
b = int(input())
c = int(input())
d = int(input())

if (a > b and b > c) or (a < b and b < c):
    if abs(a - b) <= d and abs(b - c) <= d:
        print('Yes')
elif abs(a - c) <= d:
    print('Yes')
else:
    print('No')

### FIXED CODE ###

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

if abs(a - c) <= d:
    print('Yes')
elif (a < b and b < c) or (a > b and b > c):
    if abs(a - b) <= d and abs(b - c) <= d:
        print('Yes')
    else:
        print('No')
else:
    print('No')
class UnionFind():
	def __init__(self, size):
		self.table = [-1 for _ in range(size)]

	def find(self, x):
		while self.table[x] >= 0:
			x = self.table[x]
		return x

	def union(self, x, y):
		s1 = self.find(x)
		s2 = self.find(y)
		if s1 == s2:
			return
		elif:
			if self.table[s1] > self.table[s2]:
				self.table[s2] = s1
			elif self.table[s1] < self.table[s2]:
				self.table[s1] = s2
			else:
				self.table[s1] = s2
				self.table[s2] -= 1


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

uf = UnionFind(n)

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

ans = 0
for i, pp in enumerate(p):
	if pp - 1 == i:
		ans += 1
	elif uf.find(pp - 1) == uf.find(i):
		ans += 1

print(ans)

### FIXED CODE ###

class UnionFind():
	def __init__(self, size):
		self.table = [-1 for _ in range(size)]

	def find(self, x):
		if self.table[x] < 0:
			return x
		else:
			self.table[x] = self.find(self.table[x]) #xをxの根に直接つなぐ
			return self.table[x]

	def union(self, x, y):
		s1 = self.find(x)
		s2 = self.find(y)
		if s1 == s2:
			return
		else:
			st1 = self.table[s1]
			st2 = self.table[s2]
			if st1 > st2:
				self.table[s2] = s1
			elif st1 < st2:
				self.table[s1] = s2
			else:
				self.table[s1] = s2
				self.table[s2] -= 1


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

uf = UnionFind(n)

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

ans = 0
for i, pp in enumerate(p):
	if pp - 1 == i:
		ans += 1
	elif uf.find(pp - 1) == uf.find(i):
		ans += 1

print(ans)
import sys
input = sys.stdin.readline
n,ma,mb=map(int,input().split())
dp=[[[float("inf")]*500 for _ in range(500)] for i in range(n+1)]
dp[0][0][0]=0
for i in range(n):
    a,b,c=map(int,input().split())
    for j in range(450):
        dp[i+1][j][k]=min(dp[i+1][j][k],dp[i][j][k])
        for k in range(450):
            dp[i+1][j+a][k+b]=min(dp[i+1][j+a][k+b],dp[i][j][k]+c)
ans=float("inf")
i=1
#print(dp[-1])
while i*ma<450 and i*mb<450:
    ans=min(ans,dp[-1][ma*i][mb*i])
    i+=1
print(ans if ans!=float("inf") else -1)


### FIXED CODE ###

import sys
input = sys.stdin.readline
n,ma,mb=map(int,input().split())
dp=[[[float("inf")]*500 for _ in range(500)] for i in range(n+1)]
dp[0][0][0]=0
for i in range(n):
    a,b,c=map(int,input().split())
    for j in range(450):
        for k in range(450):
            dp[i+1][j][k]=min(dp[i+1][j][k],dp[i][j][k])
            dp[i+1][j+a][k+b]=min(dp[i+1][j+a][k+b],dp[i][j][k]+c)
ans=float("inf")
i=1
#print(dp[-1])
while i*ma<450 and i*mb<450:
    ans=min(ans,dp[-1][ma*i][mb*i])
    i+=1
print(ans if ans!=float("inf") else -1)