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

import sys
from collections import *
import heapq
import math
import bisect
from itertools import permutations,accumulate,combinations,product
from fractions import gcd
def input():
    return sys.stdin.readline()[:-1]
def ruiseki(lst):
    return [0]+list(accumulate(lst))
mod=pow(10,9)+7

n=int(input())
a=[list(map(int,input().split())) for i in range(n)]
ans=0
lst=[]
for i in range(n):
    lst.append(deque(a[i]))
    # print(lst[i])
while 1:
    cnt=[0]*n
    ans+=1
    for i in range(n):
        if lst[i]!=deque():
            if cnt[i]==0  and cnt[lst[i][0]-1]==0 and lst[lst[i][0]-1][0]-1==i:
                cnt[i]=1
                cnt[lst[i][0]-1]=1
                lst[lst[i][0]-1].popleft()
                lst[i].popleft()
    # print(ans)
    # print(lst)
    for i in range(n):
        if cnt[i]==1:
            break
    else:
        print(-1)
        quit()
    
    for i in range(n):
        if lst[i]:
            break
    else:
        break
print(ans)

### FIXED CODE ###

from collections import deque

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

for i in range(n):
    for j in range(n-1):
        a[i][j]-=1
    a[i].reverse()
# print(a)
day=[0]*n
pair=[-1]*n

q=deque(range(n))

while q:
    me=q.popleft()
    if not a[me]:
        continue
    oppo=a[me].pop()
    if pair[oppo]==me:
        now=max(day[me],day[oppo])+1
        day[me]=now
        day[oppo]=now
        q.append(me)
        q.append(oppo)
    else:
        pair[me]=oppo


for i in range(n):
    if a[i]:
        print(-1)
        break
else:
    print(max(day))
### BUGGY CODE ###

H, W = map(int, input().split())
X = [[[0, 1][a=="#"] for a in input()] for i in range(H)]
def countRD(n, i, j):
    return ccc(n, i, j, 1, 1)
def countRU(n, i, j):
    return ccc(n, i, j, -1, 1)
def countLD(n, i, j):
    return ccc(n, i, j, 1, -1)
def countLU(n, i, j):
    return ccc(n, i, j, -1, -1)
def countR(n, i, j):
    return cc(n, i, j, 0, 1)
def countL(n, i, j):
    return cc(n, i, j, 0, -1)
def countD(n, i, j):
    return cc(n, i, j, 1, 0)
def countU(n, i, j):
    return cc(n, i, j, -1, 0)
def ccc(n, i, j, DU, RL):
    c = 0
    for k in range(1, n):
        if i+k*DU >= 0 and i+k*DU < H:
            if j+(n-k)*RL >= 0 and j+(n-k)*RL < W:
                c += X[i+k*DU][j+(n-k)*RL]
    return c
def cc(n, i, j, DU, RL):
    ret = 0
    if i+n*DU >= 0 and i+n*DU < H:
        if j+n*RL >= 0 and j+n*RL < W:
            ret = X[i+n*DU][j+n*RL]
    return ret

ans = 0
for i in range(H):
    for j in range(W):
        for n in range(1, min(max(i+j,H-i+W-j), max(i+W-j,H-i+j))+2):
            if countR(n, i, j) and countD(n, i, j):
                ans += countLU(n, i, j)
            if countR(n, i, j) and countU(n, i, j):
                ans += countLD(n, i, j)
            if countL(n, i, j) and countD(n, i, j):
                ans += countRU(n, i, j)
            if countL(n, i, j) and countU(n, i, j):
                ans += countRD(n, i, j)
            if countR(n, i, j) and countD(n, i, j) and countL(n, i, j):
                ans += 1
            if countR(n, i, j) and countD(n, i, j) and countU(n, i, j):
                ans += 1
            if countR(n, i, j) and countU(n, i, j) and countL(n, i, j):
                ans += 1
            if countD(n, i, j) and countU(n, i, j) and countL(n, i, j):
                ans += 1
            
            
print (ans)

### FIXED CODE ###

H, W = map(int, input().split())
I = [input() for _ in range(H)]
X = [[[0, 1][a=="#"] for a in inp] for inp in I]
k = 32
def r():
    global H, W, I
    I = ["".join([I[H - 1 - j][i] for j in range(H)]) for i in range(W)]
    H, W = W, H
def st1(s):
    return int(s.replace("#", "1" * k).replace(".", "0" * k), 2)
def st2(s):
    return int(s.replace("#", "0" * (k - 1) + "1").replace(".", "0" * k), 2)
def getsum(x):
    for i in range(8):
        x += x >> (k << i)
    return x & ((1 << k) - 1)

ans = 0
for _ in range(4):
    A1 = [st1(inp) for inp in I]
    A2 = [st1("".join([I[i][j] for i in range(H)])) for j in range(W)]
    B = [st2(inp[::-1]) for i, inp in enumerate(I)]
    C = [[0] * W for _ in range(H)]
    for j in range(W):
        s = 0
        m = (1 << j * k) - 1
        for i in range(H)[::-1]:
            s <<= k
            s += B[i] >> (j+1) * k
            s &= m
            C[i][j] = s
    for i in range(1, H):
        for j in range(1, W):
            ans += A1[i] >> (W - j) * k & A2[j] >> (H - i) * k & C[i][j]
    r()
            
print(getsum(ans))
### BUGGY CODE ###

def resolve():
    '''
    code here
    '''

    import collections
    import math

    N = int(input())
    A_list = [int(item) for item in input().split()]
    origin_dict = collections.Counter(A_list)

    memo = [-1 for _ in range(N+1)]

    for i in range(N):
        temp_num = A_list[i]

        if memo[temp_num] == -1:
            temp_dict = origin_dict.copy()
            temp_dict[temp_num] -= 1
            # print(temp_dict)
            res = 0
            for j in temp_dict.values():
                res += j*(j-1)//2
            print(res)
            memo[temp_num] = res
        else:
            print(memo[temp_num])

    

if __name__ == "__main__":
    resolve()


### FIXED CODE ###

def resolve():
    import collections

    N = int(input())
    A_list = [int(item) for item in input().split()]
    origin_dict = collections.Counter(A_list)

    twopair_in_N = 0
    for i in origin_dict.values():
        twopair_in_N += i*(i-1)//2

    for j in range(N):
        deff = origin_dict[A_list[j]] -1

        print(twopair_in_N - deff)
    

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

import math
A,B,N = map(int, input().split())

x = 0
for i in range(N+1):
    D = math.floor(x/B)
    if D != 0:
        break
    x += 1
print(math.floor(A*(x-1)/B)-math.floor((x-1)/B)*A)
    


### FIXED CODE ###

import math
A,B,N = map(int, input().split())
if (B-1)<=N:
    print(math.floor(A*(B-1)/B)-math.floor((B-1)/B)*A)
else:
    print(math.floor(A*N/B)-math.floor(N/B)*A)
### BUGGY CODE ###

N, K = map(int, input().split())
a = list(map(int, input().split()))
a = sorted(a)

if N == 1:
	if a[0] >= K:
		print(0)
	else:
		print(1)

else:
	def check(i):
		if a[i] >= K:
			return True
		if i == 0:
			b = a[1:]
		elif i == N - 1:
			b = a[:N - 1]
		else:
			b = a[:i] + a[i+1:]
		#print(b)
		#ok = False
		dp = [[False] * K for _ in range(N - 1)]
		if b[0] < K:
			dp[0][b[0]] = True
		if K - a[i] <= b[0] < K:
			return True
		for j in range(1, N - 1):
			for k in range(1, K):
				#if b[j] == K:
				#	return True
				#elif dp[j - 1][k] == True:
				if dp[j - 1][k] == True:
					dp[j][k] = True
				elif k > b[j]:
					if dp[j - 1][k - b[j]] == True:
						dp[j][k] = True

				if dp[j][k] == True and K - a[i] <= k < K:
					return True

		return False


	def bi_search(lower, upper):
		#print(lower, upper)
		mid = (lower + upper) // 2
		#print(mid)
		if mid == 0 and check(mid) == True:
			return 0
		elif mid == N - 2 and check(mid + 1) == False:
			return N
		elif check(mid) == False and check(mid + 1) == True:
			#print("hoge")
			return mid + 1
		elif check(mid) == True:
			return bi_search(lower, mid)
		else:
			return bi_search(mid, upper)


	print(bi_search(0, N - 1))


### FIXED CODE ###

import sys

n, k = map(int, input().split())
a = sorted(list(map(int, input().split())))
#print(a)
fr = 0
ba = n+1

def check(mi):
    x = a[mi-1]
    if x >= k:
        return True
    #print(mi)
    dp = [False] * (k+1)
    dp[0] = True
    for i in range(n):
        if i == mi-1:
            continue
        y = a[i]
        for j in range(k, -1, -1):
            if j >= y:
                dp[j] = dp[j] | dp[j-y]

    if sum(dp[k-x:k]):
        return True
    else:
        return False

if check(1):
    print(0)
    sys.exit()

if not check(n):
    print(n)
    sys.exit()

while ba-fr > 1:
    mi = (ba+fr+1) // 2
    if check(mi):
        ba = mi
    else:
        fr = mi

print(fr)
### BUGGY CODE ###

import math

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

ans = 0
for i in range(n):
    A2 = A.copy()
    del A2[i]
    x = A2[0]
    for i in range(1, n - 1):
        x = math.gcd(x, A2[i])
    ans = max(ans, x)
    
print(ans)

### FIXED CODE ###

N = int(input())
A = [int(i) for i in input().split()]

def gcd(x, y):
    while y > 0:
        x, y = y, x % y
    return x

B = A.copy()
for i in range(N - 1):
    B[i + 1] = gcd(B[i], B[i + 1])

C = A.copy()
C.reverse()
for i in range(N - 1):
    C[i + 1] = gcd(C[i], C[i + 1])
C.reverse()

ans = 0
for i in range(N):
    if i == 0:
        tmp = C[i + 1]
    elif i == N - 1:
        tmp = B[i - 1]
    else:
        tmp = gcd(B[i - 1], C[i + 1])
    ans = max(ans, tmp)
    
print(ans)
### BUGGY CODE ###

from collections import deque
H, W = map(int, input().split())
m = [[0] * (W + 1) for _ in range(H + 1)]
todo = deque()
for h in range(H):
    for w, c in enumerate(input()):
        if c == ".":
            m[h][w] = -1
        else:
            todo.append((h, w))
ans = 0
while todo:
    h, w = todo.popleft()
    count = m[h][w] + 1
    for dh, dw in ((1, 0), (-1, 0), (0, 1), (0, -1)):
        nh = h + dh
        nw = w + dw
        if m[nh][nw] == -1:
            m[nh][nw] = count
            todo.append((nh, nw))
            ans = count
print(ans)

### FIXED CODE ###

from collections import deque
H, W = map(int, input().split())
m = [[-1 if c == "." else 0 for c in input() + "#"] for _ in range(H)]
m.append([0] * (W + 1))
todo = deque(((h, w) for h in range(H) for w in range(W) if m[h][w] == 0))
ans = 0
while todo:
    h, w = todo.popleft()
    count = m[h][w] + 1
    for dh, dw in ((1, 0), (-1, 0), (0, 1), (0, -1)):
        nh = h + dh
        nw = w + dw
        if m[nh][nw] == -1:
            m[nh][nw] = count
            todo.append((nh, nw))
            ans = count
print(ans)
### BUGGY CODE ###

##幅優先探索
from collections import deque
 
def dfs(H,W,M):
    que = deque()
    if M[0][0] == "#":
        que.append([0,0,1,1])
    else:
        que.append([0,0,0,0])

    d = [[1,0],[0,1]]
    ans = []
    
    while que:
        x,y,num_sharp,in_sharp = que.popleft()

        for i,j in d:
            dx = x + i
            dy = y + j
            if 0 <= dx <= W-1 and 0 <= dy <= H-1:
                if M[dx][dy] == "#" and in_sharp:
                    que.append([dx,dy,num_sharp,1])
                elif M[dx][dy] == "#" and not in_sharp:
                    que.append([dx,dy,num_sharp+1,0])
                else:##M[dx][dy] == "."
                    que.append([dx,dy,num_sharp,0])
        if x == W-1 and y == H-1:
            ans.append(num_sharp)
    return min(ans)
 
 
 
def main():
    H,W = map(int,input().split())
    M = []
    for i in range(H):
        M.append(input())
    print(dfs(H,W,M))
 
if __name__ == "__main__":
    main()

### FIXED CODE ###

def ans_dp(H,W,M):
    dp = [[0 for i in range(W)] for j in range(H)]
    flag = [[0 for i in range(W)] for j in range(H)]
    if M[0][0] == "#":
        dp[0][0] = 1
        flag[0][0] = 1
    else:
        dp[0][0] == 0
    for i in range(1,W):
        if M[0][i] == "#":
            flag[0][i] = 1
            if flag[0][i-1] == 1:
                dp[0][i] = dp[0][i-1]
            else:
                dp[0][i] = dp[0][i-1] + 1 
        else:##M[0][i] = "."
            dp[0][i] = dp[0][i-1]
    for j in range(1,H):
        if M[j][0] == "#":
            flag[j][0] = 1
            if flag[j-1][0] == 1:
                dp[j][0] = dp[j-1][0]
            else:
                dp[j][0] = dp[j-1][0] + 1 
        else:##M[0][i] = "."
            dp[j][0] = dp[j-1][0]
    
    for i in range(1,H):
        for j in range(1,W):
            if M[i][j] == "#":
                flag[i][j] = 1
                dp[i][j] = min(dp[i-1][j]+int(not flag[i-1][j]),dp[i][j-1]+int(not flag[i][j-1]))
            else:#M[i][j] == "."
                dp[i][j] = min(dp[i-1][j],dp[i][j-1])
    """
    for i in range(H):
        print(dp[i])
    for i in range(H):
        print(flag[i])
    """
    return dp[H-1][W-1]

def main():
    H,W = map(int,input().split())
    M = []
    for i in range(H):
        M.append(list(input()))
    print(ans_dp(H,W,M))
 
if __name__ == "__main__":
    main()
### BUGGY CODE ###

N,Q = map(int, input().split())
S = input()
A = [0]*N
B = [0]*Q

for i in range(N-1):
    if S[i] == "A" and S[i+1] =="C":
        A[i+1] += 1

for i in range(Q):
    a, b = map(int, input().split())
    print(sum(A[:b])-sum(A[:a]))

### FIXED CODE ###

N,Q = map(int, input().split())
S = input()
A = [0]*N


for i in range(1, N):
    if S[i-1] == "A" and S[i] =="C":
        A[i] = A[i-1]+1
    else:
        A[i] = A[i-1]

for i in range(Q):
    a, b = map(int, input().split())
    print(A[b-1] - A[a-1])
### BUGGY CODE ###

takahashi, aoki, kaisu = [int(x) for x in input().split()]
for i in range(kaisu):
    if(takahashi>0):
        takahashi = takahashi - 1
    elif(aoki>0):
        aoki = aoki-1
print(str(takahashi) + " " + str(aoki))

### FIXED CODE ###

takahashi, aoki, kaisu = [int(x) for x in input().split()]
taka_amari = takahashi - kaisu
ao_amari = aoki
if taka_amari<0:
    ao_amari = aoki+taka_amari
 
if taka_amari<0:
    taka_amari = 0
if ao_amari<0:
    ao_amari = 0
print(str(taka_amari) + " " + str(ao_amari))
### BUGGY CODE ###

from math import factorial
from bisect import bisect
n=int(input())
lst=sorted(map(int,input().split()))
ans_max=0
for i in range(-1,-n,-1):
    index=bisect(lst,lst[i]/2)
    if 0<=index-1:
        tmp=factorial(lst[i])//factorial(lst[i]-lst[index-1])//factorial(lst[index-1])
        if tmp>ans_max:
            ans_max=tmp
            ans=[lst[i],lst[index-1]]
    if lst[i]!=lst[index]:
        tmp=factorial(lst[i])//factorial(lst[i]-lst[index])//factorial(lst[index])
        if tmp>ans_max:
            ans_max=tmp
            ans=[lst[i],lst[index]]
print(" ".join(map(str,ans)))

### FIXED CODE ###

from bisect import bisect
n=int(input())
lst=sorted(map(int,input().split()))
m=lst[-1]
index=bisect(lst,m/2)
if m!=lst[index]:
    q=lst[index]
    if 0<=index-1:
        p=lst[index-1]
        if abs(m/2-p)>=abs(m/2-q):
            print(m,q)
        else:
            print(m,p)
    else:
        print(m,q)
else:
    print(m,lst[index-1])
### BUGGY CODE ###

N,Q = map(int, input().split())
S = input()
for i in range(Q):
  l_i, r_i = map(int, input().split())
  A_i = S[l_i - 1 : r_i]
  count_i = 0
  for j in range(len(A_i) - 1):
    if A_i[j] == "A":
      if A_i[j+1] == "C":
        count_i = count_i + 1
  print(count_i)

### FIXED CODE ###

N,Q = map(int, input().split())
S = input()
List = [0]
p = 0
for i in range(N-1):
  if S[i] == "A":
    if S[i+1] == "C":
      p = p + 1
      List.append(p)
    else:
      List.append(p)
  else:
    List.append(p)

List.append(0)   
for i in range(Q):
  l, r = map(int, input().split())
  if List[l-2] == List[l-1]:
    print(List[r-1] - List[l-2])
  else:
    print(List[r-1] - List[l-1])
### BUGGY CODE ###

N=int(input())

for i in range(1,N+1):
    count=0
    for x in range(1,int(i**0.5)):
        for y in range(1,N-x**2):
            a=-(y+x)
            b=(y*x)**2-4*(x**2+y**2+x*y-N)
            if b<0:continue
            for z in range(1,int(a+b**0.5)+1):
                if x**2+y**2+z**2+x*y+x*z+y*z==i:count+=1


    print(count)

### FIXED CODE ###

N=int(input())
dic={}
for i in range(1,N+1):
    dic[i]=0
for x in range(1,int(N**0.5)):
    for y in range(1,N-x**2):
        for z in range(1,N-(x**2+y**2+x*y)):
            if x**2+y**2+z**2+x*y+x*z+y*z>N:break
            if x**2+y**2+z**2+x*y+x*z+y*z in dic:
                dic[x**2+y**2+z**2+x*y+x*z+y*z]+=1


for i in range(1,N+1):
    print(dic[i])
### BUGGY CODE ###

import math

ans = []
while True:
	try:
		n = int(raw_input())
		isPrime = [False, False]
		for i in range(n - 1):
			isPrime.append(-1)
		i = 2
		while i < math.sqrt(n):
			j = i 
			while j < len(isPrime):
				isPrime[j] = False
				j += i
			isPrime[i] = True
			i = isPrime.index(-1)
		ans.append(isPrime.count(True) + isPrime.count(-1))
	except EOFError:
		break
for num in ans:
	print num

### FIXED CODE ###

MAX = 1000000
prime = [1] * MAX
prime[0], prime[1] = 0, 0
i = 2
while i * i < MAX:
    j = 2
    while i * j < MAX:
        prime[i * j] = 0
        j += 1
    i += 1
for k in range(1, len(prime)):
    prime[k] += prime[k-1]

while True:
    try:
        n = int(raw_input())
        print prime[n]
    except EOFError:
        break
### BUGGY CODE ###

S = list(input())
Q = int(input())
L = []
for i in range(Q):
    l = list(input().split())
    if len(l) == 1:
        S.reverse()
    else:
        l[1] = int(l[1])
        if l[1] == 1:
            S.insert(0,l[2])
        else:
            S.append(l[2])
        
print(''.join(S))



### FIXED CODE ###

from collections import deque
S = deque(input())
Q = int(input())
count = 0
for i in range(Q):
    l = list(input().split())
    if len(l) == 1:
        count +=1
    else:
        l[1] = int(l[1])
        if count%2 == 1:
            if l[1] == 1:
                l[1] = 2
            else:
                l[1] = 1
        if l[1] == 1:
            S.appendleft(l[2])
        else:
            S.append(l[2])

if count%2 == 0:
    print(''.join(list(S)))
else:
    S.reverse()
    print(''.join(list(S)))
### BUGGY CODE ###

from fractions import gcd
n,m=map(int,input().split())
s=input()
t=input()
p=gcd(n,m)
ans=n*m//p
tt=[0 for _ in range(ans)]
for i in range(n):
	tt[i*(ans//n)]=ord(s[i])
for i in range(m):
	if tt[i*(ans//m)]!=ord(t[i]) and tt[i*(ans//m)]!=0:
		print(-1)
		exit()
print(ans)


### FIXED CODE ###

from fractions import gcd
n,m=map(int,input().split())
s=input()
t=input()
p=gcd(n,m)
ans=n*m//p 
for i in range(n):
	if abs((i*(ans//n)/(ans//m))-int(i*(ans//n)/(ans//m)))<=10**(-7):
		if s[i]==t[(i*(ans//n)//(ans//m))]:
			continue
		else:
			print(-1)
			exit()
print(ans)
### BUGGY CODE ###

n,k,s=map(int,input().split())

if s!=10**9:
    ans=""
    p0=str(s)+" "
    p1=str(s+1)+" "
    for i in range(k):
        ans+=p0
    for j in range(n-k):
        ans+=p1

else:
    ans=""
    p0=str(s)+" "
    p1=str(s-1)+" "
    
    for i in range(k):
        ans+=p0
    for j in range(n-k):
        ans+=p1


print(ans)


### FIXED CODE ###

n,k,s=map(int,input().split())
if s==10**9:
    ans=(str(s)+" ")*k+(str(1)+" ")*(n-k)


else:
    ans=(str(s)+" ")*k+(str(s+1)+" ")*(n-k)



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

import copy
from collections import deque

n = int(input())
s = []
for i in range(n):
    s.append(list(str(input())))
    
for i in s:
    i.sort()

s1 = copy.deepcopy(s)
s2 = copy.deepcopy(s)
s1.pop()
del s2[0]
#listの先頭、後方を削除してからイテレートする必要がある
cnt = 0
for i in s1:
    for j in s2:
        if i == j:
            cnt+=1
    del s2[0]

print(cnt)

### FIXED CODE ###

n = int(input())
ss = ["".join(sorted(list(input()))) for _ in range(n)]
ss.sort()

ans = 0
cnt = 0
tmp = ss.pop(0)
for s in ss:
    if tmp == s:
        cnt+=1
    elif cnt > 0:
        tmp = s
        ans+=((cnt+1) * cnt // 2)
        cnt = 0
    else:
        tmp = s
        cnt = 0
print(ans + ((cnt+1) * cnt // 2))
### BUGGY CODE ###

# D Anything Goes to Zero

import copy

n = int(input())
x = input()
for i in range(n):
  xi = copy.copy(x)
  if xi[i] == "1":
    xi = xi[:i] + "0" + xi[i+1:]
  else:
    xi = xi[:i] + "1" + xi[i+1:]
  xi = int(xi, 2)

  ans = 0
  while xi != 0:
    xi = xi % bin(xi).count("1")
    ans += 1
  print(ans)


### FIXED CODE ###

# D Anything Goes to Zero

n = int(input())
x = input()

original_pop_count = x.count("1")
one_pop_count = original_pop_count - 1
zero_pop_count = original_pop_count + 1

one_mod = 0
zero_mod = 0
for b in x:
  if one_pop_count != 0:
    one_mod = (one_mod * 2 + int(b)) % one_pop_count
  zero_mod = (zero_mod * 2 + int(b)) % zero_pop_count

#fの前計算
f = [0] * 220000
pop_count = [0] * 220000
for i in range(1, 220000):
  pop_count[i] = pop_count[i//2] + i % 2
  f[i] = f[i % pop_count[i]] + 1

#pow2の前計算
one_pow2 = [1] * 220000
zero_pow2 = [1] * 220000
for i in range(1, 220000):
  if one_pop_count != 0:
    one_pow2[i] = one_pow2[i-1] * 2 % one_pop_count
  zero_pow2[i] = zero_pow2[i-1] * 2 % zero_pop_count

for i in range(n-1, -1, -1):
  if x[n-1-i] == "1":
    if one_pop_count != 0:
      nxt = one_mod
      nxt -= one_pow2[i]
      nxt %= one_pop_count
      print(f[nxt] + 1)
    else:
      print(0)
  if x[n-1-i] == "0":
    nxt = zero_mod
    nxt += zero_pow2[i]
    nxt %= zero_pop_count
    print(f[nxt] + 1)
### BUGGY CODE ###

n,p = map(int,input().split())
s = input()
ans = 0
for i in range(1,len(s)+1):
  for k in range(len(s)-i+1):
    new_s = int(s[k:k+i])
    if new_s%p==0:
      ans+=1
print(ans)

### FIXED CODE ###

#!/usr/bin/env python3
n,p = map(int,input().split())
s=input()
ans = 0
l = [0 for i in range(p)]
l[0] = 1
z = 0
ten = 1
tmp = 0
if p == 2 or p == 5:
    if p == 2:
        for i in range(n):
            if int(s[i])%2 == 0:
                ans+=i+1
    if p == 5:
        for i in range(n):
            if int(s[i])%5 == 0:
                ans+= i+1
    
else:
    for i in s[::-1]:
        i = int(i)
        tmp=(tmp+i*ten)%p
        ten = (ten*10)%p
        l[tmp]+=1
for i in l:
    ans+= i*(i-1)//2
print(ans)
### BUGGY CODE ###

N,M=map(int,input().split())
a=[]
c=[]
for i in range(M):
  aa,bb=map(int,input().split())
  a.append(aa)
  cc=["0"]*(N+1)
  d=list(map(int,input().split()))
  for dd in d:
    cc[dd]="1"
  c.append(int("".join(cc[1:]),2))
#print(a)
#print(c)

X=[10**10]*2**N
X[0]=0
for i in range(2**N):
  if X[i]<10**10:
    for j in range(M):
      if i|c[j]<2**N:
        X[i|c[j]]=min(X[i|c[j]],X[i]+a[j])
print(X[2**N-1] if X[2**N-1]!=10**10 else -1)

### FIXED CODE ###

N,M=map(int,input().split())
a=[]
c=[]
for i in range(M):
  aa,bb=map(int,input().split())
  a.append(aa)
  cc=["0"]*(N+1)
  d=list(map(int,input().split()))
  for dd in d:
    cc[dd]="1"
  c.append(int("".join(cc[1:]),2))
#print(a)
#print(c)

X=[10**10]*2**N
X[0]=0
for i in range(2**N):
  if X[i]<10**10:
    for j in range(M):
      if i|c[j]<2**N:
        X[i|c[j]]=min(X[i|c[j]],X[i]+a[j])
print(X[2**N-1] if X[2**N-1]!=10**10 else -1)
### BUGGY CODE ###

N, M = map(int, input().split())
tmp = input().split(' ')
H = []
for i in range(N):
    H = H + [int(tmp[i])]

A = []
B = []
for i in range(M):
    ta, tb = map(int, input().split())
    A = A + [ta]
    B = B + [tb]

ans = 0
# v: 0ならいい展望台、1なら良くない展望台 
for i in range(N):
    v = 0
    for j in range(M):
        if A[j]-1 == i:
            if H[B[j]-1] >= H[i]:
                v = 1
        if B[j]-1 == i:
            if H[A[j]-1] >= H[i]:
                v = 1
    if v == 0:
        ans+=1
    
print(ans)

### FIXED CODE ###

N, M = map(int, input().split())
H = list(map(int, input().split()))

A = [0]*M
B = [0]*M
for i in range(M):
    ta, tb = map(int, input().split())
    A[i] = ta - 1
    B[i] = tb - 1

ans = [True]*N
# v: Trueならいい展望台、Falseなら良くない展望台 
for i in range(M):
    ans[A[i]] = H[A[i]] > H[B[i]] and ans[A[i]]
    ans[B[i]] = H[B[i]] > H[A[i]] and ans[B[i]]

print(ans.count(True))