Harryxun/stf_run huggingface dataset:
import unittest
import math


def solution(n, a):
    gcd_left = [0]
    gcd_right = [0]
    for i in range(n):
        gcd_left.append(math.gcd(gcd_left[i], a[i]))
        # 順に(0とa[-1]), (a[-1]とa[-2]),...の比較
        # 要は右端から順にgcdを求めている
        gcd_right.append(math.gcd(gcd_right[i], a[-(i + 1)]))

    gcd_right = gcd_right[::-1]  # gcd_right[i]がi番目以降のgcdとなるように反転

    ans = []
    for i in range(n):
        ans.append(math.gcd(gcd_left[i], gcd_right[i + 1]))


    return max(ans)


class MyTestCase(unittest.TestCase):
    def test1(self):
        self.assertEqual(solution(3, [7, 6, 8]), 2)

    def test2(self):
        self.assertEqual(solution(3, [12, 15, 18]), 6)

    def test3(self):
        self.assertEqual(solution(2, [1000000000, 1000000000]), 1000000000)


if __name__ == '__main__':
    n = int(input())
    a = list(map(int, input().split()))
    print(solution(n, a))

    unittest.main()

### FIXED CODE ###

import unittest
import fractions


def solution(n, a):
    gcd_left = [0]
    gcd_right = [0]
    for i in range(n):
        gcd_left.append(fractions.gcd(gcd_left[i], a[i]))
        # 順に(0とa[-1]), (a[-1]とa[-2]),...の比較
        # 要は右端から順にgcdを求めている
        gcd_right.append(fractions.gcd(gcd_right[i], a[-(i + 1)]))

    gcd_right = gcd_right[::-1]  # gcd_right[i]がi番目以降のgcdとなるように反転

    ans = []
    for i in range(n):
        ans.append(fractions.gcd(gcd_left[i], gcd_right[i + 1]))


    return max(ans)


class MyTestCase(unittest.TestCase):
    def test1(self):
        self.assertEqual(solution(3, [7, 6, 8]), 2)

    def test2(self):
        self.assertEqual(solution(3, [12, 15, 18]), 6)

    def test3(self):
        self.assertEqual(solution(2, [1000000000, 1000000000]), 1000000000)




if __name__ == '__main__':

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

    unittest.main()
line = ''.join(['.#']*50)
dot=['.','#']
cl=[''.join(['.']*100),''.join(['#']*100)]
ba=[b-1,a-1]
ans=[]
for c in [0,1]:
    ans.append(cl[c])
    for i in range(ba[c]//50):
        ans.append(line)
        ans.append(cl[c])
    ans.append(''.join(['.#']*(ba[c]%50))+cl[c][(ba[c]%50)*2:])
    ans.append(cl[c])
print(len(ans))
for l in ans:print(''.join(l))

### FIXED CODE ###

a,b= map(int,input().split())
line=''.join(['.#']*50)
dot=['.','#']
cl=[''.join(['.']*100),''.join(['#']*100)]
ba=[b-1,a-1]
ans=[]
y=ans.append
for c in [0,1]:
    y(cl[c])
    for i in range(ba[c]//50):
        y(line)
        y(cl[c])
    y(''.join(['.#']*(ba[c]%50))+cl[c][(ba[c]%50)*2:])
    y(cl[c])
print(len(ans),100)
for l in ans:print(''.join(l))
import copy
n,m=map(int, input().split())
a=sorted([int(i) for i in input().split()],reverse=True)
if n==1:
    print(a[0]//(2**m))
    exit()
def solve(cnt, coupon, now):
    ans = 10 ** 10
    if cnt==m:
        tmp=0
        for i in range(n):
            tmp+=a[i]//(2**coupon[i])
        return tmp
    nowcp=coupon
    for i in range(1,m-cnt+1):
        temp=copy.copy(nowcp)
        temp[now]=i
        ans=min(ans,solve(cnt+i,temp, now+1))
    return ans
print(solve(0,[0 for _ in range(n)], 0))

### FIXED CODE ###

import heapq

n, m = map(int, input().split())
a = [int(i) * (-1) for i in input().split()]
heapq.heapify(a)
for _ in range(m):
    heapq.heappush(a, heapq.heappop(a) * (-1) // 2 * (-1))
print(-sum(a))
N = int(input())
list = list(map(int, input().split()))

huriwake = [0, 0, 0, 0, 0, 0, 0, 0]
rea = 0
count = 0

for i in list:
    if i < 400:
        huriwake[0] = 1
    elif i < 800:
        huriwake[1] = 1
    elif i < 1200:
        huriwake[2] = 1
    elif i < 1600:
        huriwake[3] = 1
    elif i < 2000:
        huriwake[4] = 1
    elif i < 2400:
        huriwake[5] = 1
    elif i < 2800:
        huriwake[6] = 1
    elif i < 3200:
        huriwake[7] = 1
    else:
        rea += 1

for h in huriwake:
    if h == 1:
        count += 1

if count == 0 && rea > 0:
    count += 1

min = count

if rea > 0:
    count += rea
    if count > 8: count = 8

max = count

print("{0} {1}".format(min, max))


### FIXED CODE ###

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

huriwake = [0, 0, 0, 0, 0, 0, 0, 0]
rea = 0
count = 0

for i in list:
    if i < 400:
        huriwake[0] = 1
    elif i < 800:
        huriwake[1] = 1
    elif i < 1200:
        huriwake[2] = 1
    elif i < 1600:
        huriwake[3] = 1
    elif i < 2000:
        huriwake[4] = 1
    elif i < 2400:
        huriwake[5] = 1
    elif i < 2800:
        huriwake[6] = 1
    elif i < 3200:
        huriwake[7] = 1
    else:
        rea += 1

for h in huriwake:
    if h == 1:
        count += 1

if count == 0 and rea > 0:
    count += 1
    rea -= 1

min = count

if rea > 0:
    count += rea

max = count

print("{0} {1}".format(min, max))
N, M = map(int, input().split(' '))

def fib(n):
    if n < 2:
        return n
    else:
        return fib(n - 1) + fib(n -2)

safe_area = []
a_p = int(input())
safe_area.append(a_p)
for i in range(M-1):
    a = int(input())
    diff = a - a_p
    if diff == 1:
        print('0')
        exit()
    safe_area.append(diff-1)
    a_p = a

safe_area.append(N - a_p)

sum = 1
for i in safe_area:
    sum *= fib(i)
print(sum % 1000000007)


### FIXED CODE ###

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

MOD = 1000000007

def fib(n):
    a, b = 0, 1
    for i in range(0, n):
        a, b = b, a + b
    return a

broken_step = []
p_a = -1
for i in range(M):
    a = int(input())
    if (a - p_a == 1):
        print("0")
        exit()
    else:
        p_a = a
    broken_step.append(a-1)

count_0 = 0
count_1 = 1
next_broken = 0
pre_is_broken = False
for i in range(N):
    if (next_broken >= len(broken_step) or i != broken_step[next_broken]):
        if (pre_is_broken):
            count_0 = 0
            pre_is_broken = False
        else:
            count_0, count_1 = count_1, count_0 + count_1
            count_0 %= MOD
            count_1 %= MOD
    else:
        next_broken+=1
        count_0 = 0
        pre_is_broken = True

print(count_1)
import re
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
import functools
def v(): return input()
def k(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def X(): return list(input())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 9)
mod = 10**9+7
cnt = 0
ans = 0
inf = float("inf")

n,k=I()
a = l()
town = []
num = [0]*(n+1)
cnt = 1
num[0]=1

for i in range(n):
    num[a[cnt-1]] += 1
    if num[a[cnt-1]] == 2:
        ans = a[cnt-1]
        break
    town.append(a[cnt-1])
    cnt = a[cnt-1]

p = town.index(ans)
b = town[p:]
x = len(town)
y = len(b)
q = k-x+y
if q < 0:
    print(town[k-1])
    sys.exit()
z = q%y
if z == 0:
    print(town[k-1])
else:
    print(b[z-1])


### FIXED CODE ###

import re
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
import functools
def v(): return input()
def k(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def X(): return list(input())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 9)
mod = 10**9+7
cnt = 0
ans = 0
inf = float("inf")

n,k=I()
a = l()
town = []
num = [0]*(n+1)
cnt = 1
num[0]=1

for i in range(n):
    num[a[cnt-1]] += 1
    if num[a[cnt-1]] == 2:
        ans = a[cnt-1]
        p = town.index(ans)
        b = town[p:]
        x = len(town)
        y = len(b)
        q = k-x+y
        if y == 0:
            print(town[n-1])
            sys.exit()
        if q < 0:
            print(town[k-1])
            sys.exit()
        z = q%y
        if z == 0:
            print(town[z-1])
        else:
            print(b[z-1])
        sys.exit()
        break
    town.append(a[cnt-1])
    cnt = a[cnt-1]
h,w=map(int,input().split())
x=[]
for i in range(h):
    x.append(list(input()))
#print(x)
c=0
for i in range(h):
    for j in range(w):
        if x[i][j]==".":
            c+=1
dp=[[10000000000 for i in range(w)]for j in range(h)]
dp[0][0]=1

def go_next(I,J):
    global dp,w,h
    if I<h-1:
        if x[I+1][J]==".":
            if dp[I+1][J]>dp[I][J]+1:
                dp[I+1][J]=dp[I][J]+1
                go_next(I+1,J)

    if I>0:
        if x[I-1][J]==".":
            if dp[I-1][J]>dp[I][J]+1:
                dp[I-1][J]=dp[I][J]+1
                go_next(I-1,J)
    if J<w-1:
        if x[I][J+1]==".":
            if dp[I][J+1]>dp[I][J]+1:
                dp[I][J+1]=dp[I][J]+1
                go_next(I,J+1)
    if J>0:
        if x[I][J-1]==".":
            if dp[I][J-1]>dp[I][J]+1:
                dp[I][J-1]=dp[I][J]+1
                go_next(I,J-1)

go_next(0,0)
if dp[h-1][w-1]==10000000000:
    print(-1)
else:
    print(c-dp[h-1][w-1])


### FIXED CODE ###

#一個だけRE、わからねえ
#解答見る
import sys
sys.setrecursionlimit(1005)
h,w=map(int,input().split())

def go_next(I,J,n):
    n+=1
    global dp,w,h
    if n>1000:
        return
    if 0<=I<h-1:
        if x[I+1][J]=="." and dp[I+1][J]>dp[I][J]+1:
            dp[I+1][J]=dp[I][J]+1
            go_next(I+1,J,n)
    if 0<I<=h-1:
        if x[I-1][J]=="." and dp[I-1][J]>dp[I][J]+1:
            dp[I-1][J]=dp[I][J]+1
            go_next(I-1,J,n)
    if 0<=J<w-1:
        if x[I][J+1]=="." and dp[I][J+1]>dp[I][J]+1:
            dp[I][J+1]=dp[I][J]+1
            go_next(I,J+1,n)
    if 0<J<=w-1:
        if x[I][J-1]=="." and dp[I][J-1]>dp[I][J]+1:
            dp[I][J-1]=dp[I][J]+1
            go_next(I,J-1,n)

x=[]
for i in range(h):
    x.append(list(input()))
#print(x)
c=0
for i in range(h):
    for j in range(w):
        if x[i][j]==".":
            c+=1
dp=[[10000000000 for i in range(w)]for j in range(h)]
dp[0][0]=1
go_next(0,0,0)
if dp[h-1][w-1]==10000000000:
    print(-1)
else:
    print(c-dp[h-1][w-1])
N,M = map(int,input().split())
X = list(map(int,(input().split())))

X.sort()

memo = dict()
def get_min(n,x):
    key = str((n,x))
    tmp = memo.get(key,None)
    if tmp != None:
        return tmp
    if x == []:
        tmp = 10**8
        memo[key] = tmp
        return tmp
    elif len(x) == 1:
        memo[key] = 0
        return 0
    x0 = x[0]
    if n == 1:
        tmp = x[-1]-x0
        memo[key] = tmp
        return tmp
    tmp = min([y - x0 + get_min(n-1,x[i+1:]) for i,y in enumerate(x)])
    memo[key] = tmp
    return tmp
if N >= M:
    print(0)
else:
    print(get_min(N,X))

### FIXED CODE ###

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

X.sort()

dif_X = [X[i+1]-x for i,x in enumerate(X[:-1])]
dif_X.sort()
print(sum(dif_X[:max(0,M-N)]))
x = input().split('\n')
n = int(x[0])
w = [x[i] for i in range(1, n+1)]

def chk_shiri(w):
    for i in range(n - 1):
        if w[i][-1] == w[i + 1][0]:
            continue
        else:
            return False
    return True
    
if len(w) != len(set(w)):
    print('No')
elif chk_shiri(w):
    print('Yes')
else:
    print('No')
    

### FIXED CODE ###

n = int(input())
w = []
for i in range(n):
    w.append(input())

def chk_shiri(w):
    for i in range(n - 1):
        if w[i][-1] == w[i + 1][0]:
            continue
        else:
            return False
    return True
    
if len(w) != len(set(w)):
    print('No')
elif chk_shiri(w):
    print('Yes')
else:
    print('No')
def max_minus_min(areas):
    # print("areas", areas)
    return max(areas) - min(areas)
 
def solve2(h, w):
    return 7, 7
    # area1 = h * (w // 2)
    # area2 = h * w - area1
    # return area1, area2
 
def solve(h, w):
    w_div_3 = w // 3;
    ans = 1e9
    for w2 in range(w_div_3, w_div_3 + 2):
        area1 = w2 * h
        ans = min(ans, max_minus_min([area1] + solve2(h, w - w2)))
        ans = min(ans, max_minus_min([area1] + solve2(w - w2, h)))
    return ans
 
H, W = map(int, input().split())
print(min(solve(H,W), solve(W,H)))


### FIXED CODE ###

#!/usr/bin/env python3
# -*- coding: utf-8 -*-

# import array
# from bisect import *
# from collections import *
# import fractions
# import heapq 
# from itertools import *
# import math
# import re
# import string

def max_minus_min(areas):
    # print("areas", areas)
    return max(areas) - min(areas)

def solve2(h, w):
    area1 = h * (w // 2)
    area2 = h * w - area1
    return [area1, area2]

def solve(h, w):
    w_div_3 = w // 3;
    ans = 1e9
    for w2 in range(w_div_3, w_div_3 + 2):
        area1 = w2 * h
        ans = min(ans, max_minus_min([area1] + solve2(h, w - w2)))
        ans = min(ans, max_minus_min([area1] + solve2(w - w2, h)))
    return ans

H, W = map(int, raw_input().split())
print(min(solve(H,W), solve(W,H)))
s=input()
print(s.replace(',',' ')

### FIXED CODE ###

s=input()
print(s.replace(',',' '))
a, b = [*map(input().split(" "), int)]
print(a * b)


### FIXED CODE ###

a, b = [*map(int, input().split(" "))]
print(a * b)
pritn(eval("+".join(sorted(input()))+"*10"))

### FIXED CODE ###

print(eval("+".join(sorted(input()))+"*10"))
print("{}{}{}".format(s[0],len(s)-2,s[-1]))

### FIXED CODE ###

s = input()
print("{}{}{}".format(s[0],len(s)-2,s[-1]))
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long ll;

signed main(){
  ll h,n;cin >> h >> n;
  vector<ll> a(n);
  vector<ll> b(n);
  for(ll i=0;i<n;i++){
    cin >> a[i] >> b[i];
  }
  ll inf=10000000000;
  ll ma=*max_element(a.begin(),a.end());
  vector<ll> dp(h+1+ma,inf);dp[0]=0;
  for(ll i=0;i<n;i++){
    for(ll j=0;j<h+1+ma;j++){
      if(dp[j]!=inf){
        if(j+a[i]<=h+ma){
          dp[j+a[i]]=min(dp[j+a[i]],dp[j]+b[i]);
        }else{
          break;
        }
      }
    }
  }
  cout << *min_element(dp.begin()+h,dp.end()) << endl;
}


### FIXED CODE ###

h,n=map(int,input().split())
ab=[list(map(int,input().split())) for i in range(n)]
ab.sort(reverse=True)
inf=1000000000
ma=ab[0][0]
dp=[inf]*(h+1+ma)
dp[0]=0
for i in range(n):
    x=ab[i]
    for j in range(h):
        if dp[j]!=inf:
            if j+x[0]<=h+ma:
                if j+x[0]>=h:
                    dp[h]=min(dp[h],dp[j]+x[1])
                else:
                    dp[j+x[0]]=min(dp[j+x[0]],dp[j]+x[1])
            else:
                break
print(dp[h])
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

A.insert(0,0)
B.insert(0,0)
C.insert(0,)
manzoku = 0
prev = 0
 
for a in A:
  manzoku += B[a]
  if prev != 0 and prev != N:
    manzoku += C[prev]
  prev = a
print(manzoku)

### FIXED CODE ###

N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
 
manzoku = 0
prev = 0
 
for a in A:
  manzoku += B[a-1]
  if prev+1 == a and prev != 0:
    manzoku += C[prev-1]
  prev = a
print(manzoku)
a,b = map(int,input())

if a <= 5:
	print(0)
  
elif a <=12:
	print(b/2)
    
else:
	print(b)

### FIXED CODE ###

a,b = map(int,input().split())
 
if a <= 5:
	print(0)
        
elif a <= 12:
	print(int(b/2))
        
else:
	print(b)
"???".swapcase(<1200)

### FIXED CODE ###

s = input()
print(s.swapcase())
N = int(input())

hyaku = N // 100
resi = N - (100 * hyaku)
ju = resi // 10
iti = resi % 10

n = hyaku * ju * iti

if n % 7 == 0:
  print('Yes')

else:
  print('No')

N = int(input())

### FIXED CODE ###

N = int(input())

hyaku = N // 100
resi = N - (100 * hyaku)
ju = resi // 10
iti = resi % 10

n = hyaku * ju * iti

if not hyaku == 7:
  if not ju == 7:
    if not iti == 7:
      print('No')
    else:
      print('Yes')
  else:
    print('Yes')
else:
  print('Yes')
import math
from operator import mul
from functools import reduce

def cmb(n,r):
    r = min(n-r,r)
    if r == 0: return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))
    return over // under

N = int(input())

answer = 0
rest = 10 ** 9 + 7
  
if N == 1:
  answer = 0
else:
  answer = cmb(N, 2) * 2 * (10 ** (N - 2))
print(answer % rest)

a = cmb(N, 2)
print(a)


### FIXED CODE ###

from operator import mul
from functools import reduce

def cmb(n,r):
    r = min(n-r,r)
    if r == 0: return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))
    return over // under

N = int(input())

answer = 0
rest = 10 ** 9 + 7
if N == 1:
  answer = 0
else:
  answer = (10 ** N) - (9 ** N) - (9 ** N) + (8 ** N)
print(answer % rest)
import math
x,y = map(int,input().split())
if (2*x-y)% 3 == 0 and (2*y-x)% 3 == 0:
	n = (2*y-x)/3
	m = (2*x-y)/3
	print(int(math.factorial(n+m)/(math.factorial(n)*math.factorial(m)))%(pow(10,9)+7))
else:
	print(0)

### FIXED CODE ###

import math
x,y = map(int,input().split())
mod = pow(10,9)+7
if (2*x-y)% 3 != 0 or (2*y-x)% 3 != 0 or ((2 * y - x) / 3 < 0) or ((2 * x - y) / 3 < 0):
	print(0)
else:
	n = int((2 * y - x) / 3)
	m = int((2 * x - y) / 3)
	P = [1]*(n + m + 1)
	for i in range(1, n+m+1):
		P[i] = P[i-1]*i
		P[i] %= mod
	print((P[n+m]*pow(P[n],mod-2,mod)*pow(P[m],mod-2,mod)) % mod)
w,a,b = [int(x) for x in input().split()]
print(abs(b-w-(b-a+w))) if a+w <= b else print(0)


### FIXED CODE ###

a,b = input().split()
print('H') if a == b else print('D')
n, k = map(int, input().split())
a = [i-1 for i in list(map(int, input().split()))]

l = []
used = [0 for _ in range(n)]

c = 0
flag = True
while 1:
    if not flag:
        l.append(c)
    if used[c] == 1 and l:
        break
    if not flag:
        used[c] = 1
    c = a[c]
    flag = False

p = 0
length = len(l)
b = []
for i in range(length):
    if l[i] == l[-1]:
        l = l[i:-1]
        b = l[:i]
        p = i
        break

if len(b) >= k:
    print(b[k - 1])
else:
    print(l[(k - p - 1) % len(l)] + 1)


### FIXED CODE ###

n, m, x = map(int, input().split())
c = []
a = []
for i in range(n):
    l = list(map(int, input().split()))
    c.append(l[0])
    a.append(l[1:])

ans=float("inf")

for i in range(2 ** n):
    cost = 0
    r = [0 for _ in range(m)]
    for j in range(n):
        if (i >> j) & 1:
            cost += c[j]
            for k in range(m):
                r[k] += a[j][k]
    flag = True
    for k in r:
        if k < x:
            flag = False
    if flag:
        ans = min(ans, cost)
if ans!=float("inf"):
    print(ans)
else:
    print(-1)
from re import sub

n = int(input())
s = input()
k = int(input())

print(sub(f'[^{s[k-1]}]', '*', s))


### FIXED CODE ###

from re import sub

n = int(input())
s = input()
k = int(input())

print(sub('[^{}]'.format(s[k-1]), '*', s))
N, Q = map(int, input().split())

E = [[] for _ in range(N + 1)]
X = [0 for _ in range(N + 1)]
for _ in range(N - 1):
    a, b = map(int, input().split())
    E[a].append(b)
    E[b].append(a)

for _ in range(Q):
    p, x = map(int, input().split())
    X[p] += x

visited = [False for _ in range(N + 1)]
visited[1] = True


def add(i, val):
    X[i] += val
    for to in E[i]:
        if visited[to]:
            continue
        visited[to] = True
        add(to, X[i])


add(1, 0)

print(*X[1:])


### FIXED CODE ###

import sys

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

E = [[] for _ in range(N + 1)]
X = [0 for _ in range(N + 1)]
for _ in range(N - 1):
    a, b = map(int, input().split())
    E[a].append(b)
    E[b].append(a)

for _ in range(Q):
    p, x = map(int, input().split())
    X[p] += x

stack = [1]
visited = [False for _ in range(N + 1)]
visited[1] = True

while stack:
    i = stack.pop()
    for j in E[i]:
        if visited[j]:
            continue
        visited[j] = True
        stack.append(j)
        X[j] += X[i]

print(*X[1:])
R = map(int, input())

cir = 2*R*3.1415

ptint(cir)

### FIXED CODE ###

from math import pi

R = int(input())

print(2*pi*R)
#!/usr/bin/env python3
import sys
from collections.abc import Iterable
from math import *
from itertools import *
from collections import *
from functools import *
from operator import *
try:
    from math import gcd
except Exception:
    from fractions import gcd


def solve(N: int, C: int, x: "List[int]", v: "List[int]"):
    x = [0, *x]
    v = [0, *v]
    bi = []
    best = 0
    besti = 0
    acc_v = list(accumulate(v, lambda acc, vv: acc + vv))
    for ii, (xx, vv) in enumerate(zip(x, acc_v)):
        if best < vv - xx:
            besti = ii
            best = vv - xx
        bi.append(besti)

    ret = 0
    for b in range(len(bi)):
        a = bi[b - 1]
        c = 0
        if a != 0:
            c += acc_v[a] - x[a]
        if b != 0:
            c += (acc_v[-1] - acc_v[b-1]) - ((C - x[b]) % C)
        c -= min(x[a], ((C - x[b]) % C))
        if ret < c:
            ret = c
    return ret

def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    C = int(next(tokens))  # type: int
    x = [int()] * (N)  # type: "List[int]" 
    v = [int()] * (N)  # type: "List[int]" 
    for i in range(N):
        x[i] = int(next(tokens))
        v[i] = int(next(tokens))
    result = solve(N, C, x, v)
    if isinstance(result, Iterable):
        result = '\n'.join([str(v) for v in result])
    print(result)

if __name__ == '__main__':
    main()


### FIXED CODE ###

#!/usr/bin/env python3
import sys
from collections.abc import Iterable
from math import *
from itertools import *
from collections import *
from functools import *
from operator import *
try:
    from math import gcd
except Exception:
    from fractions import gcd


def solve(N: int, C: int, x: "List[int]", v: "List[int]"):
    x = [0] + x
    v = [0] + v

    mx_r = [0]
    for xx, acc in zip(x[1:], accumulate(v[1:], add)):
        mx_r.append(max(acc - xx, mx_r[-1]))

    mx_l = [0]
    for xx, cal in zip(reversed(x), accumulate(reversed(v), add)):
        mx_l.append(max(cal - (C - xx), mx_l[-1]))
    mx_l.reverse()

    ans = 0
    for i in range(N+1):
        ans = max(mx_r[i], mx_r[i] - x[i] + mx_l[i+1], ans)
        if i != 0:
            ans = max(mx_l[i], mx_l[i] - (C - x[i]) + mx_r[i-1], ans)
    return ans


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    C = int(next(tokens))  # type: int
    x = [int()] * (N)  # type: "List[int]" 
    v = [int()] * (N)  # type: "List[int]" 
    for i in range(N):
        x[i] = int(next(tokens))
        v[i] = int(next(tokens))
    result = solve(N, C, x, v)
    if isinstance(result, Iterable):
        result = '\n'.join([str(v) for v in result])
    print(result)

if __name__ == '__main__':
    main()
x = int(input())
for i in range(-118, 119):
    for j in range(-119, 118):
        if i**5 - j**5 == x:
            print(i,j)
            break
    else:
        continue
    break

### FIXED CODE ###

import copy
n, m =map(int, input().split())  #複数数値入力
list_h=list(map(int, input().split()))  #リスト入力
# 繰り返しリスト入力
a = []
for i in range(m):
    ai = list(map(int, input().split()))  #リスト入力
    a.append(ai)

for i in a:
    i.sort()
a = list(map(list, set(map(tuple, a))))

booler = [True] * n
for j in a:
    if list_h[j[0]-1] < list_h[j[1]-1]:
        booler[j[0]-1] = False
    elif list_h[j[0]-1] > list_h[j[1]-1]:
        booler[j[1]-1] = False
    else :
        booler[j[0]-1] = False
        booler[j[1]-1] = False
print(booler.count(True))