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

N, K = map(int, input().split())
# K > 1 かつ　N > Kの場合は、N - N // K * K をスタートにできる
if K > 1:
  N = N - N // K * K
else:
  N = 0
minimum = N
count = 0
#print(N)
while count <= N / 4:
  N = abs(N - K)
  minimum = min(N, minimum)
  count += 1
print(minimum)

### FIXED CODE ###

N, K = map(int, input().split())
# K > 1 かつ　N > Kの場合は、N - N // K * K をスタートにできる
if K > 1:
  N = N - N // K * K
else:
  N = 0
minimum = N
count = 0
#print(N)
while count <= N / K:
  N = abs(N - K)
  minimum = min(N, minimum)
  count += 1
print(minimum)
### BUGGY CODE ###

h, w, k = map(int, input().split())
s = [list(map(int, list(input()))) for _ in range(h)]
result = []
for i in range(2**(h-1)):
    checker = format(i, "0"+str(h)+"b").count("1")
    x = 0
    c = [0 for _ in range(checker+1)]
    for j in range(w):
        num = i
        p = 0
        nex = [0 for _ in range(checker+1)]
        for m in range(h):
            nex[p] += s[m][j]
            p += num%2
            num = num >> 1
        
        if all(nex[m]+c[m] <= k for m in range(checker+1)):
            c = [c[I]+nex[I] for I in range(checker+1)]
        else:
            x += 1
            c = nex
    result.append(checker+x)
print(min(result))

### FIXED CODE ###

h, w, k = map(int, input().split())
s = [list(map(int, list(input()))) for _ in range(h)]
result = []
if h*w<=k:
    result.append(0)
else:
    for i in range(2**(h-1)):
        checker, num = 0, i
        while num > 0:
            checker += num%2
            num >>= 1
        x = 0
        c = [0 for _ in range(checker+1)]
        
        num = i
        p = 0
        nex = [0 for _ in range(checker+1)]
        for m in range(h):
            nex[p] += s[m][0]
            p += num%2
            num = num >> 1
        if max(nex) > k:
            x = float('inf')
            continue

        if all(nex[m]+c[m] <= k for m in range(checker+1)):
            c = [c[I]+nex[I] for I in range(checker+1)]
        else:
            x += 1

        for j in range(1, w):
            num = i
            p = 0
            nex = [0 for _ in range(checker+1)]
            for m in range(h):
                nex[p] += s[m][j]
                p += num%2
                num = num >> 1
            if max(nex) > k:
                x = float('inf')
                break            
            
            if all(nex[m]+c[m] <= k for m in range(checker+1)):
                c = [c[I]+nex[I] for I in range(checker+1)]
            else:
                x += 1
                c = nex
        result.append(checker+x)
print(min(result))
### BUGGY CODE ###

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

def tri_able(x, y, z):
    if x+y > z and y+z > x and z+x > y:
        return True

answer = 0

for i in range(len(L)-2):
    for j in range(i+1, len(L)-1):
        for k in range(j+1,len(L)):
            if tri_able(L[i], L[j], L[k]):
                answer += 1
print(answer)


### FIXED CODE ###

import sys
import bisect

N = int(sys.stdin.readline())
L = [int(x) for x in sys.stdin.readline().split()]
L.sort()

answer = 0

for i in range(len(L)-2):
    for j in range(i+1, len(L)-1):
        answer += bisect.bisect_left(L, L[i]+L[j])-j-1

print(answer)
### BUGGY CODE ###

N = int(input())

A = []
for i in range(N):
    a = sorted(list(input()))
    A.append(a)
    
cnt = 0
for i in range(N):
    for j in range(i + 1, N):
        if A[i] == A[j]:
            cnt += 1
            
print(cnt)

### FIXED CODE ###

N = int(input())
 
D = {}
for i in range(N):
    s = ''.join(sorted(input()))
    D.setdefault(s, 0)
    D[s] += 1
    
ans = 0
for v in D.values():
    if v > 1:
        for i in range(v):
            ans += i
    
print(ans)
### BUGGY CODE ###

import itertools

N = int(input())
for n in range(1,N+1):
    if n < 6:
        print(0)
    else:
        M =int((n-2)**0.5)
        count = 0
        for x in range(1,M+1):
            for y in range(1,x+1):
                for z in range(1,y+1):
                    if (x+y)*(x+z)+y**2+z**2 == n:
                        p=[x,y,z]
                        q=[]
                        for p in itertools.permutations(p):
                            q.append(p)
                            count = len(set(q))
                    else:
                        pass
        print(count)



### FIXED CODE ###

N = int(input())
lst = [0]*(N+1)

for x in range(1,101):
    for y in range(1,101):
        for z in range(1,101):
            p = (x+y)*(x+z)+y**2+z**2
            if p > N:
                break
            else:
                lst[p] += 1
for i in range(1,N+1):
    print(lst[i])
### BUGGY CODE ###

A,B,Q = map(int, input().split())
S = [int(input()) for i in range(A)]
T = [int(input()) for i in range(B)]
X = [int(input()) for i in range(Q)]

def bs_up(x, L, ub, lb):
    if x > L[-1]:
        return 10**11+1
    if x < L[0]:
        return L[0]
    if ub-lb <= 1:
        return L[(ub+lb)//2+1]
    c = (ub+lb)//2
    if L[c] > x:
        return bs_up(x, L, c, lb)
    else:
        return bs_up(x, L, ub, c)
    
def bs_low(x, L, ub, lb):
    if x < L[0]:
        return -10**11-1
    if x > L[-1]:
        return L[-1]
    if ub-lb <= 1:
        return L[(ub+lb)//2]
    c = (ub+lb)//2
    if L[c] >= x:
        return bs_low(x, L, c, lb)
    else:
        return bs_low(x, L, ub, c)
    
for i in range(Q):
    s_u = bs_up(X[i], S, A-1, 0)-X[i]
    t_u = bs_up(X[i], T, B-1, 0)-X[i]
    s_l = bs_low(X[i], S, A-1, 0)-X[i]
    t_l = bs_low(X[i], T, B-1, 0)-X[i]
    print(min(max(s_u, t_u), max(-s_l, -t_l), s_u*2-t_l, s_u-2*t_l, t_u*2-s_l, t_u-2*s_l))

### FIXED CODE ###

import bisect
A, B, Q = map(int, input().split())
INF = 10 ** 18
s = [-INF] + [int(input()) for i in range(A)] + [INF]
t = [-INF] + [int(input()) for i in range(B)] + [INF]

for q in range(Q):
    x = int(input())
    b, d = bisect.bisect_right(s, x), bisect.bisect_right(t, x)
    res = INF
    for S in [s[b - 1], s[b]]:
        for T in [t[d - 1], t[d]]:
            d1, d2 = abs(S - x) + abs(T - S), abs(T - x) + abs(S - T)
            res = min(res, d1, d2)
    print(res)
### BUGGY CODE ###

import sys
sys.setrecursionlimit(10**5)
m = 100005
visited = [False]*(m*2)
cnt = [0,0]
def dfs(i):
    visited[i] = True
    cnt[i//m] = cnt[i//m]+1
    for j in to[i]:
        if not visited[j]:
            dfs(j)
 
input = sys.stdin.readline
n = int(input())
to = [[] for _ in range(m*2)]
for _ in range(n):
    x,y = map(int,input().split())
    y = y+m
    to[x].append(y)
    to[y].append(x)
 
ans = 0
for i in range(m):
    if not visited[i]:
        cnt = [0,0]
        dfs(i)
        ans = ans + cnt[0]*cnt[1]
 
print(ans-n)

### FIXED CODE ###

class UnionFind():
    def __init__(self, n):
        self.n = n
        self.root = [-1]*(n+1)
        self.rnk = [0]*(n+1)

    def Find_Root(self, x):
        if(self.root[x] < 0):
            return x
        else:
            self.root[x] = self.Find_Root(self.root[x])
            return self.root[x]
    def Unite(self, x, y):
        x = self.Find_Root(x)
        y = self.Find_Root(y)
        if(x == y):
            return 
        elif(self.rnk[x] > self.rnk[y]):
            self.root[x] += self.root[y]
            self.root[y] = x

        else:
            self.root[y] += self.root[x]
            self.root[x] = y
            if(self.rnk[x] == self.rnk[y]):
                self.rnk[y] += 1
    def isSameGroup(self, x, y):
        return self.Find_Root(x) == self.Find_Root(y)

    def Count(self, x):
        return -self.root[self.Find_Root(x)]

m = 100010
uf = UnionFind(m*2)
n = int(input())
for i in range(n):
    x,y = map(int,input().split())
    y = y+m
    uf.Unite(x,y)

lx = {}
ly = {}
ans = 0
for i in range(m):
    rx = uf.Find_Root(i)
    lx[rx] = lx.get(rx,0)+1
    ry = uf.Find_Root(i+m)
    ly[ry] = ly.get(ry,0)+1
for i in range(m*2):
    ans += lx.get(i,0)*ly.get(i,0)

print(ans-n)
### BUGGY CODE ###

# from pathlib import Path

"""
解説動画のコードを参考にしました
https://atcoder.jp/contests/abc175/submissions/15945829
"""


stdin = iter(
    map(int, l.split()) for l in
    # Path('./test/sample-4.in').read_text().split('\n')
    open(0).read().split('\n')
)

N,K = next(stdin)
*P, = next(stdin)
*C, = next(stdin)

ans = int(-1e18)

for start in P:
    pos = start
    scores = [] # スコア格納用

    while True:
        pos = P[pos-1] # 移動
        scores.append(C[pos-1]) # スコアの格納

        # 1周したかどうか
        if pos == start: break

    # 周期途中のどこでやめるか判定
    L = len(scores)
    S = sum(scores)
    period_score = 0
    for i in range(L):
        period_score += scores[i] # スコアの加算
        # 試行回数を超えていないか
        if i+1 > K: break
        total_score = period_score
        # 1周期の合計スコアが正なら、周期を重ねるごとにスコア増
        if S > 0:
            total_score += S * ((K-(i+1)) // L)
        ans = max(ans, total_score)

print(ans)

### FIXED CODE ###

"""
解説動画のコードを参考にしました
https://atcoder.jp/contests/abc175/submissions/15945829
"""

N,K = map(int, input().split())
*P, = map(int, input().split())
*C, = map(int, input().split())

ans = int(-1e18)

for start in P:
    pos = start
    scores = [] # スコア格納用

    while True:
        pos = P[pos-1] # 移動
        scores.append(C[pos-1]) # スコアの格納
        # 1周したかどうか
        if pos == start: break

    # 周期途中のどこでやめるか判定
    L = len(scores)
    S = sum(scores)
    period_score = 0
    for i in range(L):
        period_score += scores[i] # スコアの加算
        # 試行回数を超えていないか
        if i+1 > K: break
        total_score = period_score
        # 1周期の合計スコアが正なら、周期を重ねるごとにスコア増
        if S > 0:
            total_score += S * ((K-(i+1)) // L)
        ans = max(ans, total_score)

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

import sys
sys.setrecursionlimit(10**6)

def dfs(v, graph):
    if visited[v]:
        if not calculated[v]: #visited and not calculated == loop
            return -1 
        return depth[v]
    visited[v] = True
    for e in graph[v]: # すべての辺をなめる
        res = dfs(e, graph) # 再帰
        if res == -1: 
            return -1 # ループを見つけたら-1を返す
        
        depth[v] = max(depth[v], res+1) #より深い経路を発見したか？
    calculated[v] = True 
    return depth[v]


if __name__ == '__main__':
    N = int(input())
    Ng = N*(N-1)//2
    graph = [[] for _ in range(Ng)]
    G_id = [[-1]*N for _ in range(N)]
    
    game_id = 0
    for i in range(N):
        row = list(map(int, input().split()))
        for d, r in enumerate(row):
            if G_id[i][r-1] == -1: #新しい試合の組み合わせ
                G_id[i][r-1] = game_id 
                G_id[r-1][i] = game_id
                
                if d != 0: # 行が更新されているかのチェック
                    graph[before].append(game_id)
                
                before = game_id # idの更新・一つ記録
                game_id += 1
            else: # 既存の組み合わせ
                if d != 0: # 行が更新されているかのチェック
                    graph[before].append(G_id[i][r-1])
                before = G_id[i][r-1] #現在の試合を記録
    
    depth = [1]*Ng # 頂点から出発したときの最長経路
    visited = [False]*Ng
    calculated = [False]*Ng
    flag = True
    ans = 1
    for i in range(Ng):
        res = dfs(i, graph)
        if res == -1:
            flag = False
        else:
            ans = max(ans, res)
    if flag:
        print(ans)
    else:
        print(-1)
    
    

### FIXED CODE ###

import sys
sys.setrecursionlimit(10**6)

def dfs(v, graph):
    if visited[v]:
        if not calculated[v]: #visited and not calculated == loop
            return -1 
        return depth[v]
    visited[v] = True
    for e in graph[v]: # すべての辺をなめる
        res = dfs(e, graph) # 再帰
        if res == -1: 
            return -1 # ループを見つけたら-1を返す
        
        depth[v] = max(depth[v], res+1) #より深い経路を発見したか？
    calculated[v] = True 
    return depth[v]


if __name__ == '__main__':
    N = int(input())
    Ng = N*(N-1)//2
    graph = [[] for _ in range(Ng)]
    G_id = [[-1]*N for _ in range(N)]
    
    game_id = 0
    for i in range(N):
        row = list(map(int, input().split()))
        for d, r in enumerate(row):
            if G_id[i][r-1] == -1: #新しい試合の組み合わせ
                G_id[i][r-1] = game_id 
                G_id[r-1][i] = game_id
                
                if d != 0: # 行が更新されているかのチェック
                    graph[before].append(game_id)
                
                before = game_id # idの更新・一つ記録
                game_id += 1
            else: # 既存の組み合わせ
                if d != 0: # 行が更新されているかのチェック
                    graph[before].append(G_id[i][r-1])
                before = G_id[i][r-1] #現在の試合を記録
    
    depth = [1]*Ng # 頂点から出発したときの最長経路
    visited = [False]*Ng
    calculated = [False]*Ng
    flag = True
    ans = 1
    for i in range(Ng):
        res = dfs(i, graph)
        if res == -1:
            flag = False
        else:
            ans = max(ans, res)
    if flag:
        print(ans)
    else:
        print(-1)
### BUGGY CODE ###

N, M = list(map(int, input().split()))
A = list(map(lambda x: x % M, map(int, input().split())))
ans = 0
nums = []

for a in A:
    for i in range(len(nums)):
        nums[i] = (nums[i]+a) % M
        if not nums[i]:
            ans += 1
    if not a:
        ans += 1
    nums.append(a)

print(ans)

### FIXED CODE ###

def main():
    N, M = map(int, input().split())
    A = list(map(int, input().split()))
    
    b = 0
    count = {0:1}
    ans = 0
    
    for a in A:
        b = (a+b) % M
        if b in count:
            ans += count[b]
            count[b] += 1
        else:
            count[b] = 1
            
    print(ans)

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

# import collections
# import math

# def func(num):
#     if num == 1:
#         return 1
#     elif num == 2:
#         return 4
#     elif num == 3:
#         return 6

#     else:
#         count = 2
#         #1と自身
#         for i in range(2, int(math.sqrt(num)+2)):
#             if num%i == 0:
#                 count += 1
#         value = num*count
#         return value

# n = int(input())

# ans = 0
# for i in range(1, n+1):
#     ans += func(i)
    
# print(ans)

# import collections
# import math

# def func(num):
#     if num == 1:
#         return 1
#     elif num == 2:
#         return 4
#     elif num == 3:
#         return 6
#     else:
#         numbers = []
#         temp = num
#         while num%2 == 0:
#             numbers.append(2)
#             num //= 2

#         i = 3
#         while i*i <= num:
#             if num%i == 0:
#                 numbers.append(i)
#                 num //= i
#             else:
#                 i += 2

#         if num != 1:
#             numbers.append(n)

#         factors = collections.Counter(numbers)
#         divisor = list(factors.values())
#         count = 1

#         for i in divisor:
#             count *= (i+1)

#         value = temp*count
#         return value

# n = int(input())
# ans = 0

# for i in range(1,n+1):
#     ans += func(i)

# print(ans)

import collections
import math

def func(num):
    if num == 1:
        return 1
    elif num == 2:
        return 4
    elif num == 3:
        return 6
    else:
        arr = []
        temp = num
        for i in range(2, int(-(-n**0.5//1))+1):
            if temp%i==0:
                cnt=0
                while temp%i==0:
                    cnt+=1
                    temp //= i
                arr.append([i, cnt])

        if temp!=1:
            arr.append([temp, 1])

        if arr==[]:
            arr.append([n, 1])

        count = 1
        for i in range(len(arr)):
            count *= (arr[i][1]+1)
        value = num*count
        return value

            

n = int(input())
ans = 0

for i in range(1,n+1):
    ans += func(i)

print(ans)

            


### FIXED CODE ###


n = int(input())

ans = 0

for i in range(1,n+1):
    lim = n//i
    ans += lim*(lim+1)*i//2

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

n, k=[int(x) for x in input().split()]
a=[int(x) for x in input().split()]
d=sorted([a.count(i) for i in set(a)])[::-1]
print(n-sum(d[:k]))


### FIXED CODE ###

n, k=[int(x) for x in input().split()]
a=[int(x) for x in input().split()]
d={i:0 for i in set(a)}
for i in a: d[i]+=1
print(n-sum([t[1] for t in sorted(d.items(), key=lambda x:-x[1])][:k]))
### BUGGY CODE ###

from sys import stdin
N,Y=list(map(int,stdin.readline().strip().split()))
man=Y//10000
gosen=Y//5000

for i in range(man+1,-1,-1):
    for j in range(gosen+1,-1,-1):
        for k in range(N-(i+j)+1,-1,-1):
            goukei=10000*i+j*5000+k*1000
            if goukei==Y and (i+j+k)==N:
                print(i,j,k)
                exit()
            if goukei<Y or 10000*i+j*5000>Y :
                break
print(-1,-1,-1)


### FIXED CODE ###

from sys import stdin
N,Y=list(map(int,stdin.readline().strip().split()))
a=0
b=0
c=0
i=0
for i in range(N+1):
    for j in range(N+1):
        z=N-i-j
        if i*1000+5000*j+z*10000==Y and z>=0:
            print("%d %d %d" %(z,j,i))
            exit()
print("-1 -1 -1")
### BUGGY CODE ###

N = int(input())
A = [int(i) for i in input().split()]
lcm = [0]*10**6
mod = 10**9+7
for a in A:
    n = 2
    while a != 1:
        c = 0
        while a % n == 0:
            a //= n
            c += 1
        lcm[n] = max(lcm[n], c)
        n += 1
l = 1
for i, n in enumerate(lcm):
    l *= pow(i, n, mod)
    n %= mod
ans = 0
for a in A:
    p = pow(a, mod-2, mod)
    ans += (l*p) % mod
    ans %= mod
print(ans)


### FIXED CODE ###

N = int(input())
A = [int(i) for i in input().split()]
pn = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199, 211, 223, 227, 229, 233, 239, 241, 251, 257, 263, 269, 271, 277, 281, 283, 293, 307, 311, 313, 317, 331, 337, 347, 349, 353, 359, 367, 373, 379, 383, 389, 397, 401, 409, 419, 421, 431, 433, 439, 443,
      449, 457, 461, 463, 467, 479, 487, 491, 499, 503, 509, 521, 523, 541, 547, 557, 563, 569, 571, 577, 587, 593, 599, 601, 607, 613, 617, 619, 631, 641, 643, 647, 653, 659, 661, 673, 677, 683, 691, 701, 709, 719, 727, 733, 739, 743, 751, 757, 761, 769, 773, 787, 797, 809, 811, 821, 823, 827, 829, 839, 853, 857, 859, 863, 877, 881, 883, 887, 907, 911, 919, 929, 937, 941, 947, 953, 967, 971, 977, 983, 991, 997]
lcm = dict()
mod = 10**9+7
for a in A:
    i = 0
    while a != 1 and i < len(pn):
        c = 0
        n = pn[i]
        while a % n == 0:
            a //= n
            c += 1
        if not n in lcm:
            lcm[n] = 0
        lcm[n] = max(lcm[n], c)
        i += 1
    if a != 1:
        if not a in lcm:
            lcm[a] = 1
l = 1
for n in lcm.keys():
    l *= pow(n, lcm[n], mod)
    l %= mod
ans = 0
for a in A:
    p = pow(a, mod-2, mod)
    ans += (l*p)
    ans %= mod
print(ans)
### BUGGY CODE ###

mod=10**9+7
s=input()

b=int(s.replace("?","0"))%13
if b<=5:
    cal=5-b
else:
    cal=18-b
d=[0 for _ in range(13)]
p=[[i*j%13 for i in range(10)] for j in range(13)]
rev=s[::-1]
num=rev.find("?")
if num==-1:
    if cal==0:
        print(1)
    else:
        print(0)
else:
    tmp=10**num%13
    for i in p[tmp]:
        d[i]+=1
    c=rev[num+1:]
    for i,v in enumerate(c):
        #print(i+num+1)
        if v=="?":
            tmp=10**(i+num+1)%13
            t_d=[0 for _ in range(13)]
            #print("i,tmp:",i+num+1,",",tmp)
            for k in range(0,13):
                for j in range(0,10):
                    t_d[(p[tmp][j]+k)%13]+=d[k]
                #print(t_d)
            #for j in range(13):
                #d[j]=t_d[j]
            d=t_d
            #print(t_d)
    print(d[cal]%mod)
        



### FIXED CODE ###

#%%time
mod=10**9+7
s=input()


#p=[[i*j%13 for i in range(10)] for j in range(13)]
rev=reversed(s)
d=[0 for i in range(13)]
d[0]=1
keep=[0 for _ in range(13)]
mul=1
cal=0
for v in rev:
    #print(i+num+1)
    if v=="?":
        t_d=[0 for _ in range(13)]
        #print("i,tmp:",i+num+1,",",tmp)
        for k in range(0,13):
            for j in range(0,10):
                t_d[(mul*j+k)%13]+=d[k]
            t_d[k]%=mod
        d=t_d
    else:
        cal+=mul*int(v)%13
    mul*=10
    mul%=13
        #print(t_d)
cal%=13
if cal<=5:
    cal=5-cal
else:
    cal=18-cal
print(d[cal]%mod)
#print(d)
#h=d
#print([i%mod for i in h])
### BUGGY CODE ###

N = int(input())
L = list(map(int, input().split()))
L.sort()
ans = 0

for i in range(N):
    for j in range(i+1, N):
        for k in range(j+1, N):
            a = L[i]
            b = L[j]
            c = L[k]
            if (a < b + c) and (b < a + c) and (c < a + b):
                ans += 1
            else:
                break

print(ans)

### FIXED CODE ###

N = int(input())
L = list(map(int, input().split()))
L.sort()
ans = 0

from bisect import bisect_left
for i in range(N):
    for j in range(i+1, N):
        ab = L[i] + L[j]
        index = bisect_left(L, ab)
        num = index - j - 1
        ans += max(0, num)

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

import sys
input = sys.stdin.readline
h,w,m = map(int,input().rstrip().split())
hw = [list(map(int,input().rstrip().split()))for _ in range(m)]

tate = [0]*(h+1)
yoko = [0]*(w+1)
bombpoint = []

for x,y in hw:
    tate[x] += 1
    yoko[y] += 1
    bombpoint.append((x,y))

ans_x = []
ans_y = []
x_max = max(tate)
y_max = max(yoko)
for i in range(len(tate)):
    if tate[i] == x_max:
        ans_x.append(i)
for i in range(len(yoko)):
    if yoko[i] == y_max:
        ans_y.append(i)

ans = x_max + y_max
for x in ans_x:
    for y in ans_y:
        if (x,y) not in bombpoint:
            print(ans)
            exit()
print(ans - 1)

### FIXED CODE ###

import sys
input = sys.stdin.readline
h,w,m = map(int,input().rstrip().split())
hw = [list(map(int,input().rstrip().split()))for _ in range(m)]

tate = [0]*(h+1)
yoko = [0]*(w+1)
bombpoint = set()

for x,y in hw:
    tate[x] += 1
    yoko[y] += 1
    bombpoint.add((x,y))

ans_x = []
ans_y = []
x_max = max(tate)
y_max = max(yoko)
for i in range(len(tate)):
    if tate[i] == x_max:
        ans_x.append(i)
for i in range(len(yoko)):
    if yoko[i] == y_max:
        ans_y.append(i)

ans = x_max + y_max
for x in ans_x:
    for y in ans_y:
        if (x,y) not in bombpoint:
            print(ans)
            exit()
print(ans - 1)
### BUGGY CODE ###

n = int(input())

j = list(map(int, input().split()))
k = []
for i in range(1, len(j) + 1):
    k.append(sum(j[0:i]))
mi = 9999999999
for m in range(len(k)-1):
    mi = min(abs(k[n - 1] - 2 * k[m]), mi)
print(mi)

### FIXED CODE ###

n = int(input())

j = list(map(int, input().split()))
k = [j[0]]
for i in range(1, len(j)):
    k.append(k[i-1] + j[i])
mi = 9999999999
for m in range(len(k)-1):
    mi = min(abs(k[n - 1] - 2 * k[m]), mi)
print(mi)
### BUGGY CODE ###

from collections import Counter
n = int(input())
a = list(map(int, input().split()))
q = int(input())

a = Counter(a)
for _ in range(q):
    b, c = map(int, input().split())
    a[c] += a[b]
    del a[b]
    print(sum(a.elements()))


### FIXED CODE ###

from collections import Counter
n = int(input())
a = list(map(int, input().split()))
q = int(input())
total = sum(a)

a = Counter(a)
for _ in range(q):
    b, c = map(int, input().split())
    total += a[b] * c
    total -= a[b] * b
    a[c] += a[b]
    del a[b]
    print(total)
### BUGGY CODE ###

a=input().split()
N=int(a[0])
M=int(a[1])
H_list=input().split()
H_list=[int(i) for i in H_list]
path_list=[]
for i in range(M) :
  b=input().split()
  if [int(b[0]),int(b[1])] not in path_list :
    path_list.append([int(b[0]),int(b[1])])
count=0


for i in range(N) :
  flag=True

  for path in path_list :

    if not ((path[0]==i+1 and H_list[path[1]-1]<H_list[path[0]-1]) or (path[1]==i+1 and H_list[path[0]-1]<H_list[path[1]-1])) and  i+1 in path:
      flag=False
      break
  if flag :

    count+=1

print(count)


### FIXED CODE ###

a=input().split()
N=int(a[0])
M=int(a[1])
H_list=input().split()
H_list=[int(i) for i in H_list]
path_list=[]
for i in range(M) :
  b=input().split()
  path_list.append([int(b[0]),int(b[1])])
count=0


c=[]
for i in path_list :
    if H_list[i[0]-1]>H_list[i[1]-1] :
        c.append(i[1])
    elif H_list[i[0]-1]<H_list[i[1]-1]  :
        c.append(i[0])
    else :
        c.append(i[0])
        c.append(i[1])
k=list(set(c))
print(N-len(k))