Harryxun/stf_run huggingface dataset:
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda :sys.stdin.readline().rstrip()
def modfact(n):
    fact=[1]*(n+1)
    invfact=[1]*(n+1)
    for i in range(1,n+1):
        fact[i]=i*fact[i-1]%MOD
    invfact[n]=pow(fact[n],MOD-2,MOD)
    for i in range(n-1,-1,-1):
        invfact[i]=invfact[i+1]*(i+1)%MOD
    return fact,invfact

def prime_factorization(n):
    factor=[]
    sqrt=int(n**.5)
    for d in range(2,sqrt+1):
        while(n%d==0):
            n//=d
            factor.append(d)
    if n!=1: factor.append(n)
    return factor

def resolve():
    from collections import Counter
    n,m=map(int,input().split())
    P=prime_factorization(m)
    C=Counter(P)
    C=list(C.values())

    N=max(C)
    fact,invfact=modfact(N+n)

    ans=1
    for v in C:
        ans*=fact[v+n-1]*invfact[n-1]*invfact[v]
        ans%=MOD
    print(ans)
resolve()

### FIXED CODE ###

import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda :sys.stdin.readline().rstrip()
def modfact(n):
    fact=[1]*(n+1)
    invfact=[1]*(n+1)
    for i in range(1,n+1):
        fact[i]=i*fact[i-1]%MOD
    invfact[n]=pow(fact[n],MOD-2,MOD)
    for i in range(n-1,-1,-1):
        invfact[i]=invfact[i+1]*(i+1)%MOD
    return fact,invfact

def prime_factorization(n):
    assert(n>=2)
    factor=[]
    sqrt=int(n**.5)
    for d in range(2,sqrt+1):
        while(n%d==0):
            n//=d
            factor.append(d)
    if n!=1: factor.append(n)
    return factor

def resolve():
    from collections import Counter
    n,m=map(int,input().split())
    if(m==1):
        print(1)
        return
        
    P=prime_factorization(m)
    C=Counter(P)
    C=list(C.values())

    N=max(C)
    fact,invfact=modfact(N+n)

    ans=1
    for v in C:
        ans*=fact[v+n-1]*invfact[n-1]*invfact[v]
        ans%=MOD
    print(ans)
resolve()
import sys
from math import gcd

lines = sys.readlines()

a, b = map(int, lines[0].split())

x = gcd(a, b)

print(x * (a//x) * (b//x))

### FIXED CODE ###

import sys
from fractions import gcd

lines = sys.stdin.readlines()

a, b = map(int, lines[0].split())

x = gcd(a, b)

print(x * (a//x) * (b//x))
n = int(input())
d = int(input())
i = (d * 2) + 1
if n % i == 0 :
  print(n // i)
else :
  print((n // i) + 1)


### FIXED CODE ###

n, d = map(int, input().split())
i = (d * 2) + 1
if n % i == 0 :
  print(n // i)
else :
  print((n // i) + 1)
a = int(input())

list = []

for i in range(a):
  if a % i == 0:
    list.append(i)
list2 = []
for j in list:
  if j < 10:
    list2.append(j)

if len(list2) >= 2:
  print('Yes')
else:
  print('No')
  

### FIXED CODE ###

n = int(input())

for i in range(1, n + 1):
    if n % i == 0:
        j = n // i
        if i < 10 and j < 10:
            print('Yes')
            break
else:
    print('No')
from collections import Counter

# print('input >>')
N = input()
As = list(map(int,(input().split())))
Q = int(input())
BCs = []
for _ in range(Q):
    BCs.append(tuple(map(int,(input().split()))))

counter = dict(Counter(As))
sum_ = sum(As)

for BC in BCs:
    sa = BC[1] - BC[0]
    sum_ += counter[BC[0]] * sa
    if not BC[1] in counter:
        counter[BC[1]] = 0
    counter[BC[1]] = counter[BC[1]] + counter[BC[0]]
    counter[BC[0]] = 0
    # print(counter)
    print(sum_)

### FIXED CODE ###

from collections import Counter

# print('input >>')
N = input()
As = list(map(int,(input().split())))
Q = int(input())
BCs = []
for _ in range(Q):
    BCs.append(tuple(map(int,(input().split()))))

counter = dict(Counter(As))
sum_ = sum(As)

for BC in BCs:
    if not BC[0] in counter:
        counter[BC[0]] = 0
    if not BC[1] in counter:
        counter[BC[1]] = 0
    sa = BC[1] - BC[0]
    sum_ += counter[BC[0]] * sa
    counter[BC[1]] = counter[BC[1]] + counter[BC[0]]
    counter[BC[0]] = 0
    # print(counter)
    print(sum_)
from collections import deque
 
n = int(input())
 
def dfs(n):
  stack = deque()
  stack.append("a")
  while stack:
    q = stack.popleft()
    if len(q) == n:
      ans.append(q) 
    if len(q) < n:
      for i in range(ord("a"), ord(max(q)) + 2):
        stack.append(q + chr(i))
    print(stack)
    
ans = []
dfs(n)
 
print("\n".join(ans))

### FIXED CODE ###

from collections import deque
 
n = int(input())
 
def dfs(n):
  stack = deque()
  stack.append("a")
  while stack:
    q = stack.popleft()
    if len(q) == n:
      ans.append(q) 
    if len(q) < n:
      for i in range(ord("a"), ord(max(q)) + 2):
        stack.append(q + chr(i))
    #print(stack)
    
ans = []
dfs(n)
 
print("\n".join(ans))
N = int(input())
H = list(map(int, input().split()))

for i in range(len(tmp)):
  H.append(int(tmp[i]))

ans = 0
for i in range(len(H)):
  chkflg = True
  if i >= 1:
    for j in range(i): 
      if H[j] > H[i]:
        chkflg = False
        break

  if chkflg: ans += 1

print(ans)   



### FIXED CODE ###

N = int(input())
tmp = input().split()
H = []
for i in range(len(tmp)):
  H.append(int(tmp[i]))

ans = 0
for i in range(len(H)):
  chkflg = True
  if i >= 1:
    for j in range(i): 
      if H[j] > H[i]:
        chkflg = False
        break

  if chkflg: ans += 1

print(ans)
def main():
    import sys
    N,K=list(map(int,sys.stdin.readline().split()))
    P=list(map(int,sys.stdin.readline().split()))
    C=list(map(int,sys.stdin.readline().split()))

    output=-10**20

    lst=[[0]*(N+1) for _ in range(N)]
    for i in range(N):
        st=set()
        now=i
        count=0
        score=0
        if K==1:
            output=max(output,C[P[i]])
            continue

        while True:
            count+=1
            now=P[now]-1

            if now in st:
                count-=1
                break
    
            lst[i][count]=lst[i][count-1]+C[now]
            st.add(now)
            
            if count==K:
                break
        
        if lst[i][count]>0 and K>=count:
            if K%count:
                s=lst[i][count]*(K//count)+max(lst[i][1:K%count+1])
            else:
                s=lst[i][count]*(K//count)
        else:
            s=max(lst[i][1:count+1])
        output=max(output,s)

    print(output)

main()

### FIXED CODE ###

def main():
    import sys
    N,K=list(map(int,sys.stdin.readline().split()))
    P=list(map(int,sys.stdin.readline().split()))
    C=list(map(int,sys.stdin.readline().split()))

    output=-10**20

    lst=[[0]*(N+1) for _ in range(N)]
    for i in range(N):
        st=set()
        now=i
        count=0
        score=0
        if K==1:
            output=max(output,C[P[i]-1])
            continue

        while True:
            count+=1
            now=P[now]-1

            if now in st:
                count-=1
                break
    
            lst[i][count]=lst[i][count-1]+C[now]
            st.add(now)
            
            if count==K:
                break


        if lst[i][count]>0:
            m=max(lst[i][1:count+1])
            
            if K%count:
                p=max(lst[i][1:K%count+1])
                if p>0:
                    s=lst[i][count]*(K//count)+p
                else:
                    s=lst[i][count]*(K//count-1)+m
            else:
                s=lst[i][count]*(K//count-1)+m
        else:
            s=max(lst[i][1:count+1])
        
        output=max(output,s)

    print(output)

main()
n = int(input())
a = [int(e) for e in input().split()]
ans = float("inf")
MIN, MAX = min(a), max(a)
for i in range(MIN, MAX):
    cost = 0
    for j in a:
        cost = cost + (i-j)**2
    ans = min(ans, cost)
print(cost)

### FIXED CODE ###

n = int(input())
a = [int(e) for e in input().split()]
ans = float("inf")
MIN, MAX = min(a), max(a)
for i in range(MIN, MAX+1):
    cost = 0
    for j in a:
        cost = cost + (i-j)**2
    ans = min(ans, cost)
print(ans)
n=int(input())
a=list(map(int,input().split()))
m=0
def yakusu(x):
  lst=[]
  for i in range(1,x**(0.5)+1):
    if x%i==0:
      lst.append(i)
      lst.append(x//i)
  return list(set(lst))    
for i in range(n):
  y=yakusu(a[i])
  for j in range(len(y)):
    while y[j]%2==0:
      y[j]==y[j]//2
      m+=1
print(m)

  


### FIXED CODE ###

n=int(input())
a=list(map(int,input().split()))
m=0
for i in range(n):
  while a[i]%2==0:
    a[i]=a[i]//2
    m+=1
print(m)
s = list(map(str,input()))

ans = []

for i in range(len(s)):
    if s[i] == '0':
        ans.append('0')
    elif s[i] == '1':
        ans.append('1')
    else:
        ans.pop(-1)

print(''.join(ans))

### FIXED CODE ###

s = list(map(str,input()))

ans = []

for i in range(len(s)):
    if s[i] == '0':
        ans.append('0')
    elif s[i] == '1':
        ans.append('1')
    else:
        if ans == []:
            continue
        else:
            ans.pop(-1)

print(''.join(ans))
a,b,c,d=[int(input) for i in range(4)]
print(a*c-(c-d)*max(b-a,0))

### FIXED CODE ###

n,k,x,y=(int(input()) for i in [0]*4)
print(n*x-(x-y)*max(n-k,0))
N,K = list(map(int,input().split()))
A = list(map(int,input().split()))

low=0
high=max(A)
X=max(A)
while low<=high:
  mid=(low+high)//2
  cnt = 0
  for i in range(N):
      cnt += A[i]//mid
  if K<cnt:
    low=mid+1
  else:
    X=min(X,mid)
    high=mid-1
print(X)


### FIXED CODE ###

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

low=1
high=2*max(A)
X=max(A)
while low<=high:
  mid=(low+high)//2
  cnt = 0
  for i in range(N):
      if A[i]%mid==0:
          cnt += A[i]//mid-1
      else:
          cnt += A[i]//mid
  if K<cnt:
    low=mid+1
  else:
    X=min(X,mid)
    high=mid-1
print(X)
import sys
from collections import defaultdict
sys.setrecursionlimit(200000)
input = sys.stdin.readline

N, M, = map(int, input().split())
S = list(input().strip())
T = list(input().strip())

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

l = N * M // gcd(N, M)

m = [None] * l

for i in range(N):
    m[i * (l // N)] = S[i]

for i in range(M):
    index = i * (l // M)
    if m[index] == None:
        m[index] = T[i]
    elif m[index] == T[i]:
        pass
    else:
        print(-1)
        exit()

print(l)

### FIXED CODE ###

import sys
from collections import defaultdict
sys.setrecursionlimit(200000)
input = sys.stdin.readline

N, M, = map(int, input().split())
S = list(input().strip())
T = list(input().strip())

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

l = N * M // gcd(N, M)

# m = [None] * l
m = {}

for i in range(N):
    m[i * (l // N)] = S[i]

for i in range(M):
    index = i * (l // M)
    if m.get(index) == None:
        m[index] = T[i]
    elif m[index] == T[i]:
        pass
    else:
        print(-1)
        exit()

print(l)
n=int(input())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
remain=A[0]
ans1=0
for i in range(n):
    if B[i]<=remain:
        ans1+=B[i]
        remain=A[i+1]
    if B[i]>remain:
        ans1+=remain
        yoryoku=B[i]-remain
        if yoryoku>A[i+1]:
            ans1+=A[i+1]
            remain=0
        else:
            ans1+=yoryoku
            remain=A[i+1]-yoryoku
rA=reversed(A)
rB=reversed(B)
remain=rA[0]
ans2=0
for i in range(n):
    if rB[i]<=remain:
        ans2+=rB[i]
        remain=rA[i+1]
    if rB[i]>remain:
        ans2+=remain
        yoryoku=rB[i]-remain
        if yoryoku>rA[i+1]:
            ans2+=rA[i+1]
            remain=0
        else:
            ans2+=yoryoku
            remain=rA[i+1]-yoryoku
print(max(ans1,ans2))

### FIXED CODE ###

n=int(input())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
remain=A[0]
ans1=0
for i in range(n):
    if B[i]<remain:
        ans1+=B[i]
        remain=A[i+1]
    else:
        ans1+=remain
        yoryoku=B[i]-remain
        if yoryoku>A[i+1]:
            ans1+=A[i+1]
            remain=0
        else:
            ans1+=yoryoku
            remain=A[i+1]-yoryoku
print(ans1)
a, b = list(map(int,input.split()))
 
if a == b:
    print("a" + " == " + "b")
elif a < b:
    print("a" + " < " + "b")
elif a > b:
    print("a" + " > " + "b")
else:
    print("timpo")

### FIXED CODE ###

a,b = map(int, input().split())
  
if a == b:
    print("a" + " == " + "b")
elif a < b:
    print("a" + " < " + "b")
else:
    print("a" + " > " + "b")
date = input()
date = list(date)
date[3] = '8'
date = ''.join(date)
print(date)


### FIXED CODE ###

hour = int(input())

print(48 - hour)
N = input()
    a = [input() for y in range(N)]
    a_max = -10**9
    for i in xrange(1,len(a)-1):
        if (max(a[(i+1):]) - a[i]) >= a_max:
            a_max = max(a[(i+1):]) - a[i]
    print a_max

### FIXED CODE ###

def main():
    N = input() 
    a = [input() for y in range(N)] 
    a_max = -10**9
    a_min = a[0]
    for j in xrange(1,len(a)):
        if a[j] - a_min > a_max:
            a_max = a[j] - a_min
        if a[j] < a_min:
            a_min = a[j]
    print a_max
main()
n,h = map(int,input().split())
x = []
for i in range(n):
	x.append(list(map(int,input().split())))
a = []
for i in range(n):
	a.append(x[i][0])
b = []
for i in range(n):
	b.append(x[i][1])
x.sort(key = lambda x:x[1])

t = 0
c = []
if sum(b)>h-1:
	for i in range(n):
		t += 1
		h -= x[i+1][1]
		if h<1:
			print(t)
			break
else:
	for i in range(n):
		if b[i]>max(a)-1:
			c.append(b[i])
	h -=sum(c)
	q = h//max(a)
	print(q+len(c))


### FIXED CODE ###

n,h = map(int,input().split())
x = []
for i in range(n):
	x.append(list(map(int,input().split())))

t = 0
c = []#強い投げ刀たち
M = max(x[i][0] for i in range(n))

for i in range(n):
	if x[i][1]>M-1:
		c.append(x[i][1])
c.sort()
c.reverse()

if sum(c)>h-1:
	for i in range(len(c)):
		t += 1
		h -= c[i]
		if h<1:
			print(t)
			break
else:
	h -=sum(c)
	q = (h-1)//M+1
	print(q+len(c))
n = int(input())
a = [int(x) for x in input().split()]

c = 0

for i in range(n):
    for j in range(i + 1, n):
        if a[j - 1] > a[j]:
            tmp = a[j - 1]
            a[j - 1] = a[j]
            a[j] = tmp
            c += 1

print(" ".join([str(x) for x in a])
print(c)

### FIXED CODE ###

n = int(input())
a = [int(x) for x in input().split()]

c = 0

for i in range(n):
    for j in range(1, n):
        if a[j - 1] > a[j]:
            tmp = a[j - 1]
            a[j - 1] = a[j]
            a[j] = tmp
            c += 1

print(" ".join([str(x) for x in a]))
print(c)
N = int(input())
S = []
for _ in range(N):
    S.append(input())  # S += [input()] とも書ける

B=S.copy()
B.sort()
if N!=2:
	C=int(B[N-1])
	D=int(B[N-2])
	for i in S:
		if int(i)>=C:
			print(D)
		else:
			print(C)

else:
	print(S[1])
	print(S[0])

### FIXED CODE ###

import copy
N = int(input())
S = []
for i in range(N):
    S.append(int(input()))

B=copy.copy(S)
B.sort()
if N>2:
	C=int(B[N-1])
	D=int(B[N-2])
	for i in S:
		if int(i)>=C:
			print(D)
		else:
			print(C)

else:
	print(S[1])
	print(S[0])
n = int(input())
L,R = [0]*n,[0]*n
for i in range(n):
    L[i],R[i] = map(int,input().split())
    R[i] += 1

M = L.index(max(L))
m = R.index(min(R))

d = [R[i] - L[i] if M != i != m else 0 for i in range(n)]
ans = max(d) + max(R[m] - L[M], 0)
if m == M:
    print(ans)
    exit()
a,b = [0]*(n-2),[0]*(n-2)
j = 0
for i in range(n):
    if m != i != M:
        a[j],b[j] = max(R[i]-L[M],0) , -max(R[m]-L[i],0)
        j += 1
ab = sorted(list(zip(a,b)),reverse = True)
mb = [0]*len(a)
for i in range(len(a))[::-1]:
    if i == len(a)-1:
        mb[i] = -ab[i][1]
    else:
        mb[i] = min(-ab[i][1], mb[i+1])
d[m] = R[m] - L[m]
d[M] = R[M] - L[M]
for i in range(len(a) - 1):
    ans = max(ans,min(a[i],d[M]) + min(mb[i + 1],d[m]))
ans = max(ans , d[M] + min(mb[0], d[m]), min(a[len(a)-1],d[M]) + d[m])

print(ans)


### FIXED CODE ###

n = int(input())
L,R = [0]*n,[0]*n
for i in range(n):
    L[i],R[i] = map(int,input().split())
    R[i] += 1

M = L.index(max(L))
m = R.index(min(R))

d = [R[i] - L[i] if M != i != m else 0 for i in range(n)]
ans = max(d) + max(R[m] - L[M], 0)
d[m] = R[m] - L[m]
d[M] = R[M] - L[M]
if m == M:
    print(ans)
    exit()
if n == 2:
    print(d[m] + d[M])
    exit()
a,b = [0]*(n-2),[0]*(n-2)
j = 0
for i in range(n):
    if m != i != M:
        a[j],b[j] = max(R[i]-L[M],0) , max(R[m]-L[i],0)
        j += 1
ab = sorted(list(zip(a,b)),reverse = True)
mb = [0]*len(a)
for i in range(len(a))[::-1]:
    if i == len(a)-1:
        mb[i] = ab[i][1]
    else:
        mb[i] = min(ab[i][1], mb[i+1])
for i in range(len(a) - 1):
    ans = max(ans,min(ab[i][0],d[M]) + min(mb[i + 1],d[m]))
ans = max(ans , d[M] + min(mb[0], d[m]), min(ab[len(a)-1][0],d[M]) + d[m])

print(ans)
import sys

N = int(input())

for i in range(26):
  for j in range(16):
    if N == i * 4 + j * 7:
      print('Yes')
      sys.exit()
print('No')

### FIXED CODE ###

N, K = list(map(int, input().split(' ')))
print(0 if N % K == 0 else 1)
# -*- coding: utf-8 -*-
a,b,c = int(input())
if (c == 2 || c== 4 || c==5 || c ==7 || c==9){
	print("hon")
}else if(c == 0 || c== 1 || c==6 || c ==8){
	print("pon")
}else {
  print("bon")
}

### FIXED CODE ###

b = int(input())
a = b % 10
if a ==2 or a== 4 or a==5 or a== 7 or a== 9:
	print("hon")
elif a == 0 or a== 1 or a==6 or a == 8:
	print("pon")
else:
  print("bon")
n = int(input())
dp = [[0]*n for i in range(n)]
for i in range(n):
    l = list(map(int , input().split()))
    if i == 0:
        dp[0][0]=l[0]
        dp[0][0]=l[1]
        dp[0][0]=l[2]
    else:
        dp[i][0]=max(dp[i-1][1],dp[i-1][2])+l[0]
        dp[i][1]=max(dp[i-1][0],dp[i-1][2])+l[1]
        dp[i][2]=max(dp[i-1][0],dp[i-1][1])+l[2]
print(max(dp[-1][0], dp[-1][1], dp[-1][2]))

### FIXED CODE ###

n = int(input())
a = []
b = []
c = []
for i in range(n):
    m,v,p = map(int,input().split())
    a.append(m)
    b.append(v)
    c.append(p)
d = [[0]*3 for i in range(n)]
d[0][0]=a[0]
d[0][1]=b[0]
d[0][2]=c[0]
for i in range(1,n):
    for j in range(3):
        if j == 0:
            d[i][j] = max(d[i-1][1],d[i-1][2]) + a[i]
        elif j == 1:
            d[i][j] = max(d[i-1][0],d[i-1][2]) + b[i]
        else:
            d[i][j] = max(d[i-1][0],d[i-1][1]) + c[i]
print(max(d[-1][0],d[-1][1],d[-1][2]))
import itertools
N, M, Q = map(int, input().split())
a = [0]*Q
b = [0]*Q
c = [0]*Q
d = [0]*Q
for i in range (Q):
     a[i], b[i], c[i], d[i] = map(int, input().split())
ans = 0
for A in combinations_with_replacement(range(1, M+1), N):
    tmp = 0
    for i in range(Q):
        if A[b[i]-1] - A[a[i]-1] == c[i]:
            tmp += d[i]
    ans = max(ans, tmp)
print(ans)

### FIXED CODE ###

import itertools
N, M, Q = map(int, input().split())
a = [0]*Q
b = [0]*Q
c = [0]*Q
d = [0]*Q
for i in range(Q):
     a[i], b[i], c[i], d[i] = map(int, input().split())
ans = 0
for A in itertools.combinations_with_replacement(range(1, M+1), N):
    tmp = 0
    for i in range(Q):
        if A[b[i]-1] - A[a[i]-1] == c[i]:
            tmp += d[i]
    ans = max(ans, tmp)
print(ans)
import sys
import math
def I():return int(sys.stdin.readline().replace("\n",""))
def I2():return map(int,sys.stdin.readline().replace("\n","").split())
def S():return str(sys.stdin.readline().replace("\n",""))
def L():return list(sys.stdin.readline().replace("\n",""))
def Intl():return [int(k) for k in sys.stdin.readline().replace("\n","").split()]
def Lx(k):return list(map(lambda x:int(x)*-k,sys.stdin.readline().replace("\n","").split()))

x,n = I2()
if n != 0:
    p = Intl()
else:
    p = []
p.sort()
if not x in p:
    print(x)
else:
    b,e = 0,n-1
    for i in range(n):
        if p[i] == x:
            b = max(b,i-1)
            e = min(e,i+1)
            break
    #print(b,e)
    r = []
    s = []
    for i in range(p[b]-1,p[e]+2):
        if i not in p:
            r.append(i)
            s.append(abs(x-i))
    print(r[s.index(min(s))])

### FIXED CODE ###

import sys
import math
def I():return int(sys.stdin.readline().replace("\n",""))
def I2():return map(int,sys.stdin.readline().replace("\n","").split())
def S():return str(sys.stdin.readline().replace("\n",""))
def L():return list(sys.stdin.readline().replace("\n",""))
def Intl():return [int(k) for k in sys.stdin.readline().replace("\n","").split()]
def Lx(k):return list(map(lambda x:int(x)*-k,sys.stdin.readline().replace("\n","").split()))

x,n = I2()
if n != 0:
    p = Intl()
else:
    p = []
p.sort()
if not x in p:
    print(x)
else:
    b,e = 0,n-1
    r = []
    s = []
    for i in range(min(p)-1,max(p)+2):
        if i not in p:
            r.append(i)
            s.append(abs(x-i))
    print(r[s.index(min(s))])
import sys,math,collections,itertools,bisect
input = sys.stdin.readline

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

B = []
for i,a in enumerate(A):
    if a <=N-1:
        B.append([a,i])
B.sort()
cnt = 0
for i in range(N):
    for j in range(i+1,N):
        if B[i][0]+B[j][0]==abs(B[i][1]-B[j][1]):
            cnt +=1
        if B[i][0]+B[j][0]>=N:
            break
print(cnt)



### FIXED CODE ###

import sys,collections
input = sys.stdin.readline
N=int(input())
A=list(map(int,input().split()))
B = []
C = []
for i,a in enumerate(A):
    B.append(i+a)
    C.append(i-a)
cnt = 0
Bc = collections.Counter(B)
Cc = collections.Counter(C)

for key,val in Bc.items():
    cnt += val*Cc[key]
print(cnt)
n = int(input())

hoge = [0 for i in range(0,N)]
for i in range(0,N):
    hoge[i] = int(input())
    

number_set = set(hoge)
print(len(number_set))

### FIXED CODE ###

n = int(input())
 
hoge = [0 for i in range(0,n)]
for i in range(0,n):
    hoge[i] = int(input())
    
 
number_set = set(hoge)
print(len(number_set))
s = input()
t = input()

if s[0] == t[0] and s[1] == t[1] and s[2] == t[2]:
    print(3)
elif (s[0] == t[0] and s[1] == t[1]) or (s[1] == t[1] and s[2] == t[2]) or (s[0] == t[0] and s[3] == t[3]):
    print(2)
elif s[0] == t[0] or s[1] == t[1] or s[2] == t[2]:
    print(1)
else:
    print(0)

### FIXED CODE ###

s = input()
t = input()

ans = 0
for i in range(3):
    if s[i] == t[i]:
        ans += 1
print(ans)
N, A, B = map(int, input().split())

counter = [0 for _ in range(N)]
ans = 0

for i in range(N):
    string = str(i)
    for j in range(len(string)):
        counter[i] += string[j]

for i in range(N):
  if(counter[i]>=A && counter[i]<=B):
    ans += i

print(ans)

### FIXED CODE ###

N, A, B = map(int, input().split())
ans = 0

for i in range(1, N+1):
    num_sum = 0
    for j in str(i):
        num_sum += int(j)
    if A<= num_sum <= B:
        ans += i

print(ans)
a, b = map(int, open(0)); print((a + b + 1) // 2)


### FIXED CODE ###

a,b =map(int,input().split());print((a+b+1)//2)
X,A = int(input())
if X >= A:
  print('10')
else:
  print("0")

### FIXED CODE ###

X,A = map(int,input().split())
if X >= A:
  print('10')
else:
  print("0")