Harryxun/sft_time huggingface dataset:
### BUGGY CODE ###

x,y,a,b,c = map(int, input().split())
p = list(map(int, input().split()))
q = list(map(int, input().split()))
r = list(map(int, input().split()))

p.sort()
q.sort()
r.sort()
p.reverse()
q.reverse()
r.reverse()

ret = 0
z = 0
while(x + y > z):
    pattern = 0
    apple = 0
    if x > 0 and len(p) > 0:
        apple = p[0]
        pattern = 1
    if y > 0 and len(q) > 0:
        if apple < q[0]:
            apple = q[0]
            pattern = 2
    if len(r) > 0 and apple < r[0]:
        apple = r[0]
        pattern = 3
    ret += apple
    if pattern == 1:
        x -= 1
        p.pop(0)
    elif pattern == 2:
        y -= 1
        q.pop(0)
    elif pattern == 3:
        z += 1
        r.pop(0)

print(ret)


### FIXED CODE ###

x,y,a,b,c = map(int, input().split())
p = list(map(int, input().split()))
q = list(map(int, input().split()))
r = list(map(int, input().split()))

p.sort()
q.sort()
r.sort()
p.reverse()
q.reverse()
r.reverse()

ret = 0
z = 0

pidx=0
qidx=0
ridx=0

plen=len(p)
qlen=len(q)
rlen=len(r)
while(x + y > z):
    pattern = 0
    apple = 0
    if x > 0 and pidx < plen:
        apple = p[pidx]
        pattern = 1
    if y > 0 and qidx < qlen:
        if apple < q[qidx]:
            apple = q[qidx]
            pattern = 2
    if ridx < rlen and apple < r[ridx]:
        apple = r[ridx]
        pattern = 3
    ret += apple
    if pattern == 1:
        x -= 1
        pidx += 1
    elif pattern == 2:
        y -= 1
        qidx  += 1
    elif pattern == 3:
        z += 1
        ridx += 1

print(ret)
### BUGGY CODE ###

import math

N = int(input())
list = input().split(" ")

for k in range(N):
    change = 0
    now = 0
    for i in range(N):
        if k != i:
            if now < int(list[i]):
                change += int(list[i])-now
                now = int(list[i])
            else:
                change += now-int(list[i])
                now = int(list[i])



    change += math.fabs(now)
    change = int(change)
    print(change)


### FIXED CODE ###

import math

N = int(input())
list = input().split(" ")
list.insert(0,"0")
list.append("0")

change = 0
now = 0
for i in range(N+1):
    if now < int(list[i]):
        change += int(list[i])-now
        now = int(list[i])
    else:
        change += now-int(list[i])
        now = int(list[i])
change += math.fabs(now)
change = int(change)

for i in range(1,N+1):
   ans = change - math.fabs(int(list[i])-int(list[i-1]))
   ans = ans - math.fabs(int(list[i+1])-int(list[i]))
   ans = ans + math.fabs(int(list[i+1])-int(list[i-1]))
   ans = int(ans)
   print(ans)
### BUGGY CODE ###

import sys

sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline
f_inf = float('inf')
mod = 10 ** 9 + 7


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

    CW = [[0] * W for _ in range(H)]
    for h in range(H):
        cnt = 0
        for w in range(W):
            if S[h][w] == "#":
                cnt = 0
            else:
                cnt += 1
                CW[h][w] = cnt
        cnt = 0
        for w in reversed(range(W)):
            if S[h][w] == ".":
                cnt = max(cnt, CW[h][w])
                CW[h][w] = cnt
            else:
                cnt = 0

    CH = [[0] * W for _ in range(H)]
    for w in range(W):
        cnt = 0
        for h in range(H):
            if S[h][w] == "#":
                cnt = 0
            else:
                cnt += 1
                CH[h][w] = cnt
        cnt = 0
        for h in reversed(range(H)):
            if S[h][w] == ".":
                cnt = max(cnt, CH[h][w])
                CH[h][w] = cnt
            else:
                cnt = 0

    res = 0
    for h in range(H):
        for w in range(W):
            C = CW[h][w] + CH[h][w] - 1
            res = max(res, C)
    print(res)


if __name__ == '__main__':
    resolve()


### FIXED CODE ###

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

X = [[0] * W for _ in range(H)]
for i in range(H):
    start = 0
    cnt = 0
    for j in range(W):
        if s[i][j] == "." and j == W - 1:
            cnt += 1
            for k in range(start, W):
                if s[i][k] == ".":
                    X[i][k] = cnt
        elif s[i][j] == ".":
            cnt += 1
        elif s[i][j] == "#":
            for k in range(start, j):
                if s[i][k] == ".":
                    X[i][k] = cnt
            start = j
            cnt = 0

Y = [[0] * W for _ in range(H)]
for i in range(W):
    start = 0
    cnt = 0
    for j in range(H):
        if s[j][i] == "." and j == H - 1:
            cnt += 1
            for k in range(start, H):
                if s[k][i] == ".":
                    Y[k][i] = cnt
        elif s[j][i] == ".":
            cnt += 1
        elif s[j][i] == "#":
            for k in range(start, j):
                if s[k][i] == ".":
                    Y[k][i] = cnt
            start = j
            cnt = 0

XY = []
for i in range(H):
    for j in range(W):
        XY.append(X[i][j] + Y[i][j] - 1)

print(max(XY))
### BUGGY CODE ###

import sys
n = int(input())
a_ls = [int(i) for i in sys.stdin.readline().split()]
start = 0
end = 1
a_ls = [bin(i)[2:].zfill(20) for i in a_ls] + ["2" * 20]
dic = {i : 0 if j == "0" else 1 for i,j in enumerate(a_ls[0])}
cnt = 0
while start < n and end <= n:
    flg = True
    a = a_ls[end]
    #print()
    for i, j in enumerate(a):
        dic[i] += int(j)
        if dic[i] > 1:
            flg = False
    if flg:
        end += 1
    else:
        cnt += (end - start - 1)
        for i, j in enumerate(a_ls[start]):
            dic[i] -= int(j)
        start += 1
        if end == start:
            end += 1
        else:
            for i, j in enumerate(a):
                dic[i] -= int(j)
print(cnt + n)

### FIXED CODE ###

import sys
n = int(input())
a_ls = [int(i) for i in sys.stdin.readline().split()]
start = 0
end = 1
a_ls = [bin(i)[2:].zfill(20) for i in a_ls] + ["2" * 20]
dic = {i : 0 if j == "0" else 1 for i,j in enumerate(a_ls[0])}
cnt = 0
while start < n and end <= n:
    flg = True
    a = a_ls[end]
    for i, j in enumerate(a):
        if dic[i] + int(j) > 1:
            flg = False
    if flg:
        for i, j in enumerate(a):
            dic[i] += int(j)
        end += 1
    else:
        cnt += (end - start - 1)
        for i, j in enumerate(a_ls[start]):
            dic[i] -= int(j)
        start += 1
        if end == start:
            for i, j in enumerate(a):
                dic[i] += int(j)
            end += 1
print(cnt + n)
### BUGGY CODE ###

n, m  = map(int, input().split())
nums  = list(map(int, input().split()))
nums = sorted(nums, reverse=True)

length = len(nums)

for i in range(m):
    b, c = map(int, input().split())
    
    if c > min(nums):
        nums.remove(min(nums))
        nums.extend([c] * b)
    
nums = sorted(nums, reverse=True)
print(sum(nums[:length]))

### FIXED CODE ###

import numpy as np

n, m  = map(int, input().split())
nums  = list(map(int, input().split()))
length = len(nums)

arr = np.array([list(map(int, input().split())) for i in range(m)])
mask = arr.T[1].argsort()[::-1]
arr = arr[mask]

cnt = 0
for b, c in arr:
    nums.extend([int(c)]*b)
    cnt += b
    if cnt > length:
        break

nums = list(nums)
nums.sort(reverse=True)

print(sum(nums[:length]))
### BUGGY CODE ###

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

if sum(A) < sum(B):
    print(-1)
else:
    before = [A[i] - B[i] for i in range(N)]
    before.sort()
    diff = [A[i] - B[i] for i in range(N)]
    # print(diff)
    diff.sort()
    left = 0
    right = N - 1
    while not all([x >= 0 for x in diff]):
        if diff[left] < 0:
            temp = diff[left]
            diff[left] = min(0, diff[left] + diff[right])
            diff[right] -= diff[left] - temp
        if diff[left] == 0:
            if diff[left + 1] < 0:
                left += 1
        if diff[right] == 0:
            if diff[left] < 0:
                right -= 1
    # print(diff)
    cnt = 0
    for i in range(N):
        if before[i] != diff[i]:
            cnt += 1
    print(cnt)

### FIXED CODE ###

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

if sum(A) < sum(B):
    print(-1)
else:
    before = [A[i] - B[i] for i in range(N)]
    before.sort()
    diff = [A[i] - B[i] for i in range(N)]
    # print(diff)
    diff.sort()
    left = 0
    right = N - 1
    while True:
        if diff[left] < 0:
            temp = diff[left]
            diff[left] = min(0, diff[left] + diff[right])
            diff[right] -= diff[left] - temp
        if diff[left] == 0:
            if diff[left + 1] < 0:
                left += 1
        if diff[right] == 0:
            if diff[left] < 0:
                right -= 1
        if diff[left] == 0:
            break
    # print(diff)
    cnt = 0
    for i in range(N):
        if before[i] != diff[i]:
            cnt += 1
    print(cnt)
### BUGGY CODE ###

N = int(input())

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

P = [0] + P
     
count = 0
min = 10000000000000
for i in range(1, N+1):
    if min > P[i]:
        min = P[i]
    elif min < P[i]:
        continue

    for j in range(1, i+1):
        #print(i, P[i], j , P[j])
        if P[i] > P[j]:
            #print("out", i)
            break
    else:
        #print("ok", i)
        count += 1
        
    if P[i] == 1:
        break

print(count)

### FIXED CODE ###

N = int(input())

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

P = [0] + P
     
count = 0
min = 10000000000000
for i in range(1, N+1):
    if min > P[i]:
        min = P[i]
    elif min < P[i]:
        continue
    """
    for j in range(1, i+1):
        #print(i, P[i], j , P[j])
        if P[i] > P[j]:
            #print("out", i)
            break
    else:
        #print("ok", i)
        count += 1
    """
    count += 1
        
    if P[i] == 1:
        break

print(count)
### BUGGY CODE ###

def main(n,ab,px):
  import sys
  sys.setrecursionlimit(10**7)
  g=[[]for _ in range(n)]
  for a,b in ab:
    g[a-1].append(b-1)
    g[b-1].append(a-1)
  ans=[0 for _ in range(n)]
  for p,x in px:
    ans[p-1]+=x  
  def dfs(seen,i):
    seen[i]=1
    l=g[i]
    for li in [li for li in l if seen[li]==0]:
      ans[li]+=ans[i]
      dfs(seen,li)
  seen=[0 for _ in range(n)]
  dfs(seen,0)
  print(' '.join(list(map(str,ans))))

if __name__=='__main__':
  import sys
  input = sys.stdin.readline
  n,q=map(int,input().split())
  ab=[list(map(int,input().split())) for _ in range(n-1)]
  px=[list(map(int,input().split())) for _ in range(q)]
  main(n,ab,px)
  

### FIXED CODE ###

import sys
sys.setrecursionlimit(10 ** 9)
input = sys.stdin.readline
def main():
    n,q=map(int,input().split())
    graph=[[] for _ in range(n+1)]
    ab=[list(map(int,input().split())) for _ in range(n-1)]
    for a,b in ab:
        graph[a].append(b)
        graph[b].append(a)
    px=[list(map(int,input().split())) for _ in range(q)]
    seen=[0]*(n+1)
    ans=[0]*(n+1)
    for p,x in px:
        ans[p]+=x
    def dfs(i):
        seen[i]=1
        for li in graph[i]:
            if seen[li]==0:
                ans[li]+=ans[i]
                dfs(li)
    dfs(1)
    print(' '.join(map(str,ans[1:])))
if __name__ == '__main__':
    main()
### BUGGY CODE ###

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

result = 1
for i in range(len(A)):
    result *= A[i]

if result > 10**18:
    print(-1)
else:
    print(result)


### FIXED CODE ###

def main():
    N = int(input())
    A = list(map(int,input().split()))
    result = 1
    if 0 in A:
        print(0)
        return

    for i in A:
        result *= i
        if result > 10**18:
            print(-1)
            return
    print(result)

main()
### BUGGY CODE ###

x = int(input())
for i in range(4000):
  for j in range(-2000,4000):
    if i**5 - j**5 == x:
      print(i,j)
      break


### FIXED CODE ###

X = int(input())

AA = 0
BB = 0

for A in range(-121,121):
    for B in range(-121,121):
        if X == (A ** 5) - (B ** 5):
            AA = A
            BB = B

print(AA,BB)
### BUGGY CODE ###

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

hop_before = []
hop_to = []

for i in range(M) :
    a, b = map(int, input().split())
    
    if a == 1 :
        hop_to.append(b)
    if b == N :
        hop_before.append(a)
        
contains = False
for i in sorted(hop_to) :
    for j in sorted(hop_before) :
        if j > i : continue
        if i == j :
            contains = True
            break

if contains == True :
    print("POSSIBLE")
else :
    print("IMPOSSIBLE")

### FIXED CODE ###

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

hop_before = []
hop_to = []

hop_dict = {}

for i in range(M) :
    a, b = map(int, input().split())
    
    if a == 1 :
        if b in hop_dict.keys() :
            hop_dict[b] += 1
        else :
            hop_dict[b] = 1
    if b == N :
        if a in hop_dict.keys() :
            hop_dict[a] += 1
        else :
            hop_dict[a] = 1
        
possible = False
for i in hop_dict.keys() :
    if hop_dict[i] >= 2 :
        print("POSSIBLE")
        possible = True
        break
        
if possible == False :
    print("IMPOSSIBLE")
### BUGGY CODE ###

from functools import reduce, lru_cache


@lru_cache(maxsize=2**22)
def GCD(x, y):
    if y == 0:
        return x
    else:
        return GCD(y, x % y)


def lcm(x, y):
    return (x * y) // GCD(x, y)


def solve():
    MOD = 10 ** 9 + 7
    N, *A = map(int, open(0).read().split())
    
    lcm_num = reduce(lcm, A)
    ans = 0
    for a in A:
        ans += lcm_num // a
        ans %= MOD
    print(ans)


if __name__ == '__main__':
    solve()


### FIXED CODE ###

from fractions import gcd


def solve():
    N, *A = map(int, open(0).read().split())
    MOD = 10 ** 9 + 7

    lcm = 1
    for a in A:
        lcm = a * lcm // gcd(a, lcm)

    ans = [lcm // a for a in A]
    print(sum(ans) % MOD)


if __name__ == '__main__':
    solve()
### BUGGY CODE ###

import bisect
n=int(input())
A=list(map(int,input().split()))
S=[A[0]]
for i in range(n-1):
  S.append(S[-1]+A[i+1])
ans=10**15
for i in range(2,n-1):
  A1=A[0:i]
  A2=A[i:n]
  if len(A1)==2:
    M1=max(A1)
    m1=min(A1)
  else:
    x=bisect.bisect_left(S,S[i-1]//2,lo=0,hi=i+1)
    M11=max(S[x-1],S[i-1]-S[x-1])
    m11=min(S[x-1],S[i-1]-S[x-1])
    M12=max(S[x],S[i-1]-S[x])
    m12=min(S[x],S[i-1]-S[x])
    M1=min(M11,M12)
    m1=max(m11,m12)
  if len(A2)==2:
    M2=max(A2)
    m2=min(A2)
  else:
    x=bisect.bisect_left(S,S[i-1]+(S[-1]-S[i-1])//2,lo=0,hi=len(S))
    M21=max(S[x-1]-S[i-1],S[-1]-S[x-1])
    m21=min(S[x-1]-S[i-1],S[-1]-S[x-1])
    M22=max(S[x]-S[i-1],S[-1]-S[x])
    m22=min(S[x]-S[i-1],S[-1]-S[x])
    M2=min(M21,M22)
    m2=max(m21,m22)
  a=max(M1,M2)-min(m1,m2)
  if a<ans:
    ans=a
print(ans)

### FIXED CODE ###

import bisect
from collections import deque
n=int(input())
A=list(map(int,input().split()))
S=[A[0]]
for i in range(n-1):
  S.append(S[-1]+A[i+1])
ans=10**15
A1=deque([A[0]])
A2=deque(A[1:n])
for i in range(2,n-1):
  A1.append(A[i-1])
  A2.popleft()
  if len(A1)==2:
    M1=max(A1)
    m1=min(A1)
  else:
    x=bisect.bisect_left(S,S[i-1]//2,lo=0,hi=i+1)
    M11=max(S[x-1],S[i-1]-S[x-1])
    m11=min(S[x-1],S[i-1]-S[x-1])
    M12=max(S[x],S[i-1]-S[x])
    m12=min(S[x],S[i-1]-S[x])
    M1=min(M11,M12)
    m1=max(m11,m12)
  if len(A2)==2:
    M2=max(A2)
    m2=min(A2)
  else:
    x=bisect.bisect_left(S,S[i-1]+(S[-1]-S[i-1])//2,lo=0,hi=n)
    M21=max(S[x-1]-S[i-1],S[-1]-S[x-1])
    m21=min(S[x-1]-S[i-1],S[-1]-S[x-1])
    M22=max(S[x]-S[i-1],S[-1]-S[x])
    m22=min(S[x]-S[i-1],S[-1]-S[x])
    M2=min(M21,M22)
    m2=max(m21,m22)
  a=max(M1,M2)-min(m1,m2)
  if a<ans:
    ans=a
print(ans)
### BUGGY CODE ###

mod = 10**9+7
n, m = map(int, input().split())
l = [int(input()) for _ in range(m)]

t2 = 1
t1 = 0 if 1 in l else 1

if n == 1:
  print(1)
else:
  for i in range(2,n+1):
    if l == [] or i != l[0]:
      t0 = 0 if i in l else (t2+t1)%mod
    else:
      l.pop(0)
      t0 = 0
    t2 = t1
    t1 = t0
  print(t0)

### FIXED CODE ###

mod = 10**9+7
n, m = map(int, input().split())
l = [int(input()) for _ in range(m)]

t2 = 0
t1 = 1

for i in range(1,n+1):
  if l == [] or i != l[0]:
    t0 = (t2+t1)%mod
  else:
    l.pop(0)
    t0 = 0
  t2 = t1
  t1 = t0

print(t0)
### BUGGY CODE ###

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

inv = [i for i in range(N-1)]
visited = [1]

path = [[] for i in range(N)]

for i in range(M):
  A, B = map(int, input().split())
  path[A-1].append(B)
  path[B-1].append(A)
nows = [1]
for t in range(N):
  buf = []
  buf2 = []
  for now in nows:
    buf2 = buf2 + path[now-1]
  buf2 = set(buf2)
  buf3 = set(visited)
  buf2 = buf2 - buf3
  for p in buf2:
    buf.append(p)
    visited.append(p)
    inv[p-2]=now
  if len(buf2)==0:
    break
  nows = buf
print("Yes")
for i in inv:
  print(i)


### FIXED CODE ###

import queue

q = queue.Queue()
N, M = map(int, input().split())

ans = [-1 for i in range(N+1)]
path = [[] for i in range(N+1)]

for i in range(M):
  A, B = map(int, input().split())
  path[A].append(B)
  path[B].append(A)
q.put(1)
COUNTER = 0
while not q.empty() :
  now = q.get()
  for p in path[now]:
    if ans[p]==-1:
      ans[p]=now
      q.put(p)
      #print(COUNTER, now,p)
      COUNTER+=1
      
print("Yes")
for i in ans[2:]:
  print(i)
### BUGGY CODE ###

def search(l, n):
    left = 0
    right = len(l) - 1
    m = (left + right) // 2

    # while right - left > 1:
    while left < right:
        if n == l[m]:
            return True
        elif n < l[m]:
            right = m - 1
        elif n > l[m]:
            left = m
        else:
            raise Exception()

        m = (left + right) // 2


n = int(input())
s = [int(i) for i in input().split()]
q = int(input())
t = [int(i) for i in input().split()]

ans = 0
for ti in t:
    if search(s, ti):
        ans += 1

print(ans)



### FIXED CODE ###

def search(l, n):
    left = 0
    right = len(l) - 1
    while right - left > 1:
        m = (left + right) // 2
        if n == l[m]:
            return True
        elif n < l[m]:
            right = m
        else:
            left = m

    # print(left, right)
    if l[left] == n or l[right] == n:
        return True
    else:
        return False


n = int(input())
s = [int(i) for i in input().split()]
q = int(input())
t = [int(i) for i in input().split()]

ans = 0
for ti in t:
    if search(s, ti):
        ans += 1

print(ans)
### BUGGY CODE ###

from collections import deque
H, W = map(int, input().split())  # 迷路の縦、横の長さ
maze = []
for _ in range(H):
    maze.append(input())
# print(maze)
dist = [[-1] * W for iii in range(H)]  # スタートからの距離
check_que = deque()

for i in range(H):
    for j in range(W):
        if maze[i][j] == "#":
            dist[i][j] = 0
            check_que.append((i, j))
# print(dist)


def bfs(initial_d):  # distを編集する関数
    #print("{},{}".format(tate, yoko))
    while check_que:

        h, w = check_que.popleft()
        d = dist[h][w]
        for dh, dw in ((0, 1), (0, -1), (1, 0), (-1, 0)):
            h_prime, w_prime = h + dh, w + dw

            if 0 > h_prime or h_prime >= H or 0 > w_prime or w_prime >= W:
                continue
            if dist[h_prime][w_prime] == -1:
                dist[h_prime][w_prime] = d + 1
                check_que.append((h_prime, w_prime))

    return d


dis = bfs(0)
# print(dist)
print(dis)


### FIXED CODE ###

from collections import deque
H, W = map(int, input().split())  # 迷路の縦、横の長さ
maze = []
for _ in range(H):
    maze.append(input())
# print(maze)
dist = [[-1] * W for iii in range(H)]  # スタートからの距離
check_que = deque()

d = 0

for i in range(H):
    for j in range(W):
        if maze[i][j] == "#":
            dist[i][j] = 0
            check_que.append((i, j))
# print(dist)


def bfs(initial_d):  # distを編集する関数
    dis = 0
    #print("{},{}".format(tate, yoko))
    while len(check_que) != 0:

        h, w = check_que.popleft()
        d = dist[h][w]
        for dh, dw in ((0, 1), (0, -1), (1, 0), (-1, 0)):
            h_prime, w_prime = h + dh, w + dw

            if 0 <= h_prime <= H - 1 and 0 <= w_prime <= W - 1:
                if dist[h_prime][w_prime] == -1:
                    dist[h_prime][w_prime] = d + 1
                    check_que.append((h_prime, w_prime))
                    if d + 1 > dis:
                        dis = d+1
    return dis


dis = bfs(0)
# print(dist)
print(dis)
### BUGGY CODE ###

n=int(input())
l=input().split()
q=[]
for i in l:
  if i not in q:q.append(i)

if len(l)!=len(q):
  print('NO')
else:
  print('YES')


### FIXED CODE ###

n=int(input())
l=input().split()
l.sort()
flag=1
for i in range(n-1):
  if l[i]==l[i+1]:flag=0
if flag==1:print("YES")
else:print("NO")
### BUGGY CODE ###

NK = list(map(int, input().split()))
Hi = list(map(int, input().split()))

N = NK[0]
K = NK[1]
Hi.sort()
reversed_Hi = list(reversed(Hi))

for i in range(K):
    if not reversed_Hi:
        break

    if K == 0:
        break
    else:
        K -= 1
        reversed_Hi.pop(0)

count = 0
for i in reversed_Hi:
    count += i

print(count)

### FIXED CODE ###

NK = list(map(int, input().split()))
Hi = list(map(int, input().split()))

N = NK[0]
K = NK[1]
Hi.sort()
reversed_Hi = list(reversed(Hi))

for i in range(len(reversed_Hi)):
    if not reversed_Hi:
        break

    if K == 0:
        break
    else:
        K -= 1
        reversed_Hi[i] = 0

count = 0
for i in reversed_Hi:
    count += i

print(count)
### BUGGY CODE ###

n, m = map(int, input().split())
h = list(map(int, input().split()))
# graph作成
graph = {i: [] for i in range(1, n + 1)}
for _ in range(m):
    u, v = map(int, input().split())
    graph[u].append(v)
    graph[v].append(u)

import queue
ans = []
voi = []
def bfs(v):
    q = queue.Queue()
    depth = 0
    q.put([v,depth])
    voi[v] = True
    while not q.empty():
        if depth > 1:
            break
        sub = q.get()
        now = sub[0]
        depth = sub[1]
        for next in graph[now]:
            if voi[next]:
                continue
            voi[next] = True
            q.put([next, depth + 1])
            if depth+1 < 2:
                ss.append(h[next - 1])

ans = 0
for i in range(1, n + 1):
    voi = [False] * (n + 1)
    ss = []
    bfs(i)
    if len(ss) != 0:
        a = max(ss)
        if h[i - 1] > a:
            ans += 1
    else:
        ans += 1

print(ans)

### FIXED CODE ###

n, m = map(int, input().split())
h = list(map(int, input().split()))
k = [list(map(int, list(input().split()))) for i in range(m)]

d = [0] * n
for i in range(m):
    d[k[i][0] - 1] = max(d[k[i][0] - 1], h[k[i][1] - 1])
    d[k[i][1] - 1] = max(d[k[i][1] - 1], h[k[i][0] - 1])
    
ans = 0
for i in range(n):
    if h[i] > d[i]:
        ans += 1

print(ans)
### BUGGY CODE ###

import math
a, b, n = map(int, input().split())

max_num = 0

x_list = [i for i in range(1, n + 1)]
for x in x_list:
    num = math.floor(a * x / b) - (a * math.floor(x / b))
    if max_num < num:
        max_num = num

print(max_num)

### FIXED CODE ###

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

x = min(b - 1, n)

max_num = (a * x) // b - a * (x // b)
print(max_num)