Harryxun/stf_run huggingface dataset:
S = input()
L = len(S)
Q = 10**9 + 7
anum = [ 0 for _ in range(L+1)]
#bnum = [ 0 for _ in range(L+1)]
cnum = [ 0 for _ in range(L+1)]
hnum = [ 0 for _ in range(L+1)]
for i in range(1,L+1):
    if S[i-1] == 'A':
        anum[i] = anum[i-1] + 1
#        bnum[i] = bnum[i-1]
        cnum[i] = cnum[i-1]
        hnum[i] = hnum[i-1]
    elif S[i-1] == 'B':
        anum[i] = anum[i-1]
#        bnum[i] = bnum[i-1] + 1
        cnum[i] = cnum[i-1]
        hnum[i] = hnum[i-1]
    elif S[i-1] == 'C':
        anum[i] = anum[i-1]
#        bnum[i] = bnum[i-1]
        cnum[i] = cnum[i-1] + 1
        hnum[i] = hnum[i-1]
    else:
        anum[i] = anum[i-1]
#        bnum[i] = bnum[i-1]
        cnum[i] = cnum[i-1]
        hnum[i] = hnum[i-1] + 1

ans = 0
czen = cnum[L]
hzen = hnum[L] 
for i in range(1,L+1):
    if S[i-1] == 'B' or S[i-1] == '?':
#        A = ((anum[i-1]*(3**hnum[i-1]))%Q + (hnum[i-1]*(3**(hnum[i-1]-1)))%Q)%Q
#        C = (((czen - cnum[i])*(3**(hzen - hnum[i])))%Q + ((hzen - hnum[i])*(3**(hzen - hnum[i]-1)))%Q)%
        A = ((anum[i-1]*pow(3,hnum[i-1],Q))%Q + (hnum[i-1]*pow(3,hnum[i-1]-1,Q))%Q)%Q
        C = (((czen - cnum[i])*pow(3,hzen - hnum[i],Q))%Q + ((hzen - hnum[i])*pow(3,hzen - hnum[i]-1,Q))%Q)%Q
        K = (A*C)%Q
        ans = (ans + K)%Q
print(int(ans))

### FIXED CODE ###

S = input()
L = len(S)
Q = 10**9 + 7
anum = [ 0 for _ in range(L+1)]
#bnum = [ 0 for _ in range(L+1)]
cnum = [ 0 for _ in range(L+1)]
hnum = [ 0 for _ in range(L+1)]
for i in range(1,L+1):
    if S[i-1] == 'A':
        anum[i] = anum[i-1] + 1
#        bnum[i] = bnum[i-1]
        cnum[i] = cnum[i-1]
        hnum[i] = hnum[i-1]
    elif S[i-1] == 'B':
        anum[i] = anum[i-1]
#        bnum[i] = bnum[i-1] + 1
        cnum[i] = cnum[i-1]
        hnum[i] = hnum[i-1]
    elif S[i-1] == 'C':
        anum[i] = anum[i-1]
#        bnum[i] = bnum[i-1]
        cnum[i] = cnum[i-1] + 1
        hnum[i] = hnum[i-1]
    else:
        anum[i] = anum[i-1]
#        bnum[i] = bnum[i-1]
        cnum[i] = cnum[i-1]
        hnum[i] = hnum[i-1] + 1

ans = 0
czen = cnum[L]
hzen = hnum[L] 
for i in range(1,L+1):
    if S[i-1] == 'B' or S[i-1] == '?':
#        A = ((anum[i-1]*(3**hnum[i-1]))%Q + (hnum[i-1]*(3**(hnum[i-1]-1)))%Q)%Q
#        C = (((czen - cnum[i])*(3**(hzen - hnum[i])))%Q + ((hzen - hnum[i])*(3**(hzen - hnum[i]-1)))%Q)%
        A = ((anum[i-1]*pow(3,hnum[i-1],Q))%Q + (hnum[i-1]*pow(3,max(0,hnum[i-1]-1),Q))%Q)%Q
        C = (((czen - cnum[i])*pow(3,hzen - hnum[i],Q))%Q + ((hzen - hnum[i])*pow(3,max(0,hzen - hnum[i]-1),Q))%Q)%Q
        K = (A*C)%Q
        ans = (ans + K)%Q
print(int(ans))
n, t = list(map(int, input().split()))
a = list(map(int, input().split()))
min = 1000000000
min_c = 0
max_dif = 0
max_dif_c = 0
for i in range(n):
    if a[i] < min:
        min = a[i]
        min_c = 1
    elif a[i] == min:
        min_c += 1
    if a[i] - min > max_dif:
        max_dif = a[i] - min
        max_dif_c = 1
    elif: a[i] - min == max_dif:
        max_dif_c += 1
c = min([min_c, max_dif_c])
print(str(c))


### FIXED CODE ###

n, t = list(map(int, input().split()))
a = list(map(int, input().split()))
min_a = 1000000000
max_dif = 0
max_dif_c = 0
for i in range(n):
    if a[i] < min_a:
        min_a = a[i]
    elif a[i] - min_a > max_dif:
        max_dif = a[i] - min_a
        max_dif_c = 1
    elif a[i] - min_a == max_dif:
        max_dif_c += 1
print(str(max_dif_c))
from collections import defaultdict
from bisect import bisect_left
N, K = map(int, input().split())
a = [int(c)-1 for c in input().split()]
s = [0]
for i in range(N):
  s += [(s[-1]+a[i])%K]
dic = defaultdict(list)

for i in range(N+1):
  dic[s[i]] += [i]

ans = 0
for k in dic.keys():
  ls = dic[k]
  for j in range(len(ls)):
    ind = bisect_left(ls, ls[j]-K+2)
    ans += j-ind
    if ind>0 and ls[ind-1]+1 == ls[ind]:
      ans += 1
#  print(k, ans)

print(ans)

### FIXED CODE ###

from collections import defaultdict
import itertools

N, K = map(int, input().split())
A = [int(c)-1 for c in input().split()]
A = [0] + A
Acum = list(itertools.accumulate(A))
Acum = [x%K for x in Acum]

counter = defaultdict(int)

ans = 0
for i,x in enumerate(Acum):
  ans += counter[x]
  counter[x] += 1
  if i>=K-1:
    counter[Acum[i-K+1]] -= 1
print(ans)
from collections import defaultdict as ddydd
from collections import deque as q
N, M = map(int, input().split())
XYZ = ddydd(list)
TreeMemo = ddydd(int)
link = []
trace = []
start = 0
for _ in range(M):
  x, y, z = map(int, input().split())
  if start == 0:
    start = x
  XYZ[x].append(y)
  XYZ[y].append(x)
  TreeMemo[x] = 0
  TreeMemo[y] = 0
  if not x in link: link.append(x)
  if not y in link: link.append(y)

def searchPreMin(n):
  global trace
  trace.append(n)
  temp = min(XYZ[n])
  if temp < n:
    return searchPreMin(temp)
  else:
    return n
def searchPreMax(n):
  global trace
  trace.append(n)
  temp = max(XYZ[n])
  if temp > n:
    return searchPreMax(temp)
  else:
    return n
def searchMax(n):
  global trace
  if trace[n] != 0:
    return TreeMemo[t]
  trace = []
  n = searchPreMin(n)
  temp = searchPreMax(n)
  for t in trace:
    TreeMemo[t] = temp
  return temp

forest = []
nodes = len(link)
while link:
  temp = link.pop()
  tree = searchMax(temp)
  if not tree in forest: forest.append(tree)
    
print(N - nodes + len(forest))

### FIXED CODE ###

N, M = map(int, input().split())
XY = [i for i in range(N + 1)]

def root(x):
  temp = x
  while temp != XY[temp]:
    temp = XY[temp]
  XY[x] = temp
  return temp
for _ in range(M):
  x, y = map(int, input().split()[:2])
  XY[root(x)] = root(y)

print(sum(i == v for i, v in enumerate(XY)) - 1)
N = int(input())

for i in range(N+1):
    if int(i*1.08)==n:
        print(i)
        exit()
print(':(')


### FIXED CODE ###

n=int(input())
for i in range(n+1):
    if int(i*1.08)==n:
        print(i)
        exit()
print(':(')
x, n = map(int, input().split())
ps = list(map(int, input().split()))
sx = max(ps)
pss = [i for i in range(1, sx+1)]
ps = list(filter(lambda i: i not in ps, pss))


ans = x

for i, p in enumerate(ps):
    temp = abs(x-p)
    if i == 0:
        mins = temp
        ans = p
    else:
        if mins >= temp:
            mins = temp
            ans = p

print(ans)

### FIXED CODE ###

x, n = map(int, input().split())
ps = list(map(int, input().split()))
pss = [i for i in range(-1000, 1000)]
ps = list(filter(lambda i: i not in ps, pss))
ans = x

for i, p in enumerate(ps):
    temp = abs(x-p)
    if i == 0:
        mins = temp
        ans = p
    else:
        if mins > temp:
            mins = temp
            ans = p
        elif mins == temp:
            if ans > p:
                ans = p

print(ans)
N,Q=map(int, input().split())
#AB=[list(map(int, input().split())) for i in range(N)]
tree_dist={}
for i in range(N):
    tree_dist[i+1] = set()
for i in range(N-1):
    a,b = map(int, input().split())
    tree_dist[a].add(b)
    tree_dist[b].add(a)
    
PX=[list(map(int, input().split())) for i in range(Q)]
z=[0]*N
for p,x in PX:
    z[p-1] += x

def saiki(i,p):
    L = list(tree_dist[i])
    for l in L:
        if l == p:
            continue
        z[l-1] += z[i-1]
        saiki(l,i)
saiki(1,0)
print(" ".join(map(str,z)))




### FIXED CODE ###

import sys
sys.setrecursionlimit(10000000)
input=lambda :sys.stdin.readline()
N,Q=map(int, input().split())
tree_dist={}
for i in range(N):
    tree_dist[i+1] = []
for i in range(N-1):
    a,b = map(int, input().split())
    tree_dist[a].append(b)
    tree_dist[b].append(a)
    
z=[0]*N
for i in range(Q):
    p,x = map(int, input().split())
    z[p-1] += x

def saiki(i,p):
    L = list(tree_dist[i])
    for l in L:
        if l != p:
            z[l-1] += z[i-1]
            saiki(l,i)
saiki(1,0)
print(" ".join(map(str,z)))
#dt = {} for i in x: dt[i] = dt.get(i,0)+1
import sys;input = sys.stdin.readline
inp,ip = lambda :int(input()),lambda :[int(w) for w in input().split()]

def knapsack(sm,W,n,V):
    K = [0]*(sm+1)
    for i in range(1,n+1):
        for j in reversed(range(1,sm+1)):
            if j - W[i-1] >= 0:
                K[j] = max(V[i-1]+K[j-W[i-1]], K[j])
    return K[-1]

n,wt = ip()
V,W = [0]*n,[0]*n
for i in range(n):
    w,v = ip()
    V[i] = v
    W[i] = w
ans = knapsack(wt,W,n,V)
print(ans)
    


### FIXED CODE ###

#dt = {} for i in x: dt[i] = dt.get(i,0)+1
import sys;input = sys.stdin.readline
inp,ip = lambda :int(input()),lambda :[int(w) for w in input().split()]

def knapsack(wt,sm,W,n,V):
    K = [float('inf')]*(sm+1)
    K[0] = 0
    for i in range(n):
        for j in range(sm-V[i],-1,-1):
                K[j+V[i]] = min(K[j+V[i]],K[j]+W[i])
    #print(K)
    return max([i for i in range(sm+1) if K[i] <= wt])

n,wt = ip()
V,W = [0]*n,[0]*n
for i in range(n):
    w,v = ip()
    V[i] = v
    W[i] = w
ans = knapsack(wt,sum(V),W,n,V)
print(ans)
import sys
import  math
import fractions
from collections import defaultdict
import heapq
from bisect import bisect_left,bisect

stdin = sys.stdin
     
ns = lambda: stdin.readline().rstrip()
ni = lambda: int(stdin.readline().rstrip())
nm = lambda: map(int, stdin.readline().split())
nl = lambda: list(map(int, stdin.readline().split()))

N,K=nm()
A=nl()
l=1
r=10**9
mid=0

if(K==0):
    print(max(A))
    sys.exit(0)

while(l+1<r):
    mid=(l+r)//2
    tmp=0
    for i in range(len(A)):
        tmp+=A[i]//mid
    if(K<tmp):
        l=mid
    else:
        r=mid

tmp=0
for i in range(len(A)):
    tmp+=A[i]//l

tmp2=0
for i in range(len(A)):
    tmp2+=A[i]//r


if(tmp<=K)
    print(l)
    sys.exit(0)
    
 print(r)




    

### FIXED CODE ###

import sys
import  math
import fractions
from collections import defaultdict
import heapq
from bisect import bisect_left,bisect

stdin = sys.stdin
     
ns = lambda: stdin.readline().rstrip()
ni = lambda: int(stdin.readline().rstrip())
nm = lambda: map(int, stdin.readline().split())
nl = lambda: list(map(int, stdin.readline().split()))

N,K=nm()
A=nl()
l=0
r=10**9
mid=0

if(K==0):
    print(max(A))
    sys.exit(0)

while(l+1<r):
    mid=(l+r)//2
    tmp=0
    for i in range(len(A)):
        tmp+=((A[i]-1)//mid)
    if(tmp<=K):
        r=mid
    else:
        l=mid

print(r)
from scipy.special import comb, factorial

n, k = tuple(map(int, input().split(' ')))
for i in range(1, k+1):
  s = comb(k-1, i-1, exact=True) * (factorial(n-k+1, exact=True) / (factorial(n-k-i+1, exact=True) * factorial(i, exact=True)))
  print(int(s) % (10 ** 9 + 7))

### FIXED CODE ###

input_str = input()
items = set(list(input_str))
print('Yes' if len(items) == 2 and len(list(input_str.replace(list(items)[0], ''))) == 2 else 'No')
orders = {
    'North': (2, 6, 3, 4, 1, 5),
    'East': (4, 2, 1, 6, 5, 3),
    'West': (3, 2, 6, 1, 5, 4),
    'South': (5, 1, 3, 4, 6, 2),
    'Right': (1, 3, 5, 2, 4, 6),
    'Left': (1, 4, 2, 5, 3, 6)
}

while True:
    n = int(input())
    if not n:
        break
    dice = list(range(1, 7))
    top = 1

    while n:
        dice = [dice[s - 1] for s in orders[input()]]
        top += dice[0]
        n -= 1
    print(top)

### FIXED CODE ###

orders = {
    'North': (2, 6, 3, 4, 1, 5),
    'East': (4, 2, 1, 6, 5, 3),
    'West': (3, 2, 6, 1, 5, 4),
    'South': (5, 1, 3, 4, 6, 2),
    'Right': (1, 3, 5, 2, 4, 6),
    'Left': (1, 4, 2, 5, 3, 6)
}

while True:
    n = int(input())
    if not n:
        break
    dice = list(range(1, 7))
    top = 1

    while n:
        dice = [dice[s - 1] for s in orders[input().strip()]]
        top += dice[0]
        n -= 1
    print(top)
def mx(i):
    if i == 0: return 0
    else     : return (i+1)*i + mx(i-1)

def cns(ls,m,sm):
    global n, s
    count = 0
    if m == n:
        if sm == s: return 1
        else      : return 0
    elif s-mx(n-m+1)-1 <= sm <= s:
        for i in range(9-m+1):
            rls = ls[:]
            k = rls.pop(i)
            count += cns(rls,m+1,sm+(m+1)*k)
        return count
    else: return 0

ls = [0,1,2,3,4,5,6,7,8,9]
while True:
    n, s = map(int, raw_input().split())
    if s > mx(n): print 0
    else        : print cns(ls,0,0)

### FIXED CODE ###

def mxmn(ls,m):
	global n
	s1,s2 = 0, 0
	for i in range(m):
		s1 += (n-i)*ls[-i-1]
		s2 += (n-i)*ls[i]
	return s1,s2

def f(ls,m,s):
	global n
	count = 0
	if m > 0:
		mx,mn = mxmn(ls,m)
		if mx < s or mn > s: return 0
		elif mx == s or mn == s: return 1
		for i in range(len(ls)):
			lls = ls[:]
			a = (n-m+1)*lls.pop(i)
			if s-a < 0:	break
			else: count += f(lls,m-1,s-a)
		return count
	else:
		return 1 if s == 0 else 0
			
ls = [i for i in range(10)]
while True:
	try:
		n,s = map(int, raw_input().split())
		print f(ls,n,s)
	except:
		break
while 1:
    e = int(input().strip())
    if e ==0:break
    m=e
    for z in range(e):
        for y in range(e):
            x = e - y**2 - z**3 
            if x < 0:break
            if m > x+y+z: m = x+y+z
    print(m)
        


### FIXED CODE ###

import math
while 1:
    e = int(input().strip())
    if e ==0:break
    m=e
    z =0
    while z**3 <= e:
        y = int(math.sqrt(e-z**3))
        x = e - y**2- z**3 
        if x < 0:break
        if m > x+y+z: m = x+y+z    
        z+=1
    print(m)
N,K,X,Y=input().split()
print((K*X+(N-K)*Y) if N>=K else N*X)

### FIXED CODE ###

n = int(input())
k = int(input())
x = int(input())
y = int(input())
if n >= k:
  print(k*x+(n-k)*y)
else:
  print(n*x)
a = int(input())
b = int(input())


if a <= (a+b)//2 and b <= (a+b)//2:
    print("Yay!")
else:
    print(":(")    


### FIXED CODE ###

a, b = map(int, input().split())


if a <= 8 and b <= 8:
    print("Yay!")
else:
    print(":(")
input=list(input())
if int(input[0])==int(input[1]) or int(input[1])==int(input[2]) or int(input[2])==int(input[3]):
　print("Bad")
else:
 print("Good")

### FIXED CODE ###

input=list(input())


if int(input[0])==int(input[1]) or int(input[1])==int(input[2]) or int(input[2])==int(input[3]):
	 print("Bad")
else:
	print("Good")
import sys
input = sys.stdin.readline

S=input()
N=len(S)
mod=13
mod2=10**9+7

#i桁目までみて，あまりがjになるものの個数
dp=[[0]*mod for _ in range(N+1)]

#1桁目
if S[-1]!="?":
    a=int(S[-1])
    for j in range(mod):
        dp[1][a]=1
else:
    for j in range(mod):
        for k in range(10):
            dp[1][k]=1

for i in range(1,N):
    if S[-i-1]!="?":
        a=(pow(10,i)*int(S[-i-1]))%mod
        for j in range(mod):
            dp[i+1][(j+a)%mod]=dp[i][j]
    else:
        a=pow(10,i)%mod
        for j in range(mod):
            for k in range(10):
                dp[i+1][(j+k*a)%mod]+=dp[i][j]
                dp[i+1][(j+k*a)%mod]%=mod2

print(dp[-1][5])

### FIXED CODE ###

S=input()
N=len(S)
mod=13
mod2=10**9+7

#上からi桁目までみて，あまりがjになるものの個数
dp=[[0]*mod for _ in range(N+1)]

dp[0][0]=1

for i in range(N):
    if S[i]!="?":
        for j in range(mod):
            dp[i+1][(10*j+int(S[i]))%mod]=dp[i][j]
    else:
        for j in range(mod):
            for k in range(10):
                dp[i+1][(10*j+k)%mod]+=dp[i][j]%mod2

print(dp[-1][5]%mod2)
N,Y = map(int,input().split())
res = (-1,-1,-1)
for x in range(N+1):
  for y in range(N+1-x):
    if N-x-y >=0 and 10000*x + 5000*y + 1000*z = Y:
      res = (x,y,N-x-y)
print(res[0],res[1],res[2])

### FIXED CODE ###

N,Y = map(int,input().split())
res = (-1,-1,-1)
for x in range(N+1):
  for y in range(N+1-x):
    if N-x-y >=0 and 10000*x + 5000*y + 1000*(N-x-y) == Y:
      res = (x,y,N-x-y)
print(res[0],res[1],res[2])
s = input()
YYMM, MMYY, ova = False, False, False

if(1 <= int(s[:2]) <= 12):
    MMYY = True
if(1 <= int(s[3:]) <= 12):
    YYMM = True

if(MMYY and YYMM):
    ova = True

if(ova):
    print('AMBIGUOUS')
elif(MMYY):
    print("MMYY")
elif(YYMM):
    print('YYMM')
else:
    print('NA')

### FIXED CODE ###

N, K = map(int, input().split())
S = input()

print(S[: K-1] + S[K - 1].lower() + S[K :])
n = int(input())
a = list(map(int, input().split()))
q = int(input())
query = [list(map(int,input().split())) for _ in range(q)]

all_sum  = sum(a)

cnt = {}
for i in a:
    if i not in cnt:
        cnt[a] = 0
    cnt[a] += 1

for (b, c) in query:
    if b in cnt:
        all_sum -= b * cnt[b]
        all_sum += c * cnt[b]
        if c not in cnt:
            cnt[c]=0 
        cnt[c] += cnt[b]
        cnt[b] = 0
    print(all_sum)

### FIXED CODE ###

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

all_sum  = sum(a)

cnt = {}
for i in a:
    if i not in cnt:
        cnt[i] = 0
    cnt[i] += 1

for (b, c) in query:
    if b in cnt:
        all_sum -= b * cnt[b]
        all_sum += c * cnt[b]
        if c not in cnt:
            cnt[c]=0 
        cnt[c] += cnt[b]
        cnt[b] = 0
    print(all_sum)
import sys
input = sys.stdin.readline
import numpy as np

h, w = map(int, input().split())
A = np.array([input().split() for _ in range(h)], dtype=np.int64)
B = np.array([input().split() for _ in range(h)], dtype=np.int64)
D = abs(A-B)
M = 80*h*w
dp = np.zeros((h, w, 2*M), dtype=bool)
dp[0, 0, M-D[0, 0]] = True
dp[0, 0, M+D[0, 0]] = True
for i in range(h):
  for j in range(w):
    if i:
      dp[i, j, D[i, j]:] |= dp[i-1, j, :-D[i, j]].copy()
      dp[i, j, :-D[i, j]] |= dp[i-1, j, D[i, j]:].copy()
    if j:
      dp[i, j, D[i, j]:] |= dp[i, j-1, :-D[i, j]] .copy()
      dp[i, j, :-D[i, j]] |= dp[i, j-1, D[i, j]:].copy()
idx = np.where(dp[-1, -1, M:])
ans = idx[0][0]
print(ans)

### FIXED CODE ###

import sys
input = sys.stdin.readline

def main():
  h, w = map(int, input().split())
  A = [list(map(int, input().split())) for _ in range(h)]
  B = [list(map(int, input().split())) for _ in range(h)]
  M = 80*(h+w)
  dp = [[0]*w for i in range(h)]
  d = abs(A[0][0] - B[0][0])
  mask = (1 << (2*M)) - 1
  dp[0][0] |= 1 << (M-d)
  dp[0][0] |= 1 << (M+d)
  for i in range(h):
    for j in range(w):
      d = abs(A[i][j] - B[i][j])
      if i:
        dp[i][j] |= (dp[i-1][j] << d) & mask
        dp[i][j] |= dp[i-1][j] >> d
      if j:
        dp[i][j] |= (dp[i][j-1] << d) & mask
        dp[i][j] |= dp[i][j-1] >> d
  t = dp[-1][-1] >> M
  ans = (t & (-t)).bit_length() - 1
  print(ans)
  
if __name__ == "__main__":
  main()
N = int(input().split())
d = list(map(int, input().split()))

d.sort()
result = d[int(N/2)]-d[int((N-1)/2)]
print(result)


### FIXED CODE ###

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

d.sort()
result = d[int(N/2)]-d[int((N-1)/2)]
print(result)
#変数: S, num, formula
    
S = input()
num = len(S) - 1

for i in range(2**num):
    op=["-"]*num
    for j in range(num):
        if (i>>j)&1:
            op[num-j-1]="+"
            
    formula=""
    for op_S,op_num in zip(S,num+[""]):
        formula += op_S + op_num

    if eval(formula)==7:
        print(formula+"=7")
        break

### FIXED CODE ###

def dfs(i, Str, res):
    if i==3:
        if res==7:
            print(Str+"=7")
            exit()
        return
    
    dfs(i+1,Str+"+"+s[i+1],res+int(s[i+1]))
    dfs(i+1,Str+"-"+s[i+1],res-int(s[i+1]))

s=input()
dfs(0,s[0],int(s[0]))
n,m=map(int,input().split())
h=list(map,input().split())
x=[[] for i in range(n)]
for i in range(m):
  a,b=map(int,input().split())
  x[a-1].append(b-1)
  x[b-1].append(a-1)
c=0
for i in range(n):
  f=1
  maxh=0
  for j in x[i]:
    maxh=max(maxh,h[j])
  if maxh>=h[i]:
    f=0
  c+=f
print(c)

### FIXED CODE ###

n,m=map(int,input().split())
h=list(map(int,input().split()))
x=[[] for i in range(n)]
for i in range(m):
  a,b=map(int,input().split())
  x[a-1].append(b-1)
  x[b-1].append(a-1)
c=0
for i in range(n):
  f=1
  maxh=0
  for j in x[i]:
    maxh=max(maxh,h[j])
  if maxh>=h[i]:
    f=0
  c+=f
print(c)
s = input()

print(s[0] + (len(s)-2) + s[-1]) 

### FIXED CODE ###

s = input()

print(s[0] + str(len(s)-2) + s[-1])
a = []
b = []
for i in range(n):
    a.append(int(input()))

for i in range(n):
    if a[i] in b:
        continue
    else:
        b.append(a[i])
print(len(b))

### FIXED CODE ###

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

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

used = dictionary()
for b in range(2,sqrt(x)):
  p=2
  while(b**p<=x):
    used[b**p]=True
    p+=1
ans=0
for key,itm in used:
  ans = max(ans,key)

print(ans)
  

### FIXED CODE ###

import math
x = int(input())
if x==1:
  print(1)
  exit()

used = {}
for b in range(2,int(math.sqrt(x))+1):
  p=2
  while(b**p<=x):
    used[b**p]=True
    p+=1

ans=0
for key in used.keys():
  ans = max(ans,key)

print(ans)
n = input()
l = input().split()
cnt = 0
while len([True for x in l if l%2==0]):
  l = [x/2 for x in l]
  cnt += 1
print(cnt)

### FIXED CODE ###

n = input()
l = [int(x) for x in input().split()]
cnt = 0
while len([True for x in l if x%2==0]) == len(l):
  l = [x/2 for x in l]
  cnt += 1
print(cnt)
import numpy as np
n=10000
q = int(input())
 
is_prime = np.ones(n+1,dtype=int)
is_prime[0]=0
is_prime[1]=0
 
for i in range(2,n+1):
    if(is_prime[i]==1):
        j=i+i
        while j <= n:
            is_prime[j] = 0
            j += i
 
cnt = [is_prime[x]*is_prime[(x+1)//2] for x in range(0,n+1)]
 
for i in range(1,n+1):
    cnt[i]+=cnt[i-1]
 
for i in range(q):
    l,r = map(int, input().split())
    print(cnt[r]-cnt[l-1])

### FIXED CODE ###

import numpy as np
n=123456
q = int(input())
 
is_prime = np.ones(n+1,dtype=int)
is_prime[0]=0
is_prime[1]=0
 
for i in range(2,n+1):
    if(is_prime[i]==1):
        j=i+i
        while j <= n:
            is_prime[j] = 0
            j += i
 
cnt = [is_prime[x]*is_prime[(x+1)//2] for x in range(0,n+1)]
 
for i in range(1,n+1):
    cnt[i]+=cnt[i-1]
 
for i in range(q):
    l,r = map(int, input().split())
    print(cnt[r]-cnt[l-1])
x,y,z,k = [int(i) for i in input().split()]

cakes_types = [[int(i) for i in input().split()] for _ in range(3)]


for types in cakes_types:
    types.extend([0 for _ in range(max(x,y,z)-len(types))])
    types.sort(reverse=True)

sum_list = list()

for i in range(k):
    sum_taste = 0;
    for j in range(3):
        sum_taste += cakes_types[j][i]
    sum_list.append(sum_taste)

print(sum_list)

### FIXED CODE ###

x,y,z,k = [int(num) for num in input().split()]
a_cake,b_cake,c_cake = [sorted([int(num) for num in input().split()],reverse=True)[:k] for _ in range(3)]

sum_cake=list()
for i,a in enumerate(a_cake,1):
    for j,b in enumerate(b_cake,1):
        if(i*j>k):
            break
        for n,c in enumerate(c_cake,1):
            if(i*j*n>k):
                break
            sum_cake.append(a+b+c)


sum_cake.sort(reverse=True)

for i in sum_cake[:k]:
    print(i)
import numpy as np
import math





n= int(input())



xandy=np.ones((n,n))

xandy=xandy*(-1)

flag=0
for i in range(0,n):
    a=int(input())
    for j in range(0,a):
        x,y= map(int, input().split())
        xandy[i][x-1]=y

max=0


for l in range(0,2**n):
    i=2**n-1-l
    flag=1
    if max<bin(i).count("1"):
        for j in range(0,n):
       
        #iを2進数表示した時kの位置ででの0-1が対応してあるか立っているか？
            if  bin( i& 2**j).count("1")>0:
                 for k in range(0,n):
                      if  xandy[j][k]!=-1 and xandy[j][k]!=(i >> k)%2:
                          flag=0 
                        break
                       
            if flag==0:
                break
        if flag==1 and max<bin(i).count("1"):
             max=bin(i).count("1")
         

print(max)


### FIXED CODE ###

import numpy as np
import math





n= int(input())



xandy=np.ones((n,n))

xandy=xandy*(-1)

flag=0
for i in range(0,n):
    a=int(input())
    for j in range(0,a):
        x,y= map(int, input().split())
        xandy[i][x-1]=y

max=0


for l in range(0,2**n):
    i=2**n-1-l
    flag=1
    if max<bin(i).count("1"):
        for j in range(0,n):
       
        #iを2進数表示した時kの位置ででの0-1が対応してあるか立っているか？
            if  bin( i& 2**j).count("1")>0:
                 for k in range(0,n):
                      if  xandy[j][k]!=-1 and xandy[j][k]!=(i >> k)%2:
                          flag=0 
                          break
                       
            if flag==0:
                break
        if flag==1 and max<bin(i).count("1"):
             max=bin(i).count("1")
         

print(max)