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

import math
import re
T=input()
x=0
Td=T
d = len(re.sub(r'0', '', Td))
x += math.ceil((d/2+1)*d/2)
spT = T.split('0')
lenT = list(map(len, spT))

tmpX = math.ceil(d/2)
bT = 0
aT = d
tmp = ''
for i in range(len(spT) - 1):
    tmp += spT[i]
    bT += lenT[i]
    aT -= lenT[i]
    if bT % 2==1:
        bT += 1
        if aT % 2 ==1:
            tmpX += 1
        x += tmpX
        tmp += '0'
    else:
        tmp +='+'
tmp += spT[-1]

spT = tmp.split('+')
vT =[]
aT = bT
bT = 0
odT = 0
#ccT = 0
for i in range(len(spT)):
    vT.append([len(re.sub(r'0', '', spT[i][::2])), len(re.sub(r'0', '', spT[i][1::2]))])
    odT += vT[-1][0]
    #ccT += vT[-1][1]

while len(vT) >1:
    tmpIdx = len(vT)-1
    tmpL = 0
    tmpMax = -1
    for i in reversed(range(1, len(vT))):
        tmpL += vT[i][1] - vT[i][0]
        if tmpMax  < odT + tmpL:
            tmpIdx = i
            tmpMax = odT + tmpL

    for i in (range(tmpIdx, len(vT))):
        tmpVT = vT[i][1]
        vT[i][1] = vT[i][0]
        vT[i][0] = tmpVT
    odT = tmpMax
    x += odT
    vT[tmpIdx-1][0] += vT[tmpIdx][0]
    vT[tmpIdx-1][1] += vT[tmpIdx][1]
    del vT[tmpIdx]

print(x)

### FIXED CODE ###

import math
import re
T=input()
x=0
Td=T
d = len(re.sub(r'0', '', Td))
x += math.ceil((d/2+1)*d/2)
spT = T.split('0')
lenT = list(map(len, spT))

tmpX = math.ceil(d/2)
bT = 0
aT = d
tmp = ''
for i in range(len(spT) - 1):
    tmp += spT[i]
    bT += lenT[i]
    aT -= lenT[i]
    if bT % 2==1:
        bT += 1
        if aT % 2 ==1:
            tmpX += 1
        x += tmpX
        tmp += '0'
    else:
        tmp +='+'
tmp += spT[-1]

spT = tmp.split('+')
vT =[]
aT = bT
bT = 0

odT = 0
tmpOd = True

for i in range(len(spT)):
    
    od = len(re.sub(r'0', '', spT[i][0 if tmpOd else 1::2]))
    ev = len(re.sub(r'0', '', spT[i][1 if tmpOd else 0::2]))
    odT += od
    vT.append(od - ev)
    if len(spT[i]) %2 == 1:
        tmpOd = not tmpOd

for i in reversed(range(1, len(spT))):
    odT = odT - vT[i]
    x += odT
    vT[i-1] -= vT[i]


print(x)
### BUGGY CODE ###

n=int(input())
a=[]
for i in range(n):
    b=int(input())
    if b in a:
        a.remove(b)
    else:
        a.append(b)
print(len(a))


### FIXED CODE ###

n=int(input())
a=set()
for i in range(n):
    b=int(input())
    if b in a:
        a.remove(b)
    else:
        a.add(b)
print(len(a))
### BUGGY CODE ###

from collections import deque

n = int(input())
commands = [input().split() for _ in range(n)]

l = deque([])
for com in commands:
    if com[0]=='insert':
        l.appendleft(com[1])
    elif com[0]=='delete':
        try:
            l.remove(com[1])
        except:
            pass
    elif com[0]=='deleteFirst':
        l.popleft()
    elif com[0]=='deleteLast':
        l.pop()
s = ' '.join(l)
print(s)


### FIXED CODE ###

from collections import deque

n = int(input())
commands = [input() for _ in range(n)] # splitとかしてると間に合わない

l = deque()
for com in commands:
    if com[0]=='i':
        l.appendleft(com[7:])
    elif com[6]=='F':
        l.popleft()
    elif com[6]=='L':
        l.pop()
    else:
        try:
            l.remove(com[7:])
        except:
            pass

s = ' '.join(l)
print(s)
### BUGGY CODE ###

from collections import Counter
from collections import defaultdict
from collections import deque
from heapq import heapify
from heapq import heappop
from heapq import heappush


h,w,m=[int(x) for x in input().split()]

#defaultdictにすることにより後に使うmax関数のコストを削減
hcnt=defaultdict(int)
wcnt=defaultdict(int)
bomb=[]
#O(M)
for _ in range(m):
    hi,wi=[int(x)-1 for x in input().split()]
    hcnt[hi]+=1
    wcnt[wi]+=1
    bomb.append([hi,wi])

#O(M)
hmax=max(hcnt.values())
wmax=max(wcnt.values())

#O(M)
hidx=[x for x,y in hcnt.items() if y==hmax]
widx=[x for x,y in wcnt.items() if y==wmax]

#O(M**2*)
ofst=-1
for i in hidx:
    for j in widx:
        if not [i,j] in bomb:
            ofst=0
            break
                
print(hmax+wmax+ofst)

### FIXED CODE ###

from collections import Counter
from collections import defaultdict
from heapq import heapify
from heapq import heappop
from heapq import heappush
from _collections import defaultdict

h,w,m=[int(x) for x in input().split()]

hcnt=defaultdict(int)
wcnt=defaultdict(int)
bomb=set()
for _ in range(m):
    hi,wi=[int(x)-1 for x in input().split()]
    hcnt[hi]+=1
    wcnt[wi]+=1
    bomb.add((hi,wi))

hmax=max(hcnt.values())
wmax=max(wcnt.values())

hidx=[x for x,y in hcnt.items() if y==hmax]
widx=[x for x,y in wcnt.items() if y==wmax]

ofst=-1
for i in hidx:
    for j in widx:
        if not (i,j) in bomb:
            ofst=0
            break
                
print(hmax+wmax+ofst)
### BUGGY CODE ###

from fractions import gcd
N = int(input())
A = tuple(map(int,input().split(" ")))
g = A[0]
l = 1
for i in range(N):
    g = g*A[i]//gcd(A[i],g)
ans = 0
for i in range(N):
    ans += g//A[i]
    ans %= (10**9+7)
print(ans)

### FIXED CODE ###

def gcd(a,b):
    while b:a,b=b,a%b
    return a
def lcm(a,b):
    return a*b//gcd(a,b)

N = int(input())
A = tuple(map(int,input().split(" ")))
ans = 0
mod = 10**9+7
l = 1
for i in range(N):
    l = lcm(l,A[i])
l %= mod

for i in A:
    ans += l*pow(i,mod-2,mod)
    ans %= mod

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

import sys
sys.setrecursionlimit(10**7)

def cur(x):
    for i in neighbor[x]:
        if i==parent[x]: continue
        parent[i]=x
        ans[i]+=ans[x]
        cur(i)

n,q=map(int,input().split())
neighbor=[[]  for _ in range(n+1)]
parent=[-1]*(n+1)
ans=[0]*(n+1)
for _ in range(n-1):
    a,b=map(int,input().split())
    neighbor[a].append(b)
    neighbor[b].append(a)

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

cur(1)
print(" ".join(map(str,ans[1:])))

### FIXED CODE ###

n,q=map(int,input().split())
neighbor=[[]  for _ in range(n+1)]
ans=[0]*(n+1)

for _ in range(n-1):
    a,b=map(int,input().split())
    neighbor[a].append(b)
    neighbor[b].append(a)


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

visit=[True]*(n+1)
tmp=[1]
for x in tmp:
    visit[x]=False
    for y in neighbor[x]:
        if visit[y]:
            tmp.append(y)
            ans[y]+=ans[x]

print(*ans[1:])
### BUGGY CODE ###

def main():
  import numpy as np
  from scipy.sparse import csr_matrix
  from scipy.sparse.csgraph import dijkstra

  N = int(input())
  edge = np.array([input().split() for _ in range(N-1)], dtype = np.int64).T
  graph = csr_matrix((edge[2], (edge[:2] - 1)), (N, N))
  Q, K = map(int,input().split())
  XY = [list(map(int,input().split())) for _ in range(Q)]

  distance_mat_K = dijkstra(graph, directed = False, indices = K-1)

  for i in range(Q):
    print(int(distance_mat_K[XY[i][0]-1]+ distance_mat_K[XY[i][1]-1]))

if __name__ == '__main__':
    main()

### FIXED CODE ###

import sys
import numpy as np
readline = sys.stdin.readline
readlines = sys.stdin.readlines
from collections import defaultdict

N = int(input())
lines = readlines()
graph = defaultdict(list)
for line in lines[:N-1]:
  a,b,c = map(int,line.split())
  graph[a].append((b,c))
  graph[b].append((a,c))
Q, K = map(int,lines[N-1].split())
XY = np.array([line.split() for line in lines[N:]],np.int64)

def degreesOfSeparation(graph,start):
    if start not in graph:
        return -1
    visited = set()
    frontier = set()
    table = [0] * (len(graph) + 1)
    degrees = 0
    visited.add(start)
    frontier.add(start)
    while len(frontier) > 0:
        #print(frontier,":",degrees)
        #degrees += 1
        newfront = set()
        for g in frontier:
            for next in graph[g]:
                if next[0] not in visited:
                    visited.add(next[0])
                    newfront.add(next[0])
                    table[next[0]] += next[1] + table[g]
        frontier = newfront
    return table
table = degreesOfSeparation(graph,K)
for q in range(Q):
  print(table[XY[q][0]] + table[XY[q][1]])
### BUGGY CODE ###

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


# def print_list(lis):
#   for l in lis:
#     print(l)


# score[i][j][p] : Asのi番目を左端、j番目を右端とした時の最終スコア
#                  p = 0 が太郎君目線、p = 1 が次郎くん目線
score = [[[None for _ in range(2)] for _ in range(N)] for _ in range(N)]

for i in range(N):
  # 初期化
  # 区間長さ0であれば1通りしかない
  score[i][i][0] = As[i]
  score[i][i][1] = -As[i]

# print_list(score)

for k in range(1, N):
  # 配列の幅を広げながら計算を進める
  for i in range(0, N-k):
    # if k == 0:
    #   continue
    j = i + k
    if i == N - 1:
      score[i][j][0] = score[i][j-1][1] + As[j]
      score[i][j][1] = score[i][j-1][0] - As[j]
    else:
      # print(i,j)
      score[i][j][0] = max(score[i+1][j][1] + As[i], score[i][j-1][1] + As[j])
      score[i][j][1] = min(score[i+1][j][0] - As[i], score[i][j-1][0] - As[j])
    # print_list(score)

print(score[0][N-1][0])


### FIXED CODE ###

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

# Nの偶奇。区間幅がNの偶奇と一致すれば太郎君目線
oe = N % 2

# def print_list(lis):
#   for l in lis:
#     print(l)


# score[i][j][p] : Asのi番目を左端、j番目を右端とした時の最終スコア
#                  p = 0 が太郎君目線、p = 1 が次郎くん目線
score = [[None for _ in range(N)] for _ in range(N)]

for i in range(N):
  # 初期化
  # 区間長さ1であれば1通りしかない
  if oe == 1:
    score[i][i] = As[i]
  else:
    score[i][i] = -As[i]

# print_list(score)

for k in range(1, N):
  # 配列の幅を広げながら計算を進める
  for i in range(0, N-k):
    # if k == 0:
    #   continue
    j = i + k
    if i == N - 1:
      if (k + 1) % 2 == oe:
        score[i][j] = score[i][j-1] + As[j]
      else:
        score[i][j] = score[i][j-1] - As[j]
    else:
      # print(i,j)
      if (k + 1) % 2 == oe:
        score[i][j] = max(score[i+1][j] + As[i], score[i][j-1] + As[j])
      else:
        score[i][j] = min(score[i+1][j] - As[i], score[i][j-1] - As[j])
    # print_list(score)

print(score[0][N-1])
### BUGGY CODE ###

#!/usr/bin/env python

from collections import deque
import itertools as it
import sys
import math

sys.setrecursionlimit(1000000)

INF = 10 ** 18
MOD = 10 ** 9 + 7

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

m_fact = {}
def fact(n):
    if n in m_fact:
        return m_fact[n]
    if n == 1:
        m_fact[n] = 1
        return 1
    m_fact[n] = fact(n - 1) * n
    return m_fact[n]

def rev_mod(n):
    p = MOD - 2
    ret = 1
    p_cur = n
    while p > 0:
        if p % 2:
            ret *= p_cur
            ret %= MOD
        p_cur *= p_cur
        p_cur %= MOD
        p /= 2
    return ret

S = [0] * (N + 2)
S2 = [0] * (N + 2)

for i in range(1, N):
    num = (fact(N) * rev_mod(i + 1)) % MOD
    S[0] += num
    S[0] %= MOD
    S[i] -= num
    S[i] %= MOD
    S[N] -= num
    S[N] %= MOD
    S[N - i] += num
    S[N - i] %= MOD

S[0] += fact(N)
S[0] %= MOD
S[N] -= fact(N)
S[N] %= MOD

for i in range(N):
    S[i + 1] += S[i]
    S[i + 1] %= MOD

for i in range(1, N - 1):
    num = (fact(N) * rev_mod(i + 1) * rev_mod(i + 2) * 2) % MOD
    wid = min(i, N - 1 - i)
    S2[1] += num
    S2[1] %= MOD
    S2[wid + 1] -= num
    S2[wid + 1] %= MOD
    S2[N - wid] -= num
    S2[N - wid] %= MOD

for i in range(N):
    S2[i + 1] += S2[i]
    S2[i + 1] %= MOD

for i in range(N):
    S2[i + 1] += S2[i]
    S2[i + 1] %= MOD

for i in range(N):
    S[i] *= A[i]
    S[i] %= MOD
    S2[i] *= A[i]
    S2[i] %= MOD

print (sum(S[:N]) + sum(S2[:N])) % MOD

### FIXED CODE ###

#!/usr/bin/env python

from collections import deque
import itertools as it
import sys
import math

sys.setrecursionlimit(1000000)

INF = 10 ** 18
MOD = 10 ** 9 + 7

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

m_fact = {}
def fact(n):
    if n in m_fact:
        return m_fact[n]
    if n == 1:
        m_fact[n] = 1
        return 1
    m_fact[n] = (fact(n - 1) * n) % MOD
    return m_fact[n]

m_rev = {}
def rev_mod(n):
    if n in m_rev:
        return m_rev[n]
    p = MOD - 2
    ret = 1
    p_cur = n
    while p > 0:
        if p % 2:
            ret *= p_cur
            ret %= MOD
        p_cur *= p_cur
        p_cur %= MOD
        p /= 2
    m_rev[n] = ret
    return ret

S = [0] * (N + 2)
S2 = [0] * (N + 2)

for i in range(1, N):
    num = (fact(N) * rev_mod(i + 1)) % MOD
    S[0] += num
    S[0] %= MOD
    S[i] -= num
    S[i] %= MOD
    S[N] -= num
    S[N] %= MOD
    S[N - i] += num
    S[N - i] %= MOD

S[0] += fact(N)
S[0] %= MOD
S[N] -= fact(N)
S[N] %= MOD

for i in range(N):
    S[i + 1] += S[i]
    S[i + 1] %= MOD

for i in range(1, N - 1):
    num = (fact(N) * rev_mod(i + 1) * rev_mod(i + 2) * 2) % MOD
    wid = min(i, N - 1 - i)
    S2[1] += num
    S2[1] %= MOD
    S2[wid + 1] -= num
    S2[wid + 1] %= MOD
    S2[N - wid] -= num
    S2[N - wid] %= MOD

for i in range(N):
    S2[i + 1] += S2[i]
    S2[i + 1] %= MOD

for i in range(N):
    S2[i + 1] += S2[i]
    S2[i + 1] %= MOD

ans = 0
for i in range(N):
    ans += S[i] * A[i]
    ans += S2[i] * A[i]
    ans %= MOD

print ans
### BUGGY CODE ###

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

IS = lambda: int(input())
IA = lambda: [int(x) for x in input().split()]

N = IS()
A = IA()

h = N//2
ans = []
for i,_ in enumerate(range(N)):
    t = 0
    s = 1
    for j in range(h):
        t += s * (A[(i+j) % N] + A[i-1-j])
        s *= -1
    t += s * A[(i+h) % N]
    ans.append(t)
print(*ans)

### FIXED CODE ###

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

from itertools import islice

IS = lambda: int(input())
IA = lambda: [int(x) for x in input().split()]

N = IS()
A = IA()

h = N//2

a1 = 0
s = 1
for x,y in islice(zip(A, reversed(A)), h):
    a1 += s * (x + y)
    s *= -1
a1 += s * A[h]

ans = [a1]
for a in A[:-1]:
    ans.append((a - ans[-1] // 2) * 2)

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

import numpy as np

N = int(input())


for n in range(1, N + 1):
    cnt = 0
    th = int(np.sqrt(n))+1
    for x in range(1, th):
        for y in range(1, th):
            for z in range(1, th):
                if x**2 + y**2 + z**2 + x*y + y*z + z*x == n:
                    cnt += 1
    print(cnt)

### FIXED CODE ###

import numpy as np

N = int(input())
res = np.zeros(N+1)

th = int(np.sqrt(N)) + 1
for x in range(1, th):
    for y in range(1, x + 1):
        for z in range(1, y + 1):
            n = x ** 2 + y ** 2 + z ** 2 + x * y + y * z + z * x
            if n > N:
                continue
            if x == y and y == z:
                res[n] += 1
            elif x == y or y == z or z == x:
                res[n] += 3
            else:
                res[n] += 6
for i in range(1, N+1):
    print(int(res[i]))
### BUGGY CODE ###

s = [int(x) if x!='?' else -1 for x in input()]

mod = 1000000007
length = len(s)
ans = list([0]*13 for i in range(length+1))
ans[0][0] = 1

mod_x10 = [0]*13
for i in range(13):
    mod_x10[i] = i * 10 % 13 - 1

for i in range(length):
    if s[i] == -1:
        for j in range(13):
            x = mod_x10[j]
            for k in range(10):
                x = (x + 1) % 13
                ans[i+1][x] += ans[i][j] % mod
    else:
        for j in range(13):
            x = (mod_x10[j] + s[i] + 1) % 13
            ans[i+1][x] += ans[i][j] % mod

print(ans[length][5] % mod)


### FIXED CODE ###

MOD = 1000000007;

s = [int(x) if x!="?" else -1 for x in input()]

n=len(s)

r=[0]*13

c=s[0]
if (c!=-1):
	r[c]=1
else:
	for i in range(10):r[i]=1

for i in range(1,n):
	dp=[0]*26
	for j in range(13):dp[j*10%13]+=(r[j]%MOD)
	dp[13:26]=dp[0:13]
	c=s[i]
	r=[0]*13
	if (c==-1):
		w=sum(dp[4:14])
		for j in range(13):
				r[j]+=w
				w=w+dp[j+1]-dp[4+j]
	else:
		for j in range(13):
			r[j]+=dp[13-c+j]
print (r[5]%MOD)
### BUGGY CODE ###

from scipy.sparse.csgraph import dijkstra
n = int(input())
mat=[[0]*n for i in range(n)]
for i in range(n-1):
    a, b, c = map(int, input().split())
    mat[a-1][b-1]=c
    mat[b-1][a-1]=c
q, k  = map(int, input().split())
distance = dijkstra(mat, directed = False, indices = [k-1])
for i in range(q):
    x, y = map(int, input().split())
    print(int(distance[0][x-1]+distance[0][y-1]))

### FIXED CODE ###

N = int(input())
List = [[] for _ in range(N)]
ans = [-1]*N
for i in range(N-1):
    a, b, c = map(int, input().split())
    List[a-1].append((b-1, c))
    List[b-1].append((a-1, c))
Q, K = map(int, input().split())
queue = [K-1]
ans[K-1] = 0
while queue:
    edge = queue.pop()
    for node in List[edge]:
        index, cost = node
        if ans[index]>0:
            continue
        ans[index] = ans[edge]+cost
        queue.append(index)
for i in range(Q):
    x, y = map(int, input().split())
    print(ans[x-1]+ans[y-1])
### BUGGY CODE ###

def p_i():
    n = int(input())
    *p, = map(float, input().split())
    dp = [[0] * (n + 1) for _ in range(n + 1)]
    dp[0][0] = 1

    for i in range(n):
        for j in range(n):
            dp[i + 1][j + 1] += dp[i][j] * p[i]
            dp[i + 1][j] += dp[i][j] * (1 - p[i])

    print(sum(dp[-1][(n + 1) // 2:]))


if __name__ == '__main__':
    p_i()


### FIXED CODE ###

def p_i():
    n = int(input())
    *p, = map(float, input().split())
    dp = [[0] * (n + 1) for _ in range(n + 1)]
    dp[0][0] = 1

    for i in range(n):
        for j in range(n):
            dp[i + 1][j + 1] += dp[i][j] * p[i]
            dp[i + 1][j] += dp[i][j] * (1 - p[i])

    print(sum(dp[-1][(n + 1) // 2:]))


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

import numpy as np
import sys, math
from itertools import permutations, combinations
from collections import defaultdict, Counter, deque
from math import factorial, gcd
from bisect import bisect_left #bisect_left(list, value)
sys.setrecursionlimit(10**7)
enu = enumerate
MOD = 10**9+7
def input(): return sys.stdin.readline()[:-1]
pl = lambda x: print(*x, sep='\n')

N = int(input())
AB = [list(map(int, input().split())) for _ in range(N)]
# AB = np.array([np.array(input().split(), np.int)
AB = np.array(AB)
# tAB = list(zip(*AB))
# print(AB)
tAB = AB.T
# print(tAB)
# print()
A = tAB[0]
B = tAB[1]
A.sort()
B.sort()

# print(A, B)

if N%2 == 0:
    midA1 = A[N//2-1]
    midA2 = A[N//2]
    midB1 = B[N//2-1]
    midB2 = B[N//2]
    d = defaultdict(int)
    for val1 in range(midA1, midB1+1):
        for val2 in range(midA2, midB2+1):
            val = (val1 + val2)/2
            d[val] += 1
    print(len(d.keys()))
    
else:
    midA = A[N//2]
    midB = B[N//2]
    print(midB-midA+1)

### FIXED CODE ###

import numpy as np
import sys, math
from itertools import permutations, combinations
from collections import defaultdict, Counter, deque
from math import factorial, gcd
from bisect import bisect_left #bisect_left(list, value)
sys.setrecursionlimit(10**7)
enu = enumerate
MOD = 10**9+7
def input(): return sys.stdin.readline()[:-1]
pl = lambda x: print(*x, sep='\n')

N = int(input())
AB = [list(map(int, input().split())) for _ in range(N)]
# AB = np.array([np.array(input().split(), np.int)
AB = np.array(AB)
# tAB = list(zip(*AB))
# print(AB)
tAB = AB.T
# print(tAB)
# print()
A = tAB[0]
B = tAB[1]
A.sort()
B.sort()

# print(A, B)

if N%2 == 0:
    midA1 = A[N//2-1]
    midA2 = A[N//2]
    midB1 = B[N//2-1]
    midB2 = B[N//2]

    midmidA = (midA1+midA2)/2
    midmidB = (midB1+midB2)/2
    res = int((midmidB-midmidA)/(0.5) + 1)
    print(res)

    # d = defaultdict(int)

    # for val1 in range(midA1, midB1+1):
    #     for val2 in range(midA2, midB2+1):
    #         val = (val1 + val2)/2
            # d[val] += 1
    # print(len(d.keys()))
    
else:
    midA = A[N//2]
    midB = B[N//2]
    print(midB-midA+1)
### BUGGY CODE ###



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

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

ans = set([i for i in range(n)])


for i in range(m):
    a, b = map(int,input().split())
    a -= 1; b -= 1
    if h[a] <= h[b]:
        # table[h[a]][h[b]] = 0
        ans = ans - {a}
    if h[b] <= h[a]:
        ans = ans - {b}

print(len(ans))


### FIXED CODE ###



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

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

# a = [0] * m
# b = [0] * m

ma = [0]*n


for i in range(m):
    a, b = map(int,input().split())
    a -= 1; b -= 1
    ma[a] = max(ma[a],h[b])
    ma[b] = max(ma[b],h[a])

ans = 0    
for i in range(n):
    if h[i] > ma[i]:
        ans += 1
        

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

n=int(input())
a=list(map(int,input().split()))
ans=[]
for i in range(1,n+1):
  ans.append(a.index(i)+1)
  
print(' '.join(map(str,ans)))
  

### FIXED CODE ###

n=int(input())
a=list(map(int,input().split()))
ans={}
for i in range(1,n+1):
  ans[a[i-1]]=i
s=list(ans.keys())
s.sort()
for i in s:
  print(ans[i],end=' ')
  
print()
### BUGGY CODE ###

import sys


def input():
    return sys.stdin.readline().strip()


def main():
    N = int(input())
    S = list(input())
    ans = 0

    for p in range(1000):
        p = str(p).zfill(3)
        i = 0
        for j in range(N):
            if p[i] == S[j]:
                i += 1
            if i == 3:
                ans += 1
                break

    print(ans)


if __name__ == "__main__":
    main()


### FIXED CODE ###

import sys


def input():
    return sys.stdin.readline().strip()


def main():
    N = int(input())
    S = list(input())
    ans = 0

    for p in range(1000):
        p = str(p).zfill(3)
        i = 0
        for j in range(N):
            if p[i] == S[j]:
                i += 1
            if i == 3:
                ans += 1
                break

    print(ans)


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

n=int(input())
a=list(map(int,input().split()))
q=int(input())
bc=[list(map(int,input().split())) for i in range(q)]

for j in range(q):
  for n, i in enumerate(a):
    if i==bc[j][0]:
      a[n]=bc[j][1]
  print(sum(a))

### FIXED CODE ###

n=int(input())
a=list(map(int,input().split()))
q=int(input())
bc=[list(map(int,input().split())) for i in range(q)]

asum=sum(a) #当初の数列Aの要素の和
d={}

for i in a:
  if i in d:
    d[i]+=1
  else:
    d[i]=1

for b,c in bc:
  if b in d:
    asum+=d[b]*(c-b)
    if c in d:
      d[c]+=d[b]
    else:
      d[c]=d[b]
    d[b]=0
  print(asum)
### BUGGY CODE ###

i = 0
x =input()
while x != 0:
 i += i+1
 print("Case {}: {}".format(i,x))



### FIXED CODE ###

i = 1
while True:
 x =int(input())
 if x == 0:
  break
 print("Case {}: {}".format(i,x))
 i = i+1
### BUGGY CODE ###

n=int(input())
s=list(input())

pin=set()
for i in range(0,1000):
    yn=""
    stri=format(i,"03d")
    for ii in range(n-2):
        if stri[0]!=s[ii]:
            continue
        else:
            yn="yes1"
            break
    if yn!="yes1":
        yn="no"
        continue
    for iii in range(ii+1,n-1):
        if stri[1]!=s[iii]:
            continue
        else:
            yn="yes2"
            break
    if yn!="yes2":
        yn="no"
        continue
    for iiii in range(iii+1,n):
        if stri[2]!=s[iiii]:
            continue
        else:
            yn="yes3"
            break
    if yn=="yes3":
        pin.add(stri)
    else:
        continue

print(len(pin))        
    

### FIXED CODE ###

n=int(input())
s=list(input())

pin=set()
for i in range(0,1000):
    yn=""
    stri=format(i,"03d")
    for ii in range(n-2):
        if stri[0]!=s[ii]:
            continue
        else:
            yn="yes1"
            break
    if yn!="yes1":
        yn="no"
        continue
    for iii in range(ii+1,n-1):
        if stri[1]!=s[iii]:
            continue
        else:
            yn="yes2"
            break
    if yn!="yes2":
        yn="no"
        continue
    for iiii in range(iii+1,n):
        if stri[2]!=s[iiii]:
            continue
        else:
            yn="yes3"
            break
    if yn=="yes3":
        pin.add(stri)
    else:
        continue

print(len(pin))