Harryxun/stf_run huggingface dataset:
from operator import itemgetter

N = int(input())


A = []
for i in range(N - 1):
    A.append([int(i) for i in input().split()])

B = []
for row in A:
    B.append(sorted(row))
B.sort(key = itemgetter(0))

link_list = [[] for i in range(N)]
for row in B:
    link_list[row[0] - 1].append(row[1] - 1)
edge_color = dict()

def DFS_color(node, pre_color):
    target_list = link_list[node]
    color = 1
    if target_list == []:
        pass
    else:
        for ko_node in target_list:
            if pre_color == color:
                color += 1
            edge_color[node, ko_node] = color 
            DFS_color(ko_node, color)
            color += 1

DFS_color(0, 0)

print(max(edge_color.values()))
for node1, node2 in A:
    print(edge_color[node1 - 1, node2 - 1])

### FIXED CODE ###

from operator import itemgetter
import sys
sys.setrecursionlimit(10**7)

N = int(input())


A = []
for i in range(N - 1):
    A.append([int(i)-1 for i in input().split()])

B = []
for row in A:
    B.append(sorted(row))
B.sort(key = itemgetter(0))

link_list = [[] for i in range(N)]
for row in B:
    link_list[row[0]].append(row[1])
    link_list[row[1]].append(row[0])
edge_color = dict()
marker = [0] * N


def DFS_color(node, pre_color):
    target_list = link_list[node]
    color = 1
    for ko_node in target_list:
        if marker[ko_node] == 0:
            if pre_color == color:
                color += 1
            edge_color[node, ko_node] = color
            edge_color[ko_node, node] = color 
            marker[ko_node] = 1
            DFS_color(ko_node, color)
            color += 1
        else:
            pass

marker[0] = 1
DFS_color(0, 0)

print(max(edge_color.values()))
for node1, node2 in A:
    print(edge_color[node1, node2])
a=input()
list=[a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z]
if list(a)=False:
  print("A")
else:
  print("a")

### FIXED CODE ###

a = input()
print('a' if a.islower() else 'A')
import math
a, b = map(int, input().split())
n = math.gcd(a, b)
k = int(n**0.5)
cnt = 1
for i in range(2, k + 1):
    if n == 1:
        break
    elif n % i == 0:
        while n % i == 0:
            n //= i
        cnt += 1
if n != 1:
    cnt += 1
print(cnt)


### FIXED CODE ###

import fractions
a, b = map(int, input().split())
n = fractions.gcd(a, b)
k = int(n**0.5)
cnt = 1
for i in range(2, k + 1):
    if n == 1:
        break
    elif n % i == 0:
        while n % i == 0:
            n //= i
        cnt += 1
if n != 1:
    cnt += 1
print(cnt)
h,w=map(int,input().split())

s=[input() for i in range(h)]

print(s[0][3])
print(s)

def ok(i,j,houkou, count):
    if i==h or j==w:
        return count
    elif s[i][j]=='#':
        return count
    elif houkou=='yoko':
        return ok(i,j+1,houkou,count+1)
    else:
        return ok(i+1,j,houkou,count+1)

yoko=[[0 for i in range(w)] for j in range(h)]
tate=[[0 for i in range(w)] for j in range(h)]

# print(yoko)
for i in range(h):
    for j in range(w):
        if s[i][j]=='.' and yoko[i][j]==0:
            count=ok(i,j,'yoko',0)
            for k in range(count):
                yoko[i][j+k]=count


for i in range(h):
    for j in range(w):
        if s[i][j]=='.' and tate[i][j]==0:
            count=ok(i,j,'tate',0)
            for k in range(count):
                tate[i+k][j]=count


ans=0
for i in range(h):
    for j in range(w):
        if ans<yoko[i][j]+tate[i][j]-1:
            ans=yoko[i][j]+tate[i][j]-1
print(ans)

### FIXED CODE ###

h,w=map(int,input().split())

s=[input() for i in range(h)]

yoko=[[0 for i in range(w)] for j in range(h)]
tate=[[0 for i in range(w)] for j in range(h)]

count=0
for i in range(h):
    for j in range(w):
        if s[i][j]=='.':
            count+=1
        if s[i][j]=='#' or j+1==w:
            for k in range(count):
                yoko[i][j-k-1]=count
            count=0

# print(yoko)


for j in range(w):
    for i in range(h):
        if s[i][j]=='.':
            count+=1
        if s[i][j]=='#' or i+1==h:
            for k in range(count):
                tate[i-k-1][j]=count
            count=0

# print(tate)

ans=0
for i in range(h):
    for j in range(w):
        if ans<yoko[i][j]+tate[i][j]-1:
            ans=yoko[i][j]+tate[i][j]-1
print(ans)
N,K,Q = map(int,input().split())
K=K-Q
 
a=[]
for i in range(Q):
  a.append(int(input()))
cnt=[K-Q]*N
for i in range(1,N+1):
  cnt[i-1] += a.count(i)
  if cnt[i] > 0:
    print("Yes")
  else:
    print("No")

### FIXED CODE ###

# coding: utf-8
# Your code here!

N, K, Q = map(int,input().split())
L = [0]*N
for i in range(Q):
    a = int(input())
    L[a-1] += 1

for i in range(N):
    if Q - L[i] < K:
        print('Yes')
    else:
        print('No')
import numpy as np 

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

pt= [[0]*0 for i in range(n)] 
for i in range(n-1):
    pt[S[i][0]-1].append(S[i][1])
    pt[S[i][1]-1].append(S[i][0])

def bfs(v):
    d=[-1]*n
    d[v-1]=0
    q=[v]
    c=1
    while q:
        q1=[]
        for i in q:
            for j in pt[i-1]:
                if d[j-1]==-1:
                    d[j-1]=c
                    q1.append(j)
        q=q1
        c+=1
        #print(d,q)
    return d
bfs_v=np.array(bfs(v))
bfs_u=np.array(bfs(u))
bfs_v_replace=bfs_v[bfs_v>bfs_u]
answer=np.max(bfs_v_replace)-1
print("{}".format(answer))

### FIXED CODE ###

a = int(input())
b = int(input())

print("{}".format(6-a-b))
import sys
sys.setrecursionlimit(1000)
n=int(input())
v=sorted(list(map(float,input().split())))
x=-1
y=-1
z=10000.0
while True:
    for i in range(n-1):
        if v[i+1]-v[i] < z:
            x=i+1
            y=i
            z=v[i+1]-v[i]
    v[y]=(v[x]+v[y])/2
    del(v[x])
    v=sorted(v)
    n=len(v)
    if n==1:
        print(v[0])
        break

### FIXED CODE ###

n=int(input())
v=sorted(list(map(float,input().split())))
z = v[0]
for i in range(1,n):
    z=(z+v[i])/2
print(z)
import math
import itertools
n,*x=map(int,open(0).read().split())
x.sort()
a=[i-j for i,j in zip(x[1:],x[:-1])]
set(a)
a.sort()
b=[i for i in a if i%a[0]]
b.append(a[0])
if len(b)==1:
    print(*b)
else:
    ans=b[0]
    for i,j in itertools.combinations(b, 2):
        ans=min(ans,gcd(i,j))
    print(ans)    

### FIXED CODE ###

import fractions
n,*x=map(int,open(0).read().split())
x.sort()
a=[i-j for i,j in zip(x[1:],x[:-1])]
set(a)
a.sort()
b=[i for i in a if i%a[0]]
b.append(a[0])
if len(b)==1:
    print(*b)
else:
    ans=b[0]
    for i in b[1:]:
        ans=fractions.gcd(ans,i)
    print(ans)
N = int(input())
list = [int(input()) for i in range(N)]
if sorted(list)[-1] == sorted(list)[-2]:
    list2 = [max(list)]*range(N)
    print("\n".join(map(str,list2)))
else:
    list2 = [max(list)]*list.index(max(list))
    list2.append(sorted(list)[-2])
    list3 = [max(list)]*(N-list.index(max(list))-1)
    list2.extend(list3)
    print("\n".join(map(str,list2)))

### FIXED CODE ###

N = int(input())
list = [int(input()) for i in range(N)]
if sorted(list)[-1] == sorted(list)[-2]:
    list2 = [max(list)]*N
    print("\n".join(map(str,list2)))
else:
    list2 = [max(list)]*list.index(max(list))
    list2.append(sorted(list)[-2])
    list3 = [max(list)]*(N-list.index(max(list))-1)
    list2.extend(list3)
    print("\n".join(map(str,list2)))
from sys import stdin
N = int(stdin.readline().rstrip())
K = int(stdin.readline().rstrip())
X = [int(_) for _ in stdin.readline().rstrip().split()]
ans = 0
for i in x:
    if i < K - i:
        ans += 2 * i
    else:
        ans += 2 * (K - i)
print(route)

### FIXED CODE ###

from sys import stdin
n = int(stdin.readline().rstrip())
a = int(stdin.readline().rstrip())
print(n*n-a)
import fractions

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

A = ABCD[0]
B = ABCD[1]
C = ABCD[2]
D = ABCD[3]


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


firstC = int((A-1)/C)
firstD = int((A-1)/D)
firstCD = int((A-1)/lcm(C,D))

# if A%lcm(C,D) ==0 and firstCD > 0:
#     firstCD -= 1

endC = int(B/C)
endD = int(B/D)
endCD = int(B/lcm(C,D))

End = B-endC-firstD + endCD
First = (A-1) - firstC - firstD + firstCD



thereC = endC - firstC
thereD = endD - firstD
thereCD = endCD - firstCD

NoP = thereC+thereD - thereCD

# print(thereC)
# print(thereD)
# print(thereCD)
# print(NoP)
print((B-A+1)-NoP)
# print(End-First)









### FIXED CODE ###


S = input()

word = "p"
Judge = True

for i in range(len(S)):
    if word == S[i]:
        Judge = False
        break

    word = S[i]

if Judge:
    print("Good")
else:
    print("Bad")
N = input()
V = list(map(int,input().split()))
C = list(map(int,input().split()))
for i in range(N):
    tmp = V[i]-C[i]
    if tmp > 0:
        ans += tmp
print(ans)




### FIXED CODE ###

N = int(input())
V = list(map(int,input().split()))
C = list(map(int,input().split()))
ans = 0
for i in range(N):
    tmp = V[i]-C[i]
#     print(tmp)
    if tmp > 0:
        ans += tmp
#     print(ans)
print(ans)
import itertools
n,m=map(int,input().split())
path=[[False]*n for i in range(n)]
for i in range(m):
    a,b=map(int,input().split())
    a-=1
    b-=1
    path[a][b]=True
    path[b][a]=True
ans=0;

for i in itertools.permutations(range(n),n):
    if i[0]==0:
        for j in range(n):
            if j==n-1:
                ans+=1
                break
            if not path[i[j]][i[j]+1]:
                break
print(ans)

### FIXED CODE ###

import itertools
n,m=map(int,input().split())
path=[[False]*n for i in range(n)]
for i in range(m):
    a,b=map(int,input().split())
    a-=1
    b-=1
    path[a][b]=True
    path[b][a]=True
ans=0;

for i in itertools.permutations(range(n),n):
    if i[0]==0:
        for j in range(n):
            if j==n-1:
                ans+=1
                break
            if not path[i[j]][i[j+1]]:
                break
print(ans)
N,A,B = map(int,input().split())

min_num = min(A,B)
max_num = max(A,B)
if max_num >N : print(0)
else:
    matches = 0
    while(True):
        if max_num==min_num:
            print(matches)
            break
        else:
            if max_num - min_num == 1:
                max_num-=1
                min_num-=1 if min_num != 1else 0
                matches+=1
                max_arr.append(max_num)
                min_arr.append(min_num)
            else:
                min_num+=1 if min_num != 1 or max_num > 2 else 0
                max_num-=1
                matches+=1
                max_arr.append(max_num)
                min_arr.append(min_num)

### FIXED CODE ###

N,A,B = map(int,input().split())
ans = 0
if (B-A)%2 == 0:
    print(int((B-A)//2))
else:
    print(min(A-1,N-B)+1+int((B-A-1)//2))
from numba import jit
@jit
def resolve():
    from bisect import bisect_left
    n,k=map(int,input().split())
    a=sorted(list(map(int,input().split())))
    m=bisect_left(a,0)
    MOD=10**9+7
    if m==0 or m==n:
        ans=1
        for i in a[-k:]:
            ans=(ans*i)%MOD
    else:
        for i in range((m//2)*2,-2,-2):
            ans=0
            cal=1
            if k-i>n-m:
                break
            for j in a[:i]:
                cal=(cal*j)%MOD
            if k-i>0:
                for j in a[-(k-i):]:
                    cal=(cal*j)%MOD
            ans=max(ans,cal)
    print(ans)

if __name__ == '__main__':
    resolve()

### FIXED CODE ###

def resolve():
    from bisect import bisect_left
    n,k=map(int,input().split())
    a=sorted(list(map(int,input().split())))
    m=bisect_left(a,0)
    MOD=10**9+7
    ans=1
    if m==0 or (m==n and k%2==1):
        for i in a[-k:]:
            ans=(ans*i)%MOD
    elif m==n and k%2==0:
        for i in a[:k]:
            ans=(ans*i)%MOD
    else:
        ans=1
        l,r=0,-1
        lm=a[0]*a[1]
        rm=a[-1]*a[-2]
        for i in range(k//2):
            if lm>=rm:
                ans*=lm%MOD
                l+=2
                if l<=n-2:
                    lm=a[l]*a[l+1]
            else:
                ans*=rm%MOD
                r-=2
                if 1<=n+r:
                    rm=a[r]*a[r-1]
            ans%=MOD
        if k%2==1:
            ans*=a[r]
            ans%=MOD
    print(ans)

if __name__ == '__main__':
    resolve()
N = int(input())
X = input()
x = X[::-1]
one = X.count('1')
up = 0
down = 0
for i in range(N):
    up += (int(x[i]) * pow(2,i,one+1) % (one+1))
    up %= one+1
    if one > 1:
        down += (int(x[i]) * pow(2,i,one-1) % (one-1))
        down %= one-1
# print(up,down)
def f(ud,one):
    if one <= 0:
        return 0
    else:
        if ud == 0:
            return 1

        cnt = 0
        while ud != 0:
            ud = ud % one
            one = format(ud,'b').count('1')
            cnt += 1
        return cnt



for i in range(len(X)):
    if X[i] == '1':
        print(f((down - pow(2,(len(X)-1) - i, one-1)) % (one-1),one-1))
        #print(down - pow(2,(len(X)-1) - i, one-1) % (one-1))
    else:
        print(f((up + pow(2,(len(X)-1) - i, one+1)) % (one+1),one+1))
        #print(up + pow(2,(len(X)-1) - i, one+1) % (one+1))


### FIXED CODE ###

N = int(input())
X = input()
x = X[::-1]
one = X.count('1')
up = 0
down = 0
for i in range(N):
    up += (int(x[i]) * pow(2,i,one+1) % (one+1))
    up %= one+1
    if one > 1:
        down += (int(x[i]) * pow(2,i,one-1) % (one-1))
        down %= one-1
# print(up,down)
def f(ud,one):
    if one <= 0:
        return 0
    else:
        if ud == 0:
            return 1

        cnt = 0
        while ud != 0:
            ud = ud % one
            one = format(ud,'b').count('1')
            cnt += 1
        return cnt



for i in range(len(X)):
    if X[i] == '1':
        if one > 1:
            print(f((down - pow(2,(len(X)-1) - i, one-1)) % (one-1),one-1))
        #print(down - pow(2,(len(X)-1) - i, one-1) % (one-1))
        else:
            print(0)

    else:
        print(f((up + pow(2,(len(X)-1) - i, one+1)) % (one+1),one+1))
        #print(up + pow(2,(len(X)-1) - i, one+1) % (one+1))
import sys
while True :
    ab = sys.stdin.readline().split()
    a = ab[0]
    b = ab[1]
    if a == 0 and b == 0 :
        break

### FIXED CODE ###

import sys
while True :
    ab = list(map(int,sys.stdin.readline().split()))
    a = ab[0]
    b = ab[1]
    if a == 0 and b == 0 :
        break
    else :
        ab = sorted(ab)
        print(ab[0],ab[1])
if N % 2 == 0:
  print(N/2)
  
if N % 2 != 0:
  print((N//2)+1)

### FIXED CODE ###

N = int(input())
 
if N % 2 == 0:
  print(N//2)
  
if N % 2 != 0:
  print((N//2)+1)
n = int(input())
a = list(map(int,input().split()))

b = [0]*n
for i in range(n):
  b[i] = a[i] - (i+1)  
  
if n%2 ==0:
  median = b[n//2] 
else:
  median = (b[n//2]+b[(n//2)+1])//2
  
ans = 0
for i in range(n):
  ans+= abs(a[i] -(median + i+1))
  
print(ans)    

### FIXED CODE ###

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

b = [0]*n
for i in range(n):
  b[i] = a[i] - (i+1)  

bs = sorted(b)  
if n%2 ==1:
  median = bs[n//2] 
else:
  median = (bs[n//2 -1]+bs[(n//2)])//2
  
ans = 0
for i in range(n):
  ans+= abs(a[i] -(median + i+1))
  
print(ans)
l = input()
if l>1000:
  print(l*2)
elif l>=0 and l<1000:
  print(l)
else:
  print("Invalid")

### FIXED CODE ###

l = int(input())
print(int(l/500)*1000+int((l%500)/5)*5)
from collections import Counter
r = 0
cnt = Counter(input()):
for c in cnt:
    r += cnt[c] % 2
if r == 0:
    print("Yes")
else:
    print("No")



### FIXED CODE ###

from collections import Counter
r = 0
cnt = Counter(input())
for c in cnt:
    r += cnt[c] % 2
if r == 0:
    print("Yes")
else:
    print("No")
from collections import deque
import numpy as np

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

ans = 0
for x in range(H):
    for y in range(W):
        #壁からはスタートできない
        if maze[x][y] == "#":
            continue

        #初期化
        distance = [[0]*W for _ in range(H)]
        #start位置
        stack = deque([[x,y]])

        while stack:
            h,w = stack.popleft()
            for i,j in [[1,0],[-1,0],[0,1],[0,-1]]:
                new_h, new_w = h+i, w+j
                if new_h < 0 or new_w < 0 or new_h >= H or new_w >= W:
                    continue
                elif maze[new_h][new_w] != "#" and distance[new_h][new_w] == 0:
                    distance[new_h][new_w] = distance[h][w]+1
                    stack.append([new_h, new_w])

        #start位置は0で初期化
        distance[x][y] = 0
        ans = max(ans, np.max(distance))

print(ans)

### FIXED CODE ###

from collections import deque

def main():
    h, w = map(int, input().split())
    ls = [input() for _ in range(h)]

    def trans(a, b):
        return a * w + b

    ls2 = [[] for _ in range(h * w)]

    for i in range(h):
        for j in range(w):
            # check ij
            if ls[i][j] == '#':
                continue
            if i >= 1 and ls[i-1][j] != '#':
                ls2[trans(i, j)].append(trans(i-1, j))
            if i <= h-2 and ls[i+1][j] != '#':
                ls2[trans(i, j)].append(trans(i + 1, j))
            if j <= w-2 and ls[i][j+1] != '#':
                ls2[trans(i, j)].append(trans(i, j + 1))
            if j >= 1 and ls[i][j-1] != '#':
                ls2[trans(i, j)].append(trans(i, j - 1))


    #print(ls2)


    def route(i):
        count = 1
        ss = deque(ls2[i])
        next = deque()
        explored = {i}
        while ss or next:
            if not ss:
                count +=1
                ss = next
                next = deque()
            now =ss.popleft()
            if now in explored:
                continue
            else:
                explored.add(now)
                next.extend(ls2[now])
        return count-1
    ans = 0
    for i in range(h * w - 1):
        if ls2[i] == []:
            continue
        ans = max(ans, route(i))

    print(ans)
if __name__ == '__main__':
    main()
def inp():
    try:
        while True:
            data=raw_input()
            if not data: break
            yield data
    except KeyboardInterrupt:
        return
A = [map(int, i.split()) for i in list(inp())]
for i in A:
    print len(str(i[0]*i[1]))

### FIXED CODE ###

results=[]
from sys import stdin
for line in stdin:
    a, b = (int(i) for i in line.split())
    results.append(len(str(a+b)))
for i in results:
    print i
N = int(input())

def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    a.sort()
    return a

def eval_ab(a, b):
    if a == 1 or b == 1:
        return a + b - 1
    else:
        return a + b - 2
    
def split(ary, a, b, i):
    e = eval_ab(a, b)

    if len(ary) == i:
        return eval_ab(a, b)
    v = ary[i]

    v1 = split(ary, a * v, b, i+1)
    v2 = split(ary, a, b * v, i+1)
    return min(v1, v2)

def light(ary):
    a = 1
    b = 1
    for v in ary:
        if a < b:
            a *= v
        else:
            b *= v
    return eval_ab(a, b)

ary = prime_factorize(N)
print(ary)

if len(ary) == 1:
    print(str(ary[0] - 1))
elif len(ary) == 2:
    cost = ary[0] + ary[1] - 2
    print(str(cost))
else:
    if N < 100000:
        v1 = split(ary, 1, 1, 0)
        print(v1)
    else:
        v1 = light(ary, 1, 1, 0)
        print(v2)
    #v2 = light(ary)
    #v1 = split(ary, 1, 1, 0)
    #print(v1, v2)
    #print(str(v))



### FIXED CODE ###

import math
N = int(input())

def eval_ab(a, b):
    if a == 1 or b == 1:
        return a + b - 1
    else:
        return a + b - 2
    
min_e = N - 1
a = int(math.sqrt(N)) + 2
for i in range(1, a):

    if N % i == 0:
        j = N // i
        e = eval_ab(i, j)
        min_e = min(e, min_e)

print(min_e)
x,y,z,k = map(int,input().split())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
c = list(map(int,input().split()))

a = sorted(a)
b = sorted(b)
c = sorted(c)

la = []

for i in range(x):
    s = 3000-i
    for n in range(max(y-5-3000/s,0),y):
        u = 3000-n
        for m in range(max(z-5-3000/(s*u),0),z):
            la.append(a[i]+b[n]+c[m])

la = sorted(la)

for i in range(k):
    print(la[-i-1])


### FIXED CODE ###

x,y,z,k = map(int,input().split())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
c = list(map(int,input().split()))

a = sorted(a)
b = sorted(b)
c = sorted(c)

la = []

for i in range(x):
    s = x-i
    for n in range(max(y-5-3000//s,0),y):
        u = y-n
        for m in range(max(z-5-3000//(s*u),0),z):
            #print(s,u,m)
            la.append(a[i]+b[n]+c[m])

la = sorted(la)

for i in range(k):
    print(la[-i-1])
a,b,h = map(int,input().split())

print(int((a + b) * h / 2))

### FIXED CODE ###

a = int(input())
b = int(input())
h = int(input())

print(int((a + b) * h / 2))
k=int(input())
a,b=map(int,input().split())
for i in range(a,b+1):
  if i%n==0:
    print("OK")
print("NG")

### FIXED CODE ###

k=int(input())
a,b=map(int,input().split())
f=0
for i in range(a,b+1):
  if i%k==0:
    f=1
if f==1:
  print("OK")
else:
  print("NG")
A, P = map(int, input())

print(int((A*3+ P) //2))

### FIXED CODE ###

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

print(int((A*3+ P) //2))
input()
i = list(map(int, input().split()))
i.reverse()
for j in range(len(i) - 1) :
    print('{} '.format(i[j]), end = '')
print('{}'.format(i[j + 1]))

### FIXED CODE ###

input()
i = list(map(int, input().split()))
i.reverse()
for j in range(len(i)) :
    if j != 0 :
        print(' ', end = '')
    print(i[j], end = '')
print()
N,M=map(int,input().split())
H=list(map(int,input().split())
check=[0]*N
for i in range(M):
  A,B=map(int,input().split())
  if H[A-1]>H[B-1]:
    check[B-1]=check[B-1]+1
  elif H[A-1]<H[B-1]:
    check[A-1]=check[A-1]+1
  else:
      check[A-1]+=1
      check[B-1]+=1
    
    
ans=check.count(0)

print(ans)

### FIXED CODE ###

N,M=map(int,input().split())
H=list(map(int,input().split()))
check=[0]*N
for i in range(M):
  A,B=map(int,input().split())
  if H[A-1]>H[B-1]:
    check[B-1]=check[B-1]+1
  elif H[A-1]<H[B-1]:
    check[A-1]=check[A-1]+1
  else:
      check[A-1]+=1
      check[B-1]+=1
    
    
ans=check.count(0)

print(ans)
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

A, B, C, D = MAP()
print(min(A, B) + min(C, D))

### FIXED CODE ###

import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

COST = [INT() for _ in range(4)]
print(min(COST[0], COST[1]) + min(COST[2], COST[3]))