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

from collections import deque

S = list(input())
S = deque(S)
Q = int(input())
query = [input().split() for i in range(Q)]
for i in query:
    # if i[0] == '1':
    if len(i) == 1:
        S.reverse()
    elif i[1]=='1':
        S.appendleft(i[2])
    # elif i[0]=='2' and i[1]=='2':
    else:
        S.append(i[2])
print(''.join(list(S)))



### FIXED CODE ###

from collections import deque

S = list(input())
S = deque(S)
Q = int(input())
reverse = 1
query = [input().split() for i in range(Q)]
for i in query:
    if len(i) == 1:
        reverse *= -1
    elif (i[1]=='1' and reverse == 1) or (i[1]=='2' and reverse==-1):
        S.appendleft(i[2])
    else:
        S.append(i[2])
if reverse == -1:
   S.reverse() 
print(''.join(list(S)))
### BUGGY CODE ###

a,b = map(int,input().split())
#素数列挙
sosu = [2]
li = min(a,b)
for i in range(3,li+1,2):
    f = 0
    for j in sosu:
        if i%j == 0:
            f = 1
            break
    if f == 0:
        sosu.append(i)

sosu.append(1)
ans = 0
for i in sosu:
    if a%i == 0 and b%i == 0:
        ans += 1

print(ans)


### FIXED CODE ###

a,b = map(int,input().split())
def gcd(x,y):
    if y == 0:
        return x
    return gcd(y,x%y)

n = gcd(a,b)
ans = 0
i = 2
while i*i <= n:
    if n%i == 0:
        while n%i == 0:
            n /= i
        ans += 1
    i += 1
if n != 1:
    ans += 1
print(ans+1)
### BUGGY CODE ###

a, b, m = map(int, input().split())
a1 = list(map(int, input().split()))
b1 = list(map(int, input().split()))

disc = [list(map(int, input().split())) for i in range(m)]

import itertools
import numpy as np

b2 = np.array(b1)

a2 = np.array(a1)
a2 = a2.reshape(a,1)

from collections import deque
ans = []
ans = deque(ans)

for i in a1:
    ans.append( np.min( b2 + np.tile(i, b) ) )


for i in range(m):
    ans.append( a1[disc[i][0]-1] + b1[disc[i][1]-1] - disc[i][2] )

ans = list(ans)
print(min( min(ans), np.min(a2+b2) ))

### FIXED CODE ###

a, b, m = map(int, input().split())
a1 = list(map(int, input().split()))
b1 = list(map(int, input().split()))

disc = [list(map(int, input().split())) for i in range(m)]
import numpy as np


from collections import deque
ans = []

ans = deque(ans)

for i in range(m):
    ans.append( a1[disc[i][0]-1] + b1[disc[i][1]-1] - disc[i][2] )

ans = list(ans)

print(min( min(ans), min(a1)+min(b1) ))
### BUGGY CODE ###


def main():
    import sys
    input = sys.stdin.readline
    #n = int(input())
    #l = list(map(int, input().split()))
    '''
    A=[]
    B=[]
    for i in range():
        a, b = map(int, input().split())
        A.append(a)
        B.append(b)'''

    n=int(input())
    s=input().rstrip('\n')
    from collections import Counter
    a=Counter(s)
    #print(a)
    num=a["R"]*a["G"]*a["B"]
    #print(num)
    for i in range(n-2):
        for j in range(1,n//2+1):
            if i+2*j<n:
                #print([i,i+j,i+2*j,s[i], s[i+j], s[i+2*j]])
                if set([s[i],s[i+j],s[i+2*j]])==set(["R","G","B"]):
                    num-=1
    print(num)

if __name__ == "__main__":
    main()

### FIXED CODE ###


def main():
    import sys
    input = sys.stdin.readline
    #n = int(input())
    #l = list(map(int, input().split()))
    '''
    A=[]
    B=[]
    for i in range():
        a, b = map(int, input().split())
        A.append(a)
        B.append(b)'''

    n=int(input())
    s=input().rstrip('\n')
    a=0
    b=0
    c=0
    for i in range(n):
        if s[i]=="R":
            a+=1
        elif s[i]=="G":
            b+=1
        elif s[i]=="B":
            c+=1
    num=a*b*c
    #print(num)
    for i in range(n-2):
        for j in range(1,n//2+1):
            if i+2*j<n:
                if s[i]!=s[i+j] and s[i+j]!=s[i+2*j] and s[i]!=s[i+2*j]:
                    num-=1
    print(num)

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

n,m = map(int,input().split())
gates = []
res = 0
for i in range(m):
	l,r = map(int,input().split())
	gates.append({ i for i in range(l,r+1)})
r={i for i in range(1,n+1)}

for g in gates :
	r = r & g
print(len(r))

### FIXED CODE ###


n,m = map(int,input().split())
L = []
R = []
for i in range(m):
	l,r = map(int,input().split())
	L.append(l)
	R.append(r)

l = L[0]
r = R[0]
cnt = 0
for i in range(max(L),min(R)+1) :
	if 0<=i<=r :
		cnt += 1
print(cnt)
### BUGGY CODE ###

N = int(input())
P = input().split()
check_counter = 0
counter = 0
for i in range(N):
    k = i+1
    for j in range(k):
        if int(P[i]) <= int(P[j]):
            check_counter += 1
    if (k == check_counter):
        counter += 1
    check_counter = 0
print(counter)

### FIXED CODE ###

N = int(input())
P = input().split()
counter = 0
m = N
for p in P:
    if int(m) >= int(p):
        counter +=1
        m = p
print(counter)
### BUGGY CODE ###

k,s=map(int,input().split())
ans=0
for i in range(k+1):
    for j in range(k+1):
        for k in range(k+1):
            if i+j+k==s:
                ans+=1
print(ans)

### FIXED CODE ###

k,s=map(int,input().split())
ans=0
for i in range(k+1):
    for j in range(k+1):
            if s-(i+j) in range(k+1):
                ans+=1
print(ans)
### BUGGY CODE ###

import sys
H, W, *A = sys.stdin.read().split()
H = int(H); W = int(W)

rW = range(W)
rrW = range(W-1, -1, -1)
rH = range(H)

INF = 2000
dist = [[INF]*W for i in rH]
for di, Ai in zip(dist, A):
    for j, a in enumerate(Ai):
        if a == '#':
            di[j] = 0
for di in dist:
    cur = INF
    for j in rW:
        if not di[j]:
            cur = -j
        else:
            di[j] = cur+j
    cur = INF
    for j in rrW:
        if not di[j]:
            cur = j
        elif cur-j < di[j]:
            di[j] = cur-j
for j in rW:
    cur = INF
    for di in dist:
        if cur+1 < di[j]:
            di[j] = cur = cur+1
        else:
            cur = di[j]
    cur = INF
    for di in reversed(dist):
        if cur+1 < di[j]:
            di[j] = cur = cur+1
        else:
            cur = di[j]
sys.stdout.write("%d\n" % max(max(di) for di in dist))

### FIXED CODE ###

from collections import deque

H, W = map(int, input().split())
que = deque()
A = [input() for i in range(H)]

dist = [[-1]*W for i in range(H)]
dd = ((-1, 0), (0, -1), (1, 0), (0, 1))
for i in range(H):
    for j in range(W):
        if A[i][j] == '#':
            dist[i][j] = 0
            que.append((i, j))

d = 0
while que:
    y, x = que.popleft()
    d = dist[y][x]
    for dx, dy in dd:
        nx = x + dx; ny = y + dy
        if not 0 <= nx < W or not 0 <= ny < H or dist[ny][nx] != -1:
            continue
        dist[ny][nx] = d+1
        que.append((ny, nx))
print(d)
### BUGGY CODE ###

def apc001_c():
    import sys
    n = int(input())

    rt = 0
    print(rt)
    sys.stdout.flush()
    rt_name = str(input())
    lf = n-1
    print(lf)
    sys.stdout.flush()
    lf_name = str(input())

    while rt - lf >= 2:
        x = (rt + lf) // 2
        print(x)
        sys.stdout.flush()
        s = str(input())
        if s == rt_name: rt = x
        else: lf = x

if __name__ == '__main__':
    apc001_c()

### FIXED CODE ###

def apc001_c():
    import sys
    n = int(input())

    def ask(x:int):
        print(x)
        sys.stdout.flush()
        res = str(input())
        return res

    lower = 0
    seat_low = ask(lower)
    if seat_low == 'Vacant': return

    upper = n-1
    seat_up = ask(upper)
    if seat_up == 'Vacant': return

    while upper - lower > 1:
        x = (upper + lower) // 2
        s = ask(x)
        if s == 'Vacant': return
        if x % 2 == 0:
            if s == seat_low: lower = x
            else: upper = x
        else:
            if s == seat_up: lower = x
            else: upper = x

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

n, k = map(int, input().split())
p = [int(s) for s in input().split()]

for i in range(n):
    p[i] = (1 + p[i]) / 2

ans = 0.0
for i in range(k, n + 1):
    ans = max(ans, sum(p[i - k:i]))

print(ans)


### FIXED CODE ###

n, k = map(int, input().split())
p = [int(s) for s in input().split()]

for i in range(n):
    p[i] = (1 + p[i]) / 2

value = sum(p[0:k])
ans = value
for i in range(k, n):
    value = value + p[i] - p[i - k]
    ans = max(ans, value)

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

import numpy as np
li = np.array([])

N=int(input())
li = list(map(int, input().split()))
arr = np.array(li)

max = 0

for i in range(100000 + 1):

  a = np.count_nonzero(arr == i)
  a += np.count_nonzero(arr == (i + 1))
  a += np.count_nonzero(arr == (i - 1))

  if max < a:
    max = a

print(max)

### FIXED CODE ###

n = int(input())
cnt = [0] * 100002
a = list(map(int, input().split()))
for v in a:
    cnt[v] += 1
    cnt[v-1] += 1
    cnt[v+1] += 1
    
print(max(cnt))
### BUGGY CODE ###

N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
diff = [a-b for a,b in zip(A, B)]
orderdiff = sorted(diff, reverse=True)

# 浮いている分からマイナスを補填、何個使ったかを管理するためのリスト
plsdiffcnt = []
for i in orderdiff:
  if i > 0:
    plsdiffcnt.append(i + sum(plsdiffcnt))

#マイナス値の合計とその個数を取得
mnscnt = 0
mnssum = 0
for i in diff:
  if i < 0:
    mnscnt += 1
    mnssum -= i
    
if all([i >= 0 for i in diff]):
  print(0)
  exit()
    
if sum(diff) < 0:
  print(-1)
  exit()
     
for i, v in enumerate(plsdiffcnt):
  if mnssum <= v:
    ans = i + 1
    break
print(mnscnt+ans)

### FIXED CODE ###

N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
diff = [a-b for a,b in zip(A, B)]
orderdiff = sorted(diff, reverse=True)

# 浮いている分からマイナスを補填、何個使ったかを管理するためのリスト
plsdiffcnt = [0] * (N + 1)
plsdiffcnt[0] = orderdiff[0]
for i in range(len(orderdiff)-1):
  if orderdiff[i] > 0:
    plsdiffcnt[i+1] = plsdiffcnt[i] + orderdiff[i+1]

#マイナス値の合計とその個数を取得
mnscnt = 0
mnssum = 0
for i in diff:
  if i < 0:
    mnscnt += 1
    mnssum -= i
    
if all([i >= 0 for i in diff]):
  print(0)
  exit()
    
if sum(diff) < 0:
  print(-1)
  exit()
     
for i, v in enumerate(plsdiffcnt):
  if mnssum <= v:
    ans = i + 1
    break
print(mnscnt+ans)
### BUGGY CODE ###

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

def is_prime(n):
    if n == 1:
        return False

    for k in range(2, int(math.sqrt(n)) + 1):
        if n % k == 0:
            return False

    return True

if m%n==0:
    print(m//n)

elif is_prime(m):
    print(1)

else:
    index=m//n
    while index >0:
        if m%index==0:
            print(index)
            break
        index-=1

### FIXED CODE ###

import math
import time
n, m = map(int, input().split())
flag=0
if m%n==0:
    print(m//n)

else:
    start = time.time()
    index=m//n
    while index >0:
        elapsedTime = time.time()-start
        if elapsedTime > 1:
            flag=1
            break
        elif m%index==0:
            print(index)
            break
        index-=1

    if flag==1:
        index = 1
        while index < m+1:
            if m % index == 0:
                if index > n-1:
                    print(m//index)
                    break
            index += 1
### BUGGY CODE ###


import sys
import collections
# import math
# import string
# import bisect

def main():
    n, *parts = (int(x) for x in sys.stdin.read().split())
    uppers, middles, lowers = (parts[n*i:n*(i+1)] for i in range(3))

    count = 0
    for a, ca in collections.Counter(uppers).items():
        for b, cb in collections.Counter(middles).items():
            if a >= b: continue
            else:
                for c, cc in collections.Counter(lowers).items():
                    if b >= c: continue
                    else: count += ca * cb * cc
    print(count)

if __name__ == "__main__":
    main()


### FIXED CODE ###


import sys
# import collections
# import math
# import string
import bisect

def main():
    n, *parts = (int(x) for x in sys.stdin.read().split())
    uppers, middles, lowers = (parts[n*i:n*(i+1)] for i in range(3))
    uppers.sort()
    lowers.sort()

    count = 0
    for j in middles:
        i = bisect.bisect_left(uppers, j)
        k = len(lowers) - bisect.bisect_right(lowers, j)
        count += i * k
        
    print(count)

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

from collections import Counter
import sys


def _ia(): return map(int, sys.stdin.readline().strip().split())


class UnionFind:
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def unite(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())


def main():
    n, m = _ia()
    uf = UnionFind(n)
    for _ in range(m):
        a, b = map(lambda x: x-1, _ia())
        uf.unite(a, b)
    return max(len(uf.members(r)) for r in uf.roots())


if __name__ == "__main__":
    print(main())


### FIXED CODE ###

from collections import Counter
import sys

sys.setrecursionlimit(20000)


def _ia(): return map(int, sys.stdin.readline().strip().split())


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

    def root(self, x):
        if self._par[x] < 0:
            return x
        else:
            self._par[x] = self.root(self._par[x])
            return self._par[x]

    def unite(self, x, y):
        x = self.root(x)
        y = self.root(y)
        if x == y:
            return
        elif self._rnk[x] > self._rnk[y]:
            self._par[x] += self._par[y]
            self._par[y] = x
        else:
            self._par[y] += self._par[x]
            self._par[x] = y
            if self._rnk[x] == self._rnk[y]:
                self._rnk[y] += 1

    def same(self, x, y):
        return self.root(x) == self.root(y)


def main():
    n, m = _ia()
    uf = UnionFind(n)
    for _ in range(m):
        a, b = map(lambda x: x-1, _ia())
        uf.unite(a, b)
    c = Counter([uf.root(i) for i in range(n)])
    return max(c.values())


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

N = int(input())
t = [0 for _ in range(81)]
ans = 0
for i in range(1, 10):
    for l in range(1, 10):
        for q in range(1, N+1):
            s = 0
            a = str(q)[0]
            b = str(q)[-1]
            if int(a) == i and int(b) == l:
                s += 1
            t[9*(i - 1)+l - 1] += s
for i in range(1, N+1):
    a = str(i)[0]
    b = str(i)[-1]
    if b == "0":
        continue
    elif a == b:
        ans += t[9*(int(a)-1)+int(a)-1]
    else:
        ans += t[9*(int(b)-1)+int(a)-1]
print(ans)


### FIXED CODE ###

N = int(input())
t = [[0 for _ in range(9)] for l in range(9)]
ans = 0
for i in range(1, N+1):
    if len(str(i)) == 1:
        t[i-1][i-1] += 1
    elif str(i)[-1] != "0":
        t[int(str(i)[0])-1][int(str(i)[-1])-1] += 1
for i in range(1, N+1):
    a = str(i)[0]
    b = str(i)[-1]
    if b == "0":
        continue
    elif a == b:
        ans += t[(int(a)-1)][int(a)-1]
    else:
        ans += t[(int(b)-1)][int(a)-1]
print(ans)
### BUGGY CODE ###

s = input()
count = 0
o = 0
while 'ABC' in s:
        o = s.count('ABC')
        s = s.replace('ABC','BCA')
        count += o
print(count)

### FIXED CODE ###

a = input()
b = []
count = 0
a = a.replace('BC','D')
for i in range(1,len(a)+1):
    if a[-i] == 'D':
        count += 1
    elif a[-i] == 'A':
        b.append(count)
    else:
        count = 0
print(sum(b))
### BUGGY CODE ###

from heapq import heappush,heappop
h,w=map(int,input().split())
sx,sy=map(int,input().split())
sx-=1
sy-=1
gx,gy=map(int,input().split())
gx-=1
gy-=1
g=[list(input()) for _ in range(h)]
v=[[0 for j in range(w)] for i in range(h)]
v2=[[0 for j in range(w)] for i in range(h)]
q=[]
heappush(q,[0,sx,sy])
k=[[0,1],[0,-1],[1,0],[-1,0]]
while q:
    c,x,y=heappop(q)
    if x==gx and y==gy:
        print(c)
        exit()
    if v[x][y]==1:
        continue
    v[x][y]=1
    for a,b in k:
        nx=x+a
        ny=y+b
        if 0<=nx<h and 0<=ny<w and g[nx][ny]=='.' and v[nx][ny]==0:
            heappush(q,[c,nx,ny])
    for a in range(-2,3):
        for b in range(-2,3):
            if a*b==0 and abs(a+b)<=1:
                continue
            nx=x+a
            ny=y+b
            if 0<=nx<h and 0<=ny<w and g[nx][ny]=='.' and v[nx][ny]==0 and v2[nx][ny]==0:
                heappush(q,[c+1,nx,ny])
                v2[nx][ny]=1
print(-1)

### FIXED CODE ###

from collections import deque
def main():
    h,w=map(int,input().split())
    sx,sy=map(int,input().split())
    sx-=1
    sy-=1
    gx,gy=map(int,input().split())
    gx-=1
    gy-=1
    g=[tuple(input()) for _ in range(h)]
    v=[[0 for j in range(w)] for i in range(h)]
    q=deque([[sx,sy]])
    v[sx][sy]=1
    ans=0
    k=[[0,1],[0,-1],[1,0],[-1,0]]
    while True:
        l=[]
        while q:
            x,y=q.popleft()
            l.append([x,y])
            if x==gx and y==gy:
                print(ans)
                exit()
            for a,b in k:
                nx=x+a
                ny=y+b
                if 0<=nx<h and 0<=ny<w and g[nx][ny]=='.' and v[nx][ny]==0:
                    q.append([nx,ny])
                    v[nx][ny]=1
        if len(l)==0:
            break
        for x,y in l:              
            for a in range(-2,3):
                for b in range(-2,3):
                    if a*b==0 and abs(a+b)<=1:
                        continue
                    nx=x+a
                    ny=y+b
                    if 0<=nx<h and 0<=ny<w and g[nx][ny]=='.' and v[nx][ny]==0:
                        q.append([nx,ny])
                        v[nx][ny]=1
        ans+=1 
    print(-1)
if __name__=='__main__':
    main()
### BUGGY CODE ###

s = input()
x, y = map(int, input().split())

n = len(s)
dpx = [[False] * (n+1) * 2 for i in range(len(s)+1)]
dpy = [[False] * (n+1) * 2 for i in range(len(s)+1)]
dpxy = [dpx, dpy]
index = 0
origin = len(s)
j = [0, 0]

p = 0
while s and s[0] == 'F':
    p += 1
    s = s[1:]
dpx[0][p+origin] = True
dpy[0][origin] = True
while len(s) > 0:
    p = 0
    while s and s[0] == 'F':
        p += 1
        s = s[1:]
    jj = j[index]
    # print(p)
    # print(dpxy[0][j[0]])
    # print(dpxy[1][j[1]])
    # print('')
    for i, a in enumerate(dpxy[index][jj]):
        if i + p < n + origin:
            dpxy[index][jj+1][i+p] = dpxy[index][jj+1][i+p] or a
        if 0 < i - p:
            dpxy[index][jj+1][i-p] = dpxy[index][jj+1][i-p] or a
    j[index] += 1
    index = (index+1)%2
    if s and s[0] == 'T':
        s = s[1:]

# print(dpxy[0][j[0]])
# print(dpxy[1][j[1]])
if dpxy[0][j[0]][x+origin] and dpxy[1][j[1]][y+origin]:
    print('Yes')
else:
    print('No')


### FIXED CODE ###

s = input()
x, y = map(int, input().split())
hL = len(s)
L = 2 * hL

dp = [[False] * (L + 1) for i in range(2)]
ndp = [False] * (L + 1)

def next(i):
    global s
    while i < hL and s[i] != 'T':
        i += 1
    i += 1
    return i

def c(x):
    global hL
    return x + hL

index = 0
t = 0
js = [1]
dp[0][c(0)] = True
dp[1][c(0)] = True
mini, maxi = 0, 1
while index < hL:
    ni = next(index)
    dx, index = ni - index - 1, ni
    for i in range(mini, maxi):
        for j in js:
            if -hL <= i + j * dx <= hL:
                nx = c(i + j * dx)
                ndp[nx] = ndp[nx] or dp[t][c(i)]
    for i in range(mini, maxi):
        dp[t][c(i)] = False
    dp[t], ndp = ndp, dp[t]
    mini, maxi = mini - dx, maxi + dx
    js = [-1, 1]
    t = (t + 1) % 2
print('Yes' if dp[0][c(x)] and dp[1][c(y)] else 'No')
### BUGGY CODE ###

import numpy as np
import sys
#input = sys.stdin.readline
h, w = map(int,input().split())
grid = np.array([list(input()) for _ in range(h)])

large_grid = np.array([["." for _ in range(w+2)] for _ in range(h+2)])
goal_grid = [["#" for _ in range(w)] for _ in range(h)]
cnt = 0

for i in range(1000):
    if (grid == goal_grid).all():
        print(cnt)
        break
    for row in range(h):
        for col in range(w):
            if grid[row][col] == "#":
                large_grid[row][col+1] = "#"
                large_grid[row+2][col+1] = "#"
                large_grid[row+1][col+1] = "#"
                large_grid[row+1][col+2] = "#"
                large_grid[row+1][col] = "#"

    grid3 = large_grid[1:h+1, 1:w+1]
    #grid = grid3#参照元とかの問題でバグる
    grid = np.copy(grid3)
    cnt +=1

#     grid = grid2
#     print(grid2)
#     print(grid)








### FIXED CODE ###

from collections import deque
H, W = map(int,input().split())
grid = [list(input()) for _ in range(H)]


d = [[-1]*W for _ in range(H)]
dx = [0,1,0,-1]
dy = [1,0,-1,0]


que = deque()
for x in range(W):
    for y in range(H):
        if grid[y][x] == '#':
            d[y][x] = 0
            que.append([x,y])

while len(que) != 0:
    p = que.popleft()
    for i in range(4):
        nx = p[0] + dx[i]
        ny = p[1] + dy[i]
        #print(nx,ny)
        if 0 <= nx <= W-1 and 0 <= ny <= H-1 and grid[ny][nx] == '.' and d[ny][nx] == -1:
            que.append([nx,ny])
            d[ny][nx] = d[p[1]][p[0]] + 1

# print(d)
# print(d[H-1][W-1])
res = 0
for x in range(W):
    for y in range(H):
        res = max(res,d[y][x])
print(res)
### BUGGY CODE ###

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

badcnt = 0
for i in range(n):
  for j in range(m):
    if (i+1 == a[j]) or (i+1 == b[j]):
      if min(h[a[j]-1], h[b[j]-1]) == h[i]:
        badcnt += 1
        break
ans = n - badcnt        
print(ans)

### FIXED CODE ###

 #12716015

n, m = map(int, input().split())
h = list(map(int, input().split()))
ans = [1]*n
for i in range(m):
  a, b= map(int, input().split())
  a -= 1
  b -= 1
  if h[a] > h[b]:
    ans[b] = 0
  elif h[a] < h[b]:
    ans[a] = 0
  if h[a] == h[b]:
    ans[a] = 0
    ans[b] = 0
print(ans.count(1))
### BUGGY CODE ###

n = int(input())
a = list(map(int, input().split()))
ans = 1
k = 0
for i in range(n):
  ans = ans*a[k]
  k += 1
if ans > 10**18:
  print(-1)
else:
  print(ans)

### FIXED CODE ###

n = int(input())
a = list(map(int, input().split()))
Sa = sorted(a)
if Sa[0] == 0:
  ans = 0
else:
  k = 0
  ans = 1
  for i in range(n):
    ans = ans*a[k]
    k += 1
    if ans > 10**18:
      ans = -1
      break
print(ans)
### BUGGY CODE ###

n,k=map(int,input().split())
a=list(map(int,input().split()))
for i in range(k):
  b=[0]*(n+1)
  for j in range(n):
    b[max(0,j-a[j])]+=1
    b[min(n,j+a[j]+1)]-=1
  for j in range(n):
    b[j+1]+=b[j]
  a=b[:-1]
  if a==[n]*n:exit(print(*a))
print(*a)

### FIXED CODE ###

n,k=map(int,input().split())
a=list(map(int,input().split()))
for i in range(k):
  b=[0]*(n+1)
  for j in range(n):
    b[max(0,j-a[j])]+=1
    b[min(n,j+a[j]+1)]-=1
  for j in range(n):
    b[j+1]+=b[j]
  a=b[:-1]
  if a==[n]*n:exit(print(*a))
print(*a)