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

#!/usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys, random, itertools, math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def II(): return int(input())
def IF(): return float(input())
def S(): return input().rstrip()
def LS(): return S().split()
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = 1e10

#solve
def solve():
    n = II()
    print(0)
    s = S()
    if s == "Vacant":
        return
    x = s
    ok = 0
    ng = n
    while 1:
        mid = (ok + ng) // 2
        print(mid,flush = True)
        s = S()
        if s == "Vacant":
            return
        if mid & 1 == ok & 1:
            if s == x:
                ok = mid
            else:
                ng = mid
        else:
            if s == x:
                ng = mid
            else:
                ok = mid

    return


#main
if __name__ == '__main__':
    solve()


### FIXED CODE ###

#!/usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys, random, itertools, math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def II(): return int(input())
def IF(): return float(input())
def S(): return input().rstrip()
def LS(): return S().split()
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = 1e10

#solve
def solve():
    n = II()
    print(0,flush = True)
    s = S()
    if s == "Vacant":
        return
    x = s
    ok = 0
    ng = n
    while 1:
        mid = (ok + ng) // 2
        print(mid, flush=True)
        s = S()
        if s == "Vacant":
            return
        if mid & 1 == ok & 1:
            if s == x:
                ok = mid
            else:
                ng = mid
        else:
            if s == x:
                ng = mid
            else:
                ok = mid
                x = s

    return


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

n = int(input())
l = list(map(int, input().split()))
l = sorted(l)
res = 0
for i in range(n):
    for j in range(i+1, n, 1):
        a = l[i]
        b = l[j]
        ab = a + b
        f = 0
        for k in range(j+1, n, 1):
            if l[k] < ab:
                res += 1
                f = 1
            else:
                break
        if f == 0:
            continue
print(res)

### FIXED CODE ###

from bisect import bisect_left
n = int(input())
l = list(map(int, input().split()))
l = sorted(l)
res = 0
for i in range(n):
    for j in range(i+1,n):
        ab = l[i] + l[j]
        c_index = bisect_left(l, ab)
        res += c_index - j - 1
print(res)
### BUGGY CODE ###

n, q = map(int, input().split())
s = input()
l = [list(map(int, input().split())) for _ in range(q)]

for i in range(q):
    st = l[i][0]-1
    en = l[i][1]
    print(s[st:en].count('AC'))



### FIXED CODE ###

n, q = map(int, input().split())
s = input()
ll = list(list(map(int, input().split())) for _ in range(q))

acl = [0] * n
cnt = 0
for i in range(1, n):
    if s[i-1:i+1] == 'AC':
        cnt += 1
    acl[i] = cnt

for i in range(q):
    l = ll[i][0]
    r = ll[i][1]
    print(acl[r-1] - acl[l-1])
### BUGGY CODE ###

S = str(input())
N = len(S) + 1
l = [-1] * N
if S[0] == '<':
  l[0] = 0
else:
  i = 0
  while i <= N-2:
    if S[i] == '>':
      i += 1
    else:
      break
  l[0] = i
  
if S[-1] == '>':
  l[-1] = 0
else:
  i = N-2
  cnt = 0
  while i >= 0:
    if S[i] == '<':
      i -= 1
      cnt += 1
    else:
      break
  l[-1] = cnt
  
for i in range(N-2):
  if (S[i]=='>') and (S[i+1]=='<'):
    l[i+1] = 0
  else:
    left = 0
    right = 0
    c1 = i
    c2 = i+1
    while c1 >= 0:
      if S[c1] == '<':
        left += 1
        c1 -= 1
      else:
        break
    while c2 <= N-2:
      if S[c2] == '>':
        right += 1
        c2 += 1
      else:
        break
    num = max(left, right)
    l[i+1] = num
ans = sum(l)
print(ans)

### FIXED CODE ###

s = input()
num = len(s)
a = [0]*(num+1)

for i in range(num):
    if s[i] == '<':
        a[i+1] = max(a[i+1], a[i]+1)

for i in range(1, num+1):
    if s[-i] == '>':
        a[-(i+1)] = max(a[-(i+1)], a[-i]+1)
print(sum(a))
### BUGGY CODE ###


N=int(input())
S=list(input())


def csum(lis):
      counter=[]

      for i,l in enumerate(lis):
          counter.append(lis[i+1:].count('E') + lis[:i].count('W'))

      return min(counter)

print(csum(S))


### FIXED CODE ###

def myAnswer(N:int,S:list) -> int:
   rightW = S.count("W")
   rightE = N - rightW
   leftW = 0
   leftE = 0
   ans = 10**10
   for s in S:
      if(s == "W"):
         rightW -= 1
         ans = min(ans,rightE + leftW)
         leftW += 1
      else:
         rightE -= 1
         ans = min(ans,rightE + leftW)
         leftE += 1
   return ans

def modelAnswer():
   return
def main():
   N = int(input())
   S = list(input())
   print(myAnswer(N,S))
if __name__ == '__main__':
   main()
### BUGGY CODE ###

def main():
    s, t = input(), input()
    v = [('', False) for i in range(len(t) + 1)]
    for i in range(1, len(s) + 1):
        w = [('', False) for _ in range(len(t) + 1)]
        for j in range(1, len(t) + 1):
            u, uu = v[j]
            l, ll = w[j - 1]
            d, dd = v[j - 1]
            if s[i - 1] == t[j - 1]:
                if len(u) > len(l) and not uu:
                    l, ll = u, uu 
                if len(l) > len(d) and not ll:
                    d, dd = l, ll
                w[j] = (d + s[i - 1], True)
            else:
                if len(u) > len(l):
                    l, ll = u, uu
                dd = False
                if len(l) > len(d):
                    d, dd = l, ll
                w[j] = (d, dd)
        v = w
    print(v[-1][0])


main()


### FIXED CODE ###

def main():
    s = input()
    t = input()
    v = [0] * (len(t) + 1)
    dp = [v]
    for i, si in enumerate(s, 1):
        u, v = v, v.copy()
        dp.append(v)
        ll, ul = 0, 0
        for j, ti in enumerate(t, 1):
            uu = u[j]
            if si == ti:
                v[j] = ll = ul + 1
            else:
                if ll > uu:
                    v[j] = ll
                else:
                    ll = uu
            ul = uu
    k = dp[i][j]
    r = ''
    while k:
        if dp[i - 1][j] == k:
            i -= 1
        elif dp[i][j - 1] == k:
            j -= 1
        else:
            k -= 1
            i -= 1
            j -= 1
            r += s[i]
    print(r[::-1])

main()
### BUGGY CODE ###

#読み込み
list_num = input().split(" ") #A,B,M
list_ref = input().split(" ") #冷蔵庫の値段
list_ren = input().split(" ") #レンジの値段
list2 = [] #割引できるやつの組み
for i in range(int(list_num[2])):
    list_c = input().split(" ")
    list2.append(list_c)
A = int(list_num[0])
B = int(list_num[1])
M = int(list_num[2])

#割引なしで総当たり
list_price = []
for i in range(A):
    for j in range(B):
        list_price.append(int(list_ref[i]) + int(list_ren[j]))

#割引きを総当たり
for k in range(M):
    price = int(list_ref[int(list2[k][0])-1]) + int(list_ren[int(list2[k][1])-1]) - int(int(list2[k][2])-1) - 1
    list_price.append(price)


print(min(list_price))

### FIXED CODE ###

#読み込み
list_num = input().split(" ") #A,B,M
list_ref = input().split(" ") #冷蔵庫の値段
list_ren = input().split(" ") #レンジの値段
list2 = [] #割引できるやつの組み
for i in range(int(list_num[2])):
    list_c = input().split(" ")
    list2.append(list_c)
A = int(list_num[0])
B = int(list_num[1])
M = int(list_num[2])

list_price = []

#一番安いのと一番安いの
list_ref_int = [int(s) for s in list_ref]
list_ren_int = [int(s) for s in list_ren]
cheap = min(list_ref_int) + min(list_ren_int)
list_price.append(cheap)

#割引きを総当たり
for k in range(M):
    price = list_ref_int[int(list2[k][0])-1] + list_ren_int[int(list2[k][1])-1] - int(int(list2[k][2])-1) - 1
    list_price.append(price)

print(min(list_price))
### BUGGY CODE ###

def xgcd(a, b):
    x0, y0, x1, y1 = 1, 0, 0, 1
    while b != 0:
        q, a, b = a // b, b, a % b
        x0, x1 = x1, x0 - q * x1
        y0, y1 = y1, y0 - q * y1
    return a, x0, y0
def modinv(a, m):
    g, x, y = xgcd(a, m)
    if g != 1:
        raise Exception('modular inverse does not exist')
    else:
        return x % m
def main():
    s=list(input())
    mod=10**9+7
    K=modinv(10,13)
    U=[[0 for i in range(10) ]for k in range(13)]
    for i in range(13):
        for j in range(10):
            U[i][j]=((i-j)*K)%13

    dp=[[0 for k in range(13)] for i in range(len(s))]
    #dp[i][j]=初めのindex=i番目まで見たときに、あまりがjになるような方法の総数
    num=s[0]
    if s[0]=="?":
        for i in range(10):
            dp[0][i]=1
    else:
        number=int(s[0])
        dp[0][number]=1

    for i in range(1,len(s)):
        if s[i]=="?":
            for k in range(13):
                for j in range(10):
                    dp[i][k]+=dp[i-1][U[k][j]]
            dp[i][k]=dp[i][k]%mod
        else:
            number=int(s[i])
            for k in range(13):
                dp[i][k]=dp[i-1][U[k][number]]%mod
    print(dp[len(s)-1][5]%mod)
if __name__ == "__main__":
    main()

### FIXED CODE ###

def xgcd(a, b):
    x0, y0, x1, y1 = 1, 0, 0, 1
    while b != 0:
        q, a, b = a // b, b, a % b
        x0, x1 = x1, x0 - q * x1
        y0, y1 = y1, y0 - q * y1
    return a, x0, y0
def modinv(a, m):
    g, x, y = xgcd(a, m)
    return x % m
def main():
    s=list(input())
    mod=10**9+7
    K=modinv(10,13)
    U=[[0 for i in range(10) ]for k in range(13)]
    for i in range(13):
        for j in range(10):
            U[i][j]=((i-j)*K)%13

    dp=[[0 for k in range(13)] for i in range(len(s))]
    #dp[i][j]=初めのindex=i番目まで見たときに、あまりがjになるような方法の総数
    num=s[0]
    if s[0]=="?":
        for i in range(10):
            dp[0][i]=1
    else:
        number=int(s[0])
        dp[0][number]=1

    for i in range(1,len(s)):
        for k in range(13):
            if s[i]=="?":
                for j in range(10):
                    dp[i][k]+=dp[i-1][U[k][j]]%mod
            else:
                number=int(s[i])
                dp[i][k]=dp[i-1][U[k][number]]%mod
    print(dp[len(s)-1][5]%mod)
if __name__ == "__main__":
    main()
### BUGGY CODE ###

import sys
sys.setrecursionlimit(300000)
from fractions import gcd
from collections import defaultdict

def I(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LMI(): return list(map(int, sys.stdin.readline().split()))
MOD = 10 ** 9 + 7
INF = float('inf')


N = I()
d = defaultdict(int)
zero = 0
for i in range(N):
    a, b = MI()
    if a == 0 and b == 0:
        zero += 1
        continue
    g = gcd(a, b)
    a, b = a // g, b // g
    minus = (-1) ** ((a < 0) + (b < 0))
    d[(minus * abs(a), abs(b))] += 1

ans = 1
seen = set()
for a, b in d:
    if (a, b) not in seen:
        if (a, b) in [(1, 0), (0, 1)]:
            ainv, binv = b, a
        else:
            ainv, binv = b * (1 if a < 0 else -1), abs(a)
        lans = (2 ** d[(a, b)] - 1)
        lans += (2 ** d[(ainv, binv)] - 1) if d.get((ainv, binv)) is not None else 0
        lans += 1
        ans = ans * lans % MOD
        seen.add((a, b))
        seen.add((ainv, binv))
ans = (ans + zero) % MOD
print((ans + MOD - 1) % MOD)


### FIXED CODE ###

import sys
sys.setrecursionlimit(300000)
from fractions import gcd
from collections import defaultdict

def I(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LMI(): return list(map(int, sys.stdin.readline().split()))
MOD = 10 ** 9 + 7
INF = float('inf')


N = I()
d = defaultdict(int)
zero = 0
for i in range(N):
    a, b = MI()
    if a == 0 and b == 0:
        zero += 1
        continue
    g = gcd(a, b)
    a, b = a // g, b // g
    minus = (-1) ** ((a < 0) + (b < 0))
    d[(minus * abs(a), abs(b))] += 1

ans = 1
seen = set()
for a, b in d:
    if (a, b) not in seen:
        if (a, b) in [(1, 0), (0, 1)]:
            ainv, binv = b, a
        else:
            ainv, binv = b * (1 if a < 0 else -1), abs(a)
        lans = (2 ** d[(a, b)] - 1)
        lans += (2 ** d[(ainv, binv)] - 1) if d.get((ainv, binv)) is not None else 0
        lans += 1
        ans = ans * lans % MOD
        seen.add((a, b))
        seen.add((ainv, binv))
ans = (ans + zero) % MOD
print((ans + MOD - 1) % MOD)
### BUGGY CODE ###

n, k = [int(i) for i in input().split()]

def a(x):
    return abs(x - k)

if n > k:
    tmp = k 
    while not (n - tmp) % k == 0:
        tmp -= 1
    n = tmp

while True:
    tmp = n
    n = a(n)
    if tmp < n:
        print(tmp)
        break


### FIXED CODE ###

n, k = [int(i) for i in input().split()]
print(min(n % k, k - n % k))
### BUGGY CODE ###

from math import ceil

r, g, b, n = map(int, input().split())
cnt = 0
for i in range(ceil(n / r) + 1):
    for j in range(ceil(n / g) + 1):
        if i * r + j * g > n:
            break
        if i * r + j * g == n:
            cnt += 1
            continue
        else:
            tmp = n - (i * r + j * g)
            if tmp % b == 0:
                cnt += 1
print(cnt)


### FIXED CODE ###

from math import ceil

r, g, b, n = map(int, input().split())
cnt = 0
for i in range(ceil(n / r) + 1):
    for j in range(ceil(n / g) + 1):
        if i * r + j * g > n:
            break
        if i * r + j * g == n:
            cnt += 1
            continue
        else:
            tmp = n - (i * r + j * g)
            if tmp % b == 0:
                cnt += 1
print(cnt)
### BUGGY CODE ###

N,Q = map(int,input().split())
S = input()
rui_count = []
count = []
for i in range(N):
    rui_count.append(S[0:i+1].count('AC'))
for i in range(Q):
    l,r = map(int,input().split())
    count.append(rui_count[r-1]-rui_count[l-1])
    
for i in count:
    print(i)

### FIXED CODE ###

N,Q = map(int,input().split())
S = input()
lr = [list(map(int,input().split()))for i in range(Q)]
rui_count = []
AC_k = S.find('AC')
if AC_k == -1:
    for i in range(Q):
        print(0)
    exit()
for i in range(N):
    if AC_k+1 > i:
        if i == 0:
            rui_count.append(0)
        else:
            rui_count.append(rui_count[i-1])
        continue
    AC_k = S[i:N].find('AC')
    if AC_k == -1:
        rui_count += [rui_count[i-1]+1 for j in range(i,N)]
        break
    AC_k += i
    rui_count.append(rui_count[i-1]+1)
count = []
for i in lr:
    count.append(rui_count[i[1]-1]-rui_count[i[0]-1])
for i in count:
    print(i)
### BUGGY CODE ###

h, n = map(int, input().split())
monster = [[0, 0] for i in range(n)]

for i in range(n):
  a, b = map(int, input().split())
  monster[i][0], monster[i][1] = a, b

dps = [0 for i in range(h + 1)]
for i in range(1, h + 1):
  ans = 10 ** 10
  for m in monster:
    ans = min(ans, dps[max(i - m[0], 0)] + m[1])
  dps[i] = ans

print(dps[h])

### FIXED CODE ###

h, n = map(int, input().split())
monster = [[0, 0] for i in range(n)]
 
for i in range(n):
  a, b = map(int, input().split())
  monster[i][0], monster[i][1] = a, b

dps = [0 for i in range(h + 1)]
for i in range(1, h + 1):
  ans = 10 ** 10
  for m in monster:
    ans = min(ans, dps[max(i - m[0], 0)] + m[1])
  dps[i] = ans

print(dps[h])
### BUGGY CODE ###

N = int(input())
b = [int(x) for x in input().split()]

def solve(b):
    if len(b) == 0:
        return []
    for i in range(len(b)):
        if b[i] == i+1:
            a = solve(b[:i] + b[i+1:])
            if a != None:
                return [i+1] + a
    return None

a = solve(b)
if a == None:
    print(-1)
else:
    a.reverse()
    print('\n'.join(map(str, a)))

### FIXED CODE ###

N = int(input())
b = [int(x) for x in input().split()]

def solve(b):
    if len(b) == 0:
        return []
    if any(i+1 < b[i] for i in range(len(b))):
        return None
    erasable = [i+1 for i in range(len(b)) if i+1 == b[i]]
    if len(erasable) == 0:
        return None
    i = erasable[-1]  # 一番右から消す
    a = solve(b[:i-1] + b[i:])
    if a != None:
        return [i] + a
    return None

a = solve(b)
if a == None:
    print(-1)
else:
    a.reverse()
    print('\n'.join(map(str, a)))
### BUGGY CODE ###

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

infants = [[i, A[i]] for i in range(N)]
infants.sort(key=lambda x:x[1], reverse=True)

dp = [[0 for _ in range(N+1)] for _ in range(N+1)]

for x in range(N):
    for y in range(N-x):
        pos, infant = infants[x+y]
        dp[x][y+1] = max(dp[x][y+1], dp[x][y]+infant*abs(N-1-y-pos))
        dp[x+1][y] = max(dp[x+1][y], dp[x][y]+infant*abs(pos-x))

ans = 0
for i in range(N):
    ans = max(ans, dp[i][N-i])
print(ans)

### FIXED CODE ###

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

infants = [[i, A[i]] for i in range(N)]
infants.sort(key=lambda x:x[1], reverse=True)

dp = [[0 for _ in range(N+1)] for _ in range(N+1)]

for x in range(N):
    for y in range(N-x):
        pos, infant = infants[x+y]
        dp[x][y+1] = max(dp[x][y+1], dp[x][y]+infant*abs(N-1-y-pos))
        dp[x+1][y] = max(dp[x+1][y], dp[x][y]+infant*abs(pos-x))

ans = 0
for i in range(N):
    ans = max(ans, dp[i][N-i])
print(ans)
### BUGGY CODE ###

INF = float('inf')
class BellmanFord:
    
    def bellmanford(self,s,V,E):
        dist = [INF for _ in range(V)]
        dist[s] = 0
        while (True):
            update = False
            for e in E:
                u,v,cost = e
                if dist[u] != INF and dist[v] > dist[u] + cost:
                    dist[v] = dist[u]+cost
                    update = True
            if not update:break
        return dist

    def findneg(self,V,E):
        dist = [0 for _ in range(V)]
        for i in range(V):
            for e in E:
                u,v,cost = e
                if dist[u] != INF and dist[v] > dist[u] + cost:
                    dist[v] = dist[u]+cost
                    if i == V-1 and (v == V-1 or u == V-1):return True

def main():
    N,M = map(int,input().split())
    E = []
    for _ in range(M):
        a,b,c = map(int,input().split())
        a -= 1
        b -= 1
        E.append((a,b,-c))
    bf = BellmanFord()
    if bf.findneg(N,E):
        print('inf')
    else:
        ans = bf.bellmanford(0,N,E)
        print(-ans[-1])

if __name__ == "__main__":
    main()


### FIXED CODE ###

INF = float('inf')
class BellmanFord:
    
    def bellmanford(self,s,V,E):
        dist = [INF for _ in range(V)]
        dist[s] = 0
        for i in range(V):
            for e in E:
                u,v,cost = e
                if dist[u] != INF and dist[v] > dist[u] + cost:
                    dist[v] = dist[u]+cost
                    if i == V-1 and v == V-1:
                        return -1
        return dist
    

def main():
    N,M = map(int,input().split())
    E = []
    for _ in range(M):
        a,b,c = map(int,input().split())
        a -= 1
        b -= 1
        E.append((a,b,-c))
    bf = BellmanFord()
    dist = bf.bellmanford(0,N,E)
    if dist == -1:
        print('inf')
    else:
        ans = dist[-1]
        print(-ans)

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

n = int(input())


def main(n):
    pre = 1
    for i in range(1, n):
        pre = pre * i
    return pre * n % (pow(10, 9) + 7)


ans = main(n)
print(ans)


### FIXED CODE ###

n = int(input())


mod_num = pow(10, 9) + 7


def main(n):
    pre = 1
    for i in range(2, n + 1):
        pre = pre * i % mod_num
    return pre


ans = main(n)
print(ans)
### BUGGY CODE ###

import sys
import numpy as np
import math
import collections
import copy
from collections import deque 
from functools import reduce
from itertools import product
from itertools import combinations

# input = sys.stdin.readline
N = int(input())
Cn = list(input())
Cc = copy.copy(Cn)
if (Cn[0] == "R"):
    Rflg = True
else:
    Rflg = False
ans = 0
K = N-1    
for i in range(N):
    if Rflg and Cc[i] == "R":
        continue
    else:
        Rflg = True
    if Cc[i] == "W":
        for j in range(K, i, -1):
            if Cc[j] == "R":
#                 print("change")
                ans += 1
                Cc[i], Cc[j] = Cc[j], Cc[i]
                K = j
#                 print(Cc)
                break
    else:
#         print("replace")
        ans += 1
        Cc[i] = "W"
#         print(Cc)
print(ans)


















### FIXED CODE ###

import sys
import numpy as np
import math
import collections
import copy
from collections import deque 
from functools import reduce
from itertools import product
from itertools import combinations

# input = sys.stdin.readline
N = int(input())
Cn = list(input())

Cc = copy.copy(Cn)
if (Cn[0] == "R"):
    Rflg = True
else:
    Rflg = False
ans = 0
K = N-1    
allw = False
for i in range(N):
    if Rflg and Cc[i] == "R":
        continue
    else:
        Rflg = True
    if Cc[i] == "W":
        for j in range(K, i, -1):
            if Cc[j] == "R":
#                 print("change")
                ans += 1
                Cc[i], Cc[j] = Cc[j], Cc[i]
                K = j
#                 print(Cc)
                break
        else:
            allw = True

    else:
#         print("replace")
        ans += 1
        Cc[i] = "W"
#         print(Cc)
    if allw:
        break

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

# -*- coding: utf-8 -*-

# import itertools

num = int(input())

# 実は[5,1,2,3,4]のようにずらしたのが一番でかくなるのでは？
# ということは1～4までの和がそのまま返り値になる
rtn = 0
for v in range(num)[1:]:
  rtn += v

print(rtn)


# 実は[5,1,2,3,4]のようにずらしたのが一番でかくなるのでは？
# これはすなおにそのリストを作っている
# tgt_list = list(range(num+1))[1:-1]
# tgt_list.insert(0, num) # [1,2,3,4] -> [4,1,2,3]
# print(tgt_list)
# ここからModを計算...
# 

# 下記は全通りを調べるが、処理が長すぎてエラーになるのでボツ。
# for v_list in itertools.permutations(range(num+1)[1:]):
#   tmp = 0
#   for i, v in enumerate(v_list):
#     tmp += v % (i+1)
#   rtn = max(rtn, tmp)
#   if (rtn == tmp):
#     print(v_list)
#     print(tmp)   
# print(rtn)

### FIXED CODE ###

# -*- coding: utf-8 -*-

# import itertools

num = int(input())

# イテレーションせずに求めます
rtn = num * (num-1) //2
print(int(rtn))
### BUGGY CODE ###

def main():
  import sys
  input = sys.stdin.readline

  n,m = map(int, input().split())
  heights = tuple(map(int, input().split()))

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

  sum = 0
  for i in range(n):
    tallest = True
    for road in roads:
      if i+1 in road:
        if road.index(i+1) == 0:
          to = road[1]
        else:
          to = road[0]
        if heights[i] <= heights[to-1]:
          tallest = False
          break
    if tallest:
      sum += 1

  print(sum)

if __name__ == '__main__':
  main()

### FIXED CODE ###

import sys
input = sys.stdin.readline

def main():
  n,m = map(int, input().split())
  heights = tuple(map(int, input().split()))

  roads = [tuple(map(int, input().split())) for _ in range(m)]
  max_heights = [0 for _ in range(n)]

  for i in range(m):
    build_1 = roads[i][0]-1
    build_2 = roads[i][1]-1
    if heights[build_2] > max_heights[build_1]:
      max_heights[build_1] = heights[build_2]
    if heights[build_1] > max_heights[build_2]:
      max_heights[build_2] = heights[build_1]

  sum = 0
  for i in range(n):
    if heights[i] > max_heights[i]:
      sum += 1
  print(sum)

if __name__ == '__main__':
  main()